Top Description Inners Fields Constructors Methods
org.easymock.bytebuddy.matcher

public Class CachingMatcher<T>

extends ElementMatcher.Junction.AbstractBase<T>
Class Inheritance
Known Direct Subclasses
org.easymock.bytebuddy.matcher.CachingMatcher.WithInlineEviction
Annotations
@Enhance
permitSubclassEquality:true
Type Parameters
<T>
The actual matched type of this matcher.
Imports
edu.umd.cs.findbugs.annotations.SuppressFBWarnings, org.easymock.bytebuddy.build.HashCodeAndEqualsPlugin, org.easymock.bytebuddy.utility.nullability.MaybeNull, java.util.Iterator, java.util.concurrent.ConcurrentMap

A matcher that remembers the results of previously matching an equal target.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
CachingMatcher.WithInlineEviction<
The actual matched type of this matcher.
S
>

A caching matcher with inline cache eviction.

Field Summary

Modifier and TypeField and Description
protected final ConcurrentMap<? super T, Boolean>
map

A map that serves as a cache for previous matches.

private final ElementMatcher<? super T>
matcher

The underlying matcher to apply for non-cached targets.

private static final Object
NULL_VALUE

A substitute value to store in a map instead of a null value.

Constructor Summary

AccessConstructor and Description
public
CachingMatcher(ElementMatcher<? super T>
The underlying matcher to apply for non-cached targets.
matcher
,
ConcurrentMap<? super T, Boolean>
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.
map
)

Creates a new caching matcher.

Method Summary

Modifier and TypeMethod and Description
public boolean
matches(T
The instance to be matched or null.
target
)

Implements org.easymock.bytebuddy.matcher.ElementMatcher.matches.

Matches a target against this element matcher.
protected boolean

Returns:

true if the element is matched.
onCacheMiss
(T
The element to be matched.
target
)

Invoked if the cache is not hit.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from org.easymock.bytebuddy.matcher.ElementMatcher.Junction.AbstractBase:
andor

Field Detail

mapback to summary
protected final ConcurrentMap<? super T, Boolean> map

A map that serves as a cache for previous matches.

Annotations
@ValueHandling:IGNORE
matcherback to summary
private final ElementMatcher<? super T> matcher

The underlying matcher to apply for non-cached targets.

NULL_VALUEback to summary
private static final Object NULL_VALUE

A substitute value to store in a map instead of a null value.

Constructor Detail

CachingMatcherback to summary
public CachingMatcher(ElementMatcher<? super T> matcher, ConcurrentMap<? super T, Boolean> map)

Creates a new caching matcher.

Parameters
matcher:ElementMatcher<? super T>

The underlying matcher to apply for non-cached targets.

map:ConcurrentMap<? super T, Boolean>

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 Detail

matchesback to summary
public boolean matches(T target)

Implements org.easymock.bytebuddy.matcher.ElementMatcher.matches.

Doc from org.easymock.bytebuddy.matcher.ElementMatcher.matches.

Matches a target against this element matcher.

Parameters
target:T

The instance to be matched or null.

Returns:boolean

true if the given element is matched by this matcher or false otherwise.

onCacheMissback to summary
protected boolean onCacheMiss(T target)

Invoked if the cache is not hit.

Parameters
target:T

The element to be matched.

Returns:boolean

true if the element is matched.

Annotations
@SuppressWarnings:unchecked
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
org.easymock.bytebuddy.matcher back to summary

public Class CachingMatcher.WithInlineEviction<S>

extends CachingMatcher<S>
Class Inheritance
Annotations
@SuppressFBWarnings:EQ_DOESNT_OVERRIDE_EQUALS
justification:Equality does not consider eviction size.
Type Parameters
<S>
The actual matched type of this matcher.

A caching matcher with inline cache eviction.

Field Summary

Modifier and TypeField and Description
private final int
evictionSize

The maximum amount of entries in this map before removing a random entry from the map.

Inherited from org.easymock.bytebuddy.matcher.CachingMatcher:
map

Constructor Summary

AccessConstructor and Description
public
WithInlineEviction(ElementMatcher<? super S>
The underlying matcher to apply for non-cached targets.
matcher
,
ConcurrentMap<? super S, Boolean>
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.
map
,
int
The maximum amount of entries in this map before removing a random entry from the map.
evictionSize
)

Creates a new caching matcher with inlined cache eviction.

Method Summary

Modifier and TypeMethod and Description
protected boolean
onCacheMiss(S
The element to be matched.
target
)

Overrides org.easymock.bytebuddy.matcher.CachingMatcher.onCacheMiss.

Invoked if the cache is not hit.
Inherited from org.easymock.bytebuddy.matcher.CachingMatcher:
matchestoString

Field Detail

evictionSizeback to summary
private final int evictionSize

The maximum amount of entries in this map before removing a random entry from the map.

Constructor Detail

WithInlineEvictionback to summary
public WithInlineEviction(ElementMatcher<? super S> matcher, ConcurrentMap<? super S, Boolean> map, int evictionSize)

Creates a new caching matcher with inlined cache eviction.

Parameters
matcher:ElementMatcher<? super S>

The underlying matcher to apply for non-cached targets.

map:ConcurrentMap<? super S, Boolean>

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.

evictionSize:int

The maximum amount of entries in this map before removing a random entry from the map.

Method Detail

onCacheMissback to summary
protected boolean onCacheMiss(S target)

Overrides org.easymock.bytebuddy.matcher.CachingMatcher.onCacheMiss.

Doc from org.easymock.bytebuddy.matcher.CachingMatcher.onCacheMiss.

Invoked if the cache is not hit.

Parameters
target:S

The element to be matched.

Returns:boolean

true if the element is matched.