private void generateFullyEncodedCheck(
        final StringBuilder sb,
        final FieldPrecedenceModel fieldPrecedenceModel)
    {
        if (null == fieldPrecedenceModel)
        {
            return;
        }

        sb.append("\n");

        sb.append("    public void checkEncodingIsComplete()\n")
            .append("    {\n")
            .append("        if (").append(precedenceChecksFlagName).append(")\n")
            .append("        {\n")
            .append("            switch (codecState)\n")
            .append("            {\n");

        fieldPrecedenceModel.forEachTerminalEncoderState((state) ->
            sb.append("                case ").append(stateCaseForSwitchCase(state)).append(":\n")
            .append("                    return;\n"));

        sb.append("                default:\n")
            .append("                    throw new IllegalStateException(\"Not fully encoded, current state: \" +\n")
            .append("                        CodecStates.name(codecState) + \", allowed transitions: \" +\n")
            .append("                        CodecStates.transitions(codecState));\n")
            .append("            }\n")
            .append("        }\n")
            .append("    }\n\n");
    }
\n");
        sb.append("     * The states in which a encoder/decoder/codec can live.\n");
        sb.append("     *\n");
        sb.append("     * <p>The state machine diagram below, encoded in the dot language, describes\n");
        sb.append("     * the valid state transitions according to the order in which fields may be\n");
        sb.append("     * accessed safely. Tools such as PlantUML and Graphviz can render it.\n");
        sb.append("     *\n");
        sb.append("     * <pre>{@code\n");
        fieldPrecedenceModel.generateGraph(sb, "     *   ");
        sb.append("     * }</pre>\n");
        sb.append("
sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/java/JavaGenerator.java