001package org.eclipse.aether.collection;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 * 
012 *  http://www.apache.org/licenses/LICENSE-2.0
013 * 
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import org.eclipse.aether.graph.Dependency;
023
024/**
025 * Decides what dependencies to include in the dependency graph.
026 * <p>
027 * <strong>Note:</strong> Implementations must be stateless.
028 * <p>
029 * <em>Warning:</em> This hook is called from a hot spot and therefore implementations should pay attention to
030 * performance. Among others, implementations should provide a semantic {@link Object#equals(Object) equals()} method.
031 * 
032 * @see org.eclipse.aether.RepositorySystemSession#getDependencySelector()
033 * @see org.eclipse.aether.RepositorySystem#collectDependencies(org.eclipse.aether.RepositorySystemSession,
034 *      CollectRequest)
035 */
036public interface DependencySelector
037{
038
039    /**
040     * Decides whether the specified dependency should be included in the dependency graph.
041     * 
042     * @param dependency The dependency to check, must not be {@code null}.
043     * @return {@code false} if the dependency should be excluded from the children of the current node, {@code true}
044     *         otherwise.
045     */
046    boolean selectDependency( Dependency dependency );
047
048    /**
049     * Derives a dependency selector for the specified collection context. When calculating the child selector,
050     * implementors are strongly advised to simply return the current instance if nothing changed to help save memory.
051     * 
052     * @param context The dependency collection context, must not be {@code null}.
053     * @return The dependency selector for the target node or {@code null} if dependencies should be unconditionally
054     *         included in the sub graph.
055     */
056    DependencySelector deriveChildSelector( DependencyCollectionContext context );
057
058}