| Modifier and Type | Method and Description |
|---|---|
static <T,U extends T> |
cast(Class<? extends U> clazz)
Returns a
Function that casts it's input argument to any type. |
static <T,U extends T> |
cast(T t)
Casts it's input argument to any type.
|
static <T,U extends T> |
castIfInstanceOf(Class<? extends U> clazz)
Returns a
Function that casts it'S input argument to the
specified type if it's the right type. |
static <T,U> Function<T,U> |
constant(U u)
Creates a function returning the same result for each invocation.
|
static <T,R> Supplier<R> |
curry(Function<? super T,? extends R> function,
T t)
Curries the parameter of the
Function and creates a
Consumer. |
static <T1,T2,R> Function<T2,R> |
curryFirst(BiFunction<T1,T2,R> bifunction,
T1 t1)
Curries the first parameter of the
BiFunction and creates a
Function. |
static <T1,T2,R> Function<T1,R> |
currySecond(BiFunction<T1,T2,R> bifunction,
T2 t2)
Curries the second parameter of the
BiFunction and creates a
Function. |
static <S,T,X extends Exception> |
errorWrapper(ThrowingFunction<S,T,X> fun)
Wraps an
ThrowingFunction into an Function that throws an
Error if the function throws an Exception. |
static <T,U> Function<T,U> |
forSupplier(Supplier<U> supplier)
Create a function for the the supplier, ignoring any supplied input.
|
static <K,V> Function<Map<K,V>,Set<K>> |
keySetWhereValues(Predicate<? super V> predicate) |
static <K,V> Function<Map<K,V>,Stream<K>> |
keyStreamWhereValues(Predicate<? super V> predicate) |
static <T> BinaryOperator<T> |
mergeLeft(BiConsumer<T,T> merger) |
static <T> BinaryOperator<T> |
mergeRight(BiConsumer<T,T> merger) |
static <K,V> BinaryOperator<Map<K,V>> |
mergeToLeftMap(BinaryOperator<V> valueMerger) |
static <K,V> BinaryOperator<Map<K,V>> |
mergeToRightMap(BinaryOperator<V> valueMerger) |
static <T> Function<T,T> |
mutate(Consumer<? super T> action)
|
public static <T,U extends T> U cast(T t)
throws ClassCastException
T - The input type.U - The output type.t - The object to be casted.ClassCastException - if the object can not be casted.public static <T,U extends T> Function<T,U> cast(@Nonnull Class<? extends U> clazz)
Function that casts it's input argument to any type.T - The input type.U - The output type.clazz - The class the input should be casted to.cast(java.lang.Object)public static <T,U extends T> Function<T,Optional<U>> castIfInstanceOf(@Nonnull Class<? extends U> clazz)
Function that casts it'S input argument to the
specified type if it's the right type. The returned Optional
either contains the casted input arguemnt or is empty.T - The input type.U - The output type.clazz - The class toOptional containing the inputpublic static <T,U> Function<T,U> forSupplier(@Nonnull Supplier<U> supplier)
T - the type of the input to the functionU - the type of the result to the functionsupplier - the supplierpublic static <T,U> Function<T,U> constant(@Nullable U u)
T - the type of the input to the functionU - the type of the result to the functionu - the constant resultpublic static <T,R> Supplier<R> curry(@Nonnull Function<? super T,? extends R> function, T t)
Function and creates a
Consumer.T - the parameter typeR - the return typefunction - the functiont - the curried parameterpublic static <T1,T2,R> Function<T2,R> curryFirst(@Nonnull BiFunction<T1,T2,R> bifunction, T1 t1)
BiFunction and creates a
Function.T1 - the first parameter typeT2 - the second parameter typeR - the return typebifunction - the functiont1 - the curried parameterpublic static <T1,T2,R> Function<T1,R> currySecond(@Nonnull BiFunction<T1,T2,R> bifunction, T2 t2)
BiFunction and creates a
Function.T1 - the first parameter typeT2 - the second parameter typeR - the return typebifunction - the functiont2 - the curried parameterpublic static <T> BinaryOperator<T> mergeLeft(@Nonnull BiConsumer<T,T> merger)
public static <T> BinaryOperator<T> mergeRight(@Nonnull BiConsumer<T,T> merger)
public static <K,V> BinaryOperator<Map<K,V>> mergeToLeftMap(@Nonnull BinaryOperator<V> valueMerger)
public static <K,V> BinaryOperator<Map<K,V>> mergeToRightMap(@Nonnull BinaryOperator<V> valueMerger)
public static <K,V> Function<Map<K,V>,Set<K>> keySetWhereValues(Predicate<? super V> predicate)
public static <K,V> Function<Map<K,V>,Stream<K>> keyStreamWhereValues(Predicate<? super V> predicate)
public static <T> Function<T,T> mutate(@Nonnull Consumer<? super T> action)
T - The consumed element's type.action - The consumer.public static <S,T,X extends Exception> Function<S,T> errorWrapper(@Nonnull ThrowingFunction<S,T,X> fun)
ThrowingFunction into an Function that throws an
Error if the function throws an Exception.S - the function's input type.T - the function's output type.X - the type of the the exception that might be thrown.fun - the function.Copyright © 2015–2020 52°North Initiative for Geospatial Open Source Software GmbH. All rights reserved.