Coverage Report - org.apache.maven.archiva.dependency.graph.DependencyGraphNode
 
Classes in this File Line Coverage Branch Coverage Complexity
DependencyGraphNode
0%
0/48
0%
0/14
0
 
 1  
 package org.apache.maven.archiva.dependency.graph;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *  http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.apache.maven.archiva.model.ArtifactReference;
 23  
 import org.apache.maven.archiva.model.Dependency;
 24  
 import org.apache.maven.archiva.model.Exclusion;
 25  
 
 26  
 import java.util.ArrayList;
 27  
 import java.util.HashSet;
 28  
 import java.util.List;
 29  
 import java.util.Set;
 30  
 
 31  
 /**
 32  
  * DependencyGraphNode 
 33  
  *
 34  
  * @version $Id: DependencyGraphNode.java 755277 2009-03-17 15:18:35Z brett $
 35  
  */
 36  
 public class DependencyGraphNode
 37  
 {
 38  
     /**
 39  
      * The artifact reference for this node.
 40  
      */
 41  
     private ArtifactReference artifact;
 42  
 
 43  
     /**
 44  
      * The project level dependency management section for this artifact.
 45  
      */
 46  0
     private List<Dependency> dependencyManagement = new ArrayList<Dependency>();
 47  
 
 48  
     /**
 49  
      * The list of excluded groupId:artifactId for this node's sub-nodes. 
 50  
      */
 51  0
     private Set<String> excludes = new HashSet<String>();
 52  
 
 53  
     /**
 54  
      * Flag indicating that this node has been resolved from disk.
 55  
      * Initially this is set to false, when the node is added due to a dependency entry in the
 56  
      * project's pom.
 57  
      * When the resolver comes through and reads the model for this node, it sets this to true.
 58  
      */
 59  0
     private boolean resolved = false;
 60  
     
 61  
     /**
 62  
      * Flag indicating that this dependency exists because of a parent dependency.
 63  
      * TODO: move this to DependencyGraphEdge (where it really belongs)
 64  
      */
 65  0
     private boolean fromParent = false;
 66  
 
 67  
     /**
 68  
      * Booleaning indicating that this node is in conflict with another node in the graph.
 69  
      * If this is true, that means this node is flagged for removal.
 70  
      */
 71  0
     private boolean conflicted = false;
 72  
 
 73  
     public DependencyGraphNode( ArtifactReference artifact )
 74  
     {
 75  0
         super();
 76  0
         this.artifact = artifact;
 77  0
     }
 78  
 
 79  
     public void addExclude( Exclusion exclusion )
 80  
     {
 81  0
         this.excludes.add( DependencyGraphKeys.toManagementKey( exclusion ) );
 82  0
     }
 83  
 
 84  
     public boolean equals( Object obj )
 85  
     {
 86  0
         if ( this == obj )
 87  
         {
 88  0
             return true;
 89  
         }
 90  0
         if ( obj == null )
 91  
         {
 92  0
             return false;
 93  
         }
 94  0
         if ( getClass() != obj.getClass() )
 95  
         {
 96  0
             return false;
 97  
         }
 98  0
         final DependencyGraphNode other = (DependencyGraphNode) obj;
 99  0
         if ( artifact == null )
 100  
         {
 101  0
             if ( other.artifact != null )
 102  
             {
 103  0
                 return false;
 104  
             }
 105  
         }
 106  0
         else if ( !artifact.equals( other.artifact ) )
 107  
         {
 108  0
             return false;
 109  
         }
 110  0
         return true;
 111  
     }
 112  
 
 113  
     public ArtifactReference getArtifact()
 114  
     {
 115  0
         return artifact;
 116  
     }
 117  
 
 118  
     public List<Dependency> getDependencyManagement()
 119  
     {
 120  0
         return dependencyManagement;
 121  
     }
 122  
 
 123  
     public Set<String> getExcludes()
 124  
     {
 125  0
         return excludes;
 126  
     }
 127  
 
 128  
     public int hashCode()
 129  
     {
 130  0
         final int PRIME = 31;
 131  0
         int result = 1;
 132  0
         result = PRIME * result + ( ( artifact == null ) ? 0 : artifact.hashCode() );
 133  0
         return result;
 134  
     }
 135  
 
 136  
     public boolean isConflicted()
 137  
     {
 138  0
         return conflicted;
 139  
     }
 140  
 
 141  
     public boolean isResolved()
 142  
     {
 143  0
         return resolved;
 144  
     }
 145  
 
 146  
     public void addDependencyManagement( Dependency dep )
 147  
     {
 148  0
         this.dependencyManagement.add( dep );
 149  0
     }
 150  
 
 151  
     public void setArtifact( ArtifactReference artifact )
 152  
     {
 153  0
         this.artifact = artifact;
 154  0
     }
 155  
 
 156  
     public void setConflicted( boolean conflicted )
 157  
     {
 158  0
         this.conflicted = conflicted;
 159  0
     }
 160  
 
 161  
     public void setDependencyManagement( List<Dependency> dependencyManagement )
 162  
     {
 163  0
         this.dependencyManagement = dependencyManagement;
 164  0
     }
 165  
 
 166  
     public void setExcludes( Set<String> excludes )
 167  
     {
 168  0
         this.excludes = excludes;
 169  0
     }
 170  
 
 171  
     public void setResolved( boolean resolved )
 172  
     {
 173  0
         this.resolved = resolved;
 174  0
     }
 175  
 
 176  
     public String toString()
 177  
     {
 178  0
         return DependencyGraphKeys.toKey( artifact );
 179  
     }
 180  
 
 181  
     public boolean isFromParent()
 182  
     {
 183  0
         return fromParent;
 184  
     }
 185  
 
 186  
     public void setFromParent( boolean fromParent )
 187  
     {
 188  0
         this.fromParent = fromParent;
 189  0
     }
 190  
 }