use of com.eden.orchid.api.theme.components.ModularList in project Orchid by JavaEden.
the class ModularListOptionExtractor method getDefaultValue.
@Override
public ModularList getDefaultValue(Field field) {
OrchidContext context = contextProvider.get();
ModularList modularList = (ModularList) context.resolve(field.getType());
modularList.initialize(context, new ArrayList<>());
return modularList;
}
use of com.eden.orchid.api.theme.components.ModularList in project Orchid by JavaEden.
the class ModularListOptionExtractor method getOption.
@Override
public ModularList getOption(Field field, Object sourceObject, String key) {
OrchidContext context = contextProvider.get();
final String typeKey;
final String valueKey;
if (field.isAnnotationPresent(ImpliedKey.class)) {
ImpliedKey impliedKey = field.getAnnotation(ImpliedKey.class);
typeKey = impliedKey.typeKey();
valueKey = impliedKey.valueKey();
} else {
typeKey = null;
valueKey = null;
}
Iterable iterable = iterableConverter.convert(field.getType(), sourceObject, typeKey, valueKey).second;
List<Map<String, Object>> jsonArray = new ArrayList<>();
for (Object o : iterable) {
Map<String, Object> map = (Map<String, Object>) mapConverter.convert(field.getType(), o).second;
jsonArray.add(map);
}
if (jsonArray.size() > 0) {
ModularList modularList = (ModularList) contextProvider.get().resolve(field.getType());
modularList.initialize(context, jsonArray);
return modularList;
}
return null;
}
Aggregations