private static Arbitrary<Encoder> encodedTypeEncoder(
        final int offset,
        final Token typeToken,
        final CharGenerationMode charGenerationMode)
    {
        final Encoding encoding = typeToken.encoding();
        final Arbitrary<Encoder> arbEncoder = encodedTypeEncoder(encoding, charGenerationMode);

        if (typeToken.arrayLength() == 1)
        {
            return arbEncoder.map(encoder -> (builder, buffer, bufferOffset, limit) ->
                encoder.encode(builder, buffer, bufferOffset + offset, limit));
        }
        else
        {
            return arbEncoder.list().ofSize(typeToken.arrayLength())
                .map(encoders -> (builder, buffer, bufferOffset, limit) ->
                {
                    for (int i = 0; i < typeToken.arrayLength(); i++)
                    {
                        builder.beginScope("[" + i + "]");
                        final int elementOffset = bufferOffset + offset + i * encoding.primitiveType().size();
                        encoders.get(i).encode(builder, buffer, elementOffset, limit);
                        builder.endScope();
                    }
                });
        }
    }
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