1 package org.apache.maven.shared.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 java.util.List;
23
24 import org.apache.maven.artifact.Artifact;
25 import org.apache.maven.model.Exclusion;
26 import org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor;
27
28 /**
29 * Represents an artifact node within a Maven project's dependency graph. Notice there is no support for omitted nodes
30 * at the moment, only dependencies kept in the resolved dependency list are available.
31 *
32 * @author Hervé Boutemy
33 * @since 2.0
34 */
35 public interface DependencyNode
36 {
37 /**
38 * @return Artifact for this DependencyNode.
39 */
40 Artifact getArtifact();
41
42 /**
43 * @return children of this DependencyNode.
44 */
45 List<DependencyNode> getChildren();
46
47 /**
48 * Applies the specified dependency node visitor to this dependency node and its children.
49 *
50 * @param visitor the dependency node visitor to use
51 * @return the visitor result of ending the visit to this node
52 * @since 1.1
53 */
54 boolean accept( DependencyNodeVisitor visitor );
55
56 /**
57 * Gets the parent dependency node of this dependency node.
58 *
59 * @return the parent dependency node
60 */
61 DependencyNode getParent();
62
63 /**
64 * Gets the version or version range for the dependency before dependency management was applied (if any).
65 *
66 * @return The dependency version before dependency management or {@code null} if the version was not managed.
67 */
68 String getPremanagedVersion();
69
70 /**
71 * Gets the scope for the dependency before dependency management was applied (if any).
72 *
73 * @return The dependency scope before dependency management or {@code null} if the scope was not managed.
74 */
75 String getPremanagedScope();
76
77 /**
78 * A constraint on versions for a dependency. A constraint can either consist of one or more version ranges or a
79 * single version.
80 *
81 * @return The constraint on the dependency.
82 */
83 String getVersionConstraint();
84
85 /**
86 * Returns a string representation of this dependency node.
87 *
88 * @return the string representation
89 */
90 String toNodeString();
91
92 /**
93 * @return true for an optional dependency.
94 */
95 Boolean getOptional();
96
97 /**
98 *
99 * @return the exclusions of the dependency
100 */
101 List<Exclusion> getExclusions();
102 }