Coverage Report - org.apache.maven.shared.dependency.tree.traversal.CollectingDependencyNodeVisitor
 
Classes in this File Line Coverage Branch Coverage Complexity
CollectingDependencyNodeVisitor
100 %
7/7
N/A
1
 
 1  
 package org.apache.maven.shared.dependency.tree.traversal;
 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 java.util.ArrayList;
 23  
 import java.util.Collections;
 24  
 import java.util.List;
 25  
 
 26  
 import org.apache.maven.shared.dependency.tree.DependencyNode;
 27  
 
 28  
 /**
 29  
  * A dependency node visitor that collects visited nodes for further processing.
 30  
  * 
 31  
  * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
 32  
  * @version $Id: CollectingDependencyNodeVisitor.java 1100703 2011-05-08 08:27:33Z hboutemy $
 33  
  * @since 1.1
 34  
  */
 35  
 public class CollectingDependencyNodeVisitor
 36  
     implements DependencyNodeVisitor
 37  
 {
 38  
     // fields -----------------------------------------------------------------
 39  
 
 40  
     /**
 41  
      * The collected list of nodes.
 42  
      */
 43  
     private final List<DependencyNode> nodes;
 44  
 
 45  
     // constructors -----------------------------------------------------------
 46  
 
 47  
     /**
 48  
      * Creates a dependency node visitor that collects visited nodes for further processing.
 49  
      */
 50  
     public CollectingDependencyNodeVisitor()
 51  6
     {
 52  6
         nodes = new ArrayList<DependencyNode>();
 53  6
     }
 54  
 
 55  
     // DependencyNodeVisitor methods ------------------------------------------
 56  
 
 57  
     /**
 58  
      * {@inheritDoc}
 59  
      */
 60  
     public boolean visit( DependencyNode node )
 61  
     {
 62  
         // collect node
 63  8
         nodes.add( node );
 64  
 
 65  8
         return true;
 66  
     }
 67  
 
 68  
     /**
 69  
      * {@inheritDoc}
 70  
      */
 71  
     public boolean endVisit( DependencyNode node )
 72  
     {
 73  2
         return true;
 74  
     }
 75  
 
 76  
     // public methods ---------------------------------------------------------
 77  
 
 78  
     /**
 79  
      * Gets the list of collected dependency nodes.
 80  
      * 
 81  
      * @return the list of collected dependency nodes
 82  
      */
 83  
     public List<DependencyNode> getNodes()
 84  
     {
 85  12
         return Collections.unmodifiableList( nodes );
 86  
     }
 87  
 }