Skip to content

Commit 9d5700b

Browse files
javier-godoypaodb
authored andcommitted
fix: check use of annotations in legacy framework versions
1 parent 0024383 commit 9d5700b

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/main/java/com/flowingcode/vaadin/jsonmigration/ClassInstrumentationUtil.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,21 +165,23 @@ private List<Method> getInstrumentableMethods(Class<?> parent) {
165165
return getDeclaredCallables(parent).filter(method -> {
166166
boolean isCallable = method.isAnnotationPresent(ClientCallable.class);
167167
boolean isLegacyCallable = method.isAnnotationPresent(LegacyClientCallable.class);
168+
boolean hasJsonValueReturn = JsonValue.class.isAssignableFrom(method.getReturnType());
169+
boolean hasJsonValueParams = hasJsonValueParameters(method);
170+
171+
if (isCallable && hasJsonValueParams) {
172+
throw new IllegalArgumentException(String.format(
173+
"Instrumented method '%s' in class '%s' has JsonValue arguments and must be annotated with @%s instead of @ClientCallable",
174+
method.getName(), method.getDeclaringClass(),
175+
LegacyClientCallable.class.getSimpleName()));
176+
}
168177

169178
if (hasLegacyVaadin()) {
170179
return isLegacyCallable;
171180
}
172181

173182
if (isCallable || isLegacyCallable) {
174-
boolean hasJsonValueReturn = JsonValue.class.isAssignableFrom(method.getReturnType());
175-
boolean hasJsonValueParams = hasJsonValueParameters(method);
176-
177-
if (isCallable && hasJsonValueParams) {
178-
throw new IllegalArgumentException(String.format(
179-
"Instrumented method '%s' in class '%s' has JsonValue arguments and must be annotated with @%s instead of @ClientCallable",
180-
method.getName(), method.getDeclaringClass().getName(),
181-
LegacyClientCallable.class.getName()));
182-
} else if (isCallable && hasJsonValueReturn) {
183+
184+
if (isCallable && hasJsonValueReturn) {
183185
return true;
184186
} else if (isLegacyCallable) {
185187
return true;

0 commit comments

Comments
 (0)