Package org.springframework.util
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 match based on
a collection of includes and excludes element.
Subclasses may want to override match(Object, Object)
to provide
a custom matching algorithm.
- Since:
- 4.1
- Author:
- Stephane Nicoll
-
Constructor Summary
ConstructorsConstructorDescriptionInstanceFilter
(Collection<? extends T> includes, Collection<? extends T> excludes, boolean matchIfEmpty) Create a new instance based on includes/excludes collections. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Determine if the specifiedinstance
matches this filter.protected boolean
match
(T instance, Collection<? extends T> candidates) Determine if the specifiedinstance
matches one of the candidates.protected boolean
Determine if the specifiedinstance
is equal to the specifiedcandidate
.toString()
-
Constructor Details
-
InstanceFilter
public InstanceFilter(@Nullable Collection<? extends T> includes, @Nullable Collection<? extends T> excludes, boolean matchIfEmpty) Create a new instance based on includes/excludes collections.A particular element will match if it "matches" the one of the element in the includes list and does not match one of the element in the excludes list.
Subclasses may redefine what matching means. By default, an element match with another if it is equals according to
Object.equals(Object)
If both collections are empty,
matchIfEmpty
defines if an element matches or not.- Parameters:
includes
- the collection of includesexcludes
- the collection of excludesmatchIfEmpty
- the matching result if both the includes and the excludes collections are empty
-
-
Method Details
-
match
Determine if the specifiedinstance
matches this filter. -
match
Determine if the specifiedinstance
is equal to the specifiedcandidate
.- Parameters:
instance
- the instance to handlecandidate
- a candidate defined by this filter- Returns:
true
if the instance matches the candidate
-
match
Determine if the specifiedinstance
matches one of the candidates.If the candidates collection is
null
, returnsfalse
.- Parameters:
instance
- the instance to checkcandidates
- a list of candidates- Returns:
true
if the instance match or the candidates collection is null
-
toString
-