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  /**
28   * A dependency traverser that excludes the dependencies of fat artifacts from the traversal. Fat artifacts are
29   * artifacts that have the property {@link org.eclipse.aether.artifact.ArtifactProperties#INCLUDES_DEPENDENCIES} set to
30   * {@code true}.
31   * 
32   * @see org.eclipse.aether.artifact.Artifact#getProperties()
33   */
34  public final class FatArtifactTraverser
35      implements DependencyTraverser
36  {
37  
38      /**
39       * Creates a new instance of this dependency traverser.
40       */
41      public FatArtifactTraverser()
42      {
43      }
44  
45      public boolean traverseDependency( Dependency dependency )
46      {
47          String prop = dependency.getArtifact().getProperty( ArtifactProperties.INCLUDES_DEPENDENCIES, "" );
48          return !Boolean.parseBoolean( prop );
49      }
50  
51      public DependencyTraverser deriveChildTraverser( DependencyCollectionContext context )
52      {
53          return this;
54      }
55  
56      @Override
57      public boolean equals( Object obj )
58      {
59          if ( this == obj )
60          {
61              return true;
62          }
63          else if ( null == obj || !getClass().equals( obj.getClass() ) )
64          {
65              return false;
66          }
67          return true;
68      }
69  
70      @Override
71      public int hashCode()
72      {
73          return getClass().hashCode();
74      }
75  
76  }