in java/amazon-kinesis-producer/src/main/java/com/amazonaws/services/kinesis/producer/_ConfigTemplate.java [197:229]
public static _ConfigTemplate fromProperties(Properties props) {
_ConfigTemplate config = new _ConfigTemplate();
Enumeration<?> propNames = props.propertyNames();
while (propNames.hasMoreElements()) {
boolean found = false;
String key = propNames.nextElement().toString();
String value = props.getProperty(key);
for (Method method : _ConfigTemplate.class.getMethods()) {
if (method.getName().equals("set" + key)) {
found = true;
Class<?> type = method.getParameterTypes()[0];
try {
if (type == long.class) {
method.invoke(config, Long.valueOf(value));
} else if (type == boolean.class) {
method.invoke(config, Boolean.valueOf(value));
} else if (type == String.class) {
method.invoke(config, value);
}
} catch (Exception e) {
throw new IllegalArgumentException(
String.format("Error trying to set field %s with the value '%s'", key, value), e);
}
}
}
if (!found) {
log.warn("Property " + key + " ignored as there is no corresponding set method in " +
_ConfigTemplate.class.getSimpleName());
}
}
return config;
}