Class FilterSet<E extends Filter>

  • All Implemented Interfaces:
    Dumpable
    Direct Known Subclasses:
    ItemFilterSet, PathFilterSet

    public abstract class FilterSet<E extends Filter>
    extends java.lang.Object
    implements Dumpable
    The item filter set holds a set of item filters each attributed as include or exclude filter. The evaluation of the set allows included items and rejects excluded items.

    Additionally it contains a "root" path for which the filters are evaluated. if an item has not the node addressed by the root path as ancestor, it is always excluded.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  FilterSet.Entry<E extends Filter>
      Holds a filter entry
    • Constructor Summary

      Constructors 
      Constructor Description
      FilterSet()
      Default constructor.
      FilterSet​(java.lang.String root)
      Creates a new item filter set and sets the respective root path
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      @NotNull FilterSet<E> addAll​(@NotNull FilterSet<E> set)
      Adds (replaces) all entries from the given set to this one.
      @NotNull FilterSet<E> addExclude​(E filter)
      Adds a new item filter as excluded entry.
      @NotNull FilterSet<E> addInclude​(E filter)
      Adds a new item filter as included entry.
      boolean covers​(@NotNull java.lang.String path)
      Checks if the given item is covered by this filter set.
      void dump​(@NotNull DumpContext ctx, boolean isLast)
      Dumps some human readable information using the given context.
      boolean equals​(java.lang.Object o)
      @NotNull java.util.List<FilterSet.Entry<E>> getEntries()
      Returns the list of entries
      @NotNull ImportMode getImportMode()
      Returns the import mode that is specified for this filter set.
      @NotNull java.lang.String getRoot()
      Returns the root path
      int hashCode()
      boolean isAncestor​(@NotNull java.lang.String path)
      Checks if the given item is an ancestor of the root node.
      boolean isEmpty()
      Checks if this filter set has any entries defined.
      boolean isSealed()
      Checks if this filter set is sealed.
      @NotNull FilterSet<E> seal()
      Seals this list, i.e.
      void setImportMode​(@NotNull ImportMode mode)
      Sets the import mode.
      void setRoot​(@NotNull java.lang.String path)
      Sets the root path
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • FilterSet

        public FilterSet()
        Default constructor. initializes the root path to "/"
      • FilterSet

        public FilterSet​(java.lang.String root)
        Creates a new item filter set and sets the respective root path
        Parameters:
        root - path
    • Method Detail

      • getRoot

        @NotNull
        public @NotNull java.lang.String getRoot()
        Returns the root path
        Returns:
        root path
      • setRoot

        public void setRoot​(@NotNull
                            @NotNull java.lang.String path)
        Sets the root path
        Parameters:
        path - root path
      • getImportMode

        @NotNull
        public @NotNull ImportMode getImportMode()
        Returns the import mode that is specified for this filter set. Defaults to ImportMode.REPLACE.
        Returns:
        the import mode.
      • setImportMode

        public void setImportMode​(@NotNull
                                  @NotNull ImportMode mode)
        Sets the import mode.
        Parameters:
        mode - import mode
      • seal

        @NotNull
        public @NotNull FilterSet<E> seal()
        Seals this list, i.e. makes it unmodifiable.
        Returns:
        this list
      • isSealed

        public boolean isSealed()
        Checks if this filter set is sealed.
        Returns:
        true if sealed.
      • addAll

        @NotNull
        public @NotNull FilterSet<E> addAll​(@NotNull
                                            @NotNull FilterSet<E> set)
        Adds (replaces) all entries from the given set to this one.
        Parameters:
        set - the set of entries
        Returns:
        this suitable for chaining.
      • addInclude

        @NotNull
        public @NotNull FilterSet<E> addInclude​(@NotNull
                                                E filter)
        Adds a new item filter as included entry.
        Parameters:
        filter - the filter
        Returns:
        this suitable for chaining.
      • addExclude

        @NotNull
        public @NotNull FilterSet<E> addExclude​(@NotNull
                                                E filter)
        Adds a new item filter as excluded entry.
        Parameters:
        filter - the filter
        Returns:
        this suitable for chaining.
      • getEntries

        @NotNull
        public @NotNull java.util.List<FilterSet.Entry<E>> getEntries()
        Returns the list of entries
        Returns:
        the list of entries
      • isEmpty

        public boolean isEmpty()
        Checks if this filter set has any entries defined.
        Returns:
        true if empty
      • covers

        public boolean covers​(@NotNull
                              @NotNull java.lang.String path)
        Checks if the given item is covered by this filter set. I.e. if the node addressed by the root path is an ancestor of the given item.
        Parameters:
        path - path of the item
        Returns:
        true if this set covers the given item
      • isAncestor

        public boolean isAncestor​(@NotNull
                                  @NotNull java.lang.String path)
        Checks if the given item is an ancestor of the root node.
        Parameters:
        path - path of the item to check
        Returns:
        true if the given item is an ancestor
      • dump

        public void dump​(@NotNull
                         @NotNull DumpContext ctx,
                         boolean isLast)
        Dumps some human readable information using the given context.
        Specified by:
        dump in interface Dumpable
        Parameters:
        ctx - the dump context
        isLast - specifies if this is the last element to dump on this level
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object