Interface TraversalStrategies
-
- All Superinterfaces:
Cloneable
,Iterable<TraversalStrategy<?>>
,Serializable
- All Known Implementing Classes:
DefaultTraversalStrategies
,EmptyTraversalStrategies
public interface TraversalStrategies extends Serializable, Cloneable, Iterable<TraversalStrategy<?>>
ATraversal
maintains a set ofTraversalStrategy
instances within a TraversalStrategies object. TraversalStrategies are responsible for compiling a traversal prior to its execution.- Author:
- Marko A. Rodriguez (http://markorodriguez.com), Matthias Broecheler (me@matthiasb.com)
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
TraversalStrategies.GlobalCache
-
Field Summary
Fields Modifier and Type Field Description static List<Class<? extends TraversalStrategy>>
STRATEGY_CATEGORIES
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description TraversalStrategies
addStrategies(TraversalStrategy<?>... strategies)
Add all the providedTraversalStrategy
instances to the current collection.TraversalStrategies
clone()
default <T extends TraversalStrategy>
Optional<T>getStrategy(Class<T> traversalStrategyClass)
Return theTraversalStrategy
instance associated with the provided class.Iterator<TraversalStrategy<?>>
iterator()
Return anIterator
of theTraversalStrategy
instances.TraversalStrategies
removeStrategies(Class<? extends TraversalStrategy>... strategyClasses)
Remove all the providedTraversalStrategy
classes from the current collection.static Set<TraversalStrategy<?>>
sortStrategies(Set<TraversalStrategy<?>> strategies)
Sorts the list of provided strategies such that theTraversalStrategy.applyPost()
andTraversalStrategy.applyPrior()
dependencies are respected.default List<TraversalStrategy<?>>
toList()
Return an immutable list of theTraversalStrategy
instances.static void
visit(Map<Class<? extends TraversalStrategy>,Set<Class<? extends TraversalStrategy>>> dependencyMap, List<Class<? extends TraversalStrategy>> sortedStrategyClasses, Set<Class<? extends TraversalStrategy>> seenStrategyClases, List<Class<? extends TraversalStrategy>> unprocessedStrategyClasses, Class<? extends TraversalStrategy> strategyClass)
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
STRATEGY_CATEGORIES
static final List<Class<? extends TraversalStrategy>> STRATEGY_CATEGORIES
-
-
Method Detail
-
toList
default List<TraversalStrategy<?>> toList()
Return an immutable list of theTraversalStrategy
instances.
-
iterator
Iterator<TraversalStrategy<?>> iterator()
Return anIterator
of theTraversalStrategy
instances.- Specified by:
iterator
in interfaceIterable<TraversalStrategy<?>>
-
getStrategy
default <T extends TraversalStrategy> Optional<T> getStrategy(Class<T> traversalStrategyClass)
Return theTraversalStrategy
instance associated with the provided class.- Type Parameters:
T
- the strategy class type- Parameters:
traversalStrategyClass
- the class of the strategy to get- Returns:
- an optional containing the strategy instance or not
-
addStrategies
TraversalStrategies addStrategies(TraversalStrategy<?>... strategies)
Add all the providedTraversalStrategy
instances to the current collection. When all the provided strategies have been added, the collection is resorted. If a strategy class is found to already be defined, it is removed and replaced by the newly added one.- Parameters:
strategies
- the traversal strategies to add- Returns:
- the newly updated/sorted traversal strategies collection
-
removeStrategies
TraversalStrategies removeStrategies(Class<? extends TraversalStrategy>... strategyClasses)
Remove all the providedTraversalStrategy
classes from the current collection. When all the provided strategies have been removed, the collection is resorted.- Parameters:
strategyClasses
- the traversal strategies to remove by their class- Returns:
- the newly updated/sorted traversal strategies collection
-
clone
TraversalStrategies clone()
-
sortStrategies
static Set<TraversalStrategy<?>> sortStrategies(Set<TraversalStrategy<?>> strategies)
Sorts the list of provided strategies such that theTraversalStrategy.applyPost()
andTraversalStrategy.applyPrior()
dependencies are respected. Note, that the order may not be unique.- Parameters:
strategies
- the traversal strategies to sort
-
visit
static void visit(Map<Class<? extends TraversalStrategy>,Set<Class<? extends TraversalStrategy>>> dependencyMap, List<Class<? extends TraversalStrategy>> sortedStrategyClasses, Set<Class<? extends TraversalStrategy>> seenStrategyClases, List<Class<? extends TraversalStrategy>> unprocessedStrategyClasses, Class<? extends TraversalStrategy> strategyClass)
-
-