Package net.bytebuddy.pool
Class TypePool.CacheProvider.Simple
java.lang.Object
net.bytebuddy.pool.TypePool.CacheProvider.Simple
- All Implemented Interfaces:
TypePool.CacheProvider
- Enclosing interface:
TypePool.CacheProvider
A simple, thread-safe type cache based on a
ConcurrentHashMap
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
ATypePool.CacheProvider.Simple
cache provider that clears its storage if the heap is filled, by using a soft reference.Nested classes/interfaces inherited from interface net.bytebuddy.pool.TypePool.CacheProvider
TypePool.CacheProvider.Discriminating, TypePool.CacheProvider.NoOp, TypePool.CacheProvider.Simple
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentMap
<String, TypePool.Resolution> A map containing all cached resolutions by their names.Fields inherited from interface net.bytebuddy.pool.TypePool.CacheProvider
UNRESOLVED
-
Constructor Summary
ConstructorsConstructorDescriptionSimple()
Creates a new simple cache.Simple
(ConcurrentMap<String, TypePool.Resolution> storage) Creates a new simple cache. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears this cache.Attempts to find a resolution in this cache.Returns the underlying storage map of this simple cache provider.register
(String name, TypePool.Resolution resolution) Registers a resolution in this cache.static TypePool.CacheProvider
Returns a simple cache provider that is prepopulated with theObject
type.
-
Field Details
-
storage
A map containing all cached resolutions by their names.
-
-
Constructor Details
-
Simple
public Simple()Creates a new simple cache. -
Simple
Creates a new simple cache.- Parameters:
storage
- A map that is used for locating and storing resolutions.
-
-
Method Details
-
withObjectType
Returns a simple cache provider that is prepopulated with theObject
type.- Returns:
- A simple cache provider that is prepopulated with the
Object
type.
-
find
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
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
-
getStorage
Returns the underlying storage map of this simple cache provider.- Returns:
- A map containing all cached resolutions by their names.
-