use of com.tvd12.dahlia.core.data.DataType in project dahlia by youngmonkeys.
the class LocalCollectionSettingReader method readFieldArraySetting.
protected FieldSetting readFieldArraySetting(JSONObject setting) {
FieldArraySetting field = new FieldArraySetting();
if (setting.has(SettingFields.MAX_SIZE))
field.setMaxSize(setting.getInt(SettingFields.MAX_SIZE));
if (setting.has(SettingFields.ITEM)) {
JSONObject itemSetting = setting.getJSONObject(SettingFields.ITEM);
DataType itemType = null;
if (itemSetting.has(SettingFields.TYPE))
itemType = DataType.valueOfName(itemSetting.getString(SettingFields.TYPE));
else
throw new IllegalArgumentException("item 'type' is required");
FieldSetting item = readFieldSetting(itemType, itemSetting);
field.setItem(item);
} else {
throw new IllegalArgumentException("'item' field is required");
}
return field;
}
use of com.tvd12.dahlia.core.data.DataType in project dahlia by youngmonkeys.
the class SettingObjectToFields method toSetting.
public FieldSetting toSetting(EzyObject object) {
DataType type = DataType.valueOf(object.get(SettingFields.TYPE));
SettingObjectToField mapper = mappers.get(type);
FieldSetting answer = mapper.toSetting(this, object);
return answer;
}
use of com.tvd12.dahlia.core.data.DataType in project dahlia by youngmonkeys.
the class LocalCollectionSettingReader method readFieldSettings.
protected Map<String, FieldSetting> readFieldSettings(JSONObject settings) {
Map<String, FieldSetting> answer = new HashMap<>();
for (String fieldName : settings.keySet()) {
JSONObject setting = settings.getJSONObject(fieldName);
DataType type = null;
if (setting.has(SettingFields.TYPE))
type = DataType.valueOfName(setting.getString(SettingFields.TYPE));
else
throw new IllegalArgumentException("'type' is required at field: " + fieldName);
answer.put(fieldName, readFieldSetting(type, setting));
}
return answer;
}
Aggregations