Class MultiFilter<T extends JobParameters>

All Implemented Interfaces:
LifecycleUser<T>

public class MultiFilter<T extends JobParameters> extends TokenFilter<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 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 initially
      conjunction - The conjunction flag state
      shortCircuit - 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 capacity
      conjunction - The conjunction flag state
      shortCircuit - 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 state
      shortCircuit - The short circuit flag state
      See Also:
    • MultiFilter

      public MultiFilter(Collection<? extends TokenFilter<T>> subfilters)
      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

      public boolean add(TokenFilter<T> filter)
      Adds a token filter to the collection of subfilters.
      Parameters:
      filter - The filter to add
      Returns:
      true if the underlying collection changed
    • addAll

      public boolean addAll(Collection<? extends TokenFilter<T>> newSubfilters)
      Adds a collection of token filters to the collection of subfilters.
      Parameters:
      newSubfilters - The filters to add
      Returns:
      true if the underlying collection changed
    • addAll

      public boolean addAll(MultiFilter<T> other)
      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:
      true if the underlying collection changed
    • clone

      public MultiFilter<T> clone()
      Creates a shallow clone of this multi filter. It copies over the collection of subfilters shallowly and copies the settings.
      Overrides:
      clone in class Object
    • resetState

      public void resetState()
      Description copied from class: TokenFilter
      Resets the filter's state. Does nothing by default.
      Specified by:
      resetState in interface LifecycleUser<T extends JobParameters>
      Overrides:
      resetState in class TokenFilter<T extends JobParameters>
    • isTokenAllowed

      public boolean isTokenAllowed(Token token)
      Description copied from class: TokenFilter
      Checks if the token should be printed.
      Specified by:
      isTokenAllowed in class TokenFilter<T extends JobParameters>
      Parameters:
      token - The token to check
      Returns:
      true if the given token should be printed
    • setPlanner

      public void setPlanner(ExecutionPlanner<T> planner)
      Description copied from interface: LifecycleUser
      Sets the parent planner of this child.
      Specified by:
      setPlanner in interface LifecycleUser<T extends JobParameters>
      Overrides:
      setPlanner in class LifecycleUserImpl<T extends JobParameters>
      Parameters:
      planner - The execution planner to set as the parent