Enum PrimitiveUnboxingDelegate
- java.lang.Object
-
- java.lang.Enum<PrimitiveUnboxingDelegate>
-
- net.bytebuddy.implementation.bytecode.assign.primitive.PrimitiveUnboxingDelegate
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<PrimitiveUnboxingDelegate>,StackManipulation
public enum PrimitiveUnboxingDelegate extends java.lang.Enum<PrimitiveUnboxingDelegate> implements StackManipulation
This delegate is responsible for unboxing a wrapper type to their primitive equivalents.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classPrimitiveUnboxingDelegate.ExplicitlyTypedUnboxingResponsibleAn explicitly types unboxing responsible is applied for directly unboxing a wrapper type.protected static classPrimitiveUnboxingDelegate.ImplicitlyTypedUnboxingResponsibleAn unboxing responsible for an implicitly typed value.static interfacePrimitiveUnboxingDelegate.UnboxingResponsibleImplementations represent an unboxing delegate that is able to perform the unboxing operation.-
Nested classes/interfaces inherited from interface net.bytebuddy.implementation.bytecode.StackManipulation
StackManipulation.AbstractBase, StackManipulation.Compound, StackManipulation.Illegal, StackManipulation.Simple, StackManipulation.Size, StackManipulation.Trivial
-
-
Enum Constant Summary
Enum Constants Enum Constant Description BOOLEANThe unboxing delegate forBooleantypes.BYTEThe unboxing delegate forBytetypes.CHARACTERThe unboxing delegate forCharactertypes.DOUBLEThe unboxing delegate forDoubletypes.FLOATThe unboxing delegate forFloattypes.INTEGERThe unboxing delegate forIntegertypes.LONGThe unboxing delegate forLongtypes.SHORTThe unboxing delegate forShorttypes.
-
Field Summary
Fields Modifier and Type Field Description private TypeDescriptionprimitiveTypeThe represented primitive type.private StackManipulation.SizesizeThe size increase after a wrapper type was unwrapped.private java.lang.StringunboxingMethodDescriptorThe descriptor of the method for unboxing a wrapper value to its primitive value.private java.lang.StringunboxingMethodNameThe name of the method for unboxing a wrapper value to its primitive value.private TypeDescriptionwrapperTypeThe wrapper type of the represented primitive type.
-
Constructor Summary
Constructors Modifier Constructor Description privatePrimitiveUnboxingDelegate(java.lang.Class<?> wrapperType, java.lang.Class<?> primitiveType, StackSize sizeDifference, java.lang.String unboxingMethodName, java.lang.String unboxingMethodDescriptor)Creates a new primitive unboxing delegate.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StackManipulation.Sizeapply(org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext)Applies the stack manipulation that is described by this instance.static PrimitiveUnboxingDelegateforPrimitive(TypeDefinition typeDefinition)Locates a primitive unboxing delegate for a given primitive type.static PrimitiveUnboxingDelegate.UnboxingResponsibleforReferenceType(TypeDefinition typeDefinition)Creates an unboxing responsible that is capable of unboxing a wrapper type.protected TypeDescription.GenericgetWrapperType()Returns the wrapper type that this unboxing delegate represents.booleanisValid()Determines if this stack manipulation is valid.static PrimitiveUnboxingDelegatevalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static PrimitiveUnboxingDelegate[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
BOOLEAN
public static final PrimitiveUnboxingDelegate BOOLEAN
The unboxing delegate forBooleantypes.
-
BYTE
public static final PrimitiveUnboxingDelegate BYTE
The unboxing delegate forBytetypes.
-
SHORT
public static final PrimitiveUnboxingDelegate SHORT
The unboxing delegate forShorttypes.
-
CHARACTER
public static final PrimitiveUnboxingDelegate CHARACTER
The unboxing delegate forCharactertypes.
-
INTEGER
public static final PrimitiveUnboxingDelegate INTEGER
The unboxing delegate forIntegertypes.
-
LONG
public static final PrimitiveUnboxingDelegate LONG
The unboxing delegate forLongtypes.
-
FLOAT
public static final PrimitiveUnboxingDelegate FLOAT
The unboxing delegate forFloattypes.
-
DOUBLE
public static final PrimitiveUnboxingDelegate DOUBLE
The unboxing delegate forDoubletypes.
-
-
Field Detail
-
wrapperType
private final TypeDescription wrapperType
The wrapper type of the represented primitive type.
-
primitiveType
private final TypeDescription primitiveType
The represented primitive type.
-
size
private final StackManipulation.Size size
The size increase after a wrapper type was unwrapped.
-
unboxingMethodName
private final java.lang.String unboxingMethodName
The name of the method for unboxing a wrapper value to its primitive value.
-
unboxingMethodDescriptor
private final java.lang.String unboxingMethodDescriptor
The descriptor of the method for unboxing a wrapper value to its primitive value.
-
-
Constructor Detail
-
PrimitiveUnboxingDelegate
private PrimitiveUnboxingDelegate(java.lang.Class<?> wrapperType, java.lang.Class<?> primitiveType, StackSize sizeDifference, java.lang.String unboxingMethodName, java.lang.String unboxingMethodDescriptor)Creates a new primitive unboxing delegate.- Parameters:
wrapperType- The wrapper type of the represented primitive type.primitiveType- The represented primitive type.sizeDifference- The size difference between the wrapper type and its primitive value.unboxingMethodName- The name of the method for unboxing a wrapper value to its primitive value.unboxingMethodDescriptor- The descriptor of the method for unboxing a wrapper value to its primitive value.
-
-
Method Detail
-
values
public static PrimitiveUnboxingDelegate[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (PrimitiveUnboxingDelegate c : PrimitiveUnboxingDelegate.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static PrimitiveUnboxingDelegate valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
forPrimitive
public static PrimitiveUnboxingDelegate forPrimitive(TypeDefinition typeDefinition)
Locates a primitive unboxing delegate for a given primitive type.- Parameters:
typeDefinition- A description of the primitive type.- Returns:
- A corresponding primitive unboxing delegate.
-
forReferenceType
public static PrimitiveUnboxingDelegate.UnboxingResponsible forReferenceType(TypeDefinition typeDefinition)
Creates an unboxing responsible that is capable of unboxing a wrapper type.- If the reference type represents a wrapper type, the wrapper type will simply be unboxed.
- If the reference type does not represent a wrapper type, the wrapper type will be inferred by the primitive target
type that is later given to the
PrimitiveUnboxingDelegate.UnboxingResponsiblein order to then check if the given type is assignable to the inferred wrapper type.
- Parameters:
typeDefinition- A non-primitive type.- Returns:
- An unboxing responsible capable of performing an unboxing operation while considering a further assignment of the unboxed value.
-
getWrapperType
protected TypeDescription.Generic getWrapperType()
Returns the wrapper type that this unboxing delegate represents.- Returns:
- A generic version of this delegate's wrapper type.
-
isValid
public boolean isValid()
Determines if this stack manipulation is valid.- Specified by:
isValidin interfaceStackManipulation- Returns:
- If
false, this manipulation cannot be applied and should throw an exception.
-
apply
public StackManipulation.Size apply(org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext)
Applies the stack manipulation that is described by this instance.- Specified by:
applyin interfaceStackManipulation- Parameters:
methodVisitor- The method visitor used to write the method implementation to.implementationContext- The context of the current implementation.- Returns:
- The changes to the size of the operand stack that are implied by this stack manipulation.
-
-