Package org.pepsoft.util
Class ObjectUtils
java.lang.Object
org.pepsoft.util.ObjectUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[][]clone(byte[][] array) static double[][]clone(double[][] array) static float[][]clone(float[][] array) static int[][]clone(int[][] array) static short[][]clone(short[][] array) static DataBufferclone(DataBuffer dataBuffer) static DataBufferByteclone(DataBufferByte dataBuffer) static DataBufferDoubleclone(DataBufferDouble dataBuffer) static DataBufferFloatclone(DataBufferFloat dataBuffer) static DataBufferIntclone(DataBufferInt dataBuffer) static DataBufferShortclone(DataBufferShort dataBuffer) static DataBufferUShortclone(DataBufferUShort dataBuffer) static <T> TAnalog of the SQL COALESCE function: returns the first non-null value.static <T> TcopyObject(T object) Make a deep copy of an 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 treatsPointas 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
-
clone
-
clone
-
clone
-
clone
-
clone
-
clone
-
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 bySuppliers, 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. IffirstValueis null then at least one of these MUST return a nonnullvalue, or aNullPointerExceptionwill be thrown.- Returns:
- The first non
nullvalue. - Throws:
NullPointerException- IffirstValueisnulland allsubsequentValueSuppliersreturnnull.
-