Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## modhelxs.state_management
Class State

    java.lang.Object
      modhelxs.state_management.State

    public class State

extends java.lang.Object

A State manages the state of a NamedEntity, which is composed of its field of type `StateValue`. A State can also be used to initialize the field of type `Value` of a NamedEntity.

Author:
  boulange

Field Summary
`private NamedEntity` | `owner_` The NamedEntity which owns the Attributes managed by this State.
`private java.util.HashMap<java.lang.String,java.lang.reflect.Field>` | `snap_statevalues_`
`private java.util.HashMap<java.lang.String,java.lang.reflect.Field>` | `statevalues_` A name->attribute map of the state values of the owner.

Constructor Summary
`State(NamedEntity e)` Create a State for handling the state values of `e`.

Method Summary
`void` | `commit()` Commit the changes to this State.
`private void` | `commitValues(java.util.Collection<java.lang.reflect.Field> fields)`
`private static java.util.List<java.lang.reflect.Field>` | `getAllFields(java.lang.Class<?> c)` Get all the fields of objects of a class, even inherited ones.
`void` | `initFromProperties(java.lang.String... assignments)` Initialize the fields of type `Value` of the NamedEntity owning this state from its properties.
`void` | `revert()` Revert the regular state values to their value after the last `commit` operation.
`void` | `revertSnap()` Revert the snapshot state values to their value after the last `commit` operation.
`java.lang.String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### owner_

    private NamedEntity owner_

  The NamedEntity which owns the Attributes managed by this State.

### statevalues_

    private java.util.HashMap<java.lang.String,java.lang.reflect.Field> statevalues_

  A name->attribute map of the state values of the owner.

### snap_statevalues_

    private java.util.HashMap<java.lang.String,java.lang.reflect.Field> snap_statevalues_

Constructor Detail

### State

    public State(NamedEntity e)

  Create a State for handling the state values of `e`.

Method Detail

### getAllFields

    private static java.util.List<java.lang.reflect.Field> getAllFields(java.lang.Class<?> c)

  Get all the fields of objects of a class, even inherited ones.

### revert

    public void revert()

  Revert the regular state values to their value after the last `commit` operation.

### revertSnap

    public void revertSnap()

  Revert the snapshot state values to their value after the last `commit` operation.

### commit

    public void commit()

  Commit the changes to this State.

### commitValues

    private void commitValues(java.util.Collection<java.lang.reflect.Field> fields)

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### initFromProperties

    public void initFromProperties(java.lang.String... assignments)

  Initialize the fields of type `Value` of the NamedEntity owning this state from its properties. By default, each Value is initialized from the property by the same name. If some values should be initialized from properties with a different name, the mapping from value name to property name can be given using the `assignments` parameter. Each assignment String is in the form "=".

  Parameters:
    `assignments` - a list of strings in the form "=" to set from which property a value will be initialized. Values whose name does not appear in `assignments` will be initialized from properties which have the same name as the value, if such a property exists.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD