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
What kind of type?
|
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 |
---|---|
Class |
boxClass |
Object |
defaultValue
The default value of this primitive class.
|
Object |
max
The maximum value of this primitive class.
|
Object |
min
The minimum value of this primitive class.
|
Class |
primitiveClass |
String |
primitiveName |
Modifier and Type | Method and Description |
---|---|
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.
|
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.
|
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 Primitive |
of(Type type)
Returns the Primitive object for a given primitive class.
|
static Primitive |
ofBox(Type type)
Returns the Primitive object for a given boxing class.
|
static 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 Class primitiveClass
public final Class boxClass
public final String primitiveName
public final Object defaultValue
int
, false for
boolean
, etc.public final Object min
public final Object max
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 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 Primitive ofBox(Type type)
For example, ofBox(java.util.Long.class)
returns LONG
.
public static 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)
public static List<?> asList(Object array)
List
. For example,
asList(new double[2])
returns a List<Double>
.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
IllegalAccessException
public void arrayItem(Primitive.Source source, Object dataSet, int ordinal)
public void arrayItem(Object dataSet, int ordinal, Primitive.Sink sink)
public Object jdbcGet(ResultSet resultSet, int i) throws SQLException
resultSet
- Result seti
- Ordinal of column (1-based, per JDBC)SQLException
public void jdbc(ResultSet resultSet, int i, Primitive.Sink sink) throws SQLException
resultSet
- Result seti
- Ordinal of column (1-based, per JDBC)sink
- SinkSQLException
public void send(Primitive.Source source, Primitive.Sink sink)
public Object parse(String stringValue)
valueOf(String)
method.public boolean assignableFrom(Primitive primitive)
Copyright © 2012-2014 Julian Hyde. All Rights Reserved.