Class ScenarioStepComponentAdapter
java.lang.Object
pl.put.poznan.qualitychecker.logic.ScenarioStepComponentAdapter
- All Implemented Interfaces:
com.google.gson.JsonDeserializer<ScenarioStepComponent>,com.google.gson.JsonSerializer<ScenarioStepComponent>
public class ScenarioStepComponentAdapter
extends Object
implements com.google.gson.JsonDeserializer<ScenarioStepComponent>, com.google.gson.JsonSerializer<ScenarioStepComponent>
Custom Gson adapter for serializing and deserializing
ScenarioStepComponent objects.
This class implements both JsonDeserializer and JsonSerializer to handle
the conversion between JSON and ScenarioStepComponent subclasses.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondeserialize(com.google.gson.JsonElement json, Type typeOfT, com.google.gson.JsonDeserializationContext context) Deserializes JSON into aScenarioStepComponentobject.com.google.gson.JsonElementserialize(ScenarioStepComponent src, Type typeOfSrc, com.google.gson.JsonSerializationContext context) Serializes aScenarioStepComponentobject into its JSON representation.
-
Constructor Details
-
ScenarioStepComponentAdapter
public ScenarioStepComponentAdapter()
-
-
Method Details
-
deserialize
public ScenarioStepComponent deserialize(com.google.gson.JsonElement json, Type typeOfT, com.google.gson.JsonDeserializationContext context) throws com.google.gson.JsonParseException Deserializes JSON into aScenarioStepComponentobject. This method checks for the presence of the "substeps" field in the JSON object to determine whether to instantiate aScenarioStepCompositeorScenarioStepLeaf.- Specified by:
deserializein interfacecom.google.gson.JsonDeserializer<ScenarioStepComponent>- Parameters:
json- The JSON data being deserialized.typeOfT- The type of the Object to deserialize to.context- The deserialization context.- Returns:
- The deserialized
ScenarioStepComponentobject. - Throws:
com.google.gson.JsonParseException- If JSON is not in the expected format.
-
serialize
public com.google.gson.JsonElement serialize(ScenarioStepComponent src, Type typeOfSrc, com.google.gson.JsonSerializationContext context) Serializes aScenarioStepComponentobject into its JSON representation. This method checks the type of theScenarioStepComponentinstance and serializes it as either aScenarioStepCompositeorScenarioStepLeaf.- Specified by:
serializein interfacecom.google.gson.JsonSerializer<ScenarioStepComponent>- Parameters:
src- The source object to serialize.typeOfSrc- The actual type of the source object.context- The serialization context.- Returns:
- The serialized JSON element.
-