Class ObjectUtil

java.lang.Object
org.seppiko.commons.utils.ObjectUtil

public class ObjectUtil extends Object
Object utility
Author:
Leonard Woo
See Also:
  • 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 is null. May be null.
      Returns:
      the value, if value not null, otherwise other.
    • optionalOf

      public static <T> Optional<T> optionalOf(T value)
      Get Optional with ignore value nullable.
      Type Parameters:
      T - the type of value.
      Parameters:
      value - the possibly-null value to describe.
      Returns:
      the Optional.
    • deepCopy

      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 is null.