java.lang.Object
org.seppiko.commons.utils.ObjectUtil
Object Util
-
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectCreates and returns a deep copy.static <T> Optional<T>optionalOf(T value) GetOptionalwith ignore value nullable.static <T> TrequireWithElse(T value, T other) Get value not null or else.
-
Method Details
-
requireWithElse
public static <T> T requireWithElse(T value, T other) Get value not null or else.Like this
Optional.ofNullable(value).orElse(defaultValue);- Type Parameters:
T- the type of value.- Parameters:
value- the possibly-null value to describe.other- the value to be returned, if value isnull. May benull.- Returns:
- the value, if value not
null, otherwise other.
-
optionalOf
GetOptionalwith ignore value nullable.- Type Parameters:
T- the type of value.- Parameters:
value- the possibly-null value to describe.- Returns:
- the
Optional.
-
deepCopy
public static Object deepCopy(Object obj) throws IOException, ReflectiveOperationException, SecurityException, NullPointerException Creates and returns a deep copy.- Parameters:
obj- an object.- Returns:
- a deep copy of the object.
- Throws:
IOException- if an I/O error occurs while writing stream header.ReflectiveOperationException- object cannot be found.SecurityException- if the stream header is incorrect.NullPointerException- object isnull.
-