Class ObjectUtil

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

public class ObjectUtil extends Object
Object Util
Author:
Leonard Woo
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Object
    Deep copy
    static <T> boolean
    isArray(T obj)
    test object is array
    static <T> boolean
    isEmpty(T[] array)
    test object array is empty
    static <T> boolean
    isNull(T obj)
    test object is null
    static <T> boolean
    isNull(T[] obj)
    test object array is null
    static <T> boolean
    notNull(T obj)
    test object is not null
    static <T> boolean
    notNull(T[] obj)
    test object array is not null
    static <T> T
    safeNull(T t, T defaultValue)
    return object with default

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ObjectUtil

      public ObjectUtil()
  • Method Details

    • safeNull

      public static <T> T safeNull(T t, T defaultValue)
      return object with default
      Type Parameters:
      T - object type
      Parameters:
      t - object
      defaultValue - default value
      Returns:
      object result, if t is null this is default value
    • isArray

      public static <T> boolean isArray(T obj)
      test object is array
      Type Parameters:
      T - object type
      Parameters:
      obj - object
      Returns:
      true is not null and it's array object
    • isEmpty

      public static <T> boolean isEmpty(T[] array)
      test object array is empty
      Type Parameters:
      T - object type
      Parameters:
      array - object array
      Returns:
      true is null or empty
    • isNull

      public static <T> boolean isNull(T obj)
      test object is null
      Type Parameters:
      T - object type
      Parameters:
      obj - object
      Returns:
      true is null
    • isNull

      public static <T> boolean isNull(T[] obj)
      test object array is null
      Type Parameters:
      T - object type
      Parameters:
      obj - object array
      Returns:
      true is null
    • notNull

      public static <T> boolean notNull(T obj)
      test object is not null
      Type Parameters:
      T - object type
      Parameters:
      obj - object
      Returns:
      true is not null
    • notNull

      public static <T> boolean notNull(T[] obj)
      test object array is not null
      Type Parameters:
      T - object type
      Parameters:
      obj - object array
      Returns:
      true is not null
    • deepCopy

      public static Object deepCopy(Object obj) throws IOException, ClassNotFoundException
      Deep copy
      Parameters:
      obj - source object
      Returns:
      copy object
      Throws:
      IOException - copy failed
      ClassNotFoundException - can not found new object