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 T
firstOrNull()
Gets the first element of the result ornull
if it is empty.static <T> RecordStream<T>
fromCombined(Iterable<T> first, Iterable<T> second)
Creates aRecordStream
by combining twoIterable
s.static <T> RecordStream<T>
fromIterable(Iterable<T> iterable)
Creates aRecordStream
from anIterable
.default boolean
isEmpty()
Checks if thisRecordStream
has any elements or not.static <V> RecordStream<V>
single(V v)
Creates aRecordStream
with a single element.default long
size()
Gets the size of theRecordStream
.default List<T>
toList()
Creates aList
from aRecordStream
by iterating it.default Set<T>
toSet()
Creates aSet
from aRecordStream
by iterating it.-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Method Detail
-
fromIterable
static <T> RecordStream<T> fromIterable(Iterable<T> iterable)
Creates aRecordStream
from 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 aRecordStream
by combining twoIterable
s.- 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 aRecordStream
with 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 aList
from aRecordStream
by iterating it.- Returns:
- the list
-
toSet
default Set<T> toSet()
Creates aSet
from aRecordStream
by iterating it.- Returns:
- the set
-
isEmpty
default boolean isEmpty()
Checks if thisRecordStream
has any elements or not.- Returns:
- the boolean
-
firstOrNull
default T firstOrNull()
Gets the first element of the result ornull
if it is empty.- Returns:
- the first element or
null
-
-