Caplin Trader 5.1.0

Class: module:ct-trading/statemachine/Transition

module:ct-trading/statemachine/Transition(oTarget, sEvent, sSource)

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

Constructs a 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:ct-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 State or if the event name is not a String.

Type
module:ct-core/Error

Methods

addValidator(oValidator)

Adds a validator that must pass for this transition to be allowed.

Parameters:
Name Type Description
oValidator module:ct-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:ct-core/Error

clearValidators()

Clears all transition validators.

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:ct-trading/validation/ValidationResult}

Tests to see if all of the validators for this Transition pass. A module:ct-trading/statemachine/StateMachine should not change state if this method does not return a successful module:ct-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:ct-core/Error
Returns:

a validation result that represents the result of all the validators. Will not be null.

Type
module:ct-trading/validation/ValidationResult