/** * Converts value as per appropriate DataType of the field. * * @param strValue * : string value of the object * @param field * : field of the attribute * @return */ public static Object value(String strValue, Field field) { checkNotNull(field); // if field is not primitive type if (field.getGenericType() instanceof ParameterizedType) { Class<?> clazz = (Class<?>) ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0]; // convert to list if (field.getType().equals(List.class)) return stringToList(strValue, clazz); // convert to set else if (field.getType().equals(Set.class)) return stringToSet(strValue, clazz); else throw new IllegalArgumentException( format("unsupported field-type %s for %s", field.getType(), field.getName())); } else { return convert(strValue, field.getType()); } }