Class NonBlockingFiniteStateMachine.CoalescedEvent<S extends Enum<S>>
- java.lang.Object
 - 
- com.tangosol.util.fsm.NonBlockingFiniteStateMachine.CoalescedEvent<S>
 
 
- 
- Type Parameters:
 S- the type of the state for theFiniteStateMachine
- All Implemented Interfaces:
 Event<S>,LifecycleAwareEvent<S>
- Enclosing class:
 - NonBlockingFiniteStateMachine<S extends Enum<S>>
 
public static class NonBlockingFiniteStateMachine.CoalescedEvent<S extends Enum<S>> extends Object implements LifecycleAwareEvent<S>
ANonBlockingFiniteStateMachine.CoalescedEventis aLifecycleAwareEventthat coalesces other (wrapped)Events with the same discriminator so that only oneEventactually executes.For example: Given 10
Events submitted to aNonBlockingFiniteStateMachinewith the same discriminator, only one of the saidEvents will be processed. All others will be discarded. Once theNonBlockingFiniteStateMachine.CoalescedEventhas been processed, a new batch may be created when anotherNonBlockingFiniteStateMachine.CoalescedEventof the same discriminator is submitted.The actual
Eventprocessed depends on the mode of coalescing required. The firstNonBlockingFiniteStateMachine.CoalescedEventsubmitted to aNonBlockingFiniteStateMachinefor a specific discriminator effectively starts the coalescing ofEvents for the said discriminator. When the mode is set toNonBlockingFiniteStateMachine.CoalescedEvent.Process.FIRST, then the firstEvent(starting the coalescing) will be processed and others will be discarded. When the mode is set ofNonBlockingFiniteStateMachine.CoalescedEvent.Process.MOST_RECENTthen the most recently submittedEventwill be processed and likewise, all others for the same discriminator will be discarded. 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNonBlockingFiniteStateMachine.CoalescedEvent.DiscriminatorANonBlockingFiniteStateMachine.CoalescedEvent.Discriminatoris an object that is used to uniquely differentiate events to be coalesced, scoped by aNonBlockingFiniteStateMachine.static classNonBlockingFiniteStateMachine.CoalescedEvent.ProcessTheNonBlockingFiniteStateMachine.CoalescedEventto process. 
- 
Constructor Summary
Constructors Constructor Description CoalescedEvent(Event<S> event)Constructs aNonBlockingFiniteStateMachine.CoalescedEventof the specifiedEventtype usingNonBlockingFiniteStateMachine.CoalescedEvent.Process.FIRST.CoalescedEvent(Event<S> event, NonBlockingFiniteStateMachine.CoalescedEvent.Process mode)Constructs aNonBlockingFiniteStateMachine.CoalescedEventof the specifiedEventtype.CoalescedEvent(Event<S> event, NonBlockingFiniteStateMachine.CoalescedEvent.Process mode, Object discriminator)Constructs aNonBlockingFiniteStateMachine.CoalescedEventwith the specified discriminator andEvent. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SgetDesiredState(S state, ExecutionContext context)Determines the desired state of theFiniteStateMachinefor theEventgiven the current state of theFiniteStateMachine.booleanonAccept(ExecutionContext context)Called by aFiniteStateMachinewhen theLifecycleAwareEventis initially about to be accepted for processing.voidonProcessed(ExecutionContext context)Called by aFiniteStateMachinewhen theLifecycleAwareEventhas been processed.voidonProcessing(ExecutionContext context)Called by aFiniteStateMachinewhen theLifecycleAwareEventis about to be processed.StringtoString() 
 - 
 
- 
- 
Constructor Detail
- 
CoalescedEvent
public CoalescedEvent(Event<S> event)
Constructs aNonBlockingFiniteStateMachine.CoalescedEventof the specifiedEventtype usingNonBlockingFiniteStateMachine.CoalescedEvent.Process.FIRST.- Parameters:
 event- theEventto be executed when coalesced
 
- 
CoalescedEvent
public CoalescedEvent(Event<S> event, NonBlockingFiniteStateMachine.CoalescedEvent.Process mode)
Constructs aNonBlockingFiniteStateMachine.CoalescedEventof the specifiedEventtype.- Parameters:
 event- theEventto be coalescedmode- whichNonBlockingFiniteStateMachine.CoalescedEvents to process
 
- 
CoalescedEvent
public CoalescedEvent(Event<S> event, NonBlockingFiniteStateMachine.CoalescedEvent.Process mode, Object discriminator)
Constructs aNonBlockingFiniteStateMachine.CoalescedEventwith the specified discriminator andEvent.- Parameters:
 event- theEventto be coalescedmode- whichNonBlockingFiniteStateMachine.CoalescedEvents to processdiscriminator- the descriminator used to uniquely coalesce theEvent
 
 - 
 
- 
Method Detail
- 
getDesiredState
public S getDesiredState(S state, ExecutionContext context)
Determines the desired state of theFiniteStateMachinefor theEventgiven the current state of theFiniteStateMachine.- Specified by:
 getDesiredStatein interfaceEvent<S extends Enum<S>>- Parameters:
 state- the current state of theFiniteStateMachinecontext- theExecutionContextfor theEvent- Returns:
 - the desired state of the 
FiniteStateMachineornullif no transition is required 
 
- 
onAccept
public boolean onAccept(ExecutionContext context)
Called by aFiniteStateMachinewhen theLifecycleAwareEventis initially about to be accepted for processing.- Specified by:
 onAcceptin interfaceLifecycleAwareEvent<S extends Enum<S>>- Parameters:
 context- theExecutionContextfor theEvent- Returns:
 trueif theEventshould be accepted, orfalseif theFiniteStateMachineshould ignore theLifecycleAwareEvent
 
- 
onProcessed
public void onProcessed(ExecutionContext context)
Called by aFiniteStateMachinewhen theLifecycleAwareEventhas been processed.- Specified by:
 onProcessedin interfaceLifecycleAwareEvent<S extends Enum<S>>- Parameters:
 context- theExecutionContextfor theEvent
 
- 
onProcessing
public void onProcessing(ExecutionContext context)
Called by aFiniteStateMachinewhen theLifecycleAwareEventis about to be processed.- Specified by:
 onProcessingin interfaceLifecycleAwareEvent<S extends Enum<S>>- Parameters:
 context- theExecutionContextfor theEvent
 
 - 
 
 -