public abstract class PropertyResolver extends Object implements PropertyResolverStrategy
| Modifier and Type | Field and Description |
|---|---|
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 and Description |
|---|
PropertyResolver(boolean includePublicFields)
Creates a new PropertyResolver instance
|
| Modifier and Type | Method and Description |
|---|---|
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
|
boolean |
existsProperty(Type type,
String expr)
Determines whether a property matching the given expression exists
for the specified type.
|
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) |
public static final String ELEMENT_PROPERT_PREFIX
public static final String ELEMENT_PROPERT_SUFFIX
public PropertyResolver(boolean includePublicFields)
includePublicFields - whether public fields should be included as propertiespublic Map<String,Property> getProperties(Type theType)
PropertyResolverStrategygetProperties in interface PropertyResolverStrategytheType - the type for which to resolve propertiesprotected 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 evaluateprotected boolean isElementPropertyExpression(String expression)
expression - the expression to evaluateprotected boolean isIndividualElementExpression(String expression)
expression - the expression to evaluateprotected String[] splitNestedProperty(String propertyName)
propertyName - protected String[] splitElementProperty(String propertyName)
propertyName - public NestedProperty getNestedProperty(Type type, String p)
PropertyResolverStrategygetNestedProperty in interface PropertyResolverStrategyprotected 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)
PropertyResolverStrategygetProperty in interface PropertyResolverStrategypublic boolean existsProperty(Type type, String expr)
PropertyResolverStrategyexistsProperty in interface PropertyResolverStrategytype - the type to testpublic Property getProperty(Property owner, String expr)
PropertyResolverStrategygetProperty in interface PropertyResolverStrategyprotected 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 typeMappingException - if the expression cannot be resolved to a property for the
typeprotected boolean isInlinePropertyExpression(String expression)
expression - the expression to evaluatepublic 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 typeCopyright © 2016 Glasnost. All rights reserved.