Package com.sun.codemodel
Class JAnnotationUse
- java.lang.Object
-
- com.sun.codemodel.JAnnotationValue
-
- com.sun.codemodel.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- Author:
- Bhakti Mehta (bhakti.mehta@sun.com)
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description JAnnotationUseannotate(Class<? extends Annotation> clazz)JAnnotationUseannotationParam(String name, Class<? extends Annotation> value)Adds a member value pair to this annotation For adding class values as paramvoidgenerate(JFormatter f)JClassgetAnnotationClass()Map<String,JAnnotationValue>getAnnotationMembers()JAnnotationUseparam(String name, boolean value)Adds a member value pair to this annotationJAnnotationUseparam(String name, byte value)Adds a member value pair to this annotationJAnnotationUseparam(String name, char value)Adds a member value pair to this annotationJAnnotationUseparam(String name, double value)Adds a member value pair to this annotationJAnnotationUseparam(String name, float value)Adds a member value pair to this annotationJAnnotationUseparam(String name, int value)Adds a member value pair to this annotationJAnnotationUseparam(String name, long value)Adds a member value pair to this annotationJAnnotationUseparam(String name, short value)Adds a member value pair to this annotationJAnnotationUseparam(String name, JEnumConstant value)Adds a member value pair to this annotationJAnnotationUseparam(String name, JExpression value)Adds a member value pair to this annotation.JAnnotationUseparam(String name, JType type)Adds a member value pair to this annotation based on the type represented by the given JTypeJAnnotationUseparam(String name, Class<?> value)Adds a member value pair to this annotation This can be used for e.g to specifyJAnnotationUseparam(String name, Enum<?> value)Adds a member value pair to this annotationJAnnotationUseparam(String name, String value)Adds a member value pair to this annotationJAnnotationArrayMemberparamArray(String name)Adds a member value pair which is of type array to this annotation
-
-
-
Method Detail
-
getAnnotationClass
public JClass getAnnotationClass()
-
getAnnotationMembers
public Map<String,JAnnotationValue> getAnnotationMembers()
-
param
public JAnnotationUse param(String name, boolean value)
Adds a member value pair to this annotation- Parameters:
name- The simple name for this annotationvalue- 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(String name, byte value)
Adds a member value pair to this annotation- Parameters:
name- The simple name for this annotationvalue- 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(String name, char value)
Adds a member value pair to this annotation- Parameters:
name- The simple name for this annotationvalue- 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(String name, double value)
Adds a member value pair to this annotation- Parameters:
name- The simple name for this annotationvalue- 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(String name, float value)
Adds a member value pair to this annotation- Parameters:
name- The simple name for this annotationvalue- 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(String name, long value)
Adds a member value pair to this annotation- Parameters:
name- The simple name for this annotationvalue- 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(String name, short value)
Adds a member value pair to this annotation- Parameters:
name- The simple name for this annotationvalue- 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(String name, int value)
Adds a member value pair to this annotation- Parameters:
name- The simple name for this annotationvalue- 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(String name, String value)
Adds a member value pair to this annotation- Parameters:
name- The simple name for this annotationvalue- 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(String name, Class<? extends Annotation> value)
Adds a member value pair to this annotation For adding class values as param- Parameters:
name- The simple name for this annotationvalue- 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(String name, Enum<?> value)
Adds a member value pair to this annotation- Parameters:
name- The simple name for this annotationvalue- 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(String name, JEnumConstant value)
Adds a member value pair to this annotation- Parameters:
name- The simple name for this annotationvalue- 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(String name, Class<?> value)
Adds a member value pair to this annotation This can be used for e.g to specifyFor adding a value of@XmlCollectionItem(type=Integer.class);Class<? extends Annotation>annotationParam(java.lang.String, java.lang.Class)- Parameters:
name- The simple name for this annotation paramvalue- The class type of the param- Returns:
- The JAnnotationUse. More member value pairs can be added to it using the same or the overloaded methods.
-
param
public JAnnotationUse param(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 paramtype- 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(String name, JExpression value)
Adds a member value pair to this annotation.- Parameters:
name- The simple name for this annotationvalue- 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(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
-
annotate
public JAnnotationUse annotate(Class<? extends Annotation> clazz)
Deprecated.This can be used to add annotations inside annotations for e.g @XmlCollection(values= @XmlCollectionItem(type=Foo.class))- Parameters:
clazz- The annotation class to be included- Returns:
- The JAnnotationUse that can be used as a member within this JAnnotationUse
-
generate
public void generate(JFormatter f)
-
-