public class FuncUtils
extends java.lang.Object
Block
functions.Constructor and Description |
---|
FuncUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> void |
apply(java.lang.Object obj,
java.lang.Class<T> type,
Block<T> fun)
Run function when object is of the specific type.
|
static <T> void |
apply(java.lang.Object obj,
java.lang.Class<T> type,
Block<T> fun,
java.lang.Runnable otherwise)
Run function when object is of the specific type otherwise runnable is run.
|
static <T> void |
apply(Optional<? extends T> optional,
Block<T> fun)
Run function when optional is not absent.
|
static <T> void |
apply(Optional<? extends T> optional,
Block<T> fun,
java.lang.Runnable otherwise)
Run function when optional is not absent.
|
static <T> Optional<T> |
first(java.lang.Iterable<T> iterable)
Return first element from iterable when possible.
|
static <T> void |
forEach(java.lang.Iterable<? extends T> iterable,
Block<T> fun)
Iterate iterable and apply function on each item.
|
static <T> void |
forEachIndexed(java.lang.Iterable<? extends T> iterable,
com.tomtom.online.sdk.common.func.BlockWithIndex<T> fun)
Iterate iterable and apply function on each item.
|
static <T> void |
forWeekEach(java.lang.Iterable<java.lang.ref.WeakReference<? extends T>> iterable,
Block<java.lang.ref.WeakReference<? extends T>> fun)
Iterate iterable and apply function on each item.
|
public static <T> void forWeekEach(@NonNull java.lang.Iterable<java.lang.ref.WeakReference<? extends T>> iterable, @NonNull Block<java.lang.ref.WeakReference<? extends T>> fun)
iterable
- Iterablefun
- Function which will be appliedpublic static <T> void forEach(@NonNull java.lang.Iterable<? extends T> iterable, @NonNull Block<T> fun)
iterable
- Iterablefun
- Function which will be appliedpublic static <T> void forEachIndexed(@NonNull java.lang.Iterable<? extends T> iterable, @NonNull com.tomtom.online.sdk.common.func.BlockWithIndex<T> fun)
iterable
- Iterablefun
- Function which will be applied which contains also the index of the element.public static <T> void apply(@NonNull Optional<? extends T> optional, @NonNull Block<T> fun)
T
- optional
- When optional is present, fun is runfun
- Function which is run when optional is presentpublic static <T> void apply(@NonNull java.lang.Object obj, @NonNull java.lang.Class<T> type, @NonNull Block<T> fun)
obj
- Object that is to be cast.type
- Type to cast to.fun
- Function which is run when object is of the specific type.public static <T> void apply(@NonNull java.lang.Object obj, @NonNull java.lang.Class<T> type, @NonNull Block<T> fun, @NonNull java.lang.Runnable otherwise)
obj
- Object that is to be cast.type
- Type to cast to.fun
- Function which is run when object is of the specific type.otherwise
- Call this function when object is not of the specified typepublic static <T> void apply(@NonNull Optional<? extends T> optional, @NonNull Block<T> fun, @NonNull java.lang.Runnable otherwise)
T
- optional
- When optional is present, fun is runfun
- Function which is run when optional is presentotherwise
- Call this function when optional is not presentpublic static <T> Optional<T> first(@NonNull java.lang.Iterable<T> iterable)
iterable
-