Class FieldPrecedenceModel
java.lang.Object
uk.co.real_logic.sbe.generation.common.FieldPrecedenceModel
A state machine that models whether codec interactions are safe.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents an interaction against a codec, e.g.,encoder.wrap(...)ordecoder.myVarData().static final classA state in which a codec may reside.static final classA group of transitions that share the same end state. -
Method Summary
Modifier and TypeMethodDescriptionvoidIterates over the codec states in the order of their state numbers.voidIterates over the states in which a codec is fully encoded.voidforEachTransition(FieldPrecedenceModel.CodecInteraction interaction, Consumer<FieldPrecedenceModel.TransitionGroup> consumer) Iterates over the possible state machine transitions due to the supplied codec interaction.voidforEachTransitionFrom(FieldPrecedenceModel.State state, Consumer<FieldPrecedenceModel.TransitionGroup> consumer) Finds the possible transitions from a given state.voidIterates over the states after a codec is wrapped over a particular version of data.Returns the name of the class that models the state machine in generated code.voidgenerateGraph(StringBuilder sb, String indent) Encodes the state machine as a graphviz dot diagram.Returns a hash-consing factory for codec interactions.The state after a codec is wrapped in the latest version.static FieldPrecedenceModelnewInstance(String stateClassName, Token msgToken, List<Token> fields, List<Token> groups, List<Token> varData, Function<IntStream, IntStream> versionsSelector) Builds a state machine that models whether codec interactions are safe.The initial state before a codec is wrapped.intReturns the number of states in the state machine.intReturns the number of schema versions.
-
Method Details
-
newInstance
public static FieldPrecedenceModel newInstance(String stateClassName, Token msgToken, List<Token> fields, List<Token> groups, List<Token> varData, Function<IntStream, IntStream> versionsSelector) Builds a state machine that models whether codec interactions are safe.- Parameters:
stateClassName- the qualified name of the class that models the state machine in generated codemsgToken- the message tokenfields- the fields in the messagegroups- the groups in the messagevarData- the varData in the messageversionsSelector- a function that selects the versions to model in the state machine- Returns:
- the access order model
-
notWrappedState
The initial state before a codec is wrapped.- Returns:
- the initial state before a codec is wrapped.
-
latestVersionWrappedState
The state after a codec is wrapped in the latest version.- Returns:
- the state after a codec is wrapped in the latest version.
-
forEachWrappedStateByVersionDesc
Iterates over the states after a codec is wrapped over a particular version of data.- Parameters:
consumer- the consumer of the states.
-
versionCount
public int versionCount()Returns the number of schema versions.- Returns:
- the number of schema versions.
-
forEachTerminalEncoderState
Iterates over the states in which a codec is fully encoded.- Parameters:
consumer- the consumer of the states.
-
forEachStateOrderedByStateNumber
Iterates over the codec states in the order of their state numbers.- Parameters:
consumer- the consumer of the states.
-
stateCount
public int stateCount()Returns the number of states in the state machine.- Returns:
- the number of states in the state machine.
-
interactionFactory
Returns a hash-consing factory for codec interactions. These interactions are the transitions in the state machine.- Returns:
- a hash-consing factory for codec interactions.
- See Also:
-
generatedRepresentationClassName
Returns the name of the class that models the state machine in generated code.- Returns:
- the name of the class that models the state machine in generated code.
-
forEachTransition
public void forEachTransition(FieldPrecedenceModel.CodecInteraction interaction, Consumer<FieldPrecedenceModel.TransitionGroup> consumer) Iterates over the possible state machine transitions due to the supplied codec interaction.- Parameters:
interaction- a codec interaction.consumer- the consumer of the transitions.
-
forEachTransitionFrom
public void forEachTransitionFrom(FieldPrecedenceModel.State state, Consumer<FieldPrecedenceModel.TransitionGroup> consumer) Finds the possible transitions from a given state.- Parameters:
state- the state to find transitions from.consumer- the consumer of the transitions.
-
generateGraph
Encodes the state machine as a graphviz dot diagram.- Parameters:
sb- the string builder to append to.indent- the indentation to use.
-