modhelxs.state_management
Class Attribute<T>

java.lang.Object
  extended by modhelxs.state_management.Value<T>
      extended by modhelxs.state_management.Attribute<T>
All Implemented Interfaces:
StateValue
Direct Known Subclasses:
TransientValue

public class Attribute<T>
extends Value<T>
implements StateValue

An Attribute is a storage with commit and revert operations. An attribute has a permanent value, which is set at initialization time, and by the commit operation. It also has a transient value, which is set by the setValue operation. The transient value becomes the permanent value when commit is called. The transient value if forgotten when revert is called. The current value of an attribute is its transient value if it is set, or its permanent value otherwise.


Field Summary
private  T trans_value_
          The transient value of the attribute, which will become its value after committing.
private  boolean was_set_
           
 
Constructor Summary
Attribute(java.lang.Class<T> type)
          Create an attribute for storing a value of type type.
Attribute(java.lang.Class<T> type, boolean giveInitWarning)
          Create an attribute for storing a value of type type.
 
Method Summary
 void commit()
          Commit the transient value into the permanent value.
 T getValue()
          Get the value of the attribute.
 void revert()
          Revert to the last committed value by forgetting the transient value.
 void setValue(T val)
          Set the transient value of the attribute.
 void setValue(Value<T> val)
          Set the transient value of the attribute.
 java.lang.String toString()
           
 
Methods inherited from class modhelxs.state_management.Value
getType, init, initFromProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

trans_value_

private T trans_value_
The transient value of the attribute, which will become its value after committing.


was_set_

private boolean was_set_
Constructor Detail

Attribute

public Attribute(java.lang.Class<T> type,
                 boolean giveInitWarning)
Create an attribute for storing a value of type type.


Attribute

public Attribute(java.lang.Class<T> type)
Create an attribute for storing a value of type type.

Method Detail

getValue

public T getValue()
Get the value of the attribute. This is the transient value if setValue was called since the last call of commit, or the last committed (or initialized) value.

Overrides:
getValue in class Value<T>

setValue

public void setValue(T val)
Set the transient value of the attribute.

Overrides:
setValue in class Value<T>

setValue

public void setValue(Value<T> val)
Set the transient value of the attribute.

Overrides:
setValue in class Value<T>

commit

public void commit()
Commit the transient value into the permanent value.

Specified by:
commit in interface StateValue

revert

public void revert()
Revert to the last committed value by forgetting the transient value.

Specified by:
revert in interface StateValue

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object