|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectma.glasnost.orika.property.PropertyResolver
public abstract class PropertyResolver
PropertyResolver defines the core functionality for resolving properties; specific PropertyResolverStrategy implementations should extend from this class, implementing the 'collectProperties' method.
| Field Summary | |
|---|---|
static String |
ELEMENT_PROPERT_PREFIX
The prefix used to begin a nested element property |
static String |
ELEMENT_PROPERT_SUFFIX
The suffix used to complete a nested element property |
| Constructor Summary | |
|---|---|
PropertyResolver(boolean includePublicFields)
Creates a new PropertyResolver instance |
|
| Method Summary | |
|---|---|
protected String |
capitalize(String string)
Convert the first character of the provided string to uppercase. |
protected abstract void |
collectProperties(Class<?> type,
Type<?> referenceType,
Map<String,Property> properties)
Collects all properties for the specified type. |
protected void |
collectPublicFieldProperties(Type<?> referenceType,
Map<String,Property> properties)
Add public non-static fields as properties |
Property |
getElementProperty(Type type,
String p)
|
Property |
getElementProperty(Type type,
String p,
Property owner)
|
Property |
getIndividualElementProperty(Type type,
String p,
Property owner)
|
NestedProperty |
getNestedProperty(Type type,
String p)
Resolves a nested property for the provided type, based on the specified property expression (a sequence property names qualified by '.'). |
protected NestedProperty |
getNestedProperty(Type type,
String p,
Property owner)
|
Map<String,Property> |
getProperties(Type theType)
Collects and returns the (mappable) properties for the given type. |
Property |
getProperty(Property owner,
String expr)
Resolves a property for the specified type; nested and dynamically defined properties should be handled automatically. |
Property |
getProperty(Type type,
String expr)
Resolves a property for the specified type; nested and dynamically defined properties should be handled automatically. |
protected Property |
getProperty(Type type,
String expr,
boolean isNestedLookup,
Property owner)
Resolves the specified property expression |
protected boolean |
hasTypeParameters(Class<?> type)
Tests whether the specified class has type parameters either on itself or on it's super-class or declared interfaces |
protected boolean |
isElementPropertyExpression(String expression)
Determines whether the provided string is a valid element property expression |
protected boolean |
isIndividualElementExpression(String expression)
Determines whether the provided string is a valid element property expression |
protected boolean |
isInlinePropertyExpression(String expression)
Determines whether the provided string is a valid in-line property expression |
protected boolean |
isNestedPropertyExpression(String expression)
Determines whether the provided string is a valid nested property expression |
protected Property |
processProperty(String propertyName,
Class<?> propertyType,
Method readMethod,
Method writeMethod,
Class<?> owningType,
Type<?> referenceType,
Map<String,Property> properties)
Processes a property, adding it to the map of properties for the owning type being processed |
Property |
resolveInlineProperty(Type type,
String expr)
Resolves in-line properties, which are defined with the following format: "name{getterName|setterName|type=typeName}". Setter name can be omitted, as well as type name; if getter name is omitted, then setter name must be preceded by '|', like so: "name{|setterName|type=typeName}", or like "name{|setterName}". |
Type<?> |
resolvePropertyType(Method readMethod,
Class<?> rawType,
Class<?> owningType,
Type<?> referenceType)
Resolves the type of a property from the provided input factors. |
protected String[] |
splitElementProperty(String propertyName)
|
protected String[] |
splitNestedProperty(String propertyName)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String ELEMENT_PROPERT_PREFIX
public static final String ELEMENT_PROPERT_SUFFIX
| Constructor Detail |
|---|
public PropertyResolver(boolean includePublicFields)
includePublicFields - whether public fields should be included as properties| Method Detail |
|---|
public Map<String,Property> getProperties(Type theType)
PropertyResolverStrategy
getProperties in interface PropertyResolverStrategytheType - the type for which to resolve properties
protected String capitalize(String string)
string -
protected Property processProperty(String propertyName,
Class<?> propertyType,
Method readMethod,
Method writeMethod,
Class<?> owningType,
Type<?> referenceType,
Map<String,Property> properties)
propertyName - the name of the propertypropertyType - the Class of the propertyreadMethod - the read method for the propertywriteMethod - the write method for the propertyowningType - the owning type for which the properties are being resolvedreferenceType - a reference type to be used for resolving generic parametersproperties - protected boolean hasTypeParameters(Class<?> type)
type -
public Type<?> resolvePropertyType(Method readMethod,
Class<?> rawType,
Class<?> owningType,
Type<?> referenceType)
readMethod - rawType - owningType - referenceType -
protected void collectPublicFieldProperties(Type<?> referenceType,
Map<String,Property> properties)
referenceType - the type for which to collect public field propertiesproperties - the collected properties for this typeprotected boolean isNestedPropertyExpression(String expression)
expression - the expression to evaluate
protected boolean isElementPropertyExpression(String expression)
expression - the expression to evaluate
protected boolean isIndividualElementExpression(String expression)
expression - the expression to evaluate
protected String[] splitNestedProperty(String propertyName)
propertyName -
protected String[] splitElementProperty(String propertyName)
propertyName -
public NestedProperty getNestedProperty(Type type,
String p)
PropertyResolverStrategy
getNestedProperty in interface PropertyResolverStrategy
protected NestedProperty getNestedProperty(Type type,
String p,
Property owner)
type - p - owner -
public Property getElementProperty(Type type,
String p)
type - p -
public Property getElementProperty(Type type,
String p,
Property owner)
type - p -
public Property getIndividualElementProperty(Type type,
String p,
Property owner)
type - p -
public Property getProperty(Type type,
String expr)
PropertyResolverStrategy
getProperty in interface PropertyResolverStrategy
public Property getProperty(Property owner,
String expr)
PropertyResolverStrategy
getProperty in interface PropertyResolverStrategy
protected Property getProperty(Type type,
String expr,
boolean isNestedLookup,
Property owner)
throws MappingException
type - the property's owning typeexpr - the property expression to resolveproperties - the known properties for the type
MappingException - if the expression cannot be resolved to a property for the
typeprotected boolean isInlinePropertyExpression(String expression)
expression - the expression to evaluate
public Property resolveInlineProperty(Type type,
String expr)
type - expr -
protected abstract void collectProperties(Class<?> type,
Type<?> referenceType,
Map<String,Property> properties)
type - the type for which to collect propertiesreferenceType - the reference type for use in resolving generic parameters as
neededproperties - the properties collected for the current type
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||