* @throws MappingException
* if the expression cannot be resolved to a property for the
* type
*/
protected Property getProperty(java.lang.reflect.Type type, String expr, boolean isNestedLookup, Property owner) throws MappingException {
Property property = null;
if (isSelfReferenceExpression(expr)) {
property = new Property.Builder().name("").getter("").setter(" = %s").type(TypeFactory.valueOf(type)).container(owner).build(this);
} else if (isNestedPropertyExpression(expr) && !isElementPropertyExpression(expr)) {
property = getNestedProperty(type, expr, owner);
} else if (isElementPropertyExpression(expr)) {
property = getElementProperty(type, expr, owner);
} else if (isIndividualElementExpression(expr)) {
property = getIndividualElementProperty(type, expr, owner);
} else {
// TODO: perhaps in-line properties should be isolated to a given
// ClassMapBuilder instance, rather than made available for other
// mappings
// of the class; can this cause problems?
Map<String, Property> inlinePoperties = inlinePropertiesCache.get(type);
if (inlinePoperties != null) {
property = inlinePoperties.get(expr);
}
if (property == null) {
Map<String, Property> properties = getProperties(type);
if (properties.containsKey(expr)) {
property = properties.get(expr);
} else if (isInlinePropertyExpression(expr)) {
property = resolveInlineProperty(type, expr);
if (property != null) {
synchronized (type) {
if (inlinePoperties == null) {
inlinePoperties = new HashMap<String, Property>(1);
inlinePropertiesCache.put(type, inlinePoperties);
}
inlinePoperties.put(property.getName(), property);
}
}
} else {
throw new MappingException(expr + " does not belong to " + type);
}