public abstract class ObjectUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <V> boolean |
check(@Nullable Object value,
@NotNull Class<V> requiredClass,
@NotNull 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(@Nullable Object value,
@NotNull Class<V> requiredClass,
@NotNull Function<V,R> function)
Run a function in case the value is an instance of the required class.
|
static @NotNull PrintWriter |
toPrintWriter(@NotNull Appendable appendable)
Convert appendable to object type of PrintWriter
|
public static final <V,R> Optional<R> iof(@Nullable @Nullable Object value, @NotNull @NotNull Class<V> requiredClass, @NotNull @NotNull 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
@Nullable Object value,
@NotNull
@NotNull Class<V> requiredClass,
@NotNull
@NotNull Function<V,Boolean> function)
Object input = "ABC"; int result = ObjectUtils.check(input, String.class, v -> v.length()).orElse(0); assertEquals(3, result);
@NotNull public static @NotNull PrintWriter toPrintWriter(@NotNull @NotNull Appendable appendable)
Copyright 2015, Pavel Ponec