public final class CollectionUtils extends Object
Modifier and Type | Method and Description |
---|---|
static <T> Set<T> |
asOrderedSet(Iterable<T> elements)
Returns a set containing the given elements in iteration order.
|
static <T> Set<T> |
asOrderedSet(T... elements)
Returns a set containing the given elements in iteration order.
|
static <K,V,M extends Map<K,V>> |
entriesOf(M map)
Returns a stream containing the entries of the given map.
|
static Stream<String> |
fromCsv(String csv)
Returns the list of values specified by the given comma-separated string.
|
static <K,V> Optional<Map<K,V>> |
ifNotEmpty(Map<K,V> map)
Returns the given map if it is non-null and non-empty.
|
static <T> List<T> |
iterableOf(Optional<T> value)
If the given value is present, returns it as a singleton list.
|
static <T,C extends Collection<T>> |
membersOf(C collection)
Returns a stream containing the members of the given collection.
|
static <T> List<T> |
restOf(List<T> members,
int excluded)
Returns a list of all given members except for the one at the excluded position.
|
static <T> Stream<T> |
streamOf(Optional<T> value)
If the given value is present, returns it as a single-element stream.
|
static String |
toCsv(Stream<?> values)
Returns the given list of values as a comma-separated string.
|
static <T> Collector<T,?,Set<T>> |
toOrderedSet()
Returns a
Collector that accumulates set elements in insertion order |
static <T> Stream<T> |
toStream(Iterable<T> iterable)
Returns a stream that produces the sequence defined by the given Iterable.
|
static <T> Stream<T> |
toStream(Iterator<T> iterator)
Returns a stream that produces the sequence defined by the given Iterator.
|
public static <T> Stream<T> toStream(Iterator<T> iterator)
public static <T> Stream<T> toStream(Iterable<T> iterable)
public static <T> List<T> iterableOf(Optional<T> value)
public static <T> Stream<T> streamOf(Optional<T> value)
public static <T,C extends Collection<T>> Stream<T> membersOf(C collection)
public static <K,V,M extends Map<K,V>> Stream<Map.Entry<K,V>> entriesOf(M map)
public static <K,V> Optional<Map<K,V>> ifNotEmpty(Map<K,V> map)
Optional.empty()
.public static String toCsv(Stream<?> values)
public static Stream<String> fromCsv(String csv)
toCsv(java.util.stream.Stream<?>)
public static <T> Collector<T,?,Set<T>> toOrderedSet()
Collector
that accumulates set elements in insertion orderpublic static <T> Set<T> asOrderedSet(Iterable<T> elements)
@SafeVarargs public static <T> Set<T> asOrderedSet(T... elements)
Copyright © 2024 The Cornutum Project. All rights reserved.