Interface ISequence<ITEM_TYPE extends IItem>
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description List<ITEM_TYPE>
asList()
Get the items in this sequence as aList
.Stream<ITEM_TYPE>
asStream()
Get the items in this sequence as aStream
.void
collect()
This optional operation ensures that a list is used to back this sequence.static <ITEM_TYPE extends IItem>
ISequence<ITEM_TYPE>empty()
Get an empty sequence.void
forEach(Consumer<? super ITEM_TYPE> action)
Iterate over each item in the sequence using the providedaction
.boolean
isEmpty()
Determine if this sequence is empty.default Iterator<ITEM_TYPE>
iterator()
static <ITEM_TYPE extends IItem>
ISequence<ITEM_TYPE>of(ITEM_TYPE item)
Construct a new sequence containing the provideditem
.static <ITEM_TYPE extends IItem>
ISequence<ITEM_TYPE>of(List<ITEM_TYPE> items)
Construct a new sequence containing the provideditems
.static <ITEM_TYPE extends IItem>
ISequence<ITEM_TYPE>of(Stream<ITEM_TYPE> items)
Construct a new sequence containing the provideditems
.int
size()
Get the count of items in this sequence.static <ITEM_TYPE extends IItem>
Collector<ITEM_TYPE,?,ISequence<ITEM_TYPE>>toSequence()
-
Methods inherited from interface java.lang.Iterable
spliterator
-
-
-
-
Method Detail
-
empty
@NonNull static <ITEM_TYPE extends IItem> ISequence<ITEM_TYPE> empty()
Get an empty sequence.- Type Parameters:
ITEM_TYPE
- the item type- Returns:
- the empty sequence
-
of
@NonNull static <ITEM_TYPE extends IItem> ISequence<ITEM_TYPE> of(@Nullable ITEM_TYPE item)
Construct a new sequence containing the provideditem
.If the item is
null
and empty sequence will be created.- Type Parameters:
ITEM_TYPE
- the type of items contained in the sequence.- Parameters:
item
- the item to add to the sequence- Returns:
- the new sequence
-
of
@NonNull static <ITEM_TYPE extends IItem> ISequence<ITEM_TYPE> of(@NonNull List<ITEM_TYPE> items)
Construct a new sequence containing the provideditems
.- Type Parameters:
ITEM_TYPE
- the type of items contained in the sequence.- Parameters:
items
- the items to add to the sequence- Returns:
- the new sequence
-
of
@NonNull static <ITEM_TYPE extends IItem> ISequence<ITEM_TYPE> of(Stream<ITEM_TYPE> items)
Construct a new sequence containing the provideditems
.- Type Parameters:
ITEM_TYPE
- the type of items contained in the sequence.- Parameters:
items
- the items to add to the sequence- Returns:
- the new sequence
-
asList
@NonNull List<ITEM_TYPE> asList()
Get the items in this sequence as aList
.- Returns:
- a list containing all the items of the sequence
-
asStream
@NonNull Stream<ITEM_TYPE> asStream()
Get the items in this sequence as aStream
.- Returns:
- a stream containing all the items of the sequence
-
collect
void collect()
This optional operation ensures that a list is used to back this sequence.If a stream is currently backing this sequence, the stream will be collected into a list. This ensures the sequence can be visited multiple times.
-
isEmpty
boolean isEmpty()
Determine if this sequence is empty.- Returns:
true
if the sequence contains no items, orfalse
otherwise
-
size
int size()
Get the count of items in this sequence.- Returns:
- the count of items
-
forEach
void forEach(Consumer<? super ITEM_TYPE> action)
Iterate over each item in the sequence using the providedaction
.
-
toSequence
@NonNull static <ITEM_TYPE extends IItem> Collector<ITEM_TYPE,?,ISequence<ITEM_TYPE>> toSequence()
-
-