Now you can code the implementations of your specialized state transition methods:
/** * {@inheritDoc} */ public void close(Date endDate, int versionNo) throws InformationalException { // store the date of closure setEndDate(endDate); // transition to "closed" transitionTo(CLOSED, versionNo); } /** * {@inheritDoc} */ public void resume(int versionNo) throws InformationalException { // blank the suspension reason setSuspensionReason(null); // transition to "open" transitionTo(OPEN, versionNo); } /** * {@inheritDoc} */ public void suspend(String reason, int versionNo) throws InformationalException { // store the suspension reason setSuspensionReason(reason); // transition to "suspended" transitionTo(SUSPENDED, versionNo); }
These methods are publicly visible and callable through the entity's interface. Note that in the figure above, additional setter methods (setEndDate and setSuspensionReason) are assumed.