public enum WrapperType extends Enum<WrapperType>
| Enum Constant and Description |
|---|
BOOLEAN |
BYTE |
CHAR |
DOUBLE |
FLOAT |
INT |
LONG |
OBJECT |
SHORT |
VOID |
| Modifier and Type | Method and Description |
|---|---|
int |
bitWidth()
How many bits are in the wrapped value? Returns 0 for OBJECT or VOID.
|
boolean |
isConvertibleFrom(WrapperType source)
Does the JLS 5.1.2 allow a variable of this wrapper's
primitive type to be assigned from a value of the given wrapper's primitive type?
Cases:
unboxing followed by widening primitive conversion
any type converted to
void (i.e., dropping a method call's value)
boxing conversion followed by widening reference conversion to Object
These are the cases allowed by MethodHandle.asType. |
boolean |
isDoubleWord()
Does the wrapped value occupy two JVM stack slots?
|
boolean |
isFloating()
Is the wrapped type either float or double?
|
boolean |
isIntegral()
Is the wrapped type a primitive other than float, double, or void?
|
boolean |
isNumeric()
Is the wrapped type numeric (not void or object)?
|
boolean |
isOther()
Is the wrapped type either void or a reference?
|
boolean |
isSigned() |
boolean |
isSingleWord()
Does the wrapped value occupy a single JVM stack slot?
|
boolean |
isSubwordOrInt()
Is the wrapped type one of int, boolean, byte, char, or short?
|
boolean |
isUnsigned() |
int |
stackSlots()
How many JVM stack slots occupied by the wrapped value? Returns 0 for VOID.
|
static WrapperType |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static WrapperType[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
Object |
wrap(int x)
Wrap a value (an int or smaller value) in this wrapper's type.
|
Object |
wrap(Object x)
Wrap a value in this wrapper's type.
|
public static final WrapperType BOOLEAN
public static final WrapperType BYTE
public static final WrapperType SHORT
public static final WrapperType CHAR
public static final WrapperType INT
public static final WrapperType LONG
public static final WrapperType FLOAT
public static final WrapperType DOUBLE
public static final WrapperType OBJECT
public static final WrapperType VOID
public static WrapperType[] values()
for (WrapperType c : WrapperType.values()) System.out.println(c);
public static WrapperType 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 int bitWidth()
public int stackSlots()
public boolean isSingleWord()
public boolean isDoubleWord()
public boolean isNumeric()
public boolean isIntegral()
public boolean isSubwordOrInt()
public boolean isSigned()
public boolean isUnsigned()
public boolean isFloating()
public boolean isOther()
public boolean isConvertibleFrom(WrapperType source)
void (i.e., dropping a method call's value)
Object
public Object wrap(Object x)
OBJECT.
Returns null for VOID.
Returns a zero value for a null input.ClassCastException - if this wrapper is numeric and the operand
is not a number, character, boolean, or nullpublic Object wrap(int x)
Integer for OBJECT, although the exact type
of the operand is not known.
Returns null for VOID.Copyright © 2022. All rights reserved.