All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alibaba.dashscope.threads.runs.StepDetailDeserializer Maven / Gradle / Ivy

The newest version!
package com.alibaba.dashscope.threads.runs;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import java.lang.reflect.Type;

public class StepDetailDeserializer implements JsonDeserializer {

  @Override
  public Object deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
      throws JsonParseException {
    String typeName = json.getAsJsonObject().get("type").getAsString();
    Type type = StepDetailBase.getStepDetailClass(typeName);
    if (type == null) {
      return json.toString();
    }
    return context.deserialize(json, type);
  }
}