Forge - Dependencies API 2.0.0.Alpha3

org.jboss.forge.dependencies.collection
Class DependencyNodeUtil

java.lang.Object
  extended by org.jboss.forge.dependencies.collection.DependencyNodeUtil

public final class DependencyNodeUtil
extends Object

Provides utility methods for working with Dependency and DependencyNode objects

Author:
George Gastaldi

Field Summary
static String FORGE_ADDON_CLASSIFIER
           
 
Method Summary
static Iterator<DependencyNode> breadthFirstIterator(DependencyNode dependencyNode)
          Creates and returns an iterator that traverses the subtree rooted at this node in breadth-first order.
static Iterator<DependencyNode> depthFirstIterator(DependencyNode dependencyNode)
          Creates and returns an iterator that traverses the subtree rooted at this node in depth-first order.
static boolean isForgeAddon(Coordinate coordinate)
          Check if the Dependency object is pointing to a Forge Addon artifact
static Iterator<DependencyNode> preorderIterator(DependencyNode dependencyNode)
          Creates and returns an iterator that traverses the subtree rooted at this node in preorder.
static CharSequence prettyPrint(DependencyNode root)
          Prints a tree-like structure for this object
static String prettyPrint(DependencyNode root, Predicate<DependencyNode> filter)
           
static List<DependencyNode> select(DependencyNode node, Predicate<DependencyNode> filter)
          Returns the DependencyNode objects that satisfy the filter.
static
<T> List<T>
select(Iterator<T> iterator, Predicate<T> filter)
          Returns a List of DependencyNode objects that satisfy the filter based on the elements returned by the Iterator.
static
<T> T
selectFirst(Iterator<T> nodeIterator, Predicate<T> filter)
          Returns the first DependencyNode object found that satisfy the filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORGE_ADDON_CLASSIFIER

public static final String FORGE_ADDON_CLASSIFIER
See Also:
Constant Field Values
Method Detail

selectFirst

public static <T> T selectFirst(Iterator<T> nodeIterator,
                                Predicate<T> filter)
Returns the first DependencyNode object found that satisfy the filter.

Parameters:
nodeIterator - A tree iterator
filter - the DependencyNodeFilter being used
Returns:
the first element that matches the filter. null if nothing is found
See Also:
breadthFirstIterator(DependencyNode), depthFirstIterator(DependencyNode), preorderIterator(DependencyNode)

select

public static <T> List<T> select(Iterator<T> iterator,
                                 Predicate<T> filter)
Returns a List of DependencyNode objects that satisfy the filter based on the elements returned by the Iterator.

Parameters:
iterator - An iterator for the DependencyNode hierarchy tree
filter - the DependencyNodeFilter being used
Returns:
list of matched elements

select

public static List<DependencyNode> select(DependencyNode node,
                                          Predicate<DependencyNode> filter)
Returns the DependencyNode objects that satisfy the filter. The nodes are traversed using a pre order iterator

Parameters:
root - a DependencyNode as the starting point
filter - the DependencyNodeFilter being used
Returns:
the Collection with the output
See Also:
preorderIterator(DependencyNode)

prettyPrint

public static CharSequence prettyPrint(DependencyNode root)
Prints a tree-like structure for this object

Parameters:
root -
Returns:

prettyPrint

public static String prettyPrint(DependencyNode root,
                                 Predicate<DependencyNode> filter)

depthFirstIterator

public static Iterator<DependencyNode> depthFirstIterator(DependencyNode dependencyNode)
Creates and returns an iterator that traverses the subtree rooted at this node in depth-first order. The first node returned by Iterator.next() is the leftmost leaf.

Modifying the tree by inserting, removing, or moving a node invalidates any iterators created before the modification.

Returns:
an iterator for traversing the tree in depth-first order
See Also:
breadthFirstIterator(DependencyNode), preorderIterator(DependencyNode)

breadthFirstIterator

public static Iterator<DependencyNode> breadthFirstIterator(DependencyNode dependencyNode)
Creates and returns an iterator that traverses the subtree rooted at this node in breadth-first order. The first node returned by Iterator.next() is this node.

Modifying the tree by inserting, removing, or moving a node invalidates any iterators created before the modification.

Returns:
an enumeration for traversing the tree in breadth-first order
See Also:
depthFirstIterator(DependencyNode), preorderIterator(DependencyNode)

preorderIterator

public static Iterator<DependencyNode> preorderIterator(DependencyNode dependencyNode)
Creates and returns an iterator that traverses the subtree rooted at this node in preorder. The first node returned by Iterator.next() is this node.

Modifying the tree by inserting, removing, or moving a node invalidates any iterators created before the modification.

Returns:
an enumeration for traversing the tree in breadth-first order
See Also:
depthFirstIterator(DependencyNode), breadthFirstIterator(DependencyNode)

isForgeAddon

public static boolean isForgeAddon(Coordinate coordinate)
Check if the Dependency object is pointing to a Forge Addon artifact

Parameters:
coordinate -
Returns:

Forge - Dependencies API 2.0.0.Alpha3

Copyright © 2013 JBoss by Red Hat. All Rights Reserved.