public final class Primitives
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Primitives.Booleans |
static class |
Primitives.Bytes |
static class |
Primitives.Chars |
static class |
Primitives.Doubles |
static class |
Primitives.Floats |
static class |
Primitives.Ints |
static class |
Primitives.Longs |
static class |
Primitives.Shorts |
Modifier and Type | Method and Description |
---|---|
static java.lang.Boolean[] |
box(boolean... a)
Converts an array of primitive booleans to objects.
|
static java.lang.Boolean[][] |
box(boolean[][] a) |
static java.lang.Boolean[][][] |
box(boolean[][][] a) |
static java.lang.Boolean[] |
box(boolean[] a,
int fromIndex,
int toIndex) |
static java.lang.Byte[] |
box(byte... a)
Converts an array of primitive bytes to objects.
|
static java.lang.Byte[][] |
box(byte[][] a) |
static java.lang.Byte[][][] |
box(byte[][][] a) |
static java.lang.Byte[] |
box(byte[] a,
int fromIndex,
int toIndex) |
static java.lang.Character[] |
box(char... a)
Converts an array of primitive chars to objects.
|
static java.lang.Character[][] |
box(char[][] a) |
static java.lang.Character[][][] |
box(char[][][] a) |
static java.lang.Character[] |
box(char[] a,
int fromIndex,
int toIndex) |
static java.lang.Double[] |
box(double... a)
Converts an array of primitive doubles to objects.
|
static java.lang.Double[][] |
box(double[][] a) |
static java.lang.Double[][][] |
box(double[][][] a) |
static java.lang.Double[] |
box(double[] a,
int fromIndex,
int toIndex) |
static java.lang.Float[] |
box(float... a)
Converts an array of primitive floats to objects.
|
static java.lang.Float[][] |
box(float[][] a) |
static java.lang.Float[][][] |
box(float[][][] a) |
static java.lang.Float[] |
box(float[] a,
int fromIndex,
int toIndex) |
static java.lang.Integer[] |
box(int... a)
Converts an array of primitive ints to objects.
|
static java.lang.Integer[][] |
box(int[][] a) |
static java.lang.Integer[][][] |
box(int[][][] a) |
static java.lang.Integer[] |
box(int[] a,
int fromIndex,
int toIndex) |
static java.lang.Long[] |
box(long... a)
Converts an array of primitive longs to objects.
|
static java.lang.Long[][] |
box(long[][] a) |
static java.lang.Long[][][] |
box(long[][][] a) |
static java.lang.Long[] |
box(long[] a,
int fromIndex,
int toIndex) |
static java.lang.Short[] |
box(short... a)
Converts an array of primitive shorts to objects.
|
static java.lang.Short[][] |
box(short[][] a) |
static java.lang.Short[][][] |
box(short[][][] a) |
static java.lang.Short[] |
box(short[] a,
int fromIndex,
int toIndex) |
static boolean |
isPrimitiveArrayType(java.lang.Class<?> cls) |
static boolean |
isPrimitiveType(java.lang.Class<?> cls) |
static boolean |
isWrapperType(java.lang.Class<?> cls) |
static boolean[] |
unbox(java.lang.Boolean... a)
Converts an array of object Booleans to primitives.
|
static boolean[][] |
unbox(java.lang.Boolean[][] a) |
static boolean[][][] |
unbox(java.lang.Boolean[][][] a) |
static boolean[][][] |
unbox(java.lang.Boolean[][][] a,
boolean valueForNull) |
static boolean[][] |
unbox(java.lang.Boolean[][] a,
boolean valueForNull) |
static boolean[] |
unbox(java.lang.Boolean[] a,
boolean valueForNull)
Converts an array of object Booleans to primitives handling
null . |
static boolean[] |
unbox(java.lang.Boolean[] a,
int fromIndex,
int toIndex,
boolean valueForNull) |
static byte[] |
unbox(java.lang.Byte... a)
Converts an array of object Bytes to primitives.
|
static byte[][] |
unbox(java.lang.Byte[][] a) |
static byte[][][] |
unbox(java.lang.Byte[][][] a) |
static byte[][][] |
unbox(java.lang.Byte[][][] a,
byte valueForNull) |
static byte[][] |
unbox(java.lang.Byte[][] a,
byte valueForNull) |
static byte[] |
unbox(java.lang.Byte[] a,
byte valueForNull)
Converts an array of object Bytes to primitives handling
null . |
static byte[] |
unbox(java.lang.Byte[] a,
int fromIndex,
int toIndex,
byte valueForNull) |
static char[] |
unbox(java.lang.Character... a)
Converts an array of object Characters to primitives.
|
static char[][] |
unbox(java.lang.Character[][] a) |
static char[][][] |
unbox(java.lang.Character[][][] a) |
static char[][][] |
unbox(java.lang.Character[][][] a,
char valueForNull) |
static char[][] |
unbox(java.lang.Character[][] a,
char valueForNull) |
static char[] |
unbox(java.lang.Character[] a,
char valueForNull)
Converts an array of object Character to primitives handling
null
. |
static char[] |
unbox(java.lang.Character[] a,
int fromIndex,
int toIndex,
char valueForNull) |
static double[] |
unbox(java.lang.Double... a)
Converts an array of object Doubles to primitives.
|
static double[][] |
unbox(java.lang.Double[][] a) |
static double[][][] |
unbox(java.lang.Double[][][] a) |
static double[][][] |
unbox(java.lang.Double[][][] a,
double valueForNull) |
static double[][] |
unbox(java.lang.Double[][] a,
double valueForNull) |
static double[] |
unbox(java.lang.Double[] a,
double valueForNull)
Converts an array of object Doubles to primitives handling
null . |
static double[] |
unbox(java.lang.Double[] a,
int fromIndex,
int toIndex,
double valueForNull) |
static float[] |
unbox(java.lang.Float... a)
Converts an array of object Floats to primitives.
|
static float[][] |
unbox(java.lang.Float[][] a) |
static float[][][] |
unbox(java.lang.Float[][][] a) |
static float[][][] |
unbox(java.lang.Float[][][] a,
float valueForNull) |
static float[][] |
unbox(java.lang.Float[][] a,
float valueForNull) |
static float[] |
unbox(java.lang.Float[] a,
float valueForNull)
Converts an array of object Floats to primitives handling
null . |
static float[] |
unbox(java.lang.Float[] a,
int fromIndex,
int toIndex,
float valueForNull) |
static int[] |
unbox(java.lang.Integer... a)
Converts an array of object Integers to primitives.
|
static int[][] |
unbox(java.lang.Integer[][] a) |
static int[][][] |
unbox(java.lang.Integer[][][] a) |
static int[][][] |
unbox(java.lang.Integer[][][] a,
int valueForNull) |
static int[][] |
unbox(java.lang.Integer[][] a,
int valueForNull) |
static int[] |
unbox(java.lang.Integer[] a,
int valueForNull)
Converts an array of object Integer to primitives handling
null . |
static int[] |
unbox(java.lang.Integer[] a,
int fromIndex,
int toIndex,
int valueForNull) |
static long[] |
unbox(java.lang.Long... a)
Converts an array of object Longs to primitives.
|
static long[][] |
unbox(java.lang.Long[][] a) |
static long[][][] |
unbox(java.lang.Long[][][] a) |
static long[][][] |
unbox(java.lang.Long[][][] a,
long valueForNull) |
static long[][] |
unbox(java.lang.Long[][] a,
long valueForNull) |
static long[] |
unbox(java.lang.Long[] a,
int fromIndex,
int toIndex,
long valueForNull) |
static long[] |
unbox(java.lang.Long[] a,
long valueForNull)
Converts an array of object Long to primitives handling
null . |
static short[] |
unbox(java.lang.Short... a)
Converts an array of object Shorts to primitives.
|
static short[][] |
unbox(java.lang.Short[][] a) |
static short[][][] |
unbox(java.lang.Short[][][] a) |
static short[][][] |
unbox(java.lang.Short[][][] a,
short valueForNull) |
static short[][] |
unbox(java.lang.Short[][] a,
short valueForNull) |
static short[] |
unbox(java.lang.Short[] a,
int fromIndex,
int toIndex,
short valueForNull) |
static short[] |
unbox(java.lang.Short[] a,
short valueForNull)
Converts an array of object Short to primitives handling
null . |
static boolean |
unboxOrDefault(java.lang.Boolean b) |
static boolean |
unboxOrDefault(java.lang.Boolean b,
boolean defaultForNull) |
static byte |
unboxOrDefault(java.lang.Byte b) |
static byte |
unboxOrDefault(java.lang.Byte b,
byte defaultForNull) |
static char |
unboxOrDefault(java.lang.Character c) |
static char |
unboxOrDefault(java.lang.Character c,
char defaultForNull) |
static double |
unboxOrDefault(java.lang.Double b) |
static double |
unboxOrDefault(java.lang.Double b,
double defaultForNull) |
static float |
unboxOrDefault(java.lang.Float b) |
static float |
unboxOrDefault(java.lang.Float b,
float defaultForNull) |
static int |
unboxOrDefault(java.lang.Integer b) |
static int |
unboxOrDefault(java.lang.Integer b,
int defaultForNull) |
static long |
unboxOrDefault(java.lang.Long b) |
static long |
unboxOrDefault(java.lang.Long b,
long defaultForNull) |
static short |
unboxOrDefault(java.lang.Short b) |
static short |
unboxOrDefault(java.lang.Short b,
short defaultForNull) |
static boolean |
unboxOrGet(java.lang.Boolean b,
BooleanSupplier supplierForNull) |
static byte |
unboxOrGet(java.lang.Byte b,
ByteSupplier supplierForNull) |
static char |
unboxOrGet(java.lang.Character b,
CharSupplier supplierForNull) |
static double |
unboxOrGet(java.lang.Double b,
DoubleSupplier supplierForNull) |
static float |
unboxOrGet(java.lang.Float b,
FloatSupplier supplierForNull) |
static int |
unboxOrGet(java.lang.Integer b,
IntSupplier supplierForNull) |
static long |
unboxOrGet(java.lang.Long b,
LongSupplier supplierForNull) |
static short |
unboxOrGet(java.lang.Short b,
ShortSupplier supplierForNull) |
static java.lang.Class<?> |
unwrap(java.lang.Class<?> cls)
Returns the corresponding primitive type of
type if it is a wrapper type; otherwise
returns type itself. |
static java.lang.Class<?> |
wrap(java.lang.Class<?> cls)
Returns the corresponding wrapper type of
type if it is a primitive type; otherwise
returns type itself. |
public static boolean isPrimitiveType(java.lang.Class<?> cls)
public static boolean isWrapperType(java.lang.Class<?> cls)
public static boolean isPrimitiveArrayType(java.lang.Class<?> cls)
public static java.lang.Class<?> wrap(java.lang.Class<?> cls)
type
if it is a primitive type; otherwise
returns type
itself. Idempotent.
wrap(int.class) == Integer.class wrap(Integer.class) == Integer.class wrap(String.class) == String.class
public static java.lang.Class<?> unwrap(java.lang.Class<?> cls)
type
if it is a wrapper type; otherwise
returns type
itself. Idempotent.
unwrap(Integer.class) == int.class unwrap(int.class) == int.class unwrap(String.class) == String.class
@SafeVarargs public static java.lang.Boolean[] box(boolean... a)
Converts an array of primitive booleans to objects.
This method returns null
for a null
input array.
a
- a boolean
arrayBoolean
array, null
if null array inputpublic static java.lang.Boolean[] box(boolean[] a, int fromIndex, int toIndex)
@SafeVarargs public static java.lang.Character[] box(char... a)
Converts an array of primitive chars to objects.
This method returns null
for a null
input array.
a
- a char
arrayCharacter
array, null
if null array inputpublic static java.lang.Character[] box(char[] a, int fromIndex, int toIndex)
@SafeVarargs public static java.lang.Byte[] box(byte... a)
Converts an array of primitive bytes to objects.
This method returns null
for a null
input array.
a
- a byte
arrayByte
array, null
if null array inputpublic static java.lang.Byte[] box(byte[] a, int fromIndex, int toIndex)
@SafeVarargs public static java.lang.Short[] box(short... a)
Converts an array of primitive shorts to objects.
This method returns null
for a null
input array.
a
- a short
arrayShort
array, null
if null array inputpublic static java.lang.Short[] box(short[] a, int fromIndex, int toIndex)
@SafeVarargs public static java.lang.Integer[] box(int... a)
Converts an array of primitive ints to objects.
This method returns null
for a null
input array.
a
- an int
arrayInteger
array, null
if null array inputpublic static java.lang.Integer[] box(int[] a, int fromIndex, int toIndex)
@SafeVarargs public static java.lang.Long[] box(long... a)
Converts an array of primitive longs to objects.
This method returns null
for a null
input array.
a
- a long
arrayLong
array, null
if null array inputpublic static java.lang.Long[] box(long[] a, int fromIndex, int toIndex)
@SafeVarargs public static java.lang.Float[] box(float... a)
Converts an array of primitive floats to objects.
This method returns null
for a null
input array.
a
- a float
arrayFloat
array, null
if null array inputpublic static java.lang.Float[] box(float[] a, int fromIndex, int toIndex)
@SafeVarargs public static java.lang.Double[] box(double... a)
Converts an array of primitive doubles to objects.
This method returns null
for a null
input array.
a
- a double
arrayDouble
array, null
if null array inputpublic static java.lang.Double[] box(double[] a, int fromIndex, int toIndex)
public static java.lang.Boolean[][] box(boolean[][] a)
public static java.lang.Character[][] box(char[][] a)
public static java.lang.Byte[][] box(byte[][] a)
public static java.lang.Short[][] box(short[][] a)
public static java.lang.Integer[][] box(int[][] a)
public static java.lang.Long[][] box(long[][] a)
public static java.lang.Float[][] box(float[][] a)
public static java.lang.Double[][] box(double[][] a)
public static java.lang.Boolean[][][] box(boolean[][][] a)
public static java.lang.Character[][][] box(char[][][] a)
public static java.lang.Byte[][][] box(byte[][][] a)
public static java.lang.Short[][][] box(short[][][] a)
public static java.lang.Integer[][][] box(int[][][] a)
public static java.lang.Long[][][] box(long[][][] a)
public static java.lang.Float[][][] box(float[][][] a)
public static java.lang.Double[][][] box(double[][][] a)
@SafeVarargs public static boolean[] unbox(java.lang.Boolean... a)
Converts an array of object Booleans to primitives.
This method returns null
for a null
input array.
a
- a Boolean
array, may be null
boolean
array, null
if null array inputpublic static boolean[] unbox(java.lang.Boolean[] a, boolean valueForNull)
Converts an array of object Booleans to primitives handling null
.
This method returns null
for a null
input array.
a
- a Boolean
array, may be null
valueForNull
- the value to insert if null
foundboolean
array, null
if null array inputpublic static boolean[] unbox(java.lang.Boolean[] a, int fromIndex, int toIndex, boolean valueForNull)
@SafeVarargs public static char[] unbox(java.lang.Character... a)
Converts an array of object Characters to primitives.
This method returns null
for a null
input array.
a
- a Character
array, may be null
char
array, null
if null array inputpublic static char[] unbox(java.lang.Character[] a, char valueForNull)
Converts an array of object Character to primitives handling null
.
This method returns null
for a null
input array.
a
- a Character
array, may be null
valueForNull
- the value to insert if null
foundchar
array, null
if null array inputpublic static char[] unbox(java.lang.Character[] a, int fromIndex, int toIndex, char valueForNull)
@SafeVarargs public static byte[] unbox(java.lang.Byte... a)
Converts an array of object Bytes to primitives.
This method returns null
for a null
input array.
a
- a Byte
array, may be null
byte
array, null
if null array inputpublic static byte[] unbox(java.lang.Byte[] a, byte valueForNull)
Converts an array of object Bytes to primitives handling null
.
This method returns null
for a null
input array.
a
- a Byte
array, may be null
valueForNull
- the value to insert if null
foundbyte
array, null
if null array inputpublic static byte[] unbox(java.lang.Byte[] a, int fromIndex, int toIndex, byte valueForNull)
@SafeVarargs public static short[] unbox(java.lang.Short... a)
Converts an array of object Shorts to primitives.
This method returns null
for a null
input array.
a
- a Short
array, may be null
byte
array, null
if null array inputpublic static short[] unbox(java.lang.Short[] a, short valueForNull)
Converts an array of object Short to primitives handling null
.
This method returns null
for a null
input array.
a
- a Short
array, may be null
valueForNull
- the value to insert if null
foundbyte
array, null
if null array inputpublic static short[] unbox(java.lang.Short[] a, int fromIndex, int toIndex, short valueForNull)
@SafeVarargs public static int[] unbox(java.lang.Integer... a)
Converts an array of object Integers to primitives.
This method returns null
for a null
input array.
a
- a Integer
array, may be null
int
array, null
if null array inputpublic static int[] unbox(java.lang.Integer[] a, int valueForNull)
Converts an array of object Integer to primitives handling null
.
This method returns null
for a null
input array.
a
- a Integer
array, may be null
valueForNull
- the value to insert if null
foundint
array, null
if null array inputpublic static int[] unbox(java.lang.Integer[] a, int fromIndex, int toIndex, int valueForNull)
@SafeVarargs public static long[] unbox(java.lang.Long... a)
Converts an array of object Longs to primitives.
This method returns null
for a null
input array.
a
- a Long
array, may be null
long
array, null
if null array inputpublic static long[] unbox(java.lang.Long[] a, long valueForNull)
Converts an array of object Long to primitives handling null
.
This method returns null
for a null
input array.
a
- a Long
array, may be null
valueForNull
- the value to insert if null
foundlong
array, null
if null array inputpublic static long[] unbox(java.lang.Long[] a, int fromIndex, int toIndex, long valueForNull)
@SafeVarargs public static float[] unbox(java.lang.Float... a)
Converts an array of object Floats to primitives.
This method returns null
for a null
input array.
a
- a Float
array, may be null
float
array, null
if null array inputpublic static float[] unbox(java.lang.Float[] a, float valueForNull)
Converts an array of object Floats to primitives handling null
.
This method returns null
for a null
input array.
a
- a Float
array, may be null
valueForNull
- the value to insert if null
foundfloat
array, null
if null array inputpublic static float[] unbox(java.lang.Float[] a, int fromIndex, int toIndex, float valueForNull)
@SafeVarargs public static double[] unbox(java.lang.Double... a)
Converts an array of object Doubles to primitives.
This method returns null
for a null
input array.
a
- a Double
array, may be null
double
array, null
if null array inputpublic static double[] unbox(java.lang.Double[] a, double valueForNull)
Converts an array of object Doubles to primitives handling null
.
This method returns null
for a null
input array.
a
- a Double
array, may be null
valueForNull
- the value to insert if null
founddouble
array, null
if null array inputpublic static double[] unbox(java.lang.Double[] a, int fromIndex, int toIndex, double valueForNull)
public static boolean[][] unbox(java.lang.Boolean[][] a)
public static boolean[][] unbox(java.lang.Boolean[][] a, boolean valueForNull)
public static char[][] unbox(java.lang.Character[][] a)
public static char[][] unbox(java.lang.Character[][] a, char valueForNull)
public static byte[][] unbox(java.lang.Byte[][] a)
public static byte[][] unbox(java.lang.Byte[][] a, byte valueForNull)
public static short[][] unbox(java.lang.Short[][] a)
public static short[][] unbox(java.lang.Short[][] a, short valueForNull)
public static int[][] unbox(java.lang.Integer[][] a)
public static int[][] unbox(java.lang.Integer[][] a, int valueForNull)
public static long[][] unbox(java.lang.Long[][] a)
public static long[][] unbox(java.lang.Long[][] a, long valueForNull)
public static float[][] unbox(java.lang.Float[][] a)
public static float[][] unbox(java.lang.Float[][] a, float valueForNull)
public static double[][] unbox(java.lang.Double[][] a)
public static double[][] unbox(java.lang.Double[][] a, double valueForNull)
public static boolean[][][] unbox(java.lang.Boolean[][][] a)
public static boolean[][][] unbox(java.lang.Boolean[][][] a, boolean valueForNull)
public static char[][][] unbox(java.lang.Character[][][] a)
public static char[][][] unbox(java.lang.Character[][][] a, char valueForNull)
public static byte[][][] unbox(java.lang.Byte[][][] a)
public static byte[][][] unbox(java.lang.Byte[][][] a, byte valueForNull)
public static short[][][] unbox(java.lang.Short[][][] a)
public static short[][][] unbox(java.lang.Short[][][] a, short valueForNull)
public static int[][][] unbox(java.lang.Integer[][][] a)
public static int[][][] unbox(java.lang.Integer[][][] a, int valueForNull)
public static long[][][] unbox(java.lang.Long[][][] a)
public static long[][][] unbox(java.lang.Long[][][] a, long valueForNull)
public static float[][][] unbox(java.lang.Float[][][] a)
public static float[][][] unbox(java.lang.Float[][][] a, float valueForNull)
public static double[][][] unbox(java.lang.Double[][][] a)
public static double[][][] unbox(java.lang.Double[][][] a, double valueForNull)
public static boolean unboxOrDefault(java.lang.Boolean b)
public static boolean unboxOrDefault(java.lang.Boolean b, boolean defaultForNull)
public static char unboxOrDefault(java.lang.Character c)
public static char unboxOrDefault(java.lang.Character c, char defaultForNull)
public static byte unboxOrDefault(java.lang.Byte b)
public static byte unboxOrDefault(java.lang.Byte b, byte defaultForNull)
public static short unboxOrDefault(java.lang.Short b)
public static short unboxOrDefault(java.lang.Short b, short defaultForNull)
public static int unboxOrDefault(java.lang.Integer b)
public static int unboxOrDefault(java.lang.Integer b, int defaultForNull)
public static long unboxOrDefault(java.lang.Long b)
public static long unboxOrDefault(java.lang.Long b, long defaultForNull)
public static float unboxOrDefault(java.lang.Float b)
public static float unboxOrDefault(java.lang.Float b, float defaultForNull)
public static double unboxOrDefault(java.lang.Double b)
public static double unboxOrDefault(java.lang.Double b, double defaultForNull)
public static boolean unboxOrGet(java.lang.Boolean b, BooleanSupplier supplierForNull)
public static char unboxOrGet(java.lang.Character b, CharSupplier supplierForNull)
public static byte unboxOrGet(java.lang.Byte b, ByteSupplier supplierForNull)
public static short unboxOrGet(java.lang.Short b, ShortSupplier supplierForNull)
public static int unboxOrGet(java.lang.Integer b, IntSupplier supplierForNull)
public static long unboxOrGet(java.lang.Long b, LongSupplier supplierForNull)
public static float unboxOrGet(java.lang.Float b, FloatSupplier supplierForNull)
public static double unboxOrGet(java.lang.Double b, DoubleSupplier supplierForNull)