Enum PrimitiveUnboxingDelegate
java.lang.Object
java.lang.Enum<PrimitiveUnboxingDelegate>
net.bytebuddy.implementation.bytecode.assign.primitive.PrimitiveUnboxingDelegate
- All Implemented Interfaces:
Serializable, Comparable<PrimitiveUnboxingDelegate>, java.lang.constant.Constable, StackManipulation
public enum PrimitiveUnboxingDelegate
extends Enum<PrimitiveUnboxingDelegate>
implements StackManipulation
This delegate is responsible for unboxing a wrapper type to their primitive equivalents.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumAn explicitly types unboxing responsible is applied for directly unboxing a wrapper type.protected static classAn unboxing responsible for an implicitly typed value.static interfaceImplementations represent an unboxing delegate that is able to perform the unboxing operation.Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E>Nested classes/interfaces inherited from interface StackManipulation
StackManipulation.AbstractBase, StackManipulation.Compound, StackManipulation.Illegal, StackManipulation.Simple, StackManipulation.Size, StackManipulation.Trivial -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe unboxing delegate forBooleantypes.The unboxing delegate forBytetypes.The unboxing delegate forCharactertypes.The unboxing delegate forDoubletypes.The unboxing delegate forFloattypes.The unboxing delegate forIntegertypes.The unboxing delegate forLongtypes.The unboxing delegate forShorttypes. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final TypeDescriptionThe represented primitive type.private final StackManipulation.SizeThe size increase after a wrapper type was unwrapped.private final StringThe descriptor of the method for unboxing a wrapper value to its primitive value.private final StringThe name of the method for unboxing a wrapper value to its primitive value.private final TypeDescriptionThe wrapper type of the represented primitive type. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapply(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.forReferenceType(TypeDefinition typeDefinition) Creates an unboxing responsible that is capable of unboxing a wrapper type.protected TypeDescription.GenericReturns the wrapper type that this unboxing delegate represents.booleanisValid()Determines if this stack manipulation is valid.static PrimitiveUnboxingDelegateReturns 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 Details
-
BOOLEAN
The unboxing delegate forBooleantypes. -
BYTE
The unboxing delegate forBytetypes. -
SHORT
The unboxing delegate forShorttypes. -
CHARACTER
The unboxing delegate forCharactertypes. -
INTEGER
The unboxing delegate forIntegertypes. -
LONG
The unboxing delegate forLongtypes. -
FLOAT
The unboxing delegate forFloattypes. -
DOUBLE
The unboxing delegate forDoubletypes.
-
-
Field Details
-
wrapperType
The wrapper type of the represented primitive type. -
primitiveType
The represented primitive type. -
size
The size increase after a wrapper type was unwrapped. -
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.
-
-
Constructor Details
-
PrimitiveUnboxingDelegate
private PrimitiveUnboxingDelegate(Class<?> wrapperType, Class<?> primitiveType, StackSize sizeDifference, String unboxingMethodName, 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 Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
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:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
forPrimitive
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
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.
-