Class FieldPrecedenceModel

java.lang.Object
uk.co.real_logic.sbe.generation.common.FieldPrecedenceModel

public final class FieldPrecedenceModel extends Object
A state machine that models whether codec interactions are safe.
  • 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 code
      msgToken - the message token
      fields - the fields in the message
      groups - the groups in the message
      varData - the varData in the message
      versionsSelector - a function that selects the versions to model in the state machine
      Returns:
      the access order model
    • notWrappedState

      public FieldPrecedenceModel.State notWrappedState()
      The initial state before a codec is wrapped.
      Returns:
      the initial state before a codec is wrapped.
    • latestVersionWrappedState

      public FieldPrecedenceModel.State 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

      public void forEachWrappedStateByVersionDesc(IntObjConsumer<FieldPrecedenceModel.State> consumer)
      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

      public void forEachTerminalEncoderState(Consumer<FieldPrecedenceModel.State> consumer)
      Iterates over the states in which a codec is fully encoded.
      Parameters:
      consumer - the consumer of the states.
    • forEachStateOrderedByStateNumber

      public void forEachStateOrderedByStateNumber(Consumer<FieldPrecedenceModel.State> consumer)
      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

      public String 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

      public void generateGraph(StringBuilder sb, String indent)
      Encodes the state machine as a graphviz dot diagram.
      Parameters:
      sb - the string builder to append to.
      indent - the indentation to use.