private void allocateTransitions(
        final CodecInteraction interaction,
        final Collection<State> from,
        final State to)
    {
        final TransitionGroup transitionGroup = new TransitionGroup(interaction, from, to);
        final List<TransitionGroup> transitionsForInteraction = transitionsByInteraction.computeIfAbsent(
            interaction, (ignored) -> new ArrayList<>());

        final boolean duplicateEndState =
            transitionsForInteraction.stream().anyMatch((t) -> t.to.number == transitionGroup.to.number);

        if (duplicateEndState)
        {
            throw new IllegalStateException("Duplicate end state: " + transitionGroup.to.name);
        }

        final Optional<TransitionGroup> conflictingTransition = transitionsForInteraction.stream()
            .filter((t) -> t.from.stream().anyMatch(transitionGroup.from::contains))
            .findAny();

        if (conflictingTransition.isPresent())
        {
            throw new IllegalStateException(
                "Conflicting transition: " + transitionGroup + " conflicts with " + conflictingTransition.get());
        }

        transitionsForInteraction.add(transitionGroup);

        from.forEach((fromState) -> transitionsByState.get(fromState).add(transitionGroup));
    }
Encodes the state machine as a graphviz dot diagram.
@param sb the string builder to append to.
@param indent the indentation to use.
sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/common/FieldPrecedenceModel.java