Package com.norconex.commons.lang.map

# Class PropertyMatchers

java.lang.Object
java.util.AbstractCollection<PropertyMatcher>
java.util.AbstractList<PropertyMatcher>
java.util.ArrayList<PropertyMatcher>
com.norconex.commons.lang.map.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:
  - Serialized Form

- ## Field Summary

  ### Fields inherited from class java.util.AbstractList

  `modCount`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PropertyMatchers()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `addAll(PropertyMatcher... matchers)`
  Adds one or more property matchers.
  `boolean`
  `addAll(Collection<? extends PropertyMatcher> matchers)`
  `Properties`
  `match(Properties properties)`
  Returns a new instance that is a subset of the given properties, containing only keys and matching values.
  `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).
  `int`
  `remove(String field)`
  Removes all matchers matching the given property field.
  `Properties`
  `replace(Properties properties, String replacement)`
  Replaces all matching values of the matching keys in the given `Properties` with the given replacement.
  `boolean`
  `test(Properties properties)`
  For compatibility with `Predicate`.

  ### Methods inherited from class java.util.ArrayList

  `add, add, addAll, addFirst, addLast, clear, clone, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize`

  ### Methods inherited from class java.util.AbstractCollection

  `containsAll, toString`

  ### Methods inherited from class java.lang.Object

  `finalize, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface java.util.Collection

  `parallelStream, stream, toArray`

  ### Methods inherited from interface java.util.List

  `containsAll, reversed`

  ### Methods inherited from interface java.util.function.Predicate

  `and, negate, or`

- ## 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:
      - `test(Properties)`

  - ### 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