E - The element type.public abstract class Series<E> extends Object
Collection.
In this view, a series essentially consists of two components:
If the first component ("head") is missing, the sequence is empty. Then the rest of the sequence ("tail") is also empty.
A sequence according to this definition is immutable and cannot contain null elements.
In addition to the components mentioned above, it has a certain size (number of items contained),
can be streamed and presented as a "normal" List.
| Constructor and Description |
|---|
Series() |
| Modifier and Type | Method and Description |
|---|---|
abstract List<E> |
asList()
Returns an immutable
List representation of this series. |
static <E> Series<E> |
empty()
Returns an empty
Series. |
boolean |
equals(Object obj) |
int |
hashCode() |
abstract E |
head()
Returns this series' head element if this is charged.
|
<R> Optional<R> |
ifCharged(BiFunction<E,Series<E>,R> function)
|
boolean |
isCharged()
Returns
true if this contains at least one element, false otherwise. |
boolean |
isEmpty()
Returns
true if this does not contain any element, false otherwise. |
static <E> Series<E> |
of(Collection<? extends E> origin)
Returns a
Series composed of the given Collection's elements in the given order. |
static <E> Series<E> |
of(E... elements)
Returns a
Series composed of the given elements in the given order. |
static <E> Series<E> |
of(Iterable<? extends E> origin)
|
static <E> Series<E> |
of(Streamable<? extends E> origin)
Returns a
Series composed of the given Streamable's elements in the given order. |
abstract int |
size()
Returns the number of elements within this series.
|
Stream<E> |
stream()
|
abstract Series<E> |
tail()
Returns the remaining subseries that follows this series' head element.
|
String |
toString() |
@SafeVarargs public static <E> Series<E> of(E... elements)
Series composed of the given elements in the given order.public static <E> Series<E> of(Streamable<? extends E> origin)
Series composed of the given Streamable's elements in the given order.public static <E> Series<E> of(Collection<? extends E> origin)
Series composed of the given Collection's elements in the given order.public final boolean isEmpty()
true if this does not contain any element, false otherwise.isCharged()public final boolean isCharged()
true if this contains at least one element, false otherwise.isEmpty()public final <R> Optional<R> ifCharged(BiFunction<E,Series<E>,R> function)
R - The result type.Optional describing the result of the function call
if this is charged.Optional.empty() if the result of the function call
is null.Optional.empty() if this is empty.isCharged()public abstract E head()
NoSuchElementException - if this is empty.public abstract Series<E> tail()
public abstract int size()
Copyright © 2024 Andreas Kluge-Kaindl, Bremen (de). All rights reserved.