Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package com.flowingcode.vaadin.jsonmigration;

import com.vaadin.flow.component.ClientCallable;
import com.vaadin.flow.component.page.PendingJavaScriptResult;
import com.vaadin.flow.dom.DomEvent;
import com.vaadin.flow.dom.Element;
Expand Down Expand Up @@ -63,6 +64,18 @@ private static Class<?> lookup_BaseJsonNode() {
}
}

/**
* Converts a given Java object into the return type of a {@link ClientCallable method}.
*
* In Vaadin 25, this method converts {@code JsonValue} into {@code JsonNode}.
*
* @param object the object to convert
* @return an {@code Object} suitable to use as the result of a {@code ClientCallable} method.
*/
public static Object convertToClientCallableResult(Object object) {
return helper.convertToClientCallableResult(object);
}

/**
* Converts a given Java object into a {@code JsonValue}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ interface JsonMigrationHelper {

JsonValue convertToJsonValue(Object object);

Object convertToClientCallableResult(Object object);

Object invoke(Method method, Object instance, Object... args);

ElementalPendingJavaScriptResult convertPendingJavaScriptResult(PendingJavaScriptResult result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ public JsonValue convertToJsonValue(Object object) {
}
}

@Override
public Object convertToClientCallableResult(Object object) {
if (object instanceof JsonValue) {
return convertToJsonNode((JsonValue) object);
} else {
return object;
}
}

@Override
@SneakyThrows
public Object invoke(Method method, Object instance, Object... args) {
Expand Down
Loading