public class Functions extends Object
| Constructor and Description |
|---|
Functions() |
| Modifier and Type | Method and Description |
|---|---|
static <T> Collector<Optional<T>,List<T>,List<T>> |
flatList()
|
static <T> T |
identity(T value)
A method that is useful as a method reference to implement an identity function.
|
static <K,V> Map<K,V> |
map(Collection<V> values,
Function<V,K> key)
Create a
Map by applying a function that extracts the key from a collection of values. |
static <K,V> Map<K,V> |
map(Function<V,K> key,
V... values)
Create a
Map by applying a function that extracts the key from an array of values. |
static <I,O> Supplier<O> |
map(Supplier<I> source,
Function<I,O> map)
|
static <T> T |
requireNonNull(Class<T> type,
T value)
Require an instance not to be null, using the (simple) name of the required type as an error message if it is.
|
public static <T> T requireNonNull(Class<T> type, T value)
T - the type.type - the required type.value - the value that must not be null.Objects.requireNonNull(Object, Supplier)public static <I,O> Supplier<O> map(Supplier<I> source, Function<I,O> map)
I - the type of the value supplied by the original supplier.O - the type of the value supplied by the resulting supplier.source - the source supplier that supplies the original value.map - the function that converts the value of the original supplier.@SafeVarargs public static <K,V> Map<K,V> map(Function<V,K> key, V... values)
Map by applying a function that extracts the key from an array of values.K - the type of the keys.V - the type of the values.key - the key extraction function.values - the values of the map (from which the keys are extracted).Map from the keys of the values to the values.public static <T> T identity(T value)
T - the type of the value.value - the input (and output) value of the function.public static <K,V> Map<K,V> map(Collection<V> values, Function<V,K> key)
Map by applying a function that extracts the key from a collection of values.K - the type of the keys.V - the type of the values.values - the values of the map (from which the keys are extracted).key - the key extraction function.Map from the keys of the values to the values.Copyright © 2019. All rights reserved.