Class JAnnotationUse

  • All Implemented Interfaces:
    JGenerable

    public final class JAnnotationUse
    extends JAnnotationValue
    Represents an annotation on a program element. TODO How to add enums to the annotations
    • Field Detail

      • clazz

        private final JClass clazz
        The Annotation class
      • memberValues

        private java.util.Map<java.lang.String,​JAnnotationValue> memberValues
        Map of member values.
    • Constructor Detail

      • JAnnotationUse

        JAnnotationUse​(JClass clazz)
    • Method Detail

      • getAnnotationClass

        public JClass getAnnotationClass()
      • getAnnotationMembers

        public java.util.Map<java.lang.String,​JAnnotationValue> getAnnotationMembers()
      • addValue

        private void addValue​(java.lang.String name,
                              JAnnotationValue annotationValue)
      • param

        public JAnnotationUse param​(java.lang.String name,
                                    boolean value)
        Adds a member value pair to this annotation
        Parameters:
        name - The simple name for this annotation
        value - The boolean value for this annotation
        Returns:
        The JAnnotationUse. More member value pairs can be added to it using the same or the overloaded methods.
      • param

        public JAnnotationUse param​(java.lang.String name,
                                    byte value)
        Adds a member value pair to this annotation
        Parameters:
        name - The simple name for this annotation
        value - The byte member value for this annotation
        Returns:
        The JAnnotationUse. More member value pairs can be added to it using the same or the overloaded methods.
      • param

        public JAnnotationUse param​(java.lang.String name,
                                    char value)
        Adds a member value pair to this annotation
        Parameters:
        name - The simple name for this annotation
        value - The char member value for this annotation
        Returns:
        The JAnnotationUse. More member value pairs can be added to it using the same or the overloaded methods.
      • param

        public JAnnotationUse param​(java.lang.String name,
                                    double value)
        Adds a member value pair to this annotation
        Parameters:
        name - The simple name for this annotation
        value - The double member value for this annotation
        Returns:
        The JAnnotationUse. More member value pairs can be added to it using the same or the overloaded methods.
      • param

        public JAnnotationUse param​(java.lang.String name,
                                    float value)
        Adds a member value pair to this annotation
        Parameters:
        name - The simple name for this annotation
        value - The float member value for this annotation
        Returns:
        The JAnnotationUse. More member value pairs can be added to it using the same or the overloaded methods.
      • param

        public JAnnotationUse param​(java.lang.String name,
                                    long value)
        Adds a member value pair to this annotation
        Parameters:
        name - The simple name for this annotation
        value - The long member value for this annotation
        Returns:
        The JAnnotationUse. More member value pairs can be added to it using the same or the overloaded methods.
      • param

        public JAnnotationUse param​(java.lang.String name,
                                    short value)
        Adds a member value pair to this annotation
        Parameters:
        name - The simple name for this annotation
        value - The short member value for this annotation
        Returns:
        The JAnnotationUse. More member value pairs can be added to it using the same or the overloaded methods.
      • param

        public JAnnotationUse param​(java.lang.String name,
                                    int value)
        Adds a member value pair to this annotation
        Parameters:
        name - The simple name for this annotation
        value - The int member value for this annotation
        Returns:
        The JAnnotationUse. More member value pairs can be added to it using the same or the overloaded methods.
      • param

        public JAnnotationUse param​(java.lang.String name,
                                    java.lang.String value)
        Adds a member value pair to this annotation
        Parameters:
        name - The simple name for this annotation
        value - The String member value for this annotation
        Returns:
        The JAnnotationUse. More member value pairs can be added to it using the same or the overloaded methods.
      • annotationParam

        public JAnnotationUse annotationParam​(java.lang.String name,
                                              java.lang.Class<? extends java.lang.annotation.Annotation> value)
        Adds a member value pair to this annotation For adding class values as param
        Parameters:
        name - The simple name for this annotation
        value - The annotation class which is member value for this annotation
        Returns:
        The JAnnotationUse. More member value pairs can be added to it using the same or the overloaded methods.
        See Also:
        param(String, Class)
      • param

        public JAnnotationUse param​(java.lang.String name,
                                    java.lang.Enum<?> value)
        Adds a member value pair to this annotation
        Parameters:
        name - The simple name for this annotation
        value - The enum class which is member value for this annotation
        Returns:
        The JAnnotationUse. More member value pairs can be added to it using the same or the overloaded methods.
      • param

        public JAnnotationUse param​(java.lang.String name,
                                    JEnumConstant value)
        Adds a member value pair to this annotation
        Parameters:
        name - The simple name for this annotation
        value - The JEnumConstant which is member value for this annotation
        Returns:
        The JAnnotationUse. More member value pairs can be added to it using the same or the overloaded methods.
      • param

        public JAnnotationUse param​(java.lang.String name,
                                    java.lang.Class<?> value)
        Adds a member value pair to this annotation This can be used for e.g to specify
                @XmlCollectionItem(type=Integer.class);
         
         For adding a value of Class
      • param

        public JAnnotationUse param​(java.lang.String name,
                                    JType type)
        Adds a member value pair to this annotation based on the type represented by the given JType
        Parameters:
        name - The simple name for this annotation param
        type - the JType representing the actual type
        Returns:
        The JAnnotationUse. More member value pairs can be added to it using the same or the overloaded methods.
      • param

        public JAnnotationUse param​(java.lang.String name,
                                    JExpression value)
        Adds a member value pair to this annotation.
        Parameters:
        name - The simple name for this annotation
        value - The JExpression which provides the contant value for this annotation
        Returns:
        The JAnnotationUse. More member value pairs can be added to it using the same or the overloaded methods.
      • paramArray

        public JAnnotationArrayMember paramArray​(java.lang.String name)
        Adds a member value pair which is of type array to this annotation
        Parameters:
        name - The simple name for this annotation
        Returns:
        The JAnnotationArrayMember. For adding array values
        See Also:
        JAnnotationArrayMember
      • generate

        public void generate​(JFormatter f)
      • isOptimizable

        private boolean isOptimizable()