JTools

org.jtools.depend.impl
Class SimpleDependencies<T_TargetKey,T_ItemKey>

java.lang.Object
  extended by org.jtools.depend.impl.SimpleDependencies<T_TargetKey,T_ItemKey>
All Implemented Interfaces:
Dependencies<T_TargetKey,T_ItemKey>

public class SimpleDependencies<T_TargetKey,T_ItemKey>
extends Object
implements Dependencies<T_TargetKey,T_ItemKey>

Implementation of Dependencies.

Author:
Rainer Noack

Constructor Summary
SimpleDependencies()
           
SimpleDependencies(Comparator<? super DependencyElement<T_TargetKey,T_ItemKey>> comparator)
           
SimpleDependencies(DependencyOrder commonComparator)
           
 
Method Summary
 void changed()
           
 DependencyElement<T_TargetKey,T_ItemKey> declareElement(T_TargetKey key)
          Declares (constructs) an element with the given key.
 DependencyItem<T_ItemKey> declareItem(T_ItemKey key)
          Declares (constructs) an item with the given key.
 DependencyElement<T_TargetKey,T_ItemKey> getElement(T_TargetKey key)
          Gets a previous declared target with the given key.
 DependencyItem<T_ItemKey> getItem(T_ItemKey key)
          Gets a previous declared item with the given key.
 boolean isChanged()
          Indicates whether the dependencies had changed since the last sorting.
 boolean isDeepDependencyCheck()
          Indicates whether the sorting algorithm does a deep dependency check.
 void setAlgorithm(DependencyAlgorithm<T_TargetKey,T_ItemKey> algorithm)
          Set the algorithm to use for resolution of direct and indirect dependencies.
 void setAlgorithm(DependencyResolution x)
          Set the algorithm to use for resolution of direct and indirect dependencies.
 void setDeepDependencyCheck(Boolean onOff)
          Set deep dependency check on or off.
 void setDefaultOrder(Comparator<? super DependencyElement<T_TargetKey,T_ItemKey>> comparator)
          Sets the targets default sort order.
 void setDefaultOrder(DependencyOrder predefined)
          Sets the targets default sort order.
 Collection<DependencyElement<T_TargetKey,T_ItemKey>> sort()
          Get the targets sorted by primary and dependency order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleDependencies

public SimpleDependencies()

SimpleDependencies

public SimpleDependencies(DependencyOrder commonComparator)

SimpleDependencies

public SimpleDependencies(Comparator<? super DependencyElement<T_TargetKey,T_ItemKey>> comparator)
Method Detail

changed

public void changed()

getItem

public DependencyItem<T_ItemKey> getItem(T_ItemKey key)
Description copied from interface: Dependencies
Gets a previous declared item with the given key.

Specified by:
getItem in interface Dependencies<T_TargetKey,T_ItemKey>
Parameters:
key - The unique key for this item.
Returns:
The item with the given key or null if it not exists.

getElement

public DependencyElement<T_TargetKey,T_ItemKey> getElement(T_TargetKey key)
Description copied from interface: Dependencies
Gets a previous declared target with the given key.

Specified by:
getElement in interface Dependencies<T_TargetKey,T_ItemKey>
Parameters:
key - The unique key for this target.
Returns:
The target with the given key or null if it not exists.

declareItem

public DependencyItem<T_ItemKey> declareItem(T_ItemKey key)
Description copied from interface: Dependencies
Declares (constructs) an item with the given key. If an item with the given key is already declared, the method returns it; If not, it creates a new item.

Specified by:
declareItem in interface Dependencies<T_TargetKey,T_ItemKey>
Parameters:
key - The unique key for this item.
Returns:
The item with the given key.

declareElement

public DependencyElement<T_TargetKey,T_ItemKey> declareElement(T_TargetKey key)
Description copied from interface: Dependencies
Declares (constructs) an element with the given key. If the element with the given key is already declared, the method returns it; If not, it creates a new target.

Specified by:
declareElement in interface Dependencies<T_TargetKey,T_ItemKey>
Parameters:
key - The unique key for this target.
Returns:
The target with the given key.

isChanged

public boolean isChanged()
Description copied from interface: Dependencies
Indicates whether the dependencies had changed since the last sorting.

Specified by:
isChanged in interface Dependencies<T_TargetKey,T_ItemKey>
Returns:
True if the dependencies had changed, false otherwise.

isDeepDependencyCheck

public boolean isDeepDependencyCheck()
Description copied from interface: Dependencies
Indicates whether the sorting algorithm does a deep dependency check.

Specified by:
isDeepDependencyCheck in interface Dependencies<T_TargetKey,T_ItemKey>
Returns:
True if the sorting algorithm does a deep dependency check, false otherwise.

setAlgorithm

public void setAlgorithm(DependencyAlgorithm<T_TargetKey,T_ItemKey> algorithm)
Description copied from interface: Dependencies
Set the algorithm to use for resolution of direct and indirect dependencies.

Specified by:
setAlgorithm in interface Dependencies<T_TargetKey,T_ItemKey>
Parameters:
algorithm - The algorithm to use.

setAlgorithm

public void setAlgorithm(DependencyResolution x)
Description copied from interface: Dependencies
Set the algorithm to use for resolution of direct and indirect dependencies.

Specified by:
setAlgorithm in interface Dependencies<T_TargetKey,T_ItemKey>
Parameters:
x - The predefined algorithm to use.

setDeepDependencyCheck

public void setDeepDependencyCheck(Boolean onOff)
Description copied from interface: Dependencies
Set deep dependency check on or off.

Specified by:
setDeepDependencyCheck in interface Dependencies<T_TargetKey,T_ItemKey>
Parameters:
onOff - True to turn on the deep dependency check, false otherwise.

sort

public Collection<DependencyElement<T_TargetKey,T_ItemKey>> sort()
                                                          throws DependencyException
Description copied from interface: Dependencies
Get the targets sorted by primary and dependency order.

Specified by:
sort in interface Dependencies<T_TargetKey,T_ItemKey>
Returns:
A collection of the sorted targets.
Throws:
DependencyException - if an error occurs.

setDefaultOrder

public void setDefaultOrder(DependencyOrder predefined)
Description copied from interface: Dependencies
Sets the targets default sort order.

Specified by:
setDefaultOrder in interface Dependencies<T_TargetKey,T_ItemKey>
Parameters:
predefined - One of the predefined sort orders.

setDefaultOrder

public void setDefaultOrder(Comparator<? super DependencyElement<T_TargetKey,T_ItemKey>> comparator)
Description copied from interface: Dependencies
Sets the targets default sort order.

Specified by:
setDefaultOrder in interface Dependencies<T_TargetKey,T_ItemKey>
Parameters:
comparator - A custom comparator for DependencyTargets.

JTools

© 2000-2006, JTools.org.