in ratis-common/src/main/java/org/apache/ratis/conf/ConfUtils.java [376:403]
static void printField(Class<?> confClass, Consumer<Object> out, Field f) {
final int modifiers = f.getModifiers();
if (!Modifier.isStatic(modifiers)) {
throw new IllegalStateException("Found non-static field " + f);
}
if (!Modifier.isFinal(modifiers)) {
throw new IllegalStateException("Found non-final field " + f);
}
if (printKey(confClass, out, f, "KEY", "DEFAULT", ConfUtils::append)) {
return;
}
if (printKey(confClass, out, f, "PARAMETER", "CLASS",
(b, classField) -> b.append(classField.get(null)))) {
return;
}
final String fieldName = f.getName();
if ("LOG".equals(fieldName) || "$jacocoData".equals(fieldName)) {
return;
}
if (!"PREFIX".equals(fieldName)) {
throw new IllegalStateException("Unexpected field: " + fieldName);
}
try {
out.accept("constant: " + fieldName + " = " + f.get(null));
} catch (IllegalAccessException e) {
throw new IllegalStateException("Failed to access " + f, e);
}
}