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<S>| Modifier and Type | Field and Description |
|---|---|
protected java.util.concurrent.ConcurrentMap<? super T,java.lang.Boolean> |
map
A map that serves as a cache for previous matches.
|
private ElementMatcher<? super T> |
matcher
The underlying matcher to apply for non-cached targets.
|
| Constructor and Description |
|---|
CachingMatcher(ElementMatcher<? super T> matcher,
java.util.concurrent.ConcurrentMap<? super T,java.lang.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.
|
java.lang.String |
toString() |
and, orprivate final ElementMatcher<? super T> matcher
@HashCodeAndEqualsPlugin.ValueHandling(value=IGNORE) protected final java.util.concurrent.ConcurrentMap<? super T,java.lang.Boolean> map
public CachingMatcher(ElementMatcher<? super T> matcher, java.util.concurrent.ConcurrentMap<? super T,java.lang.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(T target)
target - The instance to be matched.true if the given element is matched by this matcher or false otherwise.protected boolean onCacheMiss(T target)
target - The element to be matched.true if the element is matched.public java.lang.String toString()
toString in class java.lang.Object