ParameterizedType pt = (ParameterizedType) field.getGenericType();
Class<?> cl = (Class<?>) pt.getActualTypeArguments()[0];
Aggregated agg = field.getAnnotation(Aggregated.class);
Filter filter = field.getAnnotation(Filter.class);
Owned related = field.getAnnotation(Owned.class);
if((agg!=null && filter!=null) || (agg!=null && related!=null)){
throw new SienaException("Found One<T> field "
+ c.getName()+"."+field.getName()
+ "with @Filter+@Aggregated or @Filter+@Owned: this is not authorized");
}
if(agg != null){
try {
Map<FieldMapKeys, Object> fieldMap = new HashMap<FieldMapKeys, Object>();
fieldMap.put(FieldMapKeys.CLASS, cl);
fieldMap.put(FieldMapKeys.MODE, RelationMode.AGGREGATION);
oneFieldMap.put(field, fieldMap);
aggregatedFields.add(field);
hasAggregatedFields = true;
} catch (Exception e) {
throw new SienaException(e);
}
}else if(filter != null){
try {
Field filterField = cl.getField(filter.value());
if(filterField == null){
throw new SienaException("@Filter error: Couldn't find field "
+ filter.value()
+ "in class "+cl.getName());
}
Map<FieldMapKeys, Object> fieldMap = new HashMap<FieldMapKeys, Object>();
fieldMap.put(FieldMapKeys.CLASS, cl);
fieldMap.put(FieldMapKeys.MODE, RelationMode.RELATION);
fieldMap.put(FieldMapKeys.FIELD, filterField);
fieldMap.put(FieldMapKeys.FILTER, filter.value());
oneFieldMap.put(field, fieldMap);
ownedFields.add(field);
hasOwnedFields = true;
} catch (Exception e) {
throw new SienaException(e);
}
}else if(related != null) {
String as = related.mappedBy();
// if related.as not specified, tries to find the first field with this type
if("".equals(as) || as == null){
ClassInfo fieldInfo = ClassInfo.getClassInfo(cl);
Field f = fieldInfo.getFirstFieldFromType(clazz);
if(f == null){