Package com.sun.codemodel
Class JVar
java.lang.Object
com.sun.codemodel.JExpressionImpl
com.sun.codemodel.JVar
- All Implemented Interfaces:
JAnnotatable
,JAssignmentTarget
,JDeclaration
,JExpression
,JGenerable
- Direct Known Subclasses:
JFieldVar
Variables and fields.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
annotate
(JAnnotationUse annotation) Adds an annotation to this variable.annotate
(Class<? extends Annotation> clazz) Adds an annotation to this variable.<W extends JAnnotationWriter<? extends Annotation>>
WAdds an annotation to this program element and returns a type-safe writer to fill in the values of such annotations.Read-only live view of all annotations on thisassign
(JExpression rhs) assignPlus
(JExpression rhs) void
bind
(JFormatter f) void
void
init
(JExpression init) Initialize this variableprotected boolean
mods()
name()
Get the name of this variablevoid
Changes the name of this variable.boolean
removeAnnotation
(JAnnotationUse annotation) Removes annotation from this program element.type()
Return the type of this variable.Sets the type of this variable.Methods inherited from class com.sun.codemodel.JExpressionImpl
_instanceof, band, bor, cand, complement, component, cor, decr, div, eq, gt, gte, incr, invoke, invoke, lt, lte, minus, minus, mod, mul, ne, not, plus, ref, ref, shl, shr, shrz, xor
-
Method Details
-
init
Initialize this variable- Parameters:
init
- JExpression to be used to initialize this field
-
name
Get the name of this variable- Returns:
- Name of the variable
-
name
Changes the name of this variable. -
type
Return the type of this variable.- Returns:
- always non-null.
-
mods
- Returns:
- the current modifiers of this method. Always return non-null valid object.
-
type
Sets the type of this variable.- Parameters:
newType
- must not be null.- Returns:
- the old type value. always non-null.
-
annotate
Adds an annotation to this variable.- Specified by:
annotate
in interfaceJAnnotatable
- Parameters:
clazz
- The annotation class to annotate the field with
-
annotate
-
annotate
Adds an annotation to this variable.- Specified by:
annotate
in interfaceJAnnotatable
- Parameters:
clazz
- The annotation class to annotate the field with
-
annotate2
Description copied from interface:JAnnotatable
Adds an annotation to this program element and returns a type-safe writer to fill in the values of such annotations.- Specified by:
annotate2
in interfaceJAnnotatable
-
removeAnnotation
Description copied from interface:JAnnotatable
Removes annotation from this program element.- Specified by:
removeAnnotation
in interfaceJAnnotatable
- Parameters:
annotation
- The annotation to be removed from the program element
-
annotations
Description copied from interface:JAnnotatable
Read-only live view of all annotations on this- Specified by:
annotations
in interfaceJAnnotatable
- Returns:
- Can be empty but never null.
-
isAnnotated
protected boolean isAnnotated() -
bind
-
declare
- Specified by:
declare
in interfaceJDeclaration
-
generate
- Specified by:
generate
in interfaceJGenerable
-
assign
- Specified by:
assign
in interfaceJAssignmentTarget
-
assignPlus
- Specified by:
assignPlus
in interfaceJAssignmentTarget
-