IModelProperty prop = createValueProperty(ptype, pname, obj, pdata);
if(prop == null) {
// related one
if(IEntity.class.isAssignableFrom(ptype)) {
final RelationInfo ri = schemaInfo.getRelationInfo(entityClass, pname);
final boolean reference = ri.isReference();
if(shouldMarshalRelation(reference, depth, options)) {
final IEntity e = (IEntity) obj;
final Model m = e == null ? null : marshalEntity(e, options, visited, depth + 1);
final IEntityType etype =
ri.getRelatedType() == null ? null : etResolver.resolveEntityType(e == null ? ri.getRelatedType() : e
.entityClass());
prop = new RelatedOneProperty(etype, m, pname, reference);
}
}
// related many collection
else if(Collection.class.isAssignableFrom(ptype)) {
final RelationInfo ri = schemaInfo.getRelationInfo(entityClass, pname);
final boolean reference = ri.isReference();
if(shouldMarshalRelation(reference, depth, options)) {
List<Model> list = null;
if(obj != null) {
list = new ArrayList<Model>();
final Collection<IEntity> set = (Collection<IEntity>) obj;
for(final IEntity e : set) {
final Model nested = marshalEntity(e, options, visited, depth + 1);
list.add(nested);
}
}
prop = new RelatedManyProperty(etResolver.resolveEntityType(ri.getRelatedType()), pname, reference, list);
}
}
// map (assume <String, String> type)
else if(Map.class.isAssignableFrom(ptype)) {