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.
  • Enum Constant Details

  • Field Details

    • 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 String unboxingMethodName
      The name of the method for unboxing a wrapper value to its primitive value.
    • unboxingMethodDescriptor

      private final String 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

      public static PrimitiveUnboxingDelegate[] 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

      public static PrimitiveUnboxingDelegate valueOf(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:
      IllegalArgumentException - if this enum type has no constant with the specified name
      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.
      1. If the reference type represents a wrapper type, the wrapper type will simply be unboxed.
      2. 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

      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:
      isValid in interface StackManipulation
      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 interface StackManipulation
      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.