Package Services.Dependencies
Class TypeFromNodeAdaptor
java.lang.Object
Services.Dependencies.TypeFromNodeAdaptor
- All Implemented Interfaces:
com.google.gson.JsonDeserializer<MyNode>
Custom Gson deserializer for
MyNode objects.
This deserializer handles polymorphic deserialization based on the
presence of specific fields in the JSON. If the JSON object contains
the field "ignorefirstLine", it is deserialized as a CSVNode;
otherwise, it is deserialized as a regular MyNode.
This is useful for converting JSON representations of nodes in a dependency graph where some nodes may represent CSV data.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondeserialize(com.google.gson.JsonElement jsonElement, Type type, com.google.gson.JsonDeserializationContext jsonDeserializationContext)
-
Constructor Details
-
TypeFromNodeAdaptor
public TypeFromNodeAdaptor()
-
-
Method Details
-
deserialize
public MyNode deserialize(com.google.gson.JsonElement jsonElement, Type type, com.google.gson.JsonDeserializationContext jsonDeserializationContext) throws com.google.gson.JsonParseException Deserializes a JSON element into either aMyNodeorCSVNodedepending on the presence of the "ignorefirstLine" field.- Specified by:
deserializein interfacecom.google.gson.JsonDeserializer<MyNode>- Parameters:
jsonElement- the JSON element to deserializetype- the type of the object to deserialize to (should beMyNode)jsonDeserializationContext- the Gson context for deserialization- Returns:
- the deserialized
MyNodeorCSVNodeinstance - Throws:
com.google.gson.JsonParseException- if deserialization fails
-