T
- The actual matched type of this matcher.@HashCodeAndEqualsPlugin.Enhance(permitSubclassEquality=true) public class CachingMatcher<T> extends ElementMatcher.Junction.AbstractBase<T>
Modifier and Type | Class and Description |
---|---|
static class |
CachingMatcher.WithInlineEviction<S>
A caching matcher with inline cache eviction.
|
ElementMatcher.Junction.AbstractBase<V>, ElementMatcher.Junction.Conjunction<W>, ElementMatcher.Junction.Disjunction<W>, ElementMatcher.Junction.ForNonNullValues<W>
ElementMatcher.Junction<S>
Modifier and Type | Field and Description |
---|---|
protected ConcurrentMap<? super T,Boolean> |
map
A map that serves as a cache for previous matches.
|
Constructor and Description |
---|
CachingMatcher(ElementMatcher<? super T> matcher,
ConcurrentMap<? super T,Boolean> map)
Creates a new caching matcher.
|
Modifier and Type | Method and Description |
---|---|
boolean |
matches(T target)
Matches a target against this element matcher.
|
protected boolean |
onCacheMiss(T target)
Invoked if the cache is not hit.
|
String |
toString() |
and, or
@HashCodeAndEqualsPlugin.ValueHandling(value=IGNORE) protected final ConcurrentMap<? super T,Boolean> map
public CachingMatcher(ElementMatcher<? super T> matcher, ConcurrentMap<? super T,Boolean> map)
matcher
- The underlying matcher to apply for non-cached targets.map
- A map that serves as a cache for previous matches. This match is strongly referenced and
can cause a memory leak if it is not evicted while keeping this matcher alive.public boolean matches(@MaybeNull T target)
target
- The instance to be matched or null
.true
if the given element is matched by this matcher or false
otherwise.protected boolean onCacheMiss(@MaybeNull T target)
target
- The element to be matched.true
if the element is matched.Copyright © 2014–2025. All rights reserved.