Package com.googlecode.objectify.util
Class ResultCache<T>
- java.lang.Object
-
- com.googlecode.objectify.util.ResultCache<T>
-
- All Implemented Interfaces:
Result<T>
,Serializable
- Direct Known Subclasses:
IteratorFirstResult
,ResultTranslator
public abstract class ResultCache<T> extends Object implements Result<T>, Serializable
Caches a result value so it is only executed once- Author:
- Jeff Schnitzer
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ResultCache()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean
isExecuted()
T
now()
Waits if necessary for the computation to complete, and then retrieves its result.protected abstract T
nowUncached()
protected void
postExecuteHook()
Executed once after the cached value is assigned.String
toString()
We can get away with this because the subclass almost always provides concrete typesprotected Object
writeReplace()
When this serializes, write out a simple version that doesn't hold complicated links to internal structures.
-
-
-
Method Detail
-
nowUncached
protected abstract T nowUncached()
-
isExecuted
protected boolean isExecuted()
-
now
public final T now()
Description copied from interface:Result
Waits if necessary for the computation to complete, and then retrieves its result. If the computation produced an exception, it will be thrown here.
-
postExecuteHook
protected void postExecuteHook()
Executed once after the cached value is assigned.
-
writeReplace
protected Object writeReplace() throws ObjectStreamException
When this serializes, write out a simple version that doesn't hold complicated links to internal structures. This is safe as long as nobody ever tries to cast to ResultCache directly, which should never happen.- Throws:
ObjectStreamException
-
-