Class TypeEdgeAdaptor

java.lang.Object
Services.Dependencies.TypeEdgeAdaptor
All Implemented Interfaces:
com.google.gson.JsonDeserializer<Edge>

public class TypeEdgeAdaptor extends Object implements com.google.gson.JsonDeserializer<Edge>
Custom Gson deserializer for Edge objects.

This class allows polymorphic deserialization of Edge subclasses based on the "type" field present in the JSON representation. Supported types include:

If an unknown type is encountered, a JsonParseException is thrown.

  • Constructor Details

    • TypeEdgeAdaptor

      public TypeEdgeAdaptor()
  • Method Details

    • deserialize

      public Edge deserialize(com.google.gson.JsonElement jsonElement, Type type, com.google.gson.JsonDeserializationContext jsonDeserializationContext) throws com.google.gson.JsonParseException
      Deserializes a JSON element into the appropriate Edge subclass based on its "type" field.
      Specified by:
      deserialize in interface com.google.gson.JsonDeserializer<Edge>
      Parameters:
      jsonElement - the JSON element to deserialize
      type - the type of the object to deserialize to (should be Edge)
      jsonDeserializationContext - the Gson context for deserialization
      Returns:
      the deserialized Edge subclass instance
      Throws:
      com.google.gson.JsonParseException - if the "type" field is missing or unknown