Class StreamIteratorUtils
java.lang.Object
io.clonecloudstore.common.standard.stream.StreamIteratorUtils
Utility class to help to create an InputStream of serialized objects from a Stream of Objects and reverse.
Note that DTO class must have an empty constructor or being a record.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceTransform interface -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic InputStreamgetInputStreamFromIterator(Iterator<?> iterator, StreamIteratorUtils.Transform transform, Class<?> forClass) static InputStreamgetInputStreamFromIterator(Iterator<?> iterator, Class<?> forClass) static InputStreamgetInputStreamFromStream(Stream<?> stream, StreamIteratorUtils.Transform transform, Class<?> forClass) static InputStreamgetInputStreamFromStream(Stream<?> stream, Class<?> forClass) static <E> ClosingIterator<E> getIteratorFromInputStream(InputStream inputStream, Class<E> forClass) static <E> List<E> getListFromIterator(Iterator<E> iterator) Transform Iterator to List (all in memory)static <E> Stream<E> getStreamFromInputStream(InputStream inputStream, Class<E> forClass) static <E> Stream<E> getStreamFromIterator(Iterator<E> iterator) Transform Iterator to Stream
-
Constructor Details
-
StreamIteratorUtils
public StreamIteratorUtils()
-
-
Method Details
-
getInputStreamFromStream
public static InputStream getInputStreamFromStream(Stream<?> stream, Class<?> forClass) throws IOException - Parameters:
stream- The Stream to transform to InputStream of Json serialized ObjectsforClass- the object Class- Returns:
- the InputStream usable in REST API
- Throws:
IOException- if an issue occurs
-
getInputStreamFromStream
public static InputStream getInputStreamFromStream(Stream<?> stream, StreamIteratorUtils.Transform transform, Class<?> forClass) throws IOException - Parameters:
stream- The Stream to transform to InputStream of Json serialized Objectstransform- function to convert source Stream object to another oneforClass- the object Class- Returns:
- the InputStream usable in REST API
- Throws:
IOException- if an issue occurs
-
getInputStreamFromIterator
public static InputStream getInputStreamFromIterator(Iterator<?> iterator, Class<?> forClass) throws IOException - Parameters:
iterator- The Iterator to transform to InputStream of Json serialized ObjectsforClass- the object Class- Returns:
- the InputStream usable in REST API
- Throws:
IOException- if an issue occurs
-
getInputStreamFromIterator
public static InputStream getInputStreamFromIterator(Iterator<?> iterator, StreamIteratorUtils.Transform transform, Class<?> forClass) throws IOException - Parameters:
iterator- The Iterator to transform to InputStream of Json serialized Objectstransform- function to convert source Stream object to another oneforClass- the object Class- Returns:
- the InputStream usable in REST API
- Throws:
IOException- if an issue occurs
-
getStreamFromInputStream
public static <E> Stream<E> getStreamFromInputStream(InputStream inputStream, Class<E> forClass) throws CcsWithStatusException - Parameters:
inputStream- the InputStream containing Json ObjectsforClass- the object Class- Returns:
- The Stream of deserialized Objects
- Throws:
CcsWithStatusException- if an issue occurs during streaming
-
getIteratorFromInputStream
public static <E> ClosingIterator<E> getIteratorFromInputStream(InputStream inputStream, Class<E> forClass) - Parameters:
inputStream- the InputStream containing Json ObjectsforClass- the object Class- Returns:
- The Stream of deserialized Objects
- Throws:
CcsInvalidArgumentRuntimeException- if an issue occurs during iterating
-
getListFromIterator
Transform Iterator to List (all in memory) -
getStreamFromIterator
Transform Iterator to Stream
-