Your entity must store its state in some form. A typical storage mechanism is to enumerate the states in a codetable and store the code's String value on a database column.
In this example, you'll enumerate these states in a new codetable called MYLIFECYCLEENTITYSTATE, and present the value as an instance of the generated MYLIFECYCLEENTITYSTATEEntry class.
Create the codetable:
<?xml version="1.0" encoding="UTF-8"?>
<codetables package="curam.mypackage.codetable">
<codetable
java_identifier="MYLIFECYCLEENTITYSTATE"
name="MYLIFECYCLEENTITYSTATE"
>
<code
default="false"
java_identifier="OPEN"
status="ENABLED"
value="OPEN"
>
<locale
language="en"
sort_order="0"
>
<description>Open</description>
<annotation/>
</locale>
</code>
<code
default="false"
java_identifier="SUSPENDED"
status="ENABLED"
value="SUSPENDED"
>
<locale
language="en"
sort_order="0"
>
<description>Suspended</description>
<annotation/>
</locale>
</code>
<code
default="false"
java_identifier="CLOSED"
status="ENABLED"
value="CLOSED"
>
<locale
language="en"
sort_order="0"
>
<description>Closed</description>
<annotation/>
</locale>
</code>
</codetable>
</codetables>
Now mark your entity's interface to extend the Lifecycle interface, parameterized with the data type used to present the state (in this case, MYLIFECYCLEENTITYSTATEEntry):
/**
* Description of my state-machine entity.
*/
@ImplementedBy(MyLifecycleEntityImpl.class)
public interface MyLifecycleEntity extends StandardEntity,
Lifecycle<MYLIFECYCLEENTITYSTATEEntry>