Class CacheValue<V>
java.lang.Object
org.graalvm.shadowed.com.ibm.icu.impl.CacheValue<V>
- Type Parameters:
V- Cache instance value type
Value type for cache items:
Holds a value either via a direct reference or via a
Reference,
depending on the current "strength" when getInstance() was called.
The value is conceptually immutable. If it is held via a direct reference, then it is actually immutable.
A Reference may be cleared (garbage-collected),
after which get() returns null.
It can then be reset via resetIfAbsent().
The new value should be the same as, or equivalent to, the old value.
Null values are supported. They can be distinguished from cleared values
via isNull().
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum"Strength" of holding a value in CacheValue instances. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanReturns true if the "strength" is set toSTRONG.abstract Vget()Returns the value (which can be null), or null if it was held in a Reference and has been cleared.static <V> CacheValue<V> getInstance(V value) Returns a CacheValue instance that holds the value.booleanisNull()Distinguishes a null value from a Reference value that has been cleared.abstract VresetIfCleared(V value) static voidsetStrength(CacheValue.Strength strength) Changes the "strength" of value references for subsequentgetInstance()calls.
-
Constructor Details
-
CacheValue
public CacheValue()
-
-
Method Details
-
setStrength
Changes the "strength" of value references for subsequentgetInstance()calls. -
futureInstancesWillBeStrong
public static boolean futureInstancesWillBeStrong()Returns true if the "strength" is set toSTRONG. -
getInstance
Returns a CacheValue instance that holds the value. It holds it directly if the value is null or if the current "strength" isSTRONG. Otherwise, it holds it via aReference. -
isNull
public boolean isNull()Distinguishes a null value from a Reference value that has been cleared.- Returns:
- true if this object represents a null value.
-
get
Returns the value (which can be null), or null if it was held in a Reference and has been cleared. -
resetIfCleared
If the value was held via aReferencewhich has been cleared, then it is replaced with a newReferenceto the new value, and the new value is returned. The old and new values should be the same or equivalent.Otherwise the old value is returned.
- Parameters:
value- Replacement value, for when the currentReferencehas been cleared.- Returns:
- The old or new value.
-