T - Type of contained elementspublic interface Nary<T> extends MultiElement<T>
Stream to interact with them.Nary is a type to be used when we don't know how many elements it will contain in runtime, but at the same time
we want to allow programmers to manipulate them as a Stream or an Optional if they somehow
know that is only 1 element that may be contained.Nary can be thought as an extended Stream api that given the necessary conditions on runtime
can be further extended to a Unary and include the api of an Optional.Nary as a Unary and use it as an Optional to better represent
the compile time semantics of the possible runtime results.Stream the api for Optional is extended to include some operations that complete original
api and makes it similar to streams (like the laziness of non terminal operations)
Created by kfgodel on 06/11/14.
Stream.Builder<T>| Modifier and Type | Method and Description |
|---|---|
static <T> Unary<T> |
empty()
Gets an empty nary to represent a 0 element Nary.
|
boolean |
equals(Object obj)
This method is redefined so two instances of
Nary are equal only if they contain
equal elements, comparing them in iteration order |
static <T> Nary<T> |
from(Collection<T> collection)
Creates a nary instance from the elements of a collection
|
static <T> Nary<T> |
from(Enumeration<T> enumeration)
Creates a nary from an enumeration
|
static <T> Nary<T> |
from(Iterable<T> iterable)
Creates a nary from an iterable source
|
static <T> Nary<T> |
from(Iterator<T> iterator)
Creates a nary from an iterator.
|
static <K,V> Nary<Map.Entry<K,V>> |
from(Map<K,V> map)
Creates a nary from the pairs of elements in a
Map |
static <T> Unary<T> |
from(Optional<? extends T> nativeOptional)
Creates a nary from a native optional.
|
static <T> Nary<T> |
from(Spliterator<T> spliterator)
Creates a nary from a spliterator as source for a stream
|
static <T> Nary<T> |
from(Stream<? extends T> stream)
Creates a nary from a native stream.
|
static <T> Nary<T> |
from(Supplier<T> supplier)
Creates a new Nary instance from the given supplier that will contain only 1 element.
The supplier will be called the first time the value is needed on a terminal operation |
static <T> Nary<T> |
from(T[] array)
Creates a nary from an array
|
int |
hashCode()
This method is redefined so the hashcode of a
Nary is based on its contained elements. |
static <T> Unary<T> |
of(T nullableElement)
Creates a nary from an element whose absence is represented by null.
If null is passed then an empty Nary is returned |
static <T> Unary<T> |
ofNonNullable(T element)
Creates a nary containing a single non null element.
|
static <T> Nary<T> |
ofNonNullable(T element,
T... additionals)
Creates a nary containing the given elements.
|
String |
toString()
This method is redefined so whenever possible, the contained elements are printed
|
add, collect, collectToList, collectToSet, concat, concat, findAnyNary, findFirstNary, findLast, flatMapOptional, forEach, mapFilteringNullResult, maxNary, minNary, reduceNary, spliterator, uniquedistinct, filter, flatMap, limit, map, peek, skip, sorted, sortedallMatch, anyMatch, builder, collect, collect, concat, count, findAny, findFirst, flatMapToDouble, flatMapToInt, flatMapToLong, forEachOrdered, generate, iterate, mapToDouble, mapToInt, mapToLong, max, min, noneMatch, reduce, reduce, reduce, toArray, toArrayclose, isParallel, iterator, onClose, parallel, sequential, unorderedboolean equals(Object obj)
Nary are equal only if they contain
equal elements, comparing them in iteration orderequals in class ObjectObject.equals(Object)int hashCode()
Nary is based on its contained elements.hashCode in class ObjectObject.hashCode()String toString()
toString in class ObjectObject.toString()static <T> Unary<T> empty()
static <T> Nary<T> from(Stream<? extends T> stream)
Stream operation on this instance will consume the stream.T - Expected type of elementsstream - original streamstatic <T> Unary<T> ofNonNullable(T element)
T - The type of expected nary contentelement - The non null elementstatic <T> Nary<T> ofNonNullable(T element, T... additionals)
T - The type of expected nary contentelement - The first mandatory elementadditionals - The optional extra elementsstatic <T> Unary<T> of(T nullableElement)
static <T> Unary<T> from(Optional<? extends T> nativeOptional)
T - The expected element typenativeOptional - original optionalstatic <T> Nary<T> from(Spliterator<T> spliterator)
T - The expected iterated element typesspliterator - A spliteratorstatic <T> Nary<T> from(Iterator<T> iterator)
T - The expected iterated typeiterator - An iteratorstatic <T> Nary<T> from(Iterable<T> iterable)
T - The expected iterable typeiterable - An iterable sourcestatic <T> Nary<T> from(Supplier<T> supplier)
T - The type of produced elementsupplier - the lambda to the get only element of this instancestatic <T> Nary<T> from(Collection<T> collection)
T - Expected type for collection elementscollection - The collectionstatic <T> Nary<T> from(T[] array)
T - The expected array element typearray - The original arraystatic <T> Nary<T> from(Enumeration<T> enumeration)
T - The expected element typesenumeration - The input enumerationCopyright © 2020. All rights reserved.