Interface TraversalStrategies
- All Superinterfaces:
Cloneable,Iterable<TraversalStrategy<?>>,Serializable
- All Known Implementing Classes:
DefaultTraversalStrategies,EmptyTraversalStrategies
public interface TraversalStrategies
extends Serializable, Cloneable, Iterable<TraversalStrategy<?>>
A
Traversal maintains a set of TraversalStrategy instances within a TraversalStrategies}
object. Of particular importance is the TraversalStrategies.GlobalCache which maintains a set of default strategies to be applied
and a registry of available strategies.- Author:
- Marko A. Rodriguez (http://markorodriguez.com), Matthias Broecheler (me@matthiasb.com)
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionaddStrategies(TraversalStrategy<?>... strategies) Add all the providedTraversalStrategyinstances to the current collection.clone()default <T extends TraversalStrategy>
Optional<T>getStrategy(Class<T> traversalStrategyClass) Return theTraversalStrategyinstance associated with the provided class.iterator()Return anIteratorof theTraversalStrategyinstances.removeStrategies(Class<? extends TraversalStrategy>... strategyClasses) Remove all the providedTraversalStrategyclasses 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 theTraversalStrategyinstances.static voidvisit(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 Details
-
STRATEGY_CATEGORIES
-
-
Method Details
-
toList
Return an immutable list of theTraversalStrategyinstances. -
iterator
Iterator<TraversalStrategy<?>> iterator()Return anIteratorof theTraversalStrategyinstances.- Specified by:
iteratorin interfaceIterable<TraversalStrategy<?>>
-
getStrategy
Return theTraversalStrategyinstance 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
Add all the providedTraversalStrategyinstances 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
Remove all the providedTraversalStrategyclasses 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
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)
-