public final class ObjectUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
areNull(Object... objects)
Check if all values are null
|
static <T> T |
cast(Class<T> clazz,
@Nullable Object object)
Try to cast or get null
|
static <T> T |
cast(Object object) |
static <T,C> boolean |
equals(T object,
C value,
Object to,
Function<T,C> getter)
Compare only one value that belongs to class and determines equality
|
static <T> boolean |
equals(T object,
Object to,
BiPredicate<T,T> equals)
Compare objects without boilerplate initial statements like (object == this) & (getClass() !
|
static boolean |
equalsOneOf(Object value,
Object... expected)
Check if the value is one of the expected
|
static boolean |
isNotNull(@Nullable Object object)
Check if object is not null
|
@Nullable public static <T> T cast(Class<T> clazz, @Nullable @Nullable Object object)
T - the result typeobject - the object to castclazz - the type to cast@Nullable public static <T> T cast(Object object)
public static boolean isNotNull(@Nullable
@Nullable Object object)
object - object to checkpublic static boolean areNull(Object... objects)
objects - array to checkpublic static boolean equalsOneOf(Object value, Object... expected)
value - value to checkexpected - expected valuespublic static <T,C> boolean equals(T object,
C value,
Object to,
Function<T,C> getter)
T - type of current objectC - type of compared valuesobject - the current object (~ this)value - the value of current objectto - the object to compare withgetter - the getter to obtain value from compared objectpublic static <T> boolean equals(T object,
Object to,
BiPredicate<T,T> equals)
T - type of objects to compareobject - the current object (this)to - the object to compare withequals - the predicate which determines equalityCopyright © 2020. All rights reserved.