Class AnnotationDescription.AnnotationInvocationHandler<T extends java.lang.annotation.Annotation>

  • Type Parameters:
    T - The type of the handled annotation.
    All Implemented Interfaces:
    java.lang.reflect.InvocationHandler
    Enclosing interface:
    AnnotationDescription

    public static class AnnotationDescription.AnnotationInvocationHandler<T extends java.lang.annotation.Annotation>
    extends java.lang.Object
    implements java.lang.reflect.InvocationHandler
    An InvocationHandler for implementing annotations.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Class<? extends java.lang.annotation.Annotation> annotationType
      The loaded annotation type.
      private static java.lang.String EQUALS
      The name of the Object.equals(Object) method.
      private static java.lang.String HASH_CODE
      The name of the Object.hashCode() method.
      private static java.lang.Object[] NO_ARGUMENTS
      An empty array that can be used to indicate no arguments to avoid an allocation on a reflective call.
      private static java.lang.String TO_STRING
      The name of the Object.toString() method.
      private java.util.LinkedHashMap<java.lang.reflect.Method,​AnnotationValue.Loaded<?>> values
      A sorted list of values of this annotation.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AnnotationInvocationHandler​(java.lang.Class<T> annotationType, java.util.LinkedHashMap<java.lang.reflect.Method,​AnnotationValue.Loaded<?>> values)
      Creates a new invocation handler.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object other)  
      private boolean equalsRepresentation​(java.lang.Object self, java.lang.Object other)
      Checks if another instance is equal to this instance.
      int hashCode()  
      private int hashCodeRepresentation()
      Returns the hash code of the represented annotation.
      java.lang.Object invoke​(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] argument)
      static <S extends java.lang.annotation.Annotation>
      S
      of​(java.lang.ClassLoader classLoader, java.lang.Class<S> annotationType, java.util.Map<java.lang.String,​? extends AnnotationValue<?,​?>> values)
      Creates a proxy instance for the supplied annotation type and values.
      protected java.lang.String toStringRepresentation()
      Returns the string representation of the represented annotation.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • HASH_CODE

        private static final java.lang.String HASH_CODE
        The name of the Object.hashCode() method.
        See Also:
        Constant Field Values
      • EQUALS

        private static final java.lang.String EQUALS
        The name of the Object.equals(Object) method.
        See Also:
        Constant Field Values
      • TO_STRING

        private static final java.lang.String TO_STRING
        The name of the Object.toString() method.
        See Also:
        Constant Field Values
      • NO_ARGUMENTS

        private static final java.lang.Object[] NO_ARGUMENTS
        An empty array that can be used to indicate no arguments to avoid an allocation on a reflective call.
      • annotationType

        private final java.lang.Class<? extends java.lang.annotation.Annotation> annotationType
        The loaded annotation type.
      • values

        private final java.util.LinkedHashMap<java.lang.reflect.Method,​AnnotationValue.Loaded<?>> values
        A sorted list of values of this annotation.
    • Constructor Detail

      • AnnotationInvocationHandler

        protected AnnotationInvocationHandler​(java.lang.Class<T> annotationType,
                                              java.util.LinkedHashMap<java.lang.reflect.Method,​AnnotationValue.Loaded<?>> values)
        Creates a new invocation handler.
        Parameters:
        annotationType - The loaded annotation type.
        values - A sorted list of values of this annotation.
    • Method Detail

      • of

        public static <S extends java.lang.annotation.Annotation> S of​(java.lang.ClassLoader classLoader,
                                                                       java.lang.Class<S> annotationType,
                                                                       java.util.Map<java.lang.String,​? extends AnnotationValue<?,​?>> values)
        Creates a proxy instance for the supplied annotation type and values.
        Type Parameters:
        S - The type of the handled annotation.
        Parameters:
        classLoader - The class loader that should be used for loading the annotation's values.
        annotationType - The annotation's type.
        values - The values that the annotation contains.
        Returns:
        A proxy for the annotation type and values.
      • invoke

        public java.lang.Object invoke​(java.lang.Object proxy,
                                       java.lang.reflect.Method method,
                                       java.lang.Object[] argument)
        Specified by:
        invoke in interface java.lang.reflect.InvocationHandler
      • toStringRepresentation

        protected java.lang.String toStringRepresentation()
        Returns the string representation of the represented annotation.
        Returns:
        The string representation of the represented annotation.
      • hashCodeRepresentation

        private int hashCodeRepresentation()
        Returns the hash code of the represented annotation.
        Returns:
        The hash code of the represented annotation.
      • equalsRepresentation

        private boolean equalsRepresentation​(java.lang.Object self,
                                             java.lang.Object other)
        Checks if another instance is equal to this instance.
        Parameters:
        self - The annotation proxy instance.
        other - The instance to be examined for equality to the represented instance.
        Returns:
        true if the given instance is equal to the represented instance.
      • hashCode

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

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object