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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List
<JAnnotationUse> Annotations on this variable.private JExpression
Initialization of the variable in its declarationprivate JMods
Modifiers.private String
Name of the variableprivate JType
JType of the variable -
Constructor Summary
ConstructorsConstructorDescriptionJVar
(JMods mods, JType type, String name, JExpression init) JVar constructor -
Method Summary
Modifier and TypeMethodDescriptionAdds an annotation to this variable.annotate
(Class<? extends Annotation> clazz) Adds an annotation to this variable.<W extends JAnnotationWriter>
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 thisJAnnotatable
assign
(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.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
-
Field Details
-
mods
Modifiers. -
type
JType of the variable -
name
Name of the variable -
init
Initialization of the variable in its declaration -
annotations
Annotations on this variable. Lazily created.
-
-
Constructor Details
-
JVar
JVar(JMods mods, JType type, String name, JExpression init) JVar constructor- Parameters:
type
- Datatype of this variablename
- Name of this variableinit
- Value to initialize this variable to
-
-
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
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
-
annotations
Description copied from interface:JAnnotatable
Read-only live view of all annotations on thisJAnnotatable
- 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
-