Package com.norconex.commons.lang.map
Class PropertyMatchers
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<PropertyMatcher>
-
- com.norconex.commons.lang.map.PropertyMatchers
-
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<PropertyMatcher>,Collection<PropertyMatcher>,Predicate<Properties>,List<PropertyMatcher>,RandomAccess
public class PropertyMatchers extends ArrayList<PropertyMatcher> implements Predicate<Properties>
Holds a collection ofPropertyMatcherto perform tests/replace on all of them at once.- Since:
- 2.0.0
- Author:
- Pascal Essiembre
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description PropertyMatchers()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAll(PropertyMatcher... matchers)Adds one or more property matchers.Propertiesmatch(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.intremove(String field)Removes all matchers for a given field.Propertiesreplace(Properties properties, String replacement)Returns properties that were replaced (or empty).booleantest(Properties properties)For compatibility withPredicate.-
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, 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
-
-
-
-
Method Detail
-
addAll
public void addAll(PropertyMatcher... matchers)
Adds one or more property matchers.- Parameters:
matchers- property matchers
-
remove
public int remove(String field)
Removes all matchers for a given field.- Parameters:
field- the field to remove matchers on- Returns:
- how many matchers were removed
-
matches
public boolean matches(Properties properties)
Returnstrueif any of the properties key and values match any of the property matchers.- 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
-
test
public boolean test(Properties properties)
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
public Properties match(Properties properties)
Returns a new instance that is a subset of the given properties, containing only keys and matching values.- 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)
Returns properties that were replaced (or empty).- Parameters:
properties- the properties to look for a match and replacereplacement- text replacement- Returns:
- properties that were replaced
-
-