|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectma.glasnost.orika.impl.generator.VariableRef
public class VariableRef
VariableRef represents a reference to a given variable or property; it contains various helper methods to properly set it's value and interrogate it's underlying property or type. It also returns a properly type-safe cast of it as the toString() method, so it can safely be used directly as a replacement parameter for source code statements.
| Field Summary | |
|---|---|
protected String |
name
|
| Constructor Summary | |
|---|---|
VariableRef(Property property,
String name)
|
|
VariableRef(Property property,
VariableRef anchor)
|
|
VariableRef(Type<?> type,
String name)
|
|
| Method Summary | |
|---|---|
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 ref)
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 |
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 |
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. |
boolean |
isArray()
|
boolean |
isAssignable()
|
boolean |
isCollection()
|
boolean |
isDeclared()
|
String |
isInstanceOf(Type<?> type)
|
boolean |
isList()
|
boolean |
isMap()
|
boolean |
isMapEntry()
|
boolean |
isNestedProperty()
|
String |
isNull()
|
boolean |
isPrimitive()
|
protected static boolean |
isPrimitiveLiteral(String expr,
Type<?> type)
|
boolean |
isReadable()
|
boolean |
isSet()
|
boolean |
isWrapper()
|
Type<?> |
mapKeyType()
|
Type<?> |
mapValueType()
|
String |
name()
|
String |
notNull()
|
String |
owner()
|
String |
primitiveType()
|
String |
primitiveType(Class<?> clazz)
|
Property |
property()
|
Class<?> |
rawType()
|
void |
setConverter(Converter<?,?> converter)
|
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 |
wrapperTypeName()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected String name
| Constructor Detail |
|---|
public VariableRef(Property property,
String name)
public VariableRef(Property property,
VariableRef anchor)
public VariableRef(Type<?> type,
String name)
| Method Detail |
|---|
public void setConverter(Converter<?,?> converter)
public Converter<?,?> getConverter()
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 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 - replacements -
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 ref)
value - the value to assignargs - any replacement arguments to applied to value via
String.format()
public boolean isDeclared()
public static String getDefaultValue(Class<?> clazz)
clazz -
public String primitiveType()
public String primitiveType(Class<?> clazz)
public String owner()
public String name()
public String isNull()
public String notNull()
public String ifNotNull()
public String ifNull()
public String toString()
toString in class Objectpublic boolean isNestedProperty()
public List<VariableRef> getPath()
public String assertType()
public String size()
protected static String getGetter(Property property,
String variableExpression)
public String isInstanceOf(Type<?> type)
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 called
public String ifPathNotNull()
protected static boolean isPrimitiveLiteral(String expr,
Type<?> type)
public int hashCode()
hashCode in class Objectpublic boolean equals(Object obj)
equals in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||