Package overit.geocall.util
Class DependencyChain<T>
java.lang.Object
overit.geocall.util.DependencyChain<T>
Simple implementation of a list that allows you to define dependency constraints between the various elements
using the
DependencyChain.Item.isAfter(DependencyChain.Item) and DependencyChain.Item.isBefore(DependencyChain.Item) methods.
Once the constraints have been defined, it allows you to obtain a list whose order of the elements respects the
assigned constraints.
DependencyChain<String> chain = new DependencyChain<>();
Item<String> i2 = chain.add("second");
Item<String> i1 = chain.add("first");
i1.isBefore(i2);
List<String> orderedList = chain.sort();
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd a new object into the chainsort()Get the list ordered based on the constraint set with theDependencyChain.Item.isAfter(DependencyChain.Item)andDependencyChain.Item.isBefore(DependencyChain.Item)methods
-
Field Details
-
list
-
changed
protected boolean changed
-
-
Constructor Details
-
DependencyChain
public DependencyChain()
-
-
Method Details
-
add
Add a new object into the chain- Parameters:
name- instance of the object that will be added- Returns:
- the Item already added
-
sort
Get the list ordered based on the constraint set with theDependencyChain.Item.isAfter(DependencyChain.Item)andDependencyChain.Item.isBefore(DependencyChain.Item)methods- Returns:
- the list ordered by the dependency constraint
-