public final class CollectorUtil extends Object
Modifier and Type | Method and Description |
---|---|
static <T,C> Collector<T,?,com.speedment.common.mapstream.MapStream<C,List<T>>> |
groupBy(Function<T,C> grouper)
Returns a new
MapStream where the elements have been grouped
together using the specified function. |
static Optional<String> |
ifEmpty(String str)
Returns the specified string wrapped as an Optional.
|
static Collector<String,?,String> |
joinIfNotEmpty(String delimiter,
String prefix,
String suffix)
Similar to the
Collectors.joining(java.lang.CharSequence, java.lang.CharSequence, java.lang.CharSequence)
method except that this method surrounds the result with the specified
prefix and suffix even if the stream is empty. |
static <I,T> T |
of(Supplier<I> supplier,
Consumer<I> modifier,
Function<I,T> finisher) |
static <T> T |
of(Supplier<T> supplier,
Consumer<T> modifier,
Consumer<T>... additionalModifiers) |
static <T> Collector<T,?,List<T>> |
toReversedList() |
static <T> Collector<T,Set<T>,Set<T>> |
toUnmodifiableSet() |
static <T> Set<T> |
unmodifiableSetOf(T... items) |
@SafeVarargs public static <T> T of(Supplier<T> supplier, Consumer<T> modifier, Consumer<T>... additionalModifiers)
@SafeVarargs public static <T> Set<T> unmodifiableSetOf(T... items)
public static Collector<String,?,String> joinIfNotEmpty(String delimiter, String prefix, String suffix)
Collectors.joining(java.lang.CharSequence, java.lang.CharSequence, java.lang.CharSequence)
method except that this method surrounds the result with the specified
prefix
and suffix
even if the stream is empty.delimiter
- the delimiter to separate the stringsprefix
- the prefix to put before the resultsuffix
- the suffix to put after the resultpublic static Optional<String> ifEmpty(String str)
str
- the string to wrappublic static <T,C> Collector<T,?,com.speedment.common.mapstream.MapStream<C,List<T>>> groupBy(Function<T,C> grouper)
MapStream
where the elements have been grouped
together using the specified function.T
- the stream element typeC
- the type of the key to group bygrouper
- the function to use for groupingMapStream
grouped by keyCopyright © 2018 Speedment, Inc.. All rights reserved.