|
15 | 15 | */ |
16 | 16 | package org.openrewrite.java.migrate.lombok; |
17 | 17 |
|
18 | | -import com.google.common.collect.ImmutableMap; |
19 | 18 | import lombok.AccessLevel; |
20 | 19 | import org.jspecify.annotations.Nullable; |
21 | 20 | import org.openrewrite.internal.StringUtils; |
22 | 21 | import org.openrewrite.java.tree.Expression; |
23 | 22 | import org.openrewrite.java.tree.J; |
24 | 23 | import org.openrewrite.java.tree.JavaType; |
25 | 24 |
|
26 | | -import java.util.Collection; |
27 | | -import java.util.Map; |
28 | | - |
29 | 25 | import static lombok.AccessLevel.*; |
30 | 26 | import static org.openrewrite.java.tree.J.Modifier.Type.*; |
31 | 27 |
|
@@ -87,17 +83,15 @@ private static String deriveGetterMethodName(@Nullable JavaType type, String fie |
87 | 83 | return "get" + StringUtils.capitalize(fieldName); |
88 | 84 | } |
89 | 85 |
|
90 | | - static AccessLevel getAccessLevel(Collection<J.Modifier> modifiers) { |
91 | | - Map<J.Modifier.Type, AccessLevel> map = ImmutableMap.<J.Modifier.Type, AccessLevel>builder() |
92 | | - .put(Public, PUBLIC) |
93 | | - .put(Protected, PROTECTED) |
94 | | - .put(Private, PRIVATE) |
95 | | - .build(); |
96 | | - |
97 | | - return modifiers.stream() |
98 | | - .map(modifier -> map.getOrDefault(modifier.getType(), AccessLevel.NONE)) |
99 | | - .filter(a -> a != AccessLevel.NONE) |
100 | | - .findAny().orElse(AccessLevel.PACKAGE); |
| 86 | + static AccessLevel getAccessLevel(J.MethodDeclaration modifiers) { |
| 87 | + if (modifiers.hasModifier(Public)) { |
| 88 | + return PUBLIC; |
| 89 | + } else if (modifiers.hasModifier(Protected)) { |
| 90 | + return PROTECTED; |
| 91 | + } else if (modifiers.hasModifier(Private)) { |
| 92 | + return PRIVATE; |
| 93 | + } |
| 94 | + return PACKAGE; |
101 | 95 | } |
102 | 96 |
|
103 | 97 | } |
0 commit comments