com.arextest.storage.service.IterableListWrapper Maven / Gradle / Ivy
package com.arextest.storage.service;
import java.util.AbstractList;
import java.util.Iterator;
import javax.validation.constraints.NotNull;
/**
* avoid create a new array List,supported serialize is our goal.
*
* @param Type of instance
* @author jmo
* @since 2021/11/11
*/
public final class IterableListWrapper extends AbstractList {
private final static int SIZE_NOT_GIVEN = 0;
private final Iterable iterable;
IterableListWrapper(@NotNull Iterable iterable) {
this.iterable = iterable;
}
@Override
public E get(int index) {
throw new UnsupportedOperationException();
}
@Override
public Iterator iterator() {
return iterable.iterator();
}
@Override
public int size() {
return SIZE_NOT_GIVEN;
}
}