Skip to content

Commit 0356976

Browse files
committed
Move down variable and method closer to usage
1 parent a118477 commit 0356976

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/java/org/openrewrite/java/migrate/lombok/LombokUtils.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ private static String deriveGetterMethodName(@Nullable JavaType type, String fie
8383
return "get" + StringUtils.capitalize(fieldName);
8484
}
8585

86-
private static boolean hasMatchingSetterMethodName(J.MethodDeclaration method, String simpleName) {
87-
return method.getSimpleName().equals("set" + StringUtils.capitalize(simpleName));
88-
}
89-
9086
static boolean isSetter(J.MethodDeclaration method) {
9187
// Check return type: void
9288
if (method.getType() != JavaType.Primitive.Void) {
@@ -102,7 +98,6 @@ static boolean isSetter(J.MethodDeclaration method) {
10298
!(method.getBody().getStatements().get(0) instanceof J.Assignment)) {
10399
return false;
104100
}
105-
JavaType.FullyQualified declaringType = method.getMethodType().getDeclaringType();
106101

107102
// Method parameter
108103
J.VariableDeclarations variableDeclarations = (J.VariableDeclarations) method.getParameters().get(0);
@@ -116,6 +111,7 @@ static boolean isSetter(J.MethodDeclaration method) {
116111
}
117112

118113
// Method name has to match
114+
JavaType.FullyQualified declaringType = method.getMethodType().getDeclaringType();
119115
if (variable instanceof J.Identifier) {
120116
J.Identifier assignedVar = (J.Identifier) variable;
121117
if (hasMatchingSetterMethodName(method, assignedVar.getSimpleName())) {
@@ -135,6 +131,10 @@ static boolean isSetter(J.MethodDeclaration method) {
135131
return false;
136132
}
137133

134+
private static boolean hasMatchingSetterMethodName(J.MethodDeclaration method, String simpleName) {
135+
return method.getSimpleName().equals("set" + StringUtils.capitalize(simpleName));
136+
}
137+
138138
static AccessLevel getAccessLevel(J.MethodDeclaration methodDeclaration) {
139139
if (methodDeclaration.hasModifier(Public)) {
140140
return PUBLIC;

0 commit comments

Comments
 (0)