}
return (T) obj;
}
public <T> T getResult(Object obj, Class<T> propertyClass, Element element) {
Parsing parsing = objectParsing.getParsing(propertyClass);
if (parsing == null) {
if (Person.class.isAssignableFrom(obj.getClass())) {
if ("constraints".equals(element.getName())) {
return (T) readConstraints(element);
} else if ("eventsMap".equals(element.getName())) {
Map map = FastMap.newInstance();
for (Object evEl : element.elements()) {
Element evElement = (Element) evEl;
long ref = getRef(evElement);
Role role = Role.valueOf(evElement.attributeValue("role"));
map.put(getObject(ref, Event.class), role);
}
return (T) map;
}
} else if (Event.class.isAssignableFrom(obj.getClass())) {
if ("constraints".equals(element.getName())) {
return (T) readConstraints(element);
} else if ("features".equals(element.getName())) {
return (T) readCollection(element, Feature.class);
}
// location already parsed via location->events
// persons already parsed via persons->events
} else if (Feature.class.isAssignableFrom(obj.getClass())) {
if ("constraints".equals(element.getName())) {
return (T) readConstraints(element);
}
} else if (Location.class.isAssignableFrom(obj.getClass())) {
if ("constraints".equals(element.getName())) {
return (T) readConstraints(element);
} else if ("events".equals(element.getName())) {
return (T) readCollection(element, Event.class);
} else if ("features".equals(element.getName())) {
return (T) readCollection(element, Feature.class);
}
}
throw new UnsupportedOperationException("No parsing found for property class "
+ propertyClass + " and object " + obj);
} else
return (T) parsing.parse(element.getText());
}