Package net.bytebuddy.pool
Class TypePool.CacheProvider.Discriminating
- java.lang.Object
-
- net.bytebuddy.pool.TypePool.CacheProvider.Discriminating
-
- All Implemented Interfaces:
TypePool.CacheProvider
- Enclosing interface:
- TypePool.CacheProvider
public static class TypePool.CacheProvider.Discriminating extends java.lang.Object implements TypePool.CacheProvider
A discriminating cache provider that delegates a type name to one of two caches.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.bytebuddy.pool.TypePool.CacheProvider
TypePool.CacheProvider.Discriminating, TypePool.CacheProvider.NoOp, TypePool.CacheProvider.Simple
-
-
Field Summary
Fields Modifier and Type Field Description private TypePool.CacheProvider
matched
The cache provider to use for matched types.private ElementMatcher<java.lang.String>
matcher
The matcher that determines which cache to use.private TypePool.CacheProvider
unmatched
The cache provider to use for unmatched types.-
Fields inherited from interface net.bytebuddy.pool.TypePool.CacheProvider
UNRESOLVED
-
-
Constructor Summary
Constructors Constructor Description Discriminating(ElementMatcher<java.lang.String> matcher, TypePool.CacheProvider matched, TypePool.CacheProvider unmatched)
Creates a new discriminating cache provider.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears this cache.TypePool.Resolution
find(java.lang.String name)
Attempts to find a resolution in this cache.TypePool.Resolution
register(java.lang.String name, TypePool.Resolution resolution)
Registers a resolution in this cache.
-
-
-
Field Detail
-
matcher
private final ElementMatcher<java.lang.String> matcher
The matcher that determines which cache to use.
-
matched
private final TypePool.CacheProvider matched
The cache provider to use for matched types.
-
unmatched
private final TypePool.CacheProvider unmatched
The cache provider to use for unmatched types.
-
-
Constructor Detail
-
Discriminating
public Discriminating(ElementMatcher<java.lang.String> matcher, TypePool.CacheProvider matched, TypePool.CacheProvider unmatched)
Creates a new discriminating cache provider.- Parameters:
matcher
- The matcher that determines which cache to use.matched
- The cache provider to use for matched types.unmatched
- The cache provider to use for unmatched types.
-
-
Method Detail
-
find
public TypePool.Resolution find(java.lang.String name)
Attempts to find a resolution in this cache.- Specified by:
find
in interfaceTypePool.CacheProvider
- Parameters:
name
- The name of the type to describe.- Returns:
- A resolution of the type or
null
if no such resolution can be found in the cache..
-
register
public TypePool.Resolution register(java.lang.String name, TypePool.Resolution resolution)
Registers a resolution in this cache. If a resolution to the given name already exists in the cache, it should be discarded.- Specified by:
register
in interfaceTypePool.CacheProvider
- Parameters:
name
- The name of the type that is to be registered.resolution
- The resolution to register.- Returns:
- The oldest version of a resolution that is currently registered in the cache which might be the given resolution or another resolution that was previously registered.
-
clear
public void clear()
Clears this cache.- Specified by:
clear
in interfaceTypePool.CacheProvider
-
-