private FieldPrecedenceModel createModel(
        final String stateClassName,
        final List<Token> tokens,
        final Function<IntStream, IntStream> versionsSelector
    )
    {
        if (context.shouldGeneratePrecedenceChecks())
        {
            final Token msgToken = tokens.get(0);

            final List<Token> messageBody = tokens.subList(1, tokens.size() - 1);
            int i = 0;

            final List<Token> fields = new ArrayList<>();
            i = collectFields(messageBody, i, fields);

            final List<Token> groups = new ArrayList<>();
            i = collectGroups(messageBody, i, groups);

            final List<Token> varData = new ArrayList<>();
            collectVarData(messageBody, i, varData);

            return FieldPrecedenceModel.newInstance(
                stateClassName,
                msgToken,
                fields,
                groups,
                varData,
                versionsSelector);
        }

        return null;
    }
Creates a new {@link PrecedenceChecks} instance.

@param context the {@link Context} describing how precedence checks should be generated.
@return a new {@link PrecedenceChecks} instance.
sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/common/PrecedenceChecks.java