Class EdgeAdapterFactory

java.lang.Object
Services.Dependencies.EdgeAdapterFactory
All Implemented Interfaces:
com.google.gson.TypeAdapterFactory

public class EdgeAdapterFactory extends Object implements com.google.gson.TypeAdapterFactory
Custom Gson TypeAdapterFactory to handle runtime conversion of Edge objects.

This factory creates a TypeAdapter that deserializes JSON into the correct subclass of Edge based on the type property in the JSON:

  • Constructor Details

    • EdgeAdapterFactory

      public EdgeAdapterFactory()
  • Method Details

    • create

      public <T> com.google.gson.TypeAdapter<T> create(com.google.gson.Gson gson, com.google.gson.reflect.TypeToken<T> type)
      Creates a custom TypeAdapter for Edge objects.
      Specified by:
      create in interface com.google.gson.TypeAdapterFactory
      Type Parameters:
      T - generic type
      Parameters:
      gson - Gson instance
      type - the type to be adapted
      Returns:
      a TypeAdapter for Edge and its subclasses, or null if not applicable