Package one.microstream.reference
Class Lazy.Default<T>
java.lang.Object
one.microstream.reference.Lazy.Default<T>
- All Implemented Interfaces:
Lazy<T>
,Referencing<T>
- Direct Known Subclasses:
ControlledLazyReference.Default
public static class Lazy.Default<T> extends Object implements Lazy<T>
-
Nested Class Summary
Nested classes/interfaces inherited from interface one.microstream.reference.Lazy
Lazy.Check, Lazy.Checker, Lazy.ClearingEvaluator, Lazy.Default<T>
-
Method Summary
Modifier and Type Method Description void
$link(long objectId, ObjectSwizzling loader)
void
$setLoader(ObjectSwizzling loader)
void
$unlink()
T
clear()
Clears the reference, leaving the option to re-load it again intact, and returns the subject that was referenced prior to clearing.boolean
clear(Lazy.ClearingEvaluator clearingEvaluator)
Clears the reference if theclearingEvaluator
decides to, leaving the option to re-load it again intact, and returns the subject that was referenced prior to clearing.static Class<Lazy.Default<?>>
genericType()
T
get()
Returns the original subject referenced by this reference instance.boolean
isLoaded()
Returns if this lazy reference is loaded.boolean
isStored()
Returns if this lazy reference was persisted before.long
lastTouched()
Returns the timestamp (corresponding toSystem.currentTimeMillis()
) when this instance has last been "touched", meaning having its reference modified or queried.long
objectId()
T
peek()
Returns the local reference without loading the referenced object if it is not present.String
toString()
-
Method Details
-
genericType
-
objectId
public final long objectId() -
lastTouched
public final long lastTouched()Description copied from interface:Lazy
Returns the timestamp (corresponding toSystem.currentTimeMillis()
) when this instance has last been "touched", meaning having its reference modified or queried.- Specified by:
lastTouched
in interfaceLazy<T>
- Returns:
- the time this instance has last been significantly used.
-
isStored
public final boolean isStored()Description copied from interface:Lazy
Returns if this lazy reference was persisted before. -
isLoaded
public final boolean isLoaded()Description copied from interface:Lazy
Returns if this lazy reference is loaded. There are three cases in which this applies:- It is not yet persisted, meaning it is implicitly always "loaded".
- A null-reference is always "loaded".
- Otherwise, the subject must be present, truly a state of having been "loaded".
-
peek
Description copied from interface:Lazy
Returns the local reference without loading the referenced object if it is not present. The value returned byLazy.lastTouched()
will not be changed by calling this method. -
clear
Description copied from interface:Lazy
Clears the reference, leaving the option to re-load it again intact, and returns the subject that was referenced prior to clearing.- Specified by:
clear
in interfaceLazy<T>
- Returns:
- the subject referenced prior to clearing the reference.
- See Also:
Lazy.clear(ClearingEvaluator)
-
clear
Description copied from interface:Lazy
Clears the reference if theclearingEvaluator
decides to, leaving the option to re-load it again intact, and returns the subject that was referenced prior to clearing.- Specified by:
clear
in interfaceLazy<T>
- Parameters:
clearingEvaluator
- evaluator which decides if the reference should be cleared- Returns:
- if this lazy references was cleared
- See Also:
Lazy.clear()
-
$link
-
$unlink
public final void $unlink() -
$setLoader
-
get
Description copied from interface:Lazy
Returns the original subject referenced by this reference instance. If the subject has (lazily) not been loaded, an attempt to do so now is made. Any exception occurring during the loading attempt will be passed along without corrupting this reference instance's internal state. -
toString
-