Enum PrimitiveUnboxingDelegate

    • Field Detail

      • wrapperType

        private final TypeDescription wrapperType
        The wrapper type of the represented primitive type.
      • primitiveType

        private final TypeDescription primitiveType
        The represented primitive type.
      • 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 name
        java.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.
        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.