1 package org.sonatype.aether.graph; 2 3 /******************************************************************************* 4 * Copyright (c) 2010-2011 Sonatype, Inc. 5 * All rights reserved. This program and the accompanying materials 6 * are made available under the terms of the Eclipse Public License v1.0 7 * which accompanies this distribution, and is available at 8 * http://www.eclipse.org/legal/epl-v10.html 9 *******************************************************************************/ 10 11 import java.util.Collection; 12 import java.util.List; 13 import java.util.Map; 14 15 import org.sonatype.aether.artifact.Artifact; 16 import org.sonatype.aether.repository.RemoteRepository; 17 import org.sonatype.aether.version.Version; 18 import org.sonatype.aether.version.VersionConstraint; 19 20 /** 21 * A node within a dependency graph. <em>Note:</em> When traversing a dirty graph, i.e. a graph which hasn't undergone 22 * conflict resolution, there can be multiple path leading to the same node instance. 23 * 24 * @author Benjamin Bentmann 25 */ 26 public interface DependencyNode 27 { 28 29 /** 30 * Gets the child nodes of this node. 31 * 32 * @return The child nodes of this node, never {@code null}. 33 */ 34 List<DependencyNode> getChildren(); 35 36 /** 37 * Gets the dependency associated with this node. <em>Note:</em> For dependency graphs that have been constructed 38 * without a root dependency, the root node will not have a dependency associated with it. 39 * 40 * @return The dependency or {@code null} if none. 41 */ 42 Dependency getDependency(); 43 44 /** 45 * Sets the artifact of the dependency. 46 * 47 * @param artifact The artifact satisfying the dependency, must not be {@code null}. 48 */ 49 void setArtifact( Artifact artifact ); 50 51 /** 52 * Gets the sequence of relocations that was followed to resolve the artifact referenced by the dependency. 53 * 54 * @return The (read-only) sequence of relocations, never {@code null}. 55 */ 56 List<Artifact> getRelocations(); 57 58 /** 59 * Gets the known aliases for this dependency's artifact. An alias can be used to mark a patched rebuild of some 60 * other artifact as such, thereby allowing conflict resolution to consider the patched and the original artifact as 61 * a conflict. 62 * 63 * @return The (read-only) set of known aliases, never {@code null}. 64 */ 65 Collection<Artifact> getAliases(); 66 67 /** 68 * Gets the version constraint that was parsed from the dependency's version declaration. 69 * 70 * @return The version constraint for this node or {@code null}. 71 */ 72 VersionConstraint getVersionConstraint(); 73 74 /** 75 * Gets the version that was selected for the dependency's target artifact. 76 * 77 * @return The parsed version or {@code null}. 78 */ 79 Version getVersion(); 80 81 /** 82 * Sets the scope of the dependency. 83 * 84 * @param scope The scope, may be {@code null}. 85 */ 86 void setScope( String scope ); 87 88 /** 89 * Gets the version or version range for the dependency before dependency management was applied (if any). 90 * 91 * @return The dependency version before dependency management or {@code null} if the version was not managed. 92 */ 93 String getPremanagedVersion(); 94 95 /** 96 * Gets the scope for the dependency before dependency management was applied (if any). 97 * 98 * @return The dependency scope before dependency management or {@code null} if the scope was not managed. 99 */ 100 String getPremanagedScope(); 101 102 /** 103 * Gets the remote repositories from which this node's artifact shall be resolved. 104 * 105 * @return The (read-only) list of remote repositories to use for artifact resolution, never {@code null}. 106 */ 107 List<RemoteRepository> getRepositories(); 108 109 /** 110 * Gets the request context in which this dependency node was created. 111 * 112 * @return The request context, never {@code null}. 113 */ 114 String getRequestContext(); 115 116 /** 117 * Sets the request context in which this dependency node was created. 118 * 119 * @param context The context, may be {@code null}. 120 */ 121 void setRequestContext( String context ); 122 123 /** 124 * Gets the custom data associated with this dependency node. Clients of the repository system can use this data to 125 * annotate dependency nodes with domain-specific information. 126 * 127 * @return The (read-only) key-value mappings, never {@code null}. 128 */ 129 Map<Object, Object> getData(); 130 131 /** 132 * Associates the specified dependency node data with the given key. <em>Note:</em> This method must not be called 133 * while {@link #getData()} is being iterated. 134 * 135 * @param key The key under which to store the data, must not be {@code null}. 136 * @param value The data to associate with the key, may be {@code null} to remove the mapping. 137 */ 138 void setData( Object key, Object value ); 139 140 /** 141 * Traverses this node and potentially its children using the specified visitor. 142 * 143 * @param visitor The visitor to call back, must not be {@code null}. 144 * @return {@code true} to visit siblings nodes of this node as well, {@code false} to skip siblings. 145 */ 146 boolean accept( DependencyVisitor visitor ); 147 148 }