View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.shared.dependency.graph;
20  
21  import java.util.List;
22  
23  import org.apache.maven.artifact.Artifact;
24  import org.apache.maven.model.Exclusion;
25  import org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor;
26  
27  /**
28   * Represents an artifact node within a Maven project's dependency graph. Notice there is no support for omitted nodes
29   * at the moment, only dependencies kept in the resolved dependency list are available.
30   *
31   * @author Hervé Boutemy
32   * @since 2.0
33   */
34  public interface DependencyNode {
35      /**
36       * @return Artifact for this DependencyNode.
37       */
38      Artifact getArtifact();
39  
40      /**
41       * @return children of this DependencyNode.
42       */
43      List<DependencyNode> getChildren();
44  
45      /**
46       * Applies the specified dependency node visitor to this dependency node and its children.
47       *
48       * @param visitor the dependency node visitor to use
49       * @return the visitor result of ending the visit to this node
50       * @since 1.1
51       */
52      boolean accept(DependencyNodeVisitor visitor);
53  
54      /**
55       * Gets the parent dependency node of this dependency node.
56       *
57       * @return the parent dependency node
58       */
59      DependencyNode getParent();
60  
61      /**
62       * Gets the version or version range for the dependency before dependency management was applied (if any).
63       *
64       * @return The dependency version before dependency management or {@code null} if the version was not managed.
65       */
66      String getPremanagedVersion();
67  
68      /**
69       * Gets the scope for the dependency before dependency management was applied (if any).
70       *
71       * @return The dependency scope before dependency management or {@code null} if the scope was not managed.
72       */
73      String getPremanagedScope();
74  
75      /**
76       * A constraint on versions for a dependency. A constraint can either consist of one or more version ranges or a
77       * single version.
78       *
79       * @return The constraint on the dependency.
80       */
81      String getVersionConstraint();
82  
83      /**
84       * Returns a string representation of this dependency node.
85       *
86       * @return the string representation
87       */
88      String toNodeString();
89  
90      /**
91       * @return true for an optional dependency.
92       */
93      Boolean getOptional();
94  
95      /**
96       *
97       * @return the exclusions of the dependency
98       */
99      List<Exclusion> getExclusions();
100 }