public enum Primitive extends Enum<Primitive>
There are fields for the native class (e.g. int, also
known as Integer.TYPE) and the boxing class
(e.g. Integer).
| Modifier and Type | Class and Description |
|---|---|
static class |
Primitive.Flavor
Whether a type is primitive (e.g.
|
static interface |
Primitive.Sink
A place to send a value.
|
static interface |
Primitive.Source
A place from which to read a value.
|
| Enum Constant and Description |
|---|
BOOLEAN |
BYTE |
CHAR |
DOUBLE |
FLOAT |
INT |
LONG |
OTHER |
SHORT |
VOID |
| Modifier and Type | Field and Description |
|---|---|
@Nullable Class |
boxClass |
@Nullable String |
boxName |
@Nullable Object |
defaultValue
The default value of this primitive class.
|
@Nullable Object |
max
The maximum value of this primitive class.
|
@Nullable Object |
maxNegative
The largest value that is less than zero.
|
@Nullable Object |
min
The minimum value of this primitive class.
|
@Nullable Object |
minPositive
The smallest value that is greater than zero.
|
@Nullable Class |
primitiveClass |
@Nullable String |
primitiveName |
int |
size
The size of a value of this type, in bits.
|
| Modifier and Type | Method and Description |
|---|---|
@Nullable Object |
arrayItem(Object dataSet,
int ordinal)
Gets an item from an array.
|
void |
arrayItem(Object dataSet,
int ordinal,
Primitive.Sink sink)
Sends to a sink an from an array.
|
void |
arrayItem(Primitive.Source source,
Object dataSet,
int ordinal)
Reads value from a source into an array.
|
String |
arrayToString(Object array)
Converts an array to a string.
|
static List<Boolean> |
asList(boolean[] elements)
|
static List<Byte> |
asList(byte[] elements)
|
static List<Character> |
asList(char[] elements)
|
static List<Double> |
asList(double[] elements)
|
static List<Float> |
asList(float[] elements)
|
static List<Integer> |
asList(int[] elements)
|
static List<Long> |
asList(long[] elements)
|
static List<?> |
asList(Object array)
Adapts a primitive array into a
List. |
static List<Short> |
asList(short[] elements)
|
boolean |
assignableFrom(Primitive primitive) |
static Class |
box(Class type)
Converts a primitive class to a boxed class; returns other classes
unchanged.
|
static Type |
box(Type type)
Converts a primitive type to a boxed type; returns other types
unchanged.
|
static Primitive.Flavor |
flavor(Type type)
Returns whether this type is a primitive, box or other type.
|
Class<?> |
getBoxClass() |
String |
getBoxName() |
Class<?> |
getPrimitiveClass() |
String |
getPrimitiveName() |
static boolean |
is(Type type)
Returns whether a given type is primitive.
|
static boolean |
isBox(Type type)
Returns whether a given type is a box type (e.g.
|
boolean |
isFixedNumeric()
Returns whether this Primitive is a fixed-point numeric type.
|
boolean |
isNumeric()
Returns whether this Primitive is a numeric type.
|
void |
jdbc(ResultSet resultSet,
int i,
Primitive.Sink sink)
Sends to a sink a value from a given column in a JDBC result set.
|
@Nullable Object |
jdbcGet(ResultSet resultSet,
int i)
Gets a value from a given column in a JDBC result set.
|
Number |
number(Number value)
Creates a number value of this primitive's box type.
|
static @Nullable Primitive |
of(Type type)
Returns the Primitive object for a given primitive class.
|
static @Nullable Primitive |
ofBox(Type type)
Returns the Primitive object for a given boxing class.
|
static @Nullable Primitive |
ofBoxOr(Type type)
Returns the Primitive object for a given primitive or boxing class.
|
Object |
parse(String stringValue)
Calls the appropriate
valueOf(String)
method. |
Object |
permute(Object array,
int[] sources)
Permutes an array.
|
void |
send(Field field,
Object o,
Primitive.Sink sink)
Sends a field value to a sink.
|
void |
send(Primitive.Source source,
Primitive.Sink sink)
Sends a value from a source to a sink.
|
void |
sortArray(Object array)
Sorts an array of this primitive type.
|
void |
sortArray(Object array,
int fromIndex,
int toIndex)
Sorts a specified range of an array of this primitive type.
|
Object |
toArray(Collection collection)
Converts a collection of boxed primitives into an array of primitives.
|
Object |
toArray2(Collection<Number> collection)
Converts a collection of
Number to a primitive array. |
static Class |
unbox(Class type)
Converts a boxed class to a primitive class; returns other types
unchanged.
|
static Type |
unbox(Type type)
Converts a boxed type to a primitive type; returns other types
unchanged.
|
static Primitive |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static Primitive[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Primitive BOOLEAN
public static final Primitive BYTE
public static final Primitive CHAR
public static final Primitive SHORT
public static final Primitive INT
public static final Primitive LONG
public static final Primitive FLOAT
public static final Primitive DOUBLE
public static final Primitive VOID
public static final Primitive OTHER
public final @Nullable Class primitiveClass
public final @Nullable Class boxClass
public final @Nullable String primitiveName
public final @Nullable String boxName
public final @Nullable Object defaultValue
int, false for
boolean, etc.public final @Nullable Object min
public final @Nullable Object maxNegative
public final @Nullable Object minPositive
public final @Nullable Object max
public final int size
public static Primitive[] values()
for (Primitive c : Primitive.values()) System.out.println(c);
public static Primitive valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic static @Nullable Primitive of(Type type)
For example, of(long.class) returns LONG.
Returns null when applied to a boxing or other class; for example
of(Long.class) and of(String.class) return
null.
public static @Nullable Primitive ofBox(Type type)
For example, ofBox(java.util.Long.class)
returns LONG.
public static @Nullable Primitive ofBoxOr(Type type)
For example, ofBoxOr(Long.class) and
ofBoxOr(long.class) both return LONG.
public static boolean is(Type type)
public static boolean isBox(Type type)
Integer).public static Primitive.Flavor flavor(Type type)
public boolean isNumeric()
public boolean isFixedNumeric()
public static Type box(Type type)
public static Class box(Class type)
public static Type unbox(Type type)
public static Class unbox(Class type)
@API(since="1.27",
status=EXPERIMENTAL)
public Class<?> getPrimitiveClass()
@API(since="1.27",
status=EXPERIMENTAL)
public Class<?> getBoxClass()
@API(since="1.27",
status=EXPERIMENTAL)
public String getPrimitiveName()
@API(since="1.27",
status=EXPERIMENTAL)
public String getBoxName()
public Object toArray(Collection collection)
collection - Collection of boxed primitivesClassCastException - if any element is not of the box typeNullPointerException - if any element is nullpublic Object toArray2(Collection<Number> collection)
Number to a primitive array.public String arrayToString(Object array)
array - Array of this primitive typepublic void sortArray(Object array)
array - Array of this primitive typepublic void sortArray(Object array, int fromIndex, int toIndex)
array - Array of this primitive typefromIndex - the index of the first element, inclusive, to be sortedtoIndex - the index of the last element, exclusive, to be sortedpublic void send(Field field, Object o, Primitive.Sink sink) throws IllegalAccessException
IllegalAccessExceptionpublic @Nullable Object arrayItem(Object dataSet, int ordinal)
public void arrayItem(Primitive.Source source, Object dataSet, int ordinal)
public void arrayItem(Object dataSet, int ordinal, Primitive.Sink sink)
public @Nullable Object jdbcGet(ResultSet resultSet, int i) throws SQLException
resultSet - Result seti - Ordinal of column (1-based, per JDBC)SQLExceptionpublic void jdbc(ResultSet resultSet, int i, Primitive.Sink sink) throws SQLException
resultSet - Result seti - Ordinal of column (1-based, per JDBC)sink - SinkSQLExceptionpublic void send(Primitive.Source source, Primitive.Sink sink)
public Object parse(String stringValue)
valueOf(String)
method.public boolean assignableFrom(Primitive primitive)
Copyright © 2012-2021 Apache Software Foundation. All Rights Reserved.