T - The type of the objectpublic class Once<T> extends Object
| Constructor and Description |
|---|
Once(T object)
Creates a new one-time wrapper, returning the given object on the first
call to
get() and null on all subsequent calls. |
Once(T object,
T emptyObject)
Creates a new one-time wrapper, returning
object on the first
call to get() and emptyObject on all subsequent calls. |
| Modifier and Type | Method and Description |
|---|---|
T |
get()
Returns the wrapped object, or an “empty object” (might be
null)
if the object has already been retrieved by an earlier call to
get(). |
boolean |
isRetrieved()
Returns whether the wrapped object has already been retrieved.
|
void |
reset()
Resets whether the wrapped object was retrieved by a call to
get(). |
public Once(T object)
get() and null on all subsequent calls.object - The object to return on the first callpublic T get()
null)
if the object has already been retrieved by an earlier call to
get().public boolean isRetrieved()
true if the object has already been retrieved by a call
to get(), false otherwisepublic void reset()
Copyright © 2026. All rights reserved.