View Javadoc
1   package org.eclipse.aether.util.graph.traverser;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   * 
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   * 
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.eclipse.aether.artifact.ArtifactProperties;
23  import org.eclipse.aether.collection.DependencyCollectionContext;
24  import org.eclipse.aether.collection.DependencyTraverser;
25  import org.eclipse.aether.graph.Dependency;
26  
27  import static java.util.Objects.requireNonNull;
28  
29  /**
30   * A dependency traverser that excludes the dependencies of fat artifacts from the traversal. Fat artifacts are
31   * artifacts that have the property {@link org.eclipse.aether.artifact.ArtifactProperties#INCLUDES_DEPENDENCIES} set to
32   * {@code true}.
33   * 
34   * @see org.eclipse.aether.artifact.Artifact#getProperties()
35   */
36  public final class FatArtifactTraverser
37      implements DependencyTraverser
38  {
39  
40      /**
41       * Creates a new instance of this dependency traverser.
42       */
43      public FatArtifactTraverser()
44      {
45      }
46  
47      public boolean traverseDependency( Dependency dependency )
48      {
49          requireNonNull( dependency, "dependency cannot be null" );
50          String prop = dependency.getArtifact().getProperty( ArtifactProperties.INCLUDES_DEPENDENCIES, "" );
51          return !Boolean.parseBoolean( prop );
52      }
53  
54      public DependencyTraverser deriveChildTraverser( DependencyCollectionContext context )
55      {
56          requireNonNull( context, "context cannot be null" );
57          return this;
58      }
59  
60      @Override
61      public boolean equals( Object obj )
62      {
63          if ( this == obj )
64          {
65              return true;
66          }
67          else if ( null == obj || !getClass().equals( obj.getClass() ) )
68          {
69              return false;
70          }
71          return true;
72      }
73  
74      @Override
75      public int hashCode()
76      {
77          return getClass().hashCode();
78      }
79  
80  }