Package net.bytebuddy.pool
Class TypePool.CacheProvider.Simple.UsingSoftReference
java.lang.Object
net.bytebuddy.pool.TypePool.CacheProvider.Simple.UsingSoftReference
- All Implemented Interfaces:
TypePool.CacheProvider
- Enclosing class:
- TypePool.CacheProvider.Simple
public static class TypePool.CacheProvider.Simple.UsingSoftReference
extends Object
implements TypePool.CacheProvider
A
TypePool.CacheProvider.Simple
cache provider that clears its storage if the heap is filled, by using a soft reference.-
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
FieldsModifier and TypeFieldDescriptionprivate final AtomicReference<SoftReference<TypePool.CacheProvider.Simple>>
A reference for the actual cache provider.Fields inherited from interface net.bytebuddy.pool.TypePool.CacheProvider
UNRESOLVED
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears this cache.Attempts to find a resolution in this cache.register
(String name, TypePool.Resolution resolution) Registers a resolution in this cache.
-
Field Details
-
delegate
A reference for the actual cache provider.
-
-
Constructor Details
-
UsingSoftReference
public UsingSoftReference()Creates a softly referencedTypePool.CacheProvider.Simple
cache provider.
-
-
Method Details
-
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
-