public abstract class ObjectUtils extends Object
Modifier and Type | Method and Description |
---|---|
static <V> boolean |
check(Object value,
Class<V> requiredClass,
Function<V,Boolean> function)
Check the result of a function in case the value have got the same class as the required one.
|
static <V,R> Optional<R> |
iof(Object value,
Class<V> requiredClass,
Function<V,R> function)
Run a function in case the value is an instance of the required class.
|
public static final <V,R> Optional<R> iof(@Nullable Object value, @Nonnull Class<V> requiredClass, @Nonnull Function<V,R> function)
Object input = "ABC"; int result = ObjectUtils.iof(input, String.class, v -> v.length()).orElse(0); assertEquals(3, result);
public static final <V> boolean check(@Nullable Object value, @Nonnull Class<V> requiredClass, @Nonnull Function<V,Boolean> function)
Object input = "ABC"; int result = ObjectUtils.check(input, String.class, v -> v.length()).orElse(0); assertEquals(3, result);
Copyright 2019-2022, Pavel Ponec