public void generate() throws IOException
    {
        packageNameByTypes.clear();
        generatePackageInfo();
        generateTypeStubs();
        generateMessageHeaderStub();

        for (final List<Token> tokens : ir.messages())
        {
            final Token msgToken = tokens.get(0);
            final List<Token> messageBody = getMessageBody(tokens);
            final boolean hasVarData = -1 != findSignal(messageBody, Signal.BEGIN_VAR_DATA);

            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);

            final String decoderClassName = formatClassName(decoderName(msgToken.name()));
            final String decoderStateClassName = decoderClassName + "#CodecStates";
            final FieldPrecedenceModel decoderPrecedenceModel = precedenceChecks.createDecoderModel(
                decoderStateClassName, tokens);
            generateDecoder(decoderClassName, msgToken, fields, groups, varData, hasVarData, decoderPrecedenceModel);

            final String encoderClassName = formatClassName(encoderName(msgToken.name()));
            final String encoderStateClassName = encoderClassName + "#CodecStates";
            final FieldPrecedenceModel encoderPrecedenceModel = precedenceChecks.createEncoderModel(
                encoderStateClassName, tokens);
            generateEncoder(encoderClassName, msgToken, fields, groups, varData, hasVarData, encoderPrecedenceModel);
        }
    }
@Test
    void shouldCreateTypesInSamePackageIfSupportDisabled() throws Exception
    {
        try (InputStream in = Tests.getLocalResource("explicit-package-test-schema.xml"))
        {
            final ParserOptions options = ParserOptions.builder().stopOnError(true).build();
            final MessageSchema schema = parse(in, options);
            final IrGenerator irg = new IrGenerator();
            ir = irg.generate(schema);

            outputManager.clear();
            outputManager.setPackageName(ir.applicableNamespace());

            final JavaGenerator generator = new JavaGenerator(
                ir, BUFFER_NAME, READ_ONLY_BUFFER_NAME, false, false, false, false, outputManager);

            generator.generate();
            final String encoderFqcn = ir.applicableNamespace() + ".TestMessageEncoder";
            final Class<?> encoderClazz = compile(encoderFqcn);
            assertNotNull(encoderClazz);

            final String decoderFqcn = ir.applicableNamespace() + ".TestMessageDecoder";
            final Class<?> decoderClazz = compile(decoderFqcn);
            assertNotNull(decoderClazz);

            final Map<String, CharSequence> sources = outputManager.getSources();
            assertNotNull(sources.get(ir.applicableNamespace() + ".CarEncoder"));
            assertNotNull(sources.get(ir.applicableNamespace() + ".CarDecoder"));
            assertNotNull(sources.get(ir.applicableNamespace() + ".BooleanType"));
            assertNotNull(sources.get(ir.applicableNamespace() + ".DaysEncoder"));
            assertNotNull(sources.get(ir.applicableNamespace() + ".DaysDecoder"));
            assertNotNull(sources.get(ir.applicableNamespace() + ".MessageHeaderEncoder"));
        }
    }