Class FilterSpec

java.lang.Object
org.wildfly.discovery.FilterSpec
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AllFilterSpec, AnyFilterSpec, BooleanFilterSpec, EqualsFilterSpec, GreaterEqualFilterSpec, HasFilterSpec, LessEqualFilterSpec, NotFilterSpec, SubstringFilterSpec

public abstract class FilterSpec extends Object implements Serializable
A filter specification for matching attributes.
Author:
David M. Lloyd
See Also:
  • Method Details

    • matchesSimple

      public abstract boolean matchesSimple(Map<String,AttributeValue> attributes)
      Determine whether the given simple attribute map matches this filter.
      Parameters:
      attributes - the attribute map
      Returns:
      true if the map matches, false otherwise
    • matchesMulti

      public abstract boolean matchesMulti(Map<String,? extends Collection<AttributeValue>> attributes)
      Determine whether the given attribute multi-map matches this filter.
      Parameters:
      attributes - the attribute map
      Returns:
      true if the map matches, false otherwise
    • willMatch

      public final boolean willMatch(Collection<String> attributeNames)
      Determine whether this filter spec will always match an attribute map containing the given keys. This is simply the inverse of mayNotMatch(Collection).
      Parameters:
      attributeNames - the attribute names
      Returns:
      true if the filter will definitely match, false if it might not match
    • mayMatch

      public abstract boolean mayMatch(Collection<String> attributeNames)
      Determine whether this filter spec might match an attribute map containing the given keys.
      Parameters:
      attributeNames - the attribute names
      Returns:
      true if the filter spec might match, false if it will definitely not match
    • mayNotMatch

      public abstract boolean mayNotMatch(Collection<String> attributeNames)
      Determine whether this filter spec might not match an attribute map containing the given keys.
      Parameters:
      attributeNames - the attribute names
      Returns:
      true if the filter spec might not match, false if it will definitely match
    • willNotMatch

      public final boolean willNotMatch(Collection<String> attributeNames)
      Determine whether this filter spec will never match an attribute map containing the given keys. This is simply the inverse of mayMatch(Collection).
      Parameters:
      attributeNames - the attribute names
      Returns:
      true if the filter will definitely not match, false if it might match
    • accept

      public abstract <P, R, E extends Exception> R accept(FilterSpec.Visitor<P,R,E> visitor, P parameter) throws E
      Throws:
      E extends Exception
    • accept

      public final <R, E extends Exception> R accept(FilterSpec.Visitor<?,R,E> visitor) throws E
      Throws:
      E extends Exception
    • fromString

      public static FilterSpec fromString(String string)
      Create a new filter from a string.
      Parameters:
      string - the filter string
      Returns:
      the filter specification
    • all

      public static FilterSpec all()
      Create a filter which matches everything.
      Returns:
      the filter specification
    • none

      public static FilterSpec none()
      Create a filter which matches nothing.
      Returns:
      the filter specification
    • all

      public static FilterSpec all(FilterSpec... specs)
      Create a filter which matches all of the given sub-filters.
      Parameters:
      specs - the sub-filters
      Returns:
      the filter specification
    • all

      public static FilterSpec all(Collection<FilterSpec> specs)
      Create a filter which matches all of the given sub-filters.
      Parameters:
      specs - the sub-filters
      Returns:
      the filter specification
    • any

      public static FilterSpec any(FilterSpec... specs)
      Create a filter which matches any of the given sub-filters.
      Parameters:
      specs - the sub-filters
      Returns:
      the filter specification
    • any

      public static FilterSpec any(Collection<FilterSpec> specs)
      Create a filter which matches any of the given sub-filters.
      Parameters:
      specs - the sub-filters
      Returns:
      the filter specification
    • not

      public static FilterSpec not(FilterSpec spec)
      Create a filter which matches the inverse of the given filter.
      Parameters:
      spec - the sub-filter
      Returns:
      the filter specification
    • equal

      public static FilterSpec equal(String attribute, String value)
      Create a filter specification which matches one attribute value.
      Parameters:
      attribute - the attribute name
      value - the attribute value
      Returns:
      the filter specification
    • equal

      public static FilterSpec equal(String attribute, byte[] value)
      Create a filter specification which matches one attribute value.
      Parameters:
      attribute - the attribute name
      value - the attribute byte value
      Returns:
      the filter specification
    • substringMatch

      public static FilterSpec substringMatch(String attribute, String initialPart, String finalPart)
      Create a filter specification which matches a leading or trailing (or both) substring of one attribute value.
      Parameters:
      attribute - the attribute name
      initialPart - the initial part, or "" to match any initial part
      finalPart - the final part, or "" to match any final part
      Returns:
      the filter specification
    • approx

      public static FilterSpec approx(String attribute, String value)
      Create a filter specification which approximately matches one attribute value.
      Parameters:
      attribute - the attribute name
      value - the attribute value
      Returns:
      the filter specification
    • greaterOrEqual

      public static FilterSpec greaterOrEqual(String attribute, String value)
      Create a filter specification which matches when the given attribute's value is lexicographically greater than or equal to the given value.
      Parameters:
      attribute - the attribute name
      value - the attribute value
      Returns:
      the filter specification
    • greaterOrEqual

      public static FilterSpec greaterOrEqual(String attribute, byte[] value)
      Create a filter specification which matches when the given attribute's value is lexicographically greater than or equal to the given value.
      Parameters:
      attribute - the attribute name
      value - the attribute value
      Returns:
      the filter specification
    • lessOrEqual

      public static FilterSpec lessOrEqual(String attribute, String value)
      Create a filter specification which matches when the given attribute's value is lexicographically less than or equal to the given value.
      Parameters:
      attribute - the attribute name
      value - the attribute value
      Returns:
      the filter specification
    • lessOrEqual

      public static FilterSpec lessOrEqual(String attribute, byte[] value)
      Create a filter specification which matches when the given attribute's value is lexicographically less than or equal to the given value.
      Parameters:
      attribute - the attribute name
      value - the attribute value
      Returns:
      the filter specification
    • hasAttribute

      public static FilterSpec hasAttribute(String attribute)
      Create a filter specification which matches when the given attribute is present.
      Parameters:
      attribute - the attribute name
      Returns:
      the filter specification
    • escape

      public static String escape(String str)
      Escape an attribute string, suitable for putting into a filter.
      Parameters:
      str - the string to escape
      Returns:
      the escaped string
    • escapeTo

      public static void escapeTo(String str, StringBuilder b)
      Escape an attribute string, suitable for putting into a filter.
      Parameters:
      str - the string to escape
      b - the builder to append to
    • equals

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object
    • equals

      public abstract boolean equals(FilterSpec other)
    • toString

      public final String toString()
      Get the string representation of this filter.
      Overrides:
      toString in class Object
      Returns:
      the string representation of this filter