Caplin Trader 4.5.2

Class: module:caplin/trading/statemachine/Transition

module:caplin/trading/statemachine/Transition

Constructor

new module:caplin/trading/statemachine/Transition(oTarget, sEvent, sSource)

Constructs a caplin.trading.statemachine.Transition A Transition represents a path that a StateMachine can take from one State to another (the target state). It is caused by an Event.
Parameters:
Name Type Description
oTarget module:caplin/trading/statemachine/State The state that this transition goes to. This may not be null.
sEvent String The name of the event that triggers this transition. May not be null.
sSource String The source of the event, either server or client.
Throws:
if the target does not implement caplin.trading.statemachine.State or if the event name is not a String.
Type
module:caplin/core/Error

Methods

addValidator(oValidator)

Adds a validator that must pass for this transition to be allowed.
Parameters:
Name Type Description
oValidator module:caplin/trading/validation/Validator A validator that must pass to allow this transition.
Throws:
if the validator has already been added or is not a validator.
Type
module:caplin/core/Error

getEvent()

Gets the name of the event that triggers this transition.
Returns:
The Event that triggers this transition. Will not be null.

getSource()

Returns the source of the event.
Returns:
The source of the event, either client or server.

getTarget()

Gets the target State.
Returns:
The target state. Will not be null.

getTradeFields() → {pArray}

Returns the list of fields that the transition should use for communication with a trade service
Returns:
Type
pArray

setTradeFields(pFields)

Sets the list of fields that the transition should use for communication with a trade service
Parameters:
Name Type Description
pFields Array The list of fields that the transition should use for communication with a trade service

validate(oContext) → {module:caplin/trading/validation/ValidationResult}

Tests to see if all of the validators for this Transition pass. A module:caplin/trading/statemachine/StateMachine should not change state if this method does not return a successful module:caplin/trading/validation/ValidationResult.
Parameters:
Name Type Description
oContext Object The data for the validators to check. It is not optional and may not be null.
Throws:
if the passed context is null or left out.
Type
module:caplin/core/Error
Returns:
a validation result that represents the result of all the validators. Will not be null.
Type
module:caplin/trading/validation/ValidationResult