diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeElementMembers.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeElementMembers.java index 8d542b3c2c..d7b073e711 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeElementMembers.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeElementMembers.java @@ -171,21 +171,17 @@ class TypeElementMembers { if (this.isRecord && this.fields.containsKey(methodName)) { return methodName; } - String name; if (methodName.startsWith("is")) { - name = methodName.substring(2); + return lowerCaseFirstCharacter(methodName.substring(2)); } - else if (methodName.startsWith("get")) { - name = methodName.substring(3); + if (methodName.startsWith("get") || methodName.startsWith("set")) { + return lowerCaseFirstCharacter(methodName.substring(3)); } - else if (methodName.startsWith("set")) { - name = methodName.substring(3); - } - else { - throw new AssertionError("methodName must start with 'is', 'get' or 'set', was '" + methodName + "'"); - } - name = Character.toLowerCase(name.charAt(0)) + name.substring(1); - return name; + throw new IllegalStateException("methodName must start with 'is', 'get' or 'set', was '" + methodName + "'"); + } + + private String lowerCaseFirstCharacter(String string) { + return Character.toLowerCase(string.charAt(0)) + string.substring(1); } private void processField(VariableElement field) {