Skip to content

Commit 470a255

Browse files
committed
Polish
1 parent 7c508fa commit 470a255

File tree

1 file changed

+8
-12
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor

1 file changed

+8
-12
lines changed

spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeElementMembers.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,21 +171,17 @@ private String getAccessorName(String methodName) {
171171
if (this.isRecord && this.fields.containsKey(methodName)) {
172172
return methodName;
173173
}
174-
String name;
175174
if (methodName.startsWith("is")) {
176-
name = methodName.substring(2);
175+
return lowerCaseFirstCharacter(methodName.substring(2));
177176
}
178-
else if (methodName.startsWith("get")) {
179-
name = methodName.substring(3);
177+
if (methodName.startsWith("get") || methodName.startsWith("set")) {
178+
return lowerCaseFirstCharacter(methodName.substring(3));
180179
}
181-
else if (methodName.startsWith("set")) {
182-
name = methodName.substring(3);
183-
}
184-
else {
185-
throw new AssertionError("methodName must start with 'is', 'get' or 'set', was '" + methodName + "'");
186-
}
187-
name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
188-
return name;
180+
throw new IllegalStateException("methodName must start with 'is', 'get' or 'set', was '" + methodName + "'");
181+
}
182+
183+
private String lowerCaseFirstCharacter(String string) {
184+
return Character.toLowerCase(string.charAt(0)) + string.substring(1);
189185
}
190186

191187
private void processField(VariableElement field) {

0 commit comments

Comments
 (0)