use of org.apache.apex.malhar.lib.util.PojoUtils.SetterShort in project apex-malhar by apache.
the class RedisPOJOInputOperator method convertMapToObject.
@SuppressWarnings("unchecked")
private Object convertMapToObject(Map<String, String> tuple) {
try {
Object mappedObject = objectClass.newInstance();
for (int i = 0; i < dataColumns.size(); i++) {
final SupportType type = dataColumns.get(i).getType();
final String columnName = dataColumns.get(i).getColumnName();
if (i < setters.size()) {
String value = tuple.get(columnName);
switch(type) {
case STRING:
((Setter<Object, String>) setters.get(i)).set(mappedObject, value);
break;
case BOOLEAN:
((SetterBoolean) setters.get(i)).set(mappedObject, Boolean.parseBoolean(value));
break;
case SHORT:
((SetterShort) setters.get(i)).set(mappedObject, Short.parseShort(value));
break;
case INTEGER:
((SetterInt) setters.get(i)).set(mappedObject, Integer.parseInt(value));
break;
case LONG:
((SetterLong) setters.get(i)).set(mappedObject, Long.parseLong(value));
break;
case FLOAT:
((SetterFloat) setters.get(i)).set(mappedObject, Float.parseFloat(value));
break;
case DOUBLE:
((SetterDouble) setters.get(i)).set(mappedObject, Double.parseDouble(value));
break;
default:
break;
}
}
}
return mappedObject;
} catch (Exception e) {
DTThrowable.wrapIfChecked(e);
}
return null;
}
Aggregations