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 @interfaceDeprecated.static class -
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Bytebox(byte value) static Characterbox(char value) static Doublebox(double value) static Floatbox(float value) static Integerbox(int value) static Longbox(long value) static Shortbox(short value) static Booleanstatic 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 booleanisBoxedArithmetic(@NotNull Class<?> c) Whether the class is a boxed arithmetic type (Long, Integer, Short, Byte)static booleanisBoxedBoolean(@NotNull Class<?> c) Whether the class is an instance of Boolean.class.static booleanisBoxedByte(@NotNull Class<?> c) Whether the class is an instance of Byte.class.static booleanisBoxedChar(@NotNull Class<?> c) Whether the class is an instance of Character.class.static booleanisBoxedDouble(@NotNull Class<?> c) Whether the class is an instance of Double.class.static booleanisBoxedFloat(@NotNull Class<?> c) Whether the class is an instance of Float.class.static booleanisBoxedInteger(@NotNull Class<?> c) Whether the class is an instance of Integer.class.static booleanisBoxedLong(@NotNull Class<?> c) Whether the class is an instance of Long.class.static booleanisBoxedShort(@NotNull Class<?> c) Whether the class is an instance of Short.class.static booleanisBoxedType(Class<?> exprType) static booleanisCharacter(@NotNull Class<?> c) Whether the class equals char.class or Character.class is assignable from it.static booleanisConvertibleToPrimitive(Class<?> type) static booleanisFloatType(Class<?> type) Checks if the type is a primitive or Boxed floate type (double or float).static booleanisPrimitiveChar(@NotNull Class<?> c) Whether the class is equal to char.class.static booleanWhether the class is aStringstatic StringnullConstantForType(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 booleanstatic bytestatic charstatic doublestatic floatstatic intstatic longstatic short
-
Field Details
-
PRIMITIVE_TYPES
-
BOXED_TYPES
-
primitiveClassNameToClass
-
-
Constructor Details
-
TypeUtils
public TypeUtils()
-
-
Method Details
-
getBoxedType
Returns a reference type corresponding to the giventype. Iftypeis itself a reference type, thentypeis returned. Iftypeis a primitive type, then the appropriate boxed type is returned.- Parameters:
type- The type
-
getUnboxedType
Returns the primitive type corresponding to the giventype. Iftypeis itself a primitive type, thentypeis returned. Iftypeis neither a primitive type nor a boxed type, thennullis 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
cequals 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
corcequals 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
-