Class InstanceFilter<T>
java.lang.Object
org.springframework.util.InstanceFilter<T>
- Type Parameters:
T- the instance type
- Direct Known Subclasses:
ExceptionTypeFilter
A simple instance filter that checks if a given instance matches based on
collections of includes and excludes.
Subclasses may override match(Object, Object) to provide a custom
matching algorithm.
- Since:
- 4.1
- Author:
- Stephane Nicoll, Sam Brannen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Collection<? extends T> protected final Collection<? extends T> protected final boolean -
Constructor Summary
ConstructorsConstructorDescriptionInstanceFilter(@nullable Collection<? extends T> includes, @nullable Collection<? extends T> excludes) Create a newInstanceFilterbased on include and exclude collections, with thematchIfEmptyflag set totrue.InstanceFilter(@nullable Collection<? extends T> includes, @nullable Collection<? extends T> excludes, boolean matchIfEmpty) Create a newInstanceFilterbased on include and exclude collections. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermine if the specifiedinstancematches this filter.protected booleanmatch(T instance, Collection<? extends T> candidates) Determine if the specifiedinstancematches one of the candidates.protected booleanDetermine if the specifiedinstancematches the specifiedcandidate.toString()
-
Field Details
-
includes
-
excludes
-
matchIfEmpty
protected final boolean matchIfEmpty
-
-
Constructor Details
-
InstanceFilter
public InstanceFilter(@nullable Collection<? extends T> includes, @nullable Collection<? extends T> excludes) Create a newInstanceFilterbased on include and exclude collections, with thematchIfEmptyflag set totrue.See
InstanceFilter(Collection, Collection, boolean)for details.- Parameters:
includes- the collection of includesexcludes- the collection of excludes- Since:
- 7.0
-
InstanceFilter
public InstanceFilter(@nullable Collection<? extends T> includes, @nullable Collection<? extends T> excludes, boolean matchIfEmpty) Create a newInstanceFilterbased on include and exclude collections.A particular element will match if it matches one of the elements in the
includeslist and does not match one of the elements in theexcludeslist.Subclasses may redefine what matching means. By default, an element matches another if the two elements are equal.
If both collections are empty,
matchIfEmptydefines if an element matches or not.- Parameters:
includes- the collection of includesexcludes- the collection of excludesmatchIfEmpty- the matching result if the includes and the excludes collections are bothnullor empty
-
-
Method Details
-
match
Determine if the specifiedinstancematches this filter. -
match
Determine if the specifiedinstancematches the specifiedcandidate.By default, the two instances match if they are equal.
Can be overridden by subclasses.
- Parameters:
instance- the instance to checkcandidate- a candidate defined by this filter- Returns:
trueif the instance matches the candidate
-
match
Determine if the specifiedinstancematches one of the candidates.- Parameters:
instance- the instance to checkcandidates- the collection of candidates- Returns:
trueif the instance matches;falseif the candidates collection is empty or there is no match
-
toString
-