Package org.dizitart.no2.common
Interface RecordStream<T>
- Type Parameters:
T- the type parameter for the records in the stream
- All Superinterfaces:
Iterable<T>
- All Known Subinterfaces:
Cursor<T>,DocumentCursor
An interface representing a stream of records of type T.
Provides methods to create, manipulate and iterate over a
stream of records.
- Since:
- 1.0
- Author:
- Anindya Chatterjee.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V> RecordStream<V>empty()Creates an emptyRecordStream.static <T> RecordStream<T>except(Iterable<T> iterable, Collection<T> elements) default TGets the first element of the result ornullif it is empty.static <T> RecordStream<T>fromCombined(Iterable<T> first, Iterable<T> second) Creates aRecordStreamby combining twoIterables.static <T> RecordStream<T>fromIterable(Iterable<T> iterable) Creates aRecordStreamfrom anIterable.default booleanisEmpty()Checks if thisRecordStreamhas any elements or not.static <V> RecordStream<V>single(V v) Creates aRecordStreamwith a single element.default longsize()Gets the size of theRecordStream.toList()Creates aListfrom aRecordStreamby iterating it.toSet()Creates aSetfrom aRecordStreamby iterating it.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
fromIterable
Creates aRecordStreamfrom anIterable.- Type Parameters:
T- the type parameter- Parameters:
iterable- the iterable- Returns:
- the record stream
-
fromCombined
Creates aRecordStreamby combining twoIterables.- Type Parameters:
T- the type parameter- Parameters:
first- the firstsecond- the second- Returns:
- the record stream
-
except
- Type Parameters:
T- the type parameter- Parameters:
iterable- the iterableelements- the elements- Returns:
- the record stream
-
empty
Creates an emptyRecordStream.- Type Parameters:
V- the type parameter- Returns:
- the record stream
-
single
Creates aRecordStreamwith a single element.- Type Parameters:
V- the type parameter- Parameters:
v- the v- Returns:
- the record stream
-
size
default long size()Gets the size of theRecordStream.- Returns:
- the long
-
toList
Creates aListfrom aRecordStreamby iterating it.- Returns:
- the list
-
toSet
Creates aSetfrom aRecordStreamby iterating it.- Returns:
- the set
-
isEmpty
default boolean isEmpty()Checks if thisRecordStreamhas any elements or not.- Returns:
- the boolean
-
firstOrNull
Gets the first element of the result ornullif it is empty.- Returns:
- the first element or
null
-