Class PropertyMatchers

All Implemented Interfaces:
Serializable, Cloneable, Iterable<PropertyMatcher>, Collection<PropertyMatcher>, Predicate<Properties>, List<PropertyMatcher>, RandomAccess, SequencedCollection<PropertyMatcher>

public class PropertyMatchers extends ArrayList<PropertyMatcher> implements Predicate<Properties>
Holds a collection of PropertyMatcher to perform multiple matches or replacements at once.
Since:
2.0.0
See Also:
  • Constructor Details

    • PropertyMatchers

      public PropertyMatchers()
  • Method Details

    • addAll

      public boolean addAll(PropertyMatcher... matchers)
      Adds one or more property matchers. A null array as well as null array elements are not added.
      Parameters:
      matchers - property matchers
      Returns:
      true if this list chanced as a result of the call
    • addAll

      public boolean addAll(Collection<? extends PropertyMatcher> matchers)
      Specified by:
      addAll in interface Collection<PropertyMatcher>
      Specified by:
      addAll in interface List<PropertyMatcher>
      Overrides:
      addAll in class ArrayList<PropertyMatcher>
    • remove

      public int remove(String field)
      Removes all matchers matching the given property field.
      Parameters:
      field - the field to remove matchers on
      Returns:
      how many matchers were removed
    • matches

      public boolean matches(Properties properties)
      Returns true if any of the properties key and values match any of the property matchers (only one property matcher needs to match). Returns false if the supplied argument is null.
      Parameters:
      properties - the properties to look for a match
      Returns:
      true if one property matcher matches.
    • test

      public boolean test(Properties properties)
      For compatibility with Predicate. Same as invoking matches(Properties).
      Specified by:
      test in interface Predicate<Properties>
      Parameters:
      properties - the properties to look for a match
      Returns:
      true if at least one value for the key matches the list of matcher regular expressions
    • match

      public Properties match(Properties properties)
      Returns a new instance that is a subset of the given properties, containing only keys and matching values. Returns an empty Properties instance if the supplied argument is null.
      Parameters:
      properties - the properties to look for a match
      Returns:
      a list of matching values, or an empty list
      See Also:
    • replace

      public Properties replace(Properties properties, String replacement)
      Replaces all matching values of the matching keys in the given Properties with the given replacement. Returns properties that were replaced (or empty). Returns an empty Properties instance if the supplied argument is null.
      Parameters:
      properties - the properties to look for a match and replace
      replacement - text replacement
      Returns:
      properties that were replaced with their original values