Package com.sun.codemodel
Class JEnumConstant
- java.lang.Object
-
- com.sun.codemodel.JExpressionImpl
-
- com.sun.codemodel.JEnumConstant
-
- All Implemented Interfaces:
JAnnotatable,JDeclaration,JDocCommentable,JExpression,JGenerable
public final class JEnumConstant extends JExpressionImpl implements JDeclaration, JAnnotatable, JDocCommentable
Enum Constant. When used as anJExpression, this object represents a reference to the enum constant.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<JAnnotationUse>annotationsAnnotations on this variable.private java.util.List<JExpression>argsList of the constructor argument expressions.private JDocCommentjdocjavadoc comments, if any.private java.lang.StringnameThe constant.private JDefinedClasstypeThe enum class.
-
Constructor Summary
Constructors Constructor Description JEnumConstant(JDefinedClass type, java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JAnnotationUseannotate(JClass clazz)Adds an annotation to this variable.JAnnotationUseannotate(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)Adds an annotation to this variable.<W extends JAnnotationWriter>
Wannotate2(java.lang.Class<W> clazz)Adds an annotation to this program element and returns a type-safe writer to fill in the values of such annotations.java.util.Collection<JAnnotationUse>annotations()JEnumConstantarg(JExpression arg)Add an expression to this constructor's argument listvoiddeclare(JFormatter f)voidgenerate(JFormatter f)java.lang.StringgetName()Returns the name of this constant.JDocCommentjavadoc()Creates, if necessary, and returns the enum constant javadoc.
-
-
-
Field Detail
-
name
private final java.lang.String name
The constant.
-
type
private final JDefinedClass type
The enum class.
-
jdoc
private JDocComment jdoc
javadoc comments, if any.
-
annotations
private java.util.List<JAnnotationUse> annotations
Annotations on this variable. Lazily created.
-
args
private java.util.List<JExpression> args
List of the constructor argument expressions. Lazily constructed.
-
-
Constructor Detail
-
JEnumConstant
JEnumConstant(JDefinedClass type, java.lang.String name)
-
-
Method Detail
-
arg
public JEnumConstant arg(JExpression arg)
Add an expression to this constructor's argument list- Parameters:
arg- Argument to add to argument list
-
getName
public java.lang.String getName()
Returns the name of this constant.- Returns:
- never null.
-
javadoc
public JDocComment javadoc()
Creates, if necessary, and returns the enum constant javadoc.- Specified by:
javadocin interfaceJDocCommentable- Returns:
- JDocComment containing javadocs for this constant.
-
annotate
public JAnnotationUse annotate(JClass clazz)
Adds an annotation to this variable.- Specified by:
annotatein interfaceJAnnotatable- Parameters:
clazz- The annotation class to annotate the field with
-
annotate
public JAnnotationUse annotate(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
Adds an annotation to this variable.- Specified by:
annotatein interfaceJAnnotatable- Parameters:
clazz- The annotation class to annotate the field with
-
annotate2
public <W extends JAnnotationWriter> W annotate2(java.lang.Class<W> clazz)
Description copied from interface:JAnnotatableAdds an annotation to this program element and returns a type-safe writer to fill in the values of such annotations.- Specified by:
annotate2in interfaceJAnnotatable
-
annotations
public java.util.Collection<JAnnotationUse> annotations()
- Specified by:
annotationsin interfaceJAnnotatable- Returns:
- Can be empty but never null.
-
declare
public void declare(JFormatter f)
- Specified by:
declarein interfaceJDeclaration
-
generate
public void generate(JFormatter f)
- Specified by:
generatein interfaceJGenerable
-
-