private static Arbitrary<Encoder> enumEncoder(
        final int offset,
        final List<Token> tokens,
        final Token typeToken,
        final MutableInteger cursor,
        final int endIdxInclusive)
    {
        cursor.increment();

        final List<Encoder> encoders = new ArrayList<>();
        for (; cursor.get() <= endIdxInclusive; cursor.increment())
        {
            final Token token = tokens.get(cursor.get());

            if (VALID_VALUE != token.signal())
            {
                throw new IllegalArgumentException("Expected VALID_VALUE token");
            }

            final Encoding encoding = token.encoding();
            final Encoder caseEncoder = integerValueEncoder(encoding, encoding.constValue().longValue());
            encoders.add(caseEncoder);
        }

        if (encoders.isEmpty())
        {
            final Encoder nullEncoder = integerValueEncoder(
                typeToken.encoding(),
                typeToken.encoding().nullValue().longValue());
            encoders.add(nullEncoder);
        }

        return Arbitraries.of(encoders).map(encoder ->
            (builder, buffer, bufferOffset, limit) ->
                encoder.encode(builder, buffer, bufferOffset + offset, limit));
    }
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