Package io.atlassian.fugue
Class Functions.WeakMemoizer<A,B>
- java.lang.Object
-
- io.atlassian.fugue.Functions.WeakMemoizer<A,B>
-
- Type Parameters:
A- comparable descriptor, the usual rules for anyHashMapkey apply.B- the value
- All Implemented Interfaces:
java.util.function.Function<A,B>
- Enclosing class:
- Functions
static final class Functions.WeakMemoizer<A,B> extends java.lang.Object implements java.util.function.Function<A,B>Class supports the implementation ofFunctions.weakMemoize(Function)and is not intended for general use.Functions.WeakMemoizercaches the result of another function. The result isweakly referencedinternally. This is useful if the result is expensive to compute or the identity of the result is particularly important.If the results from this function are further cached then they will tend to stay in this cache for longer.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classFunctions.WeakMemoizer.MappedReference<K,V>A weak reference that maintains a reference to the key so that it can be removed from the map when the value is garbage collected.
-
Constructor Summary
Constructors Constructor Description WeakMemoizer(java.util.function.Function<A,B> delegate)Construct a newFunctions.WeakMemoizerinstance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Bapply(A descriptor)Get a result for the supplied Descriptor.private voidexpungeStaleEntries()(package private) static <A,B>
Functions.WeakMemoizer<A,B>weakMemoizer(java.util.function.Function<A,B> delegate)
-
-
-
Constructor Detail
-
WeakMemoizer
WeakMemoizer(java.util.function.Function<A,B> delegate)
Construct a newFunctions.WeakMemoizerinstance.- Parameters:
delegate- for creating the initial values.
-
-
Method Detail
-
weakMemoizer
static <A,B> Functions.WeakMemoizer<A,B> weakMemoizer(java.util.function.Function<A,B> delegate)
-
expungeStaleEntries
private void expungeStaleEntries()
-
-