001package org.eclipse.aether.util.graph.traverser; 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.artifact.ArtifactProperties; 023import org.eclipse.aether.collection.DependencyCollectionContext; 024import org.eclipse.aether.collection.DependencyTraverser; 025import org.eclipse.aether.graph.Dependency; 026 027/** 028 * A dependency traverser that excludes the dependencies of fat artifacts from the traversal. Fat artifacts are 029 * artifacts that have the property {@link org.eclipse.aether.artifact.ArtifactProperties#INCLUDES_DEPENDENCIES} set to 030 * {@code true}. 031 * 032 * @see org.eclipse.aether.artifact.Artifact#getProperties() 033 */ 034public final class FatArtifactTraverser 035 implements DependencyTraverser 036{ 037 038 /** 039 * Creates a new instance of this dependency traverser. 040 */ 041 public FatArtifactTraverser() 042 { 043 } 044 045 public boolean traverseDependency( Dependency dependency ) 046 { 047 String prop = dependency.getArtifact().getProperty( ArtifactProperties.INCLUDES_DEPENDENCIES, "" ); 048 return !Boolean.parseBoolean( prop ); 049 } 050 051 public DependencyTraverser deriveChildTraverser( DependencyCollectionContext context ) 052 { 053 return this; 054 } 055 056 @Override 057 public boolean equals( Object obj ) 058 { 059 if ( this == obj ) 060 { 061 return true; 062 } 063 else if ( null == obj || !getClass().equals( obj.getClass() ) ) 064 { 065 return false; 066 } 067 return true; 068 } 069 070 @Override 071 public int hashCode() 072 { 073 return getClass().hashCode(); 074 } 075 076}