@Override
    @SuppressWarnings("unchecked")
    public <T> T[] toArray(T[] a) {
        int size = size();
        if (a.length < size) {
            // Create a new array of the same type as a with the correct size
            a = (T[]) Array.newInstance(a.getClass().getComponentType(), size);
        }
        for (int i = 0; i < size; i++) {
            a[i] = (T) Integer.valueOf(from + i);
        }
        if (a.length > size) {
            a[size] = null;
        }
        return a;
    }
Constructs a {@code RangeSet} with the specified range.

@param from      The starting value (inclusive) of the range.
@param to        The ending value (exclusive) of the range.
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/RangeSet.java