Class JavaConstant.Simple<T>

    • Constructor Detail

      • Simple

        protected Simple​(T value,
                         TypeDescription typeDescription)
        Creates a simple Java constant.
        Parameters:
        value - The represented constant pool value.
        typeDescription - A description of the type of the constant.
    • Method Detail

      • doPrivileged

        @Enhance
        private static <T> T doPrivileged​(java.security.PrivilegedAction<T> action)
        A proxy for java.security.AccessController#doPrivileged that is activated if available.
        Type Parameters:
        T - The type of the action's resolved value.
        Parameters:
        action - The action to execute from a privileged context.
        Returns:
        The action's resolved value.
      • ofAsm

        public static JavaConstant ofAsm​(TypePool typePool,
                                         java.lang.Object value)
        Resolves an ASM constant to a JavaConstant.
        Parameters:
        typePool - The type pool to resolve type descriptions with.
        value - The ASM constant value.
        Returns:
        An appropriate JavaConstant.
      • ofLoaded

        public static JavaConstant ofLoaded​(java.lang.Object value)
        Resolves a loaded Java value to a Java constant representation.
        Parameters:
        value - The value to represent.
        Returns:
        An appropriate Java constant representation.
      • ofLoadedOrNull

        @MaybeNull
        protected static JavaConstant ofLoadedOrNull​(java.lang.Object value)
        Resolves a loaded Java value to a Java constant representation.
        Parameters:
        value - The value to represent.
        Returns:
        An appropriate Java constant representation or null if the supplied argument is not a compile-time constant.
      • ofDescription

        public static JavaConstant ofDescription​(java.lang.Object value,
                                                 @MaybeNull
                                                 java.lang.ClassLoader classLoader)
        Creates a Java constant value from a java.lang.constant.ConstantDesc.
        Parameters:
        value - The java.lang.constant.ConstantDesc to represent.
        classLoader - The class loader to use for resolving type information from the supplied value.
        Returns:
        An appropriate Java constant representation.
      • ofDescription

        public static JavaConstant ofDescription​(java.lang.Object value,
                                                 ClassFileLocator classFileLocator)
        Creates a Java constant value from a java.lang.constant.ConstantDesc.
        Parameters:
        value - The java.lang.constant.ConstantDesc to represent.
        classFileLocator - The class file locator to use for resolving type information from the supplied value.
        Returns:
        An appropriate Java constant representation.
      • ofDescription

        public static JavaConstant ofDescription​(java.lang.Object value,
                                                 TypePool typePool)
        Creates a Java constant value from a java.lang.constant.ConstantDesc.
        Parameters:
        value - The java.lang.constant.ConstantDesc to represent.
        typePool - The type pool to use for resolving type information from the supplied value.
        Returns:
        An appropriate Java constant representation.
      • of

        public static JavaConstant of​(TypeDescription typeDescription)
        Returns a Java constant representation for a TypeDescription.
        Parameters:
        typeDescription - The type to represent as a constant.
        Returns:
        An appropriate Java constant representation.
      • wrap

        public static JavaConstant wrap​(java.lang.Object value)
        Wraps a value representing a loaded or unloaded constant as JavaConstant instance.
        Parameters:
        value - The value to wrap.
        Returns:
        A wrapped Java constant.
      • wrap

        public static java.util.List<JavaConstant> wrap​(java.util.List<?> values)
        Wraps a list of either loaded or unloaded constant representations as JavaConstant instances.
        Parameters:
        values - The values to wrap.
        Returns:
        A list of wrapped Java constants.
      • getValue

        public T getValue()
        Returns the represented value.
        Returns:
        The represented value.
      • getTypeDescription

        public TypeDescription getTypeDescription()
        Returns a description of the type of this constant.
        Specified by:
        getTypeDescription in interface ConstantValue
        Returns:
        A description of the type of this constant.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(@MaybeNull
                              java.lang.Object object)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object