Package com.norconex.commons.lang.map
Class PropertyMatchers
java.lang.Object
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<PropertyMatcher>,Collection<PropertyMatcher>,Predicate<Properties>,List<PropertyMatcher>,RandomAccess,SequencedCollection<PropertyMatcher>
Holds a collection of
PropertyMatcher to perform multiple matches
or replacements at once.- Since:
- 2.0.0
- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddAll(PropertyMatcher... matchers) Adds one or more property matchers.booleanaddAll(Collection<? extends PropertyMatcher> matchers) match(Properties properties) Returns a new instance that is a subset of the given properties, containing only keys and matching values.booleanmatches(Properties properties) Returnstrueif any of the properties key and values match any of the property matchers (only one property matcher needs to match).intRemoves all matchers matching the given property field.replace(Properties properties, String replacement) Replaces all matching values of the matching keys in the givenPropertieswith the given replacement.booleantest(Properties properties) For compatibility withPredicate.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, trimToSizeMethods inherited from class java.util.AbstractCollection
containsAll, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
containsAll, reversed
-
Constructor Details
-
PropertyMatchers
public PropertyMatchers()
-
-
Method Details
-
addAll
Adds one or more property matchers. Anullarray as well asnullarray elements are not added.- Parameters:
matchers- property matchers- Returns:
trueif this list chanced as a result of the call
-
addAll
- Specified by:
addAllin interfaceCollection<PropertyMatcher>- Specified by:
addAllin interfaceList<PropertyMatcher>- Overrides:
addAllin classArrayList<PropertyMatcher>
-
remove
Removes all matchers matching the given property field.- Parameters:
field- the field to remove matchers on- Returns:
- how many matchers were removed
-
matches
Returnstrueif any of the properties key and values match any of the property matchers (only one property matcher needs to match). Returnsfalseif the supplied argument isnull.- Parameters:
properties- the properties to look for a match- Returns:
trueif one property matcher matches.
-
test
For compatibility withPredicate. Same as invokingmatches(Properties).- Specified by:
testin interfacePredicate<Properties>- Parameters:
properties- the properties to look for a match- Returns:
trueif at least one value for the key matches the list of matcher regular expressions
-
match
Returns a new instance that is a subset of the given properties, containing only keys and matching values. Returns an emptyPropertiesinstance if the supplied argument isnull.- Parameters:
properties- the properties to look for a match- Returns:
- a list of matching values, or an empty list
- See Also:
-
replace
Replaces all matching values of the matching keys in the givenPropertieswith the given replacement. Returns properties that were replaced (or empty). Returns an emptyPropertiesinstance if the supplied argument isnull.- Parameters:
properties- the properties to look for a match and replacereplacement- text replacement- Returns:
- properties that were replaced with their original values
-