Package de.eldoria.eldoutilities.utils
Class ObjUtil
java.lang.Object
de.eldoria.eldoutilities.utils.ObjUtil
General handling of objects.
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> boolean
Consumes a object if object is not nullstatic <T> boolean
Consumes a object if object is not null or executes a runnable when object is nullstatic <T,
U> U Execute a function on a object if the object is not nullstatic <T> T
nonNull
(T obj, T otherObject) get the object or the other object if object is nullstatic <R,
A> R nonNullOrElse
(A obj, Function<A, R> function, R defaultVal) Executes a function on object and return value or default value if object is null
-
Method Details
-
nonNull
Consumes a object if object is not null- Type Parameters:
T
- type of object- Parameters:
obj
- object to condumeexecute
- consumer to handle object- Returns:
- true if the object was not null and the consumer was applied
-
nonNull
Consumes a object if object is not null or executes a runnable when object is null- Type Parameters:
T
- type of object- Parameters:
obj
- object to condumeexecute
- consumer to handle objectrunnable
- runnable to run when object is null- Returns:
- true if the object was not null and the consumer was applied false if the object was null
-
nonNull
Execute a function on a object if the object is not null- Type Parameters:
T
- object typeU
- return type- Parameters:
obj
- object to checkexecute
- function to parse object to return type- Returns:
- object of return type U
-
nonNull
get the object or the other object if object is null- Type Parameters:
T
- type of object- Parameters:
obj
- object to checkotherObject
- other object- Returns:
- object or other object if object is null
-
nonNullOrElse
Executes a function on object and return value or default value if object is null- Type Parameters:
R
- type of output objectA
- type of input object- Parameters:
obj
- objectfunction
- function to parsedefaultVal
- default value- Returns:
- value of function or default value
-