Package net.bytebuddy.matcher
Class CachingMatcher<T>
java.lang.Object
net.bytebuddy.matcher.ElementMatcher.Junction.AbstractBase<T>
net.bytebuddy.matcher.CachingMatcher<T>
- Type Parameters:
T
- The actual matched type of this matcher.
- All Implemented Interfaces:
ElementMatcher<T>
,ElementMatcher.Junction<T>
- Direct Known Subclasses:
CachingMatcher.WithInlineEviction
@Enhance(permitSubclassEquality=true)
public class CachingMatcher<T>
extends ElementMatcher.Junction.AbstractBase<T>
A matcher that remembers the results of previously matching an equal target.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A caching matcher with inline cache eviction.Nested classes/interfaces inherited from interface net.bytebuddy.matcher.ElementMatcher
ElementMatcher.Junction<S>
Nested classes/interfaces inherited from interface net.bytebuddy.matcher.ElementMatcher.Junction
ElementMatcher.Junction.AbstractBase<V>, ElementMatcher.Junction.Conjunction<W>, ElementMatcher.Junction.Disjunction<W>, ElementMatcher.Junction.ForNonNullValues<W>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ConcurrentMap
<? super T, Boolean> A map that serves as a cache for previous matches.private final ElementMatcher
<? super T> The underlying matcher to apply for non-cached targets.private static final Object
A substitute value to store in a map instead of anull
value. -
Constructor Summary
ConstructorsConstructorDescriptionCachingMatcher
(ElementMatcher<? super T> matcher, ConcurrentMap<? super T, Boolean> map) Creates a new caching matcher. -
Method Summary
Methods inherited from class net.bytebuddy.matcher.ElementMatcher.Junction.AbstractBase
and, or
-
Field Details
-
NULL_VALUE
A substitute value to store in a map instead of anull
value. -
matcher
The underlying matcher to apply for non-cached targets. -
map
A map that serves as a cache for previous matches.
-
-
Constructor Details
-
CachingMatcher
Creates a new caching matcher.- Parameters:
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.
-
-
Method Details
-
matches
Matches a target against this element matcher.- Parameters:
target
- The instance to be matched ornull
.- Returns:
true
if the given element is matched by this matcher orfalse
otherwise.
-
onCacheMiss
Invoked if the cache is not hit.- Parameters:
target
- The element to be matched.- Returns:
true
if the element is matched.
-
toString
-