KEYCLOAK-12689 - Improvements for camelCase config properties
This commit is contained in:
parent
b7b78c87ca
commit
e6b4685659
1 changed files with 23 additions and 2 deletions
|
@ -104,10 +104,31 @@ public class MicroProfileConfigProvider implements Config.ConfigProvider {
|
|||
}
|
||||
|
||||
private <T> T getValue(String key, Class<T> clazz, T defaultValue) {
|
||||
T value = config.getOptionalValue(prefix + "." + key, clazz).orElse(defaultValue);
|
||||
return value;
|
||||
String property = prefix + "." + key;
|
||||
return config.getOptionalValue(toDashCase(property), clazz)
|
||||
.orElseGet(() -> config.getOptionalValue(property, clazz)
|
||||
.orElse(defaultValue));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static String toDashCase(String s) {
|
||||
|
||||
StringBuilder sb = new StringBuilder(s.length());
|
||||
boolean l = false;
|
||||
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char c = s.charAt(i);
|
||||
if (l && Character.isUpperCase(c)) {
|
||||
sb.append('-');
|
||||
c = Character.toLowerCase(c);
|
||||
l = false;
|
||||
} else {
|
||||
l = Character.isLowerCase(c);
|
||||
}
|
||||
sb.append(c);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue