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
public interface RecordStream<T> extends Iterable<T>
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
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description static <V> RecordStream<V>empty()Creates an emptyRecordStream.static <T> RecordStream<T>except(Iterable<T> iterable, Collection<T> elements)default TfirstOrNull()Gets 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.default List<T>toList()Creates aListfrom aRecordStreamby iterating it.default Set<T>toSet()Creates aSetfrom aRecordStreamby iterating it.-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Method Detail
-
fromIterable
static <T> RecordStream<T> fromIterable(Iterable<T> iterable)
Creates aRecordStreamfrom anIterable.- Type Parameters:
T- the type parameter- Parameters:
iterable- the iterable- Returns:
- the record stream
-
fromCombined
static <T> RecordStream<T> fromCombined(Iterable<T> first, Iterable<T> second)
Creates aRecordStreamby combining twoIterables.- Type Parameters:
T- the type parameter- Parameters:
first- the firstsecond- the second- Returns:
- the record stream
-
except
static <T> RecordStream<T> except(Iterable<T> iterable, Collection<T> elements)
- Type Parameters:
T- the type parameter- Parameters:
iterable- the iterableelements- the elements- Returns:
- the record stream
-
empty
static <V> RecordStream<V> empty()
Creates an emptyRecordStream.- Type Parameters:
V- the type parameter- Returns:
- the record stream
-
single
static <V> RecordStream<V> single(V v)
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
default List<T> toList()
Creates aListfrom aRecordStreamby iterating it.- Returns:
- the list
-
toSet
default Set<T> toSet()
Creates aSetfrom aRecordStreamby iterating it.- Returns:
- the set
-
isEmpty
default boolean isEmpty()
Checks if thisRecordStreamhas any elements or not.- Returns:
- the boolean
-
firstOrNull
default T firstOrNull()
Gets the first element of the result ornullif it is empty.- Returns:
- the first element or
null
-
-