001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.eclipse.aether.util.graph.traverser;
020
021import org.eclipse.aether.artifact.ArtifactProperties;
022import org.eclipse.aether.collection.DependencyCollectionContext;
023import org.eclipse.aether.collection.DependencyTraverser;
024import org.eclipse.aether.graph.Dependency;
025
026import static java.util.Objects.requireNonNull;
027
028/**
029 * A dependency traverser that excludes the dependencies of fat artifacts from the traversal. Fat artifacts are
030 * artifacts that have the property {@link org.eclipse.aether.artifact.ArtifactProperties#INCLUDES_DEPENDENCIES} set to
031 * {@code true}.
032 *
033 * @see org.eclipse.aether.artifact.Artifact#getProperties()
034 * @deprecated since 2.0, the DependencyTraverser implementation should be provided by the resolver consumer
035 */
036@Deprecated
037public final class FatArtifactTraverser implements DependencyTraverser {
038
039    /**
040     * Creates a new instance of this dependency traverser.
041     */
042    public FatArtifactTraverser() {}
043
044    public boolean traverseDependency(Dependency dependency) {
045        requireNonNull(dependency, "dependency cannot be null");
046        String prop = dependency.getArtifact().getProperty(ArtifactProperties.INCLUDES_DEPENDENCIES, "");
047        return !Boolean.parseBoolean(prop);
048    }
049
050    public DependencyTraverser deriveChildTraverser(DependencyCollectionContext context) {
051        requireNonNull(context, "context cannot be null");
052        return this;
053    }
054
055    @Override
056    public boolean equals(Object obj) {
057        if (this == obj) {
058            return true;
059        } else if (null == obj || !getClass().equals(obj.getClass())) {
060            return false;
061        }
062        return true;
063    }
064
065    @Override
066    public int hashCode() {
067        return getClass().hashCode();
068    }
069}