Class JsonMigration

java.lang.Object
com.flowingcode.vaadin.jsonmigration.JsonMigration

public class JsonMigration extends Object
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 Details

    • JsonMigration

      public JsonMigration()
  • Method Details

    • convertToJsonValue

      public static elemental.json.JsonValue convertToJsonValue(Object object)
      Converts a given Java object into a JsonValue.

      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 JsonValue representation of the object
    • setPropertyJson

      public static void setPropertyJson(Element element, String name, elemental.json.JsonValue json)
      Sets a JSON-valued property on a given Element, transparently handling version-specific method signatures.

      This method uses reflection to call the appropriate setPropertyJson method on the Element class, which has a different signature for its JSON parameter in library versions before and after Vaadin 25.

      Parameters:
      element - the Element on which to set the property
      name - the name of the property to set
      json - the JsonValue to be set as the property's value
    • getEventData

      public static elemental.json.JsonObject getEventData(DomEvent event)
      Gets additional data related to the event.
      Parameters:
      event - the DomEvent from which to retrieve the data
      Returns:
      a JSON object containing event data, never null
      See Also: