Class JsonMigration
java.lang.Object
com.flowingcode.vaadin.jsonmigration.JsonMigration
Provides a compatibility layer for JSON handling to abstract away breaking changes
introduced in Vaadin version 25.
This utility class detects the runtime version and uses version-specific helpers to ensure that code calling its methods does not need to be aware of underlying Vaadin API changes.
- Author:
- Javier Godoy
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic elemental.json.JsonValueconvertToJsonValue(Object object) Converts a given Java object into aJsonValue.static voidsetPropertyJson(Element element, String name, elemental.json.JsonValue json) Sets a JSON-valued property on a givenElement, transparently handling version-specific method signatures.
-
Constructor Details
-
JsonMigration
public JsonMigration()
-
-
Method Details
-
convertToJsonValue
Converts a given Java object into aJsonValue.This method delegates the conversion to a version-specific helper to handle any differences in the serialization process.
- Parameters:
object- the object to convert- Returns:
- the
JsonValuerepresentation of the object
-
setPropertyJson
Sets a JSON-valued property on a givenElement, transparently handling version-specific method signatures.This method uses reflection to call the appropriate
setPropertyJsonmethod on theElementclass, which has a different signature for its JSON parameter in library versions before and after Vaadin 25.- Parameters:
element- theElementon which to set the propertyname- the name of the property to setjson- theJsonValueto be set as the property's value
-