Class ObjectUtils

java.lang.Object
org.pepsoft.util.ObjectUtils

public final class ObjectUtils extends Object
  • Method Details

    • copyObject

      public static <T> T copyObject(T object)
      Make a deep copy of an object. Only a restricted set of types is supported.

      Note that this method also treats Point as immutable, even though technically it is not!

      Type Parameters:
      T - The type of the object.
      Parameters:
      object - The object to copy.
      Returns:
      A deep copy of the object.
      Throws:
      OutOfMemoryError - If there is not enough memory to copy the object.
    • clone

      public static DataBuffer clone(DataBuffer dataBuffer)
    • clone

      public static DataBufferByte clone(DataBufferByte dataBuffer)
    • clone

      public static DataBufferDouble clone(DataBufferDouble dataBuffer)
    • clone

      public static DataBufferFloat clone(DataBufferFloat dataBuffer)
    • clone

      public static DataBufferInt clone(DataBufferInt dataBuffer)
    • clone

      public static DataBufferShort clone(DataBufferShort dataBuffer)
    • clone

      public static DataBufferUShort clone(DataBufferUShort dataBuffer)
    • clone

      public static byte[][] clone(byte[][] array)
    • clone

      public static double[][] clone(double[][] array)
    • clone

      public static float[][] clone(float[][] array)
    • clone

      public static int[][] clone(int[][] array)
    • clone

      public static short[][] clone(short[][] array)
    • coalesce

      @SafeVarargs @NotNull public static <T> T coalesce(T firstValue, Supplier<T>... subsequentValueSuppliers)
      Analog of the SQL COALESCE function: returns the first non-null value. An additional property is that all but the first value are supplied by Suppliers, so that the value need not actually be created if it is not needed.
      Type Parameters:
      T - The type of the value.
      Parameters:
      firstValue - The first value.
      subsequentValueSuppliers - One or more suppliers of subsequent values. If firstValue is null then at least one of these MUST return a non null value, or a NullPointerException will be thrown.
      Returns:
      The first non null value.
      Throws:
      NullPointerException - If firstValue is null and all subsequentValueSuppliers return null.