public void forEachStateOrderedByStateNumber(final Consumer<State> consumer)
    {
        transitionsByState.keySet().stream()
            .sorted(Comparator.comparingInt((s) -> s.number))
            .forEach(consumer);
    }
Iterates over the codec states in the order of their state numbers.
@param consumer the consumer of the states.
sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/common/FieldPrecedenceModel.java