Class MultiFilter<T extends JobParameters>
java.lang.Object
io.github.douira.glsl_transformer.transform.LifecycleUserImpl<T>
io.github.douira.glsl_transformer.print.filter.TokenFilter<T>
io.github.douira.glsl_transformer.print.filter.MultiFilter<T>
- All Implemented Interfaces:
LifecycleUser<T>
A multi filter checks all contained filters with either requiring all of them
or at least one of them to allow the token. It can also be configured to
short-circuit, meaning that it stops checking the filters if the result can't
change anymore.
By default it's a conjunction that doesn't short-circuit
checking all filters to allow the token and continuing even if an earlier
filter has disallowed it. Since filters can have state, it can be desirerable
to notify all of them of all tokens.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new empty default multi filter.MultiFilter(boolean conjunction, boolean shortCircuit) Creates a new multi filter the behavior options.MultiFilter(int initialCapacity) Creates a new default multi filter with an initial size capacity.MultiFilter(int initialCapacity, boolean conjunction, boolean shortCircuit) Creates a new multi filter with an initial size capacity and the behavior options.MultiFilter(Collection<? extends TokenFilter<T>> subfilters) Creates a new default multi filter with the given list of subfilters.MultiFilter(Collection<TokenFilter<T>> subfilters, boolean conjunction, boolean shortCircuit) Creates a new multi filter with the given list of subfilters and the behavior options. -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(TokenFilter<T> filter) Adds a token filter to the collection of subfilters.booleanaddAll(MultiFilter<T> other) Adds all subfilters contained in an other multi filter to this multi filter's collection of subfilters.booleanaddAll(Collection<? extends TokenFilter<T>> newSubfilters) Adds a collection of token filters to the collection of subfilters.clone()Creates a shallow clone of this multi filter.booleanisTokenAllowed(Token token) Checks if the token should be printed.voidResets the filter's state.voidsetConjunction(boolean conjunction) Sets the conjunction behavior flagvoidsetPlanner(ExecutionPlanner<T> planner) Sets the parent planner of this child.voidsetShortCircuit(boolean shortCircuit) Sets the conjunction short circuit flagMethods inherited from class io.github.douira.glsl_transformer.print.filter.TokenFilter
joinMethods inherited from class io.github.douira.glsl_transformer.transform.LifecycleUserImpl
getPlanner, isInitialized, setInitializedMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.douira.glsl_transformer.transform.LifecycleUser
getJobParameters, getLexer, getParser, getRootNode, init, initOnce
-
Constructor Details
-
MultiFilter
public MultiFilter(Collection<TokenFilter<T>> subfilters, boolean conjunction, boolean shortCircuit) Creates a new multi filter with the given list of subfilters and the behavior options.- Parameters:
subfilters- The subfilters to add initiallyconjunction- The conjunction flag stateshortCircuit- The short circuit flag state- See Also:
-
MultiFilter
public MultiFilter(int initialCapacity, boolean conjunction, boolean shortCircuit) Creates a new multi filter with an initial size capacity and the behavior options.- Parameters:
initialCapacity- The initial list capacityconjunction- The conjunction flag stateshortCircuit- The short circuit flag state- See Also:
-
MultiFilter
public MultiFilter(boolean conjunction, boolean shortCircuit) Creates a new multi filter the behavior options.- Parameters:
conjunction- The conjunction flag stateshortCircuit- The short circuit flag state- See Also:
-
MultiFilter
Creates a new default multi filter with the given list of subfilters.- Parameters:
subfilters- The subfilters to add initially- See Also:
-
MultiFilter
public MultiFilter(int initialCapacity) Creates a new default multi filter with an initial size capacity.- Parameters:
initialCapacity- The initial list capacity- See Also:
-
MultiFilter
public MultiFilter()Creates a new empty default multi filter.- See Also:
-
-
Method Details
-
setConjunction
public void setConjunction(boolean conjunction) Sets the conjunction behavior flag- Parameters:
conjunction- The new conjunction flag state
-
setShortCircuit
public void setShortCircuit(boolean shortCircuit) Sets the conjunction short circuit flag- Parameters:
shortCircuit- The new short circuit flag state
-
add
Adds a token filter to the collection of subfilters.- Parameters:
filter- The filter to add- Returns:
trueif the underlying collection changed
-
addAll
Adds a collection of token filters to the collection of subfilters.- Parameters:
newSubfilters- The filters to add- Returns:
trueif the underlying collection changed
-
addAll
Adds all subfilters contained in an other multi filter to this multi filter's collection of subfilters.- Parameters:
other- The other multi filter to take subfilters from- Returns:
trueif the underlying collection changed
-
clone
Creates a shallow clone of this multi filter. It copies over the collection of subfilters shallowly and copies the settings. -
resetState
public void resetState()Description copied from class:TokenFilterResets the filter's state. Does nothing by default.- Specified by:
resetStatein interfaceLifecycleUser<T extends JobParameters>- Overrides:
resetStatein classTokenFilter<T extends JobParameters>
-
isTokenAllowed
Description copied from class:TokenFilterChecks if the token should be printed.- Specified by:
isTokenAllowedin classTokenFilter<T extends JobParameters>- Parameters:
token- The token to check- Returns:
trueif the given token should be printed
-
setPlanner
Description copied from interface:LifecycleUserSets the parent planner of this child.- Specified by:
setPlannerin interfaceLifecycleUser<T extends JobParameters>- Overrides:
setPlannerin classLifecycleUserImpl<T extends JobParameters>- Parameters:
planner- The execution planner to set as the parent
-