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
29 * for ommitted nodes at the moment, only dependencies kept in the resolved dependency list are
30 * available.
31 *
32 * @author Hervé Boutemy
33 * @since 2.0
34 */
35 public interface DependencyNode
36 {
37 Artifact getArtifact();
38
39 List<DependencyNode> getChildren();
40
41 /**
42 * Applies the specified dependency node visitor to this dependency node and its children.
43 *
44 * @param visitor
45 * the dependency node visitor to use
46 * @return the visitor result of ending the visit to this node
47 * @since 1.1
48 */
49 boolean accept( DependencyNodeVisitor visitor );
50
51 /**
52 * Gets the parent dependency node of this dependency node.
53 *
54 * @return the parent dependency node
55 */
56 DependencyNode getParent();
57
58 /**
59 * Gets the version or version range for the dependency before dependency management was applied (if any).
60 *
61 * @return The dependency version before dependency management or {@code null} if the version was not managed.
62 */
63 String getPremanagedVersion();
64
65 /**
66 * Gets the scope for the dependency before dependency management was applied (if any).
67 *
68 * @return The dependency scope before dependency management or {@code null} if the scope was not managed.
69 */
70 String getPremanagedScope();
71
72 /**
73 * A constraint on versions for a dependency. A constraint can either consist of one or more version ranges or a
74 * single version.
75 *
76 * @return The constraint on the dependency.
77 */
78 String getVersionConstraint();
79
80 /**
81 * Returns a string representation of this dependency node.
82 *
83 * @return the string representation
84 */
85 String toNodeString();
86 }