public void onEnterRepeatingGroup(
            final Token token,
            final List<Token> groupFields,
            final List<Token> groupGroups,
            final List<Token> groupVarData)
        {
            if (filter.test(token))
            {
                final String groupName = token.name().toUpperCase();
                final String groupPrefix = statePrefix + groupName + "_";
                final State nRemainingGroup = allocateState(groupPrefix + "N");
                final State nRemainingGroupElement = allocateState(groupPrefix + "N_BLOCK");
                final State oneRemainingGroupElement = allocateState(groupPrefix + "1_BLOCK");
                final State doneGroup = allocateState(groupPrefix + "DONE");

                final Set<State> beginGroupStates = new HashSet<>(currentStates);

                // fooCount(0)
                final CodecInteraction emptyGroupInteraction = interactionFactory.determineGroupIsEmpty(token);
                allocateTransitions(emptyGroupInteraction, beginGroupStates, doneGroup);

                // fooCount(N) where N > 0
                final CodecInteraction nonEmptyGroupInteraction = interactionFactory.determineGroupHasElements(token);
                allocateTransitions(nonEmptyGroupInteraction, beginGroupStates, nRemainingGroup);

                currentStates.clear();
                currentStates.add(nRemainingGroupElement);
                final TransitionCollector nRemainingCollector = new TransitionCollector(
                    groupPrefix + "N_",
                    currentStates,
                    nRemainingGroupElement,
                    filter);
                walkSchemaLevel(nRemainingCollector, groupFields, groupGroups, groupVarData);

                currentStates.clear();
                currentStates.add(nRemainingGroup);
                currentStates.addAll(nRemainingCollector.exitStates());

                // where more than one element remains in the group
                final CodecInteraction nextGroupElementInteraction = interactionFactory.moveToNextElement(token);
                allocateTransitions(nextGroupElementInteraction, currentStates, nRemainingGroupElement);

                currentStates.clear();
                currentStates.add(nRemainingGroup);
                currentStates.addAll(nRemainingCollector.exitStates());

                // where only one element remains in the group
                final CodecInteraction lastGroupElementInteraction = interactionFactory.moveToLastElement(token);
                allocateTransitions(lastGroupElementInteraction, currentStates, oneRemainingGroupElement);

                currentStates.clear();
                currentStates.add(oneRemainingGroupElement);

                final TransitionCollector oneRemainingCollector = new TransitionCollector(
                    groupPrefix + "1_",
                    currentStates,
                    oneRemainingGroupElement,
                    filter);
                walkSchemaLevel(oneRemainingCollector, groupFields, groupGroups, groupVarData);

                final CodecInteraction resetCountToIndexInteraction = interactionFactory.resetCountToIndex(token);
                currentStates.clear();
                currentStates.add(doneGroup);
                currentStates.add(nRemainingGroup);
                currentStates.addAll(nRemainingCollector.exitStates());
                currentStates.addAll(oneRemainingCollector.exitStates());
                allocateTransitions(resetCountToIndexInteraction, currentStates, doneGroup);

                currentStates.clear();
                currentStates.add(doneGroup);
                currentStates.addAll(oneRemainingCollector.exitStates());
            }
        }
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