@Test public void buildStreamTest() throws IOException { String[] data = {"dog","cat","pig","frog"}; ObjectStream<String> stream = ObjectStreamUtils.createObjectStream(data); compare(stream, data); List<String> dataList = Arrays.asList(data); stream = ObjectStreamUtils.createObjectStream(Arrays.asList(data)); compare(stream, data); Arrays.sort(data); stream = ObjectStreamUtils.createObjectStream(new TreeSet<>(dataList)); compare(stream, data); }
@SafeVarargs public static <T> ObjectStream<T> createObjectStream(final T... array) { return new ObjectStream<T>() { private int index = 0; public T read() { if (index < array.length) return array[index++]; else return null; } public void reset() { index = 0; } public void close() { } }; }
ObjectStreamUtils { @SafeVarargs public static <T> ObjectStream<T> createObjectStream(final T... array) { return new ObjectStream<T>() { private int index = 0; public T read() { if (index < array.length) return array[index++]; else return null; } public void reset() { index = 0; } public void close() { } }; } }
ObjectStreamUtils { @SafeVarargs public static <T> ObjectStream<T> createObjectStream(final T... array) { return new ObjectStream<T>() { private int index = 0; public T read() { if (index < array.length) return array[index++]; else return null; } public void reset() { index = 0; } public void close() { } }; }  }
ObjectStreamUtils { @SafeVarargs public static <T> ObjectStream<T> createObjectStream(final T... array) { return new ObjectStream<T>() { private int index = 0; public T read() { if (index < array.length) return array[index++]; else return null; } public void reset() { index = 0; } public void close() { } }; }  @SafeVarargs static ObjectStream<T> createObjectStream(final T... array); static ObjectStream<T> createObjectStream(final Collection<T> collection); static ObjectStream<T> concatenateObjectStream(final Collection<ObjectStream<T>> streams); @SafeVarargs static ObjectStream<T> concatenateObjectStream(final ObjectStream<T>... streams); }
ObjectStreamUtils { @SafeVarargs public static <T> ObjectStream<T> createObjectStream(final T... array) { return new ObjectStream<T>() { private int index = 0; public T read() { if (index < array.length) return array[index++]; else return null; } public void reset() { index = 0; } public void close() { } }; }  @SafeVarargs static ObjectStream<T> createObjectStream(final T... array); static ObjectStream<T> createObjectStream(final Collection<T> collection); static ObjectStream<T> concatenateObjectStream(final Collection<ObjectStream<T>> streams); @SafeVarargs static ObjectStream<T> concatenateObjectStream(final ObjectStream<T>... streams);  }