org.schmant.lang
Class TwoState<T>

java.lang.Object
  extended by org.schmant.lang.TwoState<T>

public class TwoState<T>
extends Object

The TwoState contains a value that is either set or not set. If set, the value is an object or null.

Since:
0.5
Author:
Karl Gustafsson

Constructor Summary
TwoState()
          Create a new, unset TwoState.
TwoState(TwoState<T> obj)
          Create a new TwoState object with the same state as another.
 
Method Summary
 T get()
          Get the value.
 boolean isSet()
          Is a value set on this object.
 void set(T val)
          Set the value.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TwoState

public TwoState()
Create a new, unset TwoState.


TwoState

public TwoState(TwoState<T> obj)
Create a new TwoState object with the same state as another.

Parameters:
obj - The other TwoState object.
Method Detail

set

public void set(T val)
Set the value.

Parameters:
val - The value.

isSet

public boolean isSet()
Is a value set on this object.

Returns:
true if a value is set.

get

public T get()
      throws IllegalStateException
Get the value.

Returns:
The value.
Throws:
IllegalStateException - If a value is not set.

toString

public String toString()
Overrides:
toString in class Object