All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.arextest.storage.service.IterableListWrapper Maven / Gradle / Ivy

There is a newer version: 1.3.4
Show newest version
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;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy