public class VariableRef extends Object
| Type | Property and Description |
|---|---|
boolean |
isNested
Gets the value of the property nestedProperty.
|
| Constructor and Description |
|---|
VariableRef(Property property,
String name) |
VariableRef(Property property,
VariableRef anchor) |
VariableRef(Type<?> type,
String name) |
| Modifier and Type | Method and Description |
|---|---|
String |
assertType() |
String |
assign(String value,
Object... replacements)
Generates code to perform assignment to this VariableRef.
|
String |
assign(VariableRef value)
Returns java code which assigns the value of the provided PropertyRef to
this PropertyRef
|
String |
assignIfPossible(String value,
Object... replacements)
Generates code to perform assignment to this VariableRef, if it is
assignable.
|
String |
assignIfPossible(VariableRef value)
Generates code to perform assignment to this VariableRef, if it is
assignable.
|
String |
asWrapper() |
String |
cast(String value)
Returns Java code which provides a cast of the specified value to the
type of this property ref
|
protected static String |
cast(String value,
Type<?> type)
Returns Java code which provides a cast of the specified value to the
type of this property ref
|
String |
cast(VariableRef ref) |
protected static String |
cast(VariableRef value,
Type<?> type)
Returns Java code which provides a cast of the specified value to the
type of this property ref
|
String |
declare()
Returns Java code which declares this variable, initialized with it's
default value.
|
String |
declare(String value,
Object... args)
Returns Java code which declares this variable, initialized with the
provided value.
|
String |
declare(VariableRef initialValueRef)
Returns Java code which declares this variable, initialized with the
provided value.
|
VariableRef |
elementRef(String name) |
Type<?> |
elementType() |
String |
elementTypeName() |
Type<?> |
elementValueType() |
boolean |
equals(Object obj) |
Converter<?,?> |
getConverter() |
static String |
getDefaultValue(Class<?> clazz)
Returns the Java code which represents the default value for the
specified type
|
Filter<?,?> |
getFilter() |
protected static String |
getGetter(Property property,
String variableExpression) |
VariableRef |
getOwner() |
List<VariableRef> |
getPath() |
protected static String |
getSetter(Property property,
String variableExpression)
Returns a fully type-cast setter for the property which has no reliance
on java generics.
|
protected String |
getter() |
int |
hashCode() |
String |
ifNotNull() |
String |
ifNotNull(boolean includePath) |
String |
ifNull() |
String |
ifPathNotNull()
Return Java code which avoids a NullPointerException when accessing this
variable reference; if it is not backed by a nested property, this method
returns the empty string.
|
String |
ifPathNull()
Return Java code which checks if this path is null;
if it is not backed by a nested property, this method
returns the empty string.
|
boolean |
isArray() |
boolean |
isAssignable() |
boolean |
isCollection() |
boolean |
isDeclared() |
String |
isInstanceOf(Type<?> type) |
boolean |
isList() |
boolean |
isMap() |
boolean |
isMapEntry() |
boolean |
isNestedProperty()
Gets the value of the property nestedProperty.
|
String |
isNull() |
boolean |
isNullPathPossible() |
boolean |
isNullPossible() |
boolean |
isOptional() |
boolean |
isPrimitive() |
protected static boolean |
isPrimitiveLiteral(String expr,
Type<?> type) |
boolean |
isReadable() |
boolean |
isSet() |
boolean |
isValidPropertyReference(PropertyResolverStrategy resolver)
Returns true if this VariableRef represents a valid property reference,
or is not a property
|
boolean |
isWrapper() |
Type<?> |
mapKeyType() |
Type<?> |
mapValueType() |
String |
name() |
String |
notNull() |
String |
notNull(boolean includePath) |
String |
owner() |
String |
pathNotNull()
Return Java code which avoids a NullPointerException when accessing this
variable reference; if it is not backed by a nested property, this method
returns the empty string.
|
String |
pathNull()
Return Java code which checks if this path is null;
if it is not backed by a nested property, this method
returns the empty string.
|
String |
primitiveType() |
String |
primitiveType(Class<?> clazz) |
Property |
property() |
Class<?> |
rawType() |
void |
setConverter(Converter<?,?> converter) |
void |
setFilter(Filter<?,?> filter) |
void |
setNullImpossible()
Used to mark that this variable can not possibly be null at the
current state within code (because null has already been checked)
|
void |
setNullPathImpossible()
Used to mark that this variable can not possibly be null at the
current state within code (because null has already been checked)
|
void |
setOwner(VariableRef owner) |
protected String |
setter() |
String |
size()
Generates java code for a reference to the "size" of this VariableRef
|
String |
toString() |
Type<?> |
type() |
String |
typeName() |
String |
validVariableName() |
String |
wrapperTypeName() |
public boolean isNestedProperty
protected String name
public VariableRef(Property property, VariableRef anchor)
public void setConverter(Converter<?,?> converter)
public Converter<?,?> getConverter()
public Filter<?,?> getFilter()
public void setFilter(Filter<?,?> filter)
public void setOwner(VariableRef owner)
public VariableRef getOwner()
protected String getter()
protected String setter()
public boolean isReadable()
public boolean isAssignable()
public Class<?> rawType()
public Property property()
public Type<?> type()
public boolean isOptional()
public boolean isPrimitive()
public boolean isArray()
public boolean isCollection()
public boolean isList()
public boolean isSet()
public boolean isMap()
public boolean isMapEntry()
public boolean isWrapper()
public String wrapperTypeName()
public VariableRef elementRef(String name)
public String elementTypeName()
public Type<?> elementValueType()
public Type<?> elementType()
public Type<?> mapKeyType()
public Type<?> mapValueType()
public String typeName()
public String asWrapper()
public String assign(String value, Object... replacements)
value - replacements - public String assignIfPossible(String value, Object... replacements)
value - replacements - public String assignIfPossible(VariableRef value)
value - public String assign(VariableRef value)
value - public String cast(VariableRef ref)
public String cast(String value)
value - protected static String cast(String value, Type<?> type)
value - protected static String cast(VariableRef value, Type<?> type)
value - public String declare()
public String declare(String value, Object... args)
value - the value to assignargs - any replacement arguments to applied to value via
String.format()public String declare(VariableRef initialValueRef)
initialValueRef - the VariableRef instance which describes the
initial value of the receiverpublic boolean isDeclared()
public static String getDefaultValue(Class<?> clazz)
clazz - public String primitiveType()
public String owner()
public String name()
public String validVariableName()
public String isNull()
public String notNull()
public String notNull(boolean includePath)
public String ifNotNull()
public String ifNotNull(boolean includePath)
public String ifNull()
public boolean isNestedProperty()
public List<VariableRef> getPath()
public String assertType()
public String size()
protected static String getSetter(Property property, String variableExpression)
property - the Property for which to return the gettervariableExpression - the String value to use for the variable on which the getter
is calledpublic boolean isNullPossible()
public void setNullImpossible()
public boolean isNullPathPossible()
public void setNullPathImpossible()
public String pathNotNull()
public String pathNull()
public String ifPathNotNull()
public String ifPathNull()
public boolean isValidPropertyReference(PropertyResolverStrategy resolver)
resolver - Copyright © 2017 Glasnost. All Rights Reserved.