public final class SetOnce<T> extends Object implements Cloneable
set(Object) is called more than once,
 SetOnce.AlreadySetException is thrown and the operation
 will fail.| Modifier and Type | Class and Description | 
|---|---|
static class  | 
SetOnce.AlreadySetException
Thrown when  
set(Object) is called more than once. | 
| Constructor and Description | 
|---|
SetOnce()
A default constructor which does not set the internal object, and allows
 setting it by calling  
set(Object). | 
SetOnce(T obj)
Creates a new instance with the internal object set to the given object. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
T | 
get()
Returns the object set by  
set(Object). | 
void | 
set(T obj)
Sets the given object. 
 | 
boolean | 
trySet(T obj)
Sets the given object if none was set before. 
 | 
public SetOnce()
set(Object).public SetOnce(T obj)
set(Object) afterwards will result in
 SetOnce.AlreadySetExceptionSetOnce.AlreadySetException - if called more than onceset(Object)public final void set(T obj)
public final boolean trySet(T obj)
public final T get()
set(Object).Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.