T - type of elements.public final class Elements<T> extends Object
| Modifier and Type | Method and Description |
|---|---|
T[] |
asArray(T[] array) |
List<T> |
asList() |
<K> Map<K,T> |
asMap(Function<? super T,? extends K> keyMapper) |
<K,V> Map<K,V> |
asMap(Function<? super T,? extends K> keyMapper,
Function<? super T,? extends V> valueMapper) |
Set<T> |
asSet() |
Stream<T> |
asStream() |
String |
asText()
Concatenate all elements in stream to String.
|
String |
asText(String joinText)
Concatenate all elements in stream to String with join text.
|
static <T> Elements<T> |
elements(Iterable<T> iterable) |
static <T> Elements<T> |
elements(Stream<T> stream) |
static <T> Elements<T> |
elements(T... array) |
Elements<T> |
filter(Predicate<T> predicate) |
<R> Elements<R> |
flatMap(Function<? super T,? extends Stream<? extends R>> mapper) |
void |
forEach(BiConsumer<Integer,T> consumer)
For each with index and element.
|
void |
forEach(Consumer<IndexedElement<T>> consumer)
For each with index and element and useful method isFirst, isLast.
|
T |
getFirst() |
T |
getLast() |
<R> Elements<R> |
map(Function<? super T,? extends R> mapper) |
String |
toString()
Concatenate all elements in stream to String.
|
public static <T> Elements<T> elements(T... array)
public T getFirst()
public T getLast()
public <K,V> Map<K,V> asMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends V> valueMapper)
public String toString()
public String asText(String joinText)
joinText - text between every elementpublic String asText()
public void forEach(BiConsumer<Integer,T> consumer)
consumer - consumer of index and element.public void forEach(Consumer<IndexedElement<T>> consumer)
consumer - for IndexedElement which holds element with T type and indexCopyright © 2020. All rights reserved.