Package io.deephaven.util.type
Class TypeUtils
java.lang.Object
io.deephaven.util.type.TypeUtils
Utility functions to convert primitive types.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interface
Deprecated.static class
-
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Byte
box
(byte value) static Character
box
(char value) static Double
box
(double value) static Float
box
(float value) static Integer
box
(int value) static Long
box
(long value) static Short
box
(short value) static Boolean
static Class<?>
getBoxedType
(Class<?> type) Returns a reference type corresponding to the giventype
.static <T> TypeUtils.TypeBoxer<T>
getTypeBoxer
(Class<T> type) static Class<?>
getUnboxedType
(Class<?> type) Returns the primitive type corresponding to the giventype
.static Class<?>
getUnboxedTypeIfBoxed
(@NotNull Class<?> type) Same asgetUnboxedType(Class)
, but returns non-wrapper classes unmolested.static boolean
isBoxedArithmetic
(@NotNull Class<?> c) Whether the class is a boxed arithmetic type (Long, Integer, Short, Byte)static boolean
isBoxedBoolean
(@NotNull Class<?> c) Whether the class is an instance of Boolean.class.static boolean
isBoxedByte
(@NotNull Class<?> c) Whether the class is an instance of Byte.class.static boolean
isBoxedChar
(@NotNull Class<?> c) Whether the class is an instance of Character.class.static boolean
isBoxedDouble
(@NotNull Class<?> c) Whether the class is an instance of Double.class.static boolean
isBoxedFloat
(@NotNull Class<?> c) Whether the class is an instance of Float.class.static boolean
isBoxedInteger
(@NotNull Class<?> c) Whether the class is an instance of Integer.class.static boolean
isBoxedLong
(@NotNull Class<?> c) Whether the class is an instance of Long.class.static boolean
isBoxedShort
(@NotNull Class<?> c) Whether the class is an instance of Short.class.static boolean
isBoxedType
(Class<?> exprType) static boolean
isCharacter
(@NotNull Class<?> c) Whether the class equals char.class or Character.class is assignable from it.static boolean
isConvertibleToPrimitive
(Class<?> type) static boolean
isFloatType
(Class<?> type) Checks if the type is a primitive or Boxed floate type (double or float).static boolean
isPrimitiveChar
(@NotNull Class<?> c) Whether the class is equal to char.class.static boolean
Whether the class is aString
static String
nullConstantForType
(Class<?> type) static byte[]
toByteArray
(double[] array) static byte[]
toByteArray
(float[] array) static byte[]
toByteArray
(int[] array) static byte[]
toByteArray
(long[] array) static byte[]
toByteArray
(short[] array) static double[]
toDoubleArray
(double[] array) static double[]
toDoubleArray
(float[] array) static double[]
toDoubleArray
(int[] array) static double[]
toDoubleArray
(long[] array) static double[]
toDoubleArray
(short[] array) static float[]
toFloatArray
(byte[] array) static float[]
toFloatArray
(double[] array) static float[]
toFloatArray
(int[] array) static float[]
toFloatArray
(long[] array) static float[]
toFloatArray
(short[] array) static int[]
toIntArray
(byte[] array) static int[]
toIntArray
(double[] array) static int[]
toIntArray
(float[] array) static int[]
toIntArray
(long[] array) static int[]
toIntArray
(short[] array) static long[]
toLongArray
(byte[] array) static long[]
toLongArray
(double[] array) static long[]
toLongArray
(float[] array) static long[]
toLongArray
(int[] array) static long[]
toLongArray
(short[] array) static short[]
toShortArray
(byte[] array) static short[]
toShortArray
(double[] array) static short[]
toShortArray
(float[] array) static short[]
toShortArray
(int[] array) static short[]
toShortArray
(long[] array) static boolean
static byte
static char
static double
static float
static int
static long
static short
-
Field Details
-
PRIMITIVE_TYPES
-
BOXED_TYPES
-
primitiveClassNameToClass
-
-
Constructor Details
-
TypeUtils
public TypeUtils()
-
-
Method Details
-
getBoxedType
Returns a reference type corresponding to the giventype
. Iftype
is itself a reference type, thentype
is returned. Iftype
is a primitive type, then the appropriate boxed type is returned.- Parameters:
type
- The type
-
getUnboxedType
Returns the primitive type corresponding to the giventype
. Iftype
is itself a primitive type, thentype
is returned. Iftype
is neither a primitive type nor a boxed type, thennull
is returned.- Parameters:
type
- The type- Returns:
- type's primitive equivalent, or null
-
getUnboxedTypeIfBoxed
Same asgetUnboxedType(Class)
, but returns non-wrapper classes unmolested.- Parameters:
type
- The type- Returns:
- type's unboxed equivalent, or type
-
toByteArray
public static byte[] toByteArray(float[] array) -
toByteArray
public static byte[] toByteArray(int[] array) -
toByteArray
public static byte[] toByteArray(short[] array) -
toByteArray
public static byte[] toByteArray(long[] array) -
toByteArray
public static byte[] toByteArray(double[] array) -
toFloatArray
public static float[] toFloatArray(byte[] array) -
toFloatArray
public static float[] toFloatArray(int[] array) -
toFloatArray
public static float[] toFloatArray(short[] array) -
toFloatArray
public static float[] toFloatArray(long[] array) -
toFloatArray
public static float[] toFloatArray(double[] array) -
toShortArray
public static short[] toShortArray(float[] array) -
toShortArray
public static short[] toShortArray(int[] array) -
toShortArray
public static short[] toShortArray(byte[] array) -
toShortArray
public static short[] toShortArray(long[] array) -
toShortArray
public static short[] toShortArray(double[] array) -
toLongArray
public static long[] toLongArray(float[] array) -
toLongArray
public static long[] toLongArray(int[] array) -
toLongArray
public static long[] toLongArray(short[] array) -
toLongArray
public static long[] toLongArray(byte[] array) -
toLongArray
public static long[] toLongArray(double[] array) -
toIntArray
public static int[] toIntArray(float[] array) -
toIntArray
public static int[] toIntArray(byte[] array) -
toIntArray
public static int[] toIntArray(short[] array) -
toIntArray
public static int[] toIntArray(long[] array) -
toIntArray
public static int[] toIntArray(double[] array) -
toDoubleArray
public static double[] toDoubleArray(float[] array) -
toDoubleArray
public static double[] toDoubleArray(int[] array) -
toDoubleArray
public static double[] toDoubleArray(short[] array) -
toDoubleArray
public static double[] toDoubleArray(long[] array) -
toDoubleArray
public static double[] toDoubleArray(double[] array) -
isConvertibleToPrimitive
-
isBoxedType
-
nullConstantForType
-
isPrimitiveChar
Whether the class is equal to char.class.- Parameters:
c
- class- Returns:
- true if
c
equals char.class, false otherwise
-
isBoxedChar
Whether the class is an instance of Character.class.- Parameters:
c
- class- Returns:
- true if Character.class is assignable from
c
, false otherwise
-
isBoxedInteger
Whether the class is an instance of Integer.class.- Parameters:
c
- class- Returns:
- true if Integer.class is assignable from
c
, false otherwise
-
isBoxedLong
Whether the class is an instance of Long.class.- Parameters:
c
- class- Returns:
- true if Long.class is assignable from
c
, false otherwise
-
isBoxedShort
Whether the class is an instance of Short.class.- Parameters:
c
- class- Returns:
- true if Short.class is assignable from
c
, false otherwise
-
isBoxedFloat
Whether the class is an instance of Float.class.- Parameters:
c
- class- Returns:
- true if Float.class is assignable from
c
, false otherwise
-
isBoxedDouble
Whether the class is an instance of Double.class.- Parameters:
c
- class- Returns:
- true if Double.class is assignable from
c
, false otherwise
-
isBoxedByte
Whether the class is an instance of Byte.class.- Parameters:
c
- class- Returns:
- true if Byte.class is assignable from
c
, false otherwise
-
isBoxedArithmetic
Whether the class is a boxed arithmetic type (Long, Integer, Short, Byte)- Parameters:
c
- class- Returns:
- true if the class is a boxed arithmetic type, false otherwise
-
isBoxedBoolean
Whether the class is an instance of Boolean.class.- Parameters:
c
- class- Returns:
- true if Boolean.class is assignable from
c
, false otherwise
-
isCharacter
Whether the class equals char.class or Character.class is assignable from it.- Parameters:
c
- class- Returns:
- true if Character.class is assignable from
c
orc
equals char.class
-
isString
Whether the class is aString
- Parameters:
type
- the class- Returns:
- true if the type is a String, false otherwise
-
isFloatType
Checks if the type is a primitive or Boxed floate type (double or float).- Parameters:
type
- the class- Returns:
- true if it is a float type, false otherwise
-
getTypeBoxer
-
box
-
box
-
box
-
box
-
box
-
box
-
box
-
box
-
unbox
-
unbox
-
unbox
-
unbox
-
unbox
-
unbox
-
unbox
-
unbox
-