in src/main/java/com/googlesource/gerrit/plugins/rabbitmq/config/section/Sections.java [60:82]
public static <T extends Section> Config toConfig(T section, Config config) {
Field[] fs = section.getClass().getFields();
for (Field f : fs) {
try {
Class<?> type = f.getType();
Object obj = f.get(section);
if (obj != null) {
if (type == String.class) {
config.setString(getName(section), null, f.getName(), String.class.cast(obj));
} else if (type == Integer.class) {
config.setInt(getName(section), null, f.getName(), Integer.class.cast(obj));
} else if (type == Long.class) {
config.setLong(getName(section), null, f.getName(), Long.class.cast(obj));
} else if (type == Boolean.class) {
config.setBoolean(getName(section), null, f.getName(), Boolean.class.cast(obj));
}
}
} catch (IllegalAccessException ex) {
LOGGER.warn("Cannot access field {}. Cause: {}", f.getName(), ex.getMessage());
}
}
return config;
}