Package panda.utilities
Class ObjectUtils
java.lang.Object
panda.utilities.ObjectUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanCheck if all values are nullstatic <T> TTry to cast or get nullstatic <T> Tstatic <T,C> boolean Compare only one value that belongs to class and determines equalitystatic <T> booleanequals(T object, Object to, BiPredicate<T, T> equals) Compare objects without boilerplate initial statements like (object == this) and (getClass() !static booleanequalsOneOf(Object value, Object... expected) Check if the value is one of the expectedstatic booleanCheck if object is not null
-
Method Details
-
cast
Try to cast or get null- Type Parameters:
T- the result type- Parameters:
object- the object to castclazz- the type to cast- Returns:
- casted object or null if object is not a clazz type
-
cast
-
isNotNull
Check if object is not null- Parameters:
object- object to check- Returns:
- true if object is not null
-
areNull
Check if all values are null- Parameters:
objects- array to check- Returns:
- true if all values are null and false for non null element/empty array
-
equalsOneOf
Check if the value is one of the expected- Parameters:
value- value to checkexpected- expected values- Returns:
- true if expected values contains the specified value
-
equals
Compare only one value that belongs to class and determines equality- Type Parameters:
T- type of current objectC- type of compared values- Parameters:
object- the current object (~ this)value- the value of current objectto- the object to compare withgetter- the getter to obtain value from compared object- Returns:
- true if compared objects are equal
-
equals
Compare objects without boilerplate initial statements like (object == this) and (getClass() != to.getClass())- Type Parameters:
T- type of objects to compare- Parameters:
object- the current object (this)to- the object to compare withequals- the predicate which determines equality- Returns:
- true if objects are the same type and fulfils the predicate
-