Enum Class PrimitiveUnboxingDelegate
java.lang.Object
java.lang.Enum<PrimitiveUnboxingDelegate>
net.bytebuddy.implementation.bytecode.assign.primitive.PrimitiveUnboxingDelegate
- All Implemented Interfaces:
Serializable
,Comparable<PrimitiveUnboxingDelegate>
,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 enum
An explicitly types unboxing responsible is applied for directly unboxing a wrapper type.protected static class
An unboxing responsible for an implicitly typed value.static interface
Implementations represent an unboxing delegate that is able to perform the unboxing operation.Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
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 ConstantsEnum ConstantDescriptionThe unboxing delegate forBoolean
types.The unboxing delegate forByte
types.The unboxing delegate forCharacter
types.The unboxing delegate forDouble
types.The unboxing delegate forFloat
types.The unboxing delegate forInteger
types.The unboxing delegate forLong
types.The unboxing delegate forShort
types. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final TypeDescription
The represented primitive type.private final StackManipulation.Size
The size increase after a wrapper type was unwrapped.private final String
The descriptor of the method for unboxing a wrapper value to its primitive value.private final String
The name of the method for unboxing a wrapper value to its primitive value.private final TypeDescription
The 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 PrimitiveUnboxingDelegate
forPrimitive
(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.Generic
Returns the wrapper type that this unboxing delegate represents.boolean
isValid()
Determines if this stack manipulation is valid.static PrimitiveUnboxingDelegate
Returns the enum constant of this class with the specified name.static PrimitiveUnboxingDelegate[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
BOOLEAN
The unboxing delegate forBoolean
types. -
BYTE
The unboxing delegate forByte
types. -
SHORT
The unboxing delegate forShort
types. -
CHARACTER
The unboxing delegate forCharacter
types. -
INTEGER
The unboxing delegate forInteger
types. -
LONG
The unboxing delegate forLong
types. -
FLOAT
The unboxing delegate forFloat
types. -
DOUBLE
The unboxing delegate forDouble
types.
-
-
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 class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class 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.UnboxingResponsible
in 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:
isValid
in 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:
apply
in 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.
-