| java.lang.Object com.tc.util.concurrent.SetOnceRef
SetOnceRef | final public class SetOnceRef (Code) | | An object reference holder class in which the reference can only be set once. This might be useful for a member
variable that you'd like to make final, but that you aren't able to set within a constructor. I suppose this class is
a lot like TCFuture, but this class doesn't offer methods to wait for a value to set. The use case for this class has
nothing to do with communication/synchronization between threads. This class is meant to make sure you can't change a
reference once it's been set (ie. it provides a reference member variable that behaves like it was marked "final" and
won't let anyone read it until it has been set)
author: teck |
SetOnceRef | public SetOnceRef()(Code) | | Create a new set() 'able instance This instance will not permitted to contain a null
reference
|
SetOnceRef | public SetOnceRef(Object ref)(Code) | | Create and immediately set() to the given reference. This instance will not permitted to
contain a null reference
Parameters: ref - The reference to hold throws: IllegalArgumentException - If the reference to hold is null |
SetOnceRef | public SetOnceRef(Object ref, boolean allowNull)(Code) | | Create and immediately set() to the given refernce
Parameters: ref - the reference to hold Parameters: allowNull - true to allow nulls to be stored in this instance throws: IllegalArgumentException - if allowNull is true and the given reference is null |
SetOnceRef | public SetOnceRef(boolean allowNull)(Code) | | Create a new set() 'able instance
Parameters: allowNull - true to allow this instance to hold the value null |
allowsNull | public boolean allowsNull()(Code) | | Can null ever be the value of this reference
true if null is allowed, false otherwise |
get | public Object get()(Code) | | Get the reference value contained in this instance
the reference, may be null if this instance allow nulls (see allowNull throws: IllegalStateException - if a valid reference value has not yet been set |
isSet | public boolean isSet()(Code) | | Has someone set the reference yet
true iff the reference has been set |
set | public void set(Object ref)(Code) | | Attmept to set the reference to the given value
Parameters: ref - the reference to set in this instance throws: IllegalStateException - if the reference has already been set by another thread throws: IllegalArgumentException - if the given reference is null and this instance does not allow the null value |
|
|