public static Arbitrary<EncodedMessage> encodedMessage(final CharGenerationMode mode)
    {
        return SbeArbitraries.messageSchema().flatMap(testSchema ->
        {
            final String xml = TestXmlSchemaWriter.writeString(testSchema);
            try (InputStream in = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)))
            {
                final ParserOptions options = ParserOptions.builder()
                    .suppressOutput(false)
                    .warningsFatal(true)
                    .stopOnError(true)
                    .build();
                final uk.co.real_logic.sbe.xml.MessageSchema parsedSchema = parse(in, options);
                final Ir ir = new IrGenerator().generate(parsedSchema);
                return SbeArbitraries.messageValueEncoder(ir, testSchema.templateId(), mode)
                    .map(encoder ->
                    {
                        final EncodingLogger logger = new EncodingLogger();
                        final ExpandableArrayBuffer buffer = new ExpandableArrayBuffer();
                        final MutableInteger limit = new MutableInteger();
                        encoder.encode(logger, buffer, 0, limit);
                        return new EncodedMessage(xml, ir, buffer, limit.get(), logger.toString());
                    });
            }
            catch (final Exception e)
            {
                throw new AssertionError(
                    "Failed to generate encoded value for schema.\n\n" +
                    "SCHEMA:\n" + xml,
                    e);
            }
        }).withoutEdgeCases();
    }
This combinator adds duplicates to an arbitrary list. We prefer this to JQwik's built-in functionality,
as that is inefficient and dominates test runs.
<p>
This method works by generating a list of integers, which represent, in an alternating manner,
the number of items to skip before <i>selecting</i> an item to duplicate
and the number of items to skip before <i>inserting</i> the duplicate.

@param maxDuplicates the maximum number of duplicates to add
@param arbitrary     the arbitrary list to duplicate items in
@param <T>           the type of the list
@return an arbitrary list with duplicates
sbe-tool/src/propertyTest/java/uk/co/real_logic/sbe/properties/arbitraries/SbeArbitraries.java