Class CompositeItemFilter

java.lang.Object
org.craftercms.core.service.impl.CompositeItemFilter
All Implemented Interfaces:
ItemFilter

public class CompositeItemFilter extends Object implements ItemFilter
Composite ItemFilter implementation. Calls ItemFilters before processing and after processing, depending on what their ItemFilter.runBeforeProcessing() and ItemFilter.runAfterProcessing() methods return.
Author:
Sumer Jabri, Alfonso Vásquez
  • Constructor Details

    • CompositeItemFilter

      public CompositeItemFilter()
      Creates a composite filter with a null list of ItemFilters.
    • CompositeItemFilter

      public CompositeItemFilter(List<ItemFilter> filters)
      Creates a composite filter with the specified list of ItemFilters.
    • CompositeItemFilter

      public CompositeItemFilter(ItemFilter... filters)
      Creates a composite filter with the specified array of ItemFilters.
  • Method Details

    • setFilters

      public void setFilters(List<ItemFilter> filters)
      Sets the list of filters.
    • addFilter

      public void addFilter(ItemFilter filter)
      Adds the specified ItemFilter to the filter list, creating the list if necessary.
    • removeFilter

      public boolean removeFilter(ItemFilter filter)
      Removes the specified ItemFilter from the filter list, only if the list is not null.
    • runBeforeProcessing

      public boolean runBeforeProcessing()
      Always returns true so that filters that need to run before processing are called.
      Specified by:
      runBeforeProcessing in interface ItemFilter
    • runAfterProcessing

      public boolean runAfterProcessing()
      Always returns true so that filters that need to run after processing are called.
      Specified by:
      runAfterProcessing in interface ItemFilter
    • accepts

      public boolean accepts(Item item, List<Item> acceptedItems, List<Item> rejectedItems, boolean runningBeforeProcessing)
      If runningBeforeProcessing is true, calls all filters that need to be run before processing. If it is false, calls all filters that need to be run after processing. Filters in the chain are called until one of them rejects the item.
      Specified by:
      accepts in interface ItemFilter
      Parameters:
      item - the item to accept or reject
      acceptedItems - the list of the currently accepted items
      rejectedItems - the list of the currently rejected items
      runningBeforeProcessing - if the filter is running before processing (true) or after processing (false)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object