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.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 /**
37 * @return Artifact for this DependencyNode.
38 */
39 Artifact getArtifact();
40
41 /**
42 * @return children of this DependencyNode.
43 */
44 List<DependencyNode> getChildren();
45
46 /**
47 * Applies the specified dependency node visitor to this dependency node and its children.
48 *
49 * @param visitor the dependency node visitor to use
50 * @return the visitor result of ending the visit to this node
51 * @since 1.1
52 */
53 boolean accept( DependencyNodeVisitor visitor );
54
55 /**
56 * Gets the parent dependency node of this dependency node.
57 *
58 * @return the parent dependency node
59 */
60 DependencyNode getParent();
61
62 /**
63 * Gets the version or version range for the dependency before dependency management was applied (if any).
64 *
65 * @return The dependency version before dependency management or {@code null} if the version was not managed.
66 */
67 String getPremanagedVersion();
68
69 /**
70 * Gets the scope for the dependency before dependency management was applied (if any).
71 *
72 * @return The dependency scope before dependency management or {@code null} if the scope was not managed.
73 */
74 String getPremanagedScope();
75
76 /**
77 * A constraint on versions for a dependency. A constraint can either consist of one or more version ranges or a
78 * single version.
79 *
80 * @return The constraint on the dependency.
81 */
82 String getVersionConstraint();
83
84 /**
85 * Returns a string representation of this dependency node.
86 *
87 * @return the string representation
88 */
89 String toNodeString();
90
91 /**
92 * @return true for an optional dependency.
93 */
94 Boolean getOptional();
95 }