View Javadoc
1   /*******************************************************************************
2    * Copyright (c) 2010, 2014 Sonatype, Inc.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Eclipse Public License v1.0
5    * which accompanies this distribution, and is available at
6    * http://www.eclipse.org/legal/epl-v10.html
7    *
8    * Contributors:
9    *    Sonatype, Inc. - initial API and implementation
10   *******************************************************************************/
11  package org.eclipse.aether.collection;
12  
13  import org.eclipse.aether.graph.Dependency;
14  
15  /**
16   * Decides what dependencies to include in the dependency graph.
17   * <p>
18   * <strong>Note:</strong> Implementations must be stateless.
19   * <p>
20   * <em>Warning:</em> This hook is called from a hot spot and therefore implementations should pay attention to
21   * performance. Among others, implementations should provide a semantic {@link Object#equals(Object) equals()} method.
22   * 
23   * @see org.eclipse.aether.RepositorySystemSession#getDependencySelector()
24   * @see org.eclipse.aether.RepositorySystem#collectDependencies(org.eclipse.aether.RepositorySystemSession,
25   *      CollectRequest)
26   */
27  public interface DependencySelector
28  {
29  
30      /**
31       * Decides whether the specified dependency should be included in the dependency graph.
32       * 
33       * @param dependency The dependency to check, must not be {@code null}.
34       * @return {@code false} if the dependency should be excluded from the children of the current node, {@code true}
35       *         otherwise.
36       */
37      boolean selectDependency( Dependency dependency );
38  
39      /**
40       * Derives a dependency selector for the specified collection context. When calculating the child selector,
41       * implementors are strongly advised to simply return the current instance if nothing changed to help save memory.
42       * 
43       * @param context The dependency collection context, must not be {@code null}.
44       * @return The dependency selector for the target node or {@code null} if dependencies should be unconditionally
45       *         included in the sub graph.
46       */
47      DependencySelector deriveChildSelector( DependencyCollectionContext context );
48  
49  }