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 * Applies dependency management to the dependencies of a dependency node.
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#getDependencyManager()
033 * @see org.eclipse.aether.RepositorySystem#collectDependencies(org.eclipse.aether.RepositorySystemSession,
034 *      CollectRequest)
035 */
036public interface DependencyManager
037{
038
039    /**
040     * Applies dependency management to the specified dependency.
041     * 
042     * @param dependency The dependency to manage, must not be {@code null}.
043     * @return The management update to apply to the dependency or {@code null} if the dependency is not managed at all.
044     */
045    DependencyManagement manageDependency( Dependency dependency );
046
047    /**
048     * Derives a dependency manager for the specified collection context. When calculating the child manager,
049     * implementors are strongly advised to simply return the current instance if nothing changed to help save memory.
050     * 
051     * @param context The dependency collection context, must not be {@code null}.
052     * @return The dependency manager for the dependencies of the target node or {@code null} if dependency management
053     *         should no longer be applied.
054     */
055    DependencyManager deriveChildManager( DependencyCollectionContext context );
056
057}