The CodetableState and Transition helper classes provide the following standard validation to disallow any transition which is not explicitly specified. For example, the state transition diagram does not permit an entity instance in the closed state to transition to any other state; by default, any attempts to.suspend() an entity instance which is currently closed will result in this error being raised: Cannot transition from 'Closed' to 'Suspended'.
See the Javadoc for the State, CodetableState and Transition helper classes for more information.
For example, if you want your logic to send an email whenever your entity is closed (regardless of whether it was previously open or suspended), override the onEnter method of your CLOSED state:
/** * No longer conducting business with the agency. */ private final State<MYLIFECYCLEENTITYSTATEEntry> CLOSED = new CodetableState<MYLIFECYCLEENTITYSTATEEntry>( states, MYLIFECYCLEENTITYSTATEEntry.CLOSED, false, false) { @Override protected void onEnter() { // whenever the entity is closed, send an email sendClosureEmail(); } };