/*
 * 支付宝开放平台API
 * 支付宝开放平台v3协议文档
 *
 * The version of the OpenAPI document: 2023-08-14
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


package com.alipay.v3.model;

import java.util.Objects;
import java.util.Arrays;
import com.alipay.v3.model.ConversionProperty;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import com.alipay.v3.JSON;

/**
 * ConversionData
 */
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class ConversionData {
  public static final String SERIALIZED_NAME_BIZ_NO = "biz_no";
  @SerializedName(SERIALIZED_NAME_BIZ_NO)
  private String bizNo;

  public static final String SERIALIZED_NAME_CALLBACK_EXT_INFO = "callback_ext_info";
  @SerializedName(SERIALIZED_NAME_CALLBACK_EXT_INFO)
  private String callbackExtInfo;

  public static final String SERIALIZED_NAME_CONVERSION_AMOUNT = "conversion_amount";
  @SerializedName(SERIALIZED_NAME_CONVERSION_AMOUNT)
  private String conversionAmount;

  public static final String SERIALIZED_NAME_CONVERSION_ID = "conversion_id";
  @SerializedName(SERIALIZED_NAME_CONVERSION_ID)
  private String conversionId;

  public static final String SERIALIZED_NAME_CONVERSION_TIME = "conversion_time";
  @SerializedName(SERIALIZED_NAME_CONVERSION_TIME)
  private Integer conversionTime;

  public static final String SERIALIZED_NAME_CONVERSION_TYPE = "conversion_type";
  @SerializedName(SERIALIZED_NAME_CONVERSION_TYPE)
  private String conversionType;

  public static final String SERIALIZED_NAME_CREATIVE_ID = "creative_id";
  @SerializedName(SERIALIZED_NAME_CREATIVE_ID)
  private String creativeId;

  public static final String SERIALIZED_NAME_DATA_ID = "data_id";
  @SerializedName(SERIALIZED_NAME_DATA_ID)
  private String dataId;

  public static final String SERIALIZED_NAME_DATA_SRC_TYPE = "data_src_type";
  @SerializedName(SERIALIZED_NAME_DATA_SRC_TYPE)
  private String dataSrcType;

  public static final String SERIALIZED_NAME_GROUP_ID = "group_id";
  @SerializedName(SERIALIZED_NAME_GROUP_ID)
  private String groupId;

  public static final String SERIALIZED_NAME_PLAN_ID = "plan_id";
  @SerializedName(SERIALIZED_NAME_PLAN_ID)
  private String planId;

  public static final String SERIALIZED_NAME_PRINCIPAL_ID = "principal_id";
  @SerializedName(SERIALIZED_NAME_PRINCIPAL_ID)
  private String principalId;

  public static final String SERIALIZED_NAME_PRINCIPAL_TAG = "principal_tag";
  @SerializedName(SERIALIZED_NAME_PRINCIPAL_TAG)
  private String principalTag;

  public static final String SERIALIZED_NAME_PROPERTY_LIST = "property_list";
  @SerializedName(SERIALIZED_NAME_PROPERTY_LIST)
  private List<ConversionProperty> propertyList = null;

  public static final String SERIALIZED_NAME_SOURCE = "source";
  @SerializedName(SERIALIZED_NAME_SOURCE)
  private String source;

  public static final String SERIALIZED_NAME_TARGET_ID = "target_id";
  @SerializedName(SERIALIZED_NAME_TARGET_ID)
  private String targetId;

  public static final String SERIALIZED_NAME_TARGET_TYPE = "target_type";
  @SerializedName(SERIALIZED_NAME_TARGET_TYPE)
  private String targetType;

  public static final String SERIALIZED_NAME_UUID = "uuid";
  @SerializedName(SERIALIZED_NAME_UUID)
  private String uuid;

  public static final String SERIALIZED_NAME_UUID_TYPE = "uuid_type";
  @SerializedName(SERIALIZED_NAME_UUID_TYPE)
  private String uuidType;

  public ConversionData() { 
  }

  public ConversionData bizNo(String bizNo) {
    
    this.bizNo = bizNo;
    return this;
  }

   /**
   * 转化流水号，用于幂等  对于source&#x3D;XLIGHT，转化流水号来自灯火的留资明细 对于source&#x3D;DATASET/OTHER，转化流水号由调用方自定义
   * @return bizNo
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "Zybnom890437Mvcu", value = "转化流水号，用于幂等  对于source=XLIGHT，转化流水号来自灯火的留资明细 对于source=DATASET/OTHER，转化流水号由调用方自定义")

  public String getBizNo() {
    return bizNo;
  }


  public void setBizNo(String bizNo) {
    this.bizNo = bizNo;
  }


  public ConversionData callbackExtInfo(String callbackExtInfo) {
    
    this.callbackExtInfo = callbackExtInfo;
    return this;
  }

   /**
   * 转化回调扩展信息
   * @return callbackExtInfo
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "ZXdmcmZkbGZkZmRmZmRmMTI=", value = "转化回调扩展信息")

  public String getCallbackExtInfo() {
    return callbackExtInfo;
  }


  public void setCallbackExtInfo(String callbackExtInfo) {
    this.callbackExtInfo = callbackExtInfo;
  }


  public ConversionData conversionAmount(String conversionAmount) {
    
    this.conversionAmount = conversionAmount;
    return this;
  }

   /**
   * 当source&#x3D;DATASET或者OTHER时使用：  转化金额，单位分
   * @return conversionAmount
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "20", value = "当source=DATASET或者OTHER时使用：  转化金额，单位分")

  public String getConversionAmount() {
    return conversionAmount;
  }


  public void setConversionAmount(String conversionAmount) {
    this.conversionAmount = conversionAmount;
  }


  public ConversionData conversionId(String conversionId) {
    
    this.conversionId = conversionId;
    return this;
  }

   /**
   * 当source&#x3D;XLIGHT时使用:  转化事件id，来自推广页关联转化事件id
   * @return conversionId
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "167390987332", value = "当source=XLIGHT时使用:  转化事件id，来自推广页关联转化事件id")

  public String getConversionId() {
    return conversionId;
  }


  public void setConversionId(String conversionId) {
    this.conversionId = conversionId;
  }


  public ConversionData conversionTime(Integer conversionTime) {
    
    this.conversionTime = conversionTime;
    return this;
  }

   /**
   * 转化时间，UTC 时间戳，单位：秒
   * @return conversionTime
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "12389637", value = "转化时间，UTC 时间戳，单位：秒")

  public Integer getConversionTime() {
    return conversionTime;
  }


  public void setConversionTime(Integer conversionTime) {
    this.conversionTime = conversionTime;
  }


  public ConversionData conversionType(String conversionType) {
    
    this.conversionType = conversionType;
    return this;
  }

   /**
   * 当source&#x3D;XLIGHT时使用:  转化事件类型
   * @return conversionType
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "51", value = "当source=XLIGHT时使用:  转化事件类型")

  public String getConversionType() {
    return conversionType;
  }


  public void setConversionType(String conversionType) {
    this.conversionType = conversionType;
  }


  public ConversionData creativeId(String creativeId) {
    
    this.creativeId = creativeId;
    return this;
  }

   /**
   * 创意ID
   * @return creativeId
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "6785", value = "创意ID")

  public String getCreativeId() {
    return creativeId;
  }


  public void setCreativeId(String creativeId) {
    this.creativeId = creativeId;
  }


  public ConversionData dataId(String dataId) {
    
    this.dataId = dataId;
    return this;
  }

   /**
   * 当source&#x3D;XLIGHT或者DATASET时使用：  数据集id
   * @return dataId
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "20391", value = "当source=XLIGHT或者DATASET时使用：  数据集id")

  public String getDataId() {
    return dataId;
  }


  public void setDataId(String dataId) {
    this.dataId = dataId;
  }


  public ConversionData dataSrcType(String dataSrcType) {
    
    this.dataSrcType = dataSrcType;
    return this;
  }

   /**
   * 当source&#x3D;OTHER时使用:  数据类型： KR_MEMBER - 客如云入会 KR_TRADE - 客如云交易 TB_LIVE -  淘宝直播
   * @return dataSrcType
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "KR_MEMBER", value = "当source=OTHER时使用:  数据类型： KR_MEMBER - 客如云入会 KR_TRADE - 客如云交易 TB_LIVE -  淘宝直播")

  public String getDataSrcType() {
    return dataSrcType;
  }


  public void setDataSrcType(String dataSrcType) {
    this.dataSrcType = dataSrcType;
  }


  public ConversionData groupId(String groupId) {
    
    this.groupId = groupId;
    return this;
  }

   /**
   * 单元ID
   * @return groupId
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "7896", value = "单元ID")

  public String getGroupId() {
    return groupId;
  }


  public void setGroupId(String groupId) {
    this.groupId = groupId;
  }


  public ConversionData planId(String planId) {
    
    this.planId = planId;
    return this;
  }

   /**
   * 计划ID
   * @return planId
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "1789", value = "计划ID")

  public String getPlanId() {
    return planId;
  }


  public void setPlanId(String planId) {
    this.planId = planId;
  }


  public ConversionData principalId(String principalId) {
    
    this.principalId = principalId;
    return this;
  }

   /**
   * 商户在灯火pb端的id, 可代替principal_tag
   * @return principalId
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "1", value = "商户在灯火pb端的id, 可代替principal_tag")

  public String getPrincipalId() {
    return principalId;
  }


  public void setPrincipalId(String principalId) {
    this.principalId = principalId;
  }


  public ConversionData principalTag(String principalTag) {
    
    this.principalTag = principalTag;
    return this;
  }

   /**
   * 商家标志，可代替principal_id
   * @return principalTag
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "HYjofejnnlp89730202bcklHH", value = "商家标志，可代替principal_id")

  public String getPrincipalTag() {
    return principalTag;
  }


  public void setPrincipalTag(String principalTag) {
    this.principalTag = principalTag;
  }


  public ConversionData propertyList(List<ConversionProperty> propertyList) {
    
    this.propertyList = propertyList;
    return this;
  }

  public ConversionData addPropertyListItem(ConversionProperty propertyListItem) {
    if (this.propertyList == null) {
      this.propertyList = new ArrayList<>();
    }
    this.propertyList.add(propertyListItem);
    return this;
  }

   /**
   * 当source&#x3D;DATASET或者OTHER时使用：  转化属性列表
   * @return propertyList
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(value = "当source=DATASET或者OTHER时使用：  转化属性列表")

  public List<ConversionProperty> getPropertyList() {
    return propertyList;
  }


  public void setPropertyList(List<ConversionProperty> propertyList) {
    this.propertyList = propertyList;
  }


  public ConversionData source(String source) {
    
    this.source = source;
    return this;
  }

   /**
   * 来源： XLIGHT-灯火留资 DATASET-数据集 OTHER-其它
   * @return source
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "XLIGHT", value = "来源： XLIGHT-灯火留资 DATASET-数据集 OTHER-其它")

  public String getSource() {
    return source;
  }


  public void setSource(String source) {
    this.source = source;
  }


  public ConversionData targetId(String targetId) {
    
    this.targetId = targetId;
    return this;
  }

   /**
   * 当source&#x3D;OTHER时使用： 主体id，比如品牌id
   * @return targetId
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "123", value = "当source=OTHER时使用： 主体id，比如品牌id")

  public String getTargetId() {
    return targetId;
  }


  public void setTargetId(String targetId) {
    this.targetId = targetId;
  }


  public ConversionData targetType(String targetType) {
    
    this.targetType = targetType;
    return this;
  }

   /**
   * 当source&#x3D;OTHER时使用：  主体类型： BRAND - 品牌 STORE - 店铺 LIVE - 直播 等等
   * @return targetType
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "STORE", value = "当source=OTHER时使用：  主体类型： BRAND - 品牌 STORE - 店铺 LIVE - 直播 等等")

  public String getTargetType() {
    return targetType;
  }


  public void setTargetType(String targetType) {
    this.targetType = targetType;
  }


  public ConversionData uuid(String uuid) {
    
    this.uuid = uuid;
    return this;
  }

   /**
   * 当source&#x3D;DATASET或者OTHER时使用：  转化用户唯一标识
   * @return uuid
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "7893ybc7032173", value = "当source=DATASET或者OTHER时使用：  转化用户唯一标识")

  public String getUuid() {
    return uuid;
  }


  public void setUuid(String uuid) {
    this.uuid = uuid;
  }


  public ConversionData uuidType(String uuidType) {
    
    this.uuidType = uuidType;
    return this;
  }

   /**
   * 当source&#x3D;DATASET或者OTHER时使用：  转化客户唯一标志类型： PID - 2088pid
   * @return uuidType
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "PID", value = "当source=DATASET或者OTHER时使用：  转化客户唯一标志类型： PID - 2088pid")

  public String getUuidType() {
    return uuidType;
  }


  public void setUuidType(String uuidType) {
    this.uuidType = uuidType;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    ConversionData conversionData = (ConversionData) o;
    return Objects.equals(this.bizNo, conversionData.bizNo) &&
        Objects.equals(this.callbackExtInfo, conversionData.callbackExtInfo) &&
        Objects.equals(this.conversionAmount, conversionData.conversionAmount) &&
        Objects.equals(this.conversionId, conversionData.conversionId) &&
        Objects.equals(this.conversionTime, conversionData.conversionTime) &&
        Objects.equals(this.conversionType, conversionData.conversionType) &&
        Objects.equals(this.creativeId, conversionData.creativeId) &&
        Objects.equals(this.dataId, conversionData.dataId) &&
        Objects.equals(this.dataSrcType, conversionData.dataSrcType) &&
        Objects.equals(this.groupId, conversionData.groupId) &&
        Objects.equals(this.planId, conversionData.planId) &&
        Objects.equals(this.principalId, conversionData.principalId) &&
        Objects.equals(this.principalTag, conversionData.principalTag) &&
        Objects.equals(this.propertyList, conversionData.propertyList) &&
        Objects.equals(this.source, conversionData.source) &&
        Objects.equals(this.targetId, conversionData.targetId) &&
        Objects.equals(this.targetType, conversionData.targetType) &&
        Objects.equals(this.uuid, conversionData.uuid) &&
        Objects.equals(this.uuidType, conversionData.uuidType);
  }

  @Override
  public int hashCode() {
    return Objects.hash(bizNo, callbackExtInfo, conversionAmount, conversionId, conversionTime, conversionType, creativeId, dataId, dataSrcType, groupId, planId, principalId, principalTag, propertyList, source, targetId, targetType, uuid, uuidType);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class ConversionData {\n");
    sb.append("    bizNo: ").append(toIndentedString(bizNo)).append("\n");
    sb.append("    callbackExtInfo: ").append(toIndentedString(callbackExtInfo)).append("\n");
    sb.append("    conversionAmount: ").append(toIndentedString(conversionAmount)).append("\n");
    sb.append("    conversionId: ").append(toIndentedString(conversionId)).append("\n");
    sb.append("    conversionTime: ").append(toIndentedString(conversionTime)).append("\n");
    sb.append("    conversionType: ").append(toIndentedString(conversionType)).append("\n");
    sb.append("    creativeId: ").append(toIndentedString(creativeId)).append("\n");
    sb.append("    dataId: ").append(toIndentedString(dataId)).append("\n");
    sb.append("    dataSrcType: ").append(toIndentedString(dataSrcType)).append("\n");
    sb.append("    groupId: ").append(toIndentedString(groupId)).append("\n");
    sb.append("    planId: ").append(toIndentedString(planId)).append("\n");
    sb.append("    principalId: ").append(toIndentedString(principalId)).append("\n");
    sb.append("    principalTag: ").append(toIndentedString(principalTag)).append("\n");
    sb.append("    propertyList: ").append(toIndentedString(propertyList)).append("\n");
    sb.append("    source: ").append(toIndentedString(source)).append("\n");
    sb.append("    targetId: ").append(toIndentedString(targetId)).append("\n");
    sb.append("    targetType: ").append(toIndentedString(targetType)).append("\n");
    sb.append("    uuid: ").append(toIndentedString(uuid)).append("\n");
    sb.append("    uuidType: ").append(toIndentedString(uuidType)).append("\n");
    sb.append("}");
    return sb.toString();
  }

  /**
   * Convert the given object to string with each line indented by 4 spaces
   * (except the first line).
   */
  private String toIndentedString(Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }


  public static HashSet<String> openapiFields;
  public static HashSet<String> openapiRequiredFields;

  static {
    // a set of all properties/fields (JSON key names)
    openapiFields = new HashSet<String>();
    openapiFields.add("biz_no");
    openapiFields.add("callback_ext_info");
    openapiFields.add("conversion_amount");
    openapiFields.add("conversion_id");
    openapiFields.add("conversion_time");
    openapiFields.add("conversion_type");
    openapiFields.add("creative_id");
    openapiFields.add("data_id");
    openapiFields.add("data_src_type");
    openapiFields.add("group_id");
    openapiFields.add("plan_id");
    openapiFields.add("principal_id");
    openapiFields.add("principal_tag");
    openapiFields.add("property_list");
    openapiFields.add("source");
    openapiFields.add("target_id");
    openapiFields.add("target_type");
    openapiFields.add("uuid");
    openapiFields.add("uuid_type");

    // a set of required properties/fields (JSON key names)
    openapiRequiredFields = new HashSet<String>();
  }

 /**
  * Validates the JSON Object and throws an exception if issues found
  *
  * @param jsonObj JSON Object
  * @throws IOException if the JSON Object is invalid with respect to ConversionData
  */
  public static void validateJsonObject(JsonObject jsonObj) throws IOException {
      if (jsonObj == null) {
        if (ConversionData.openapiRequiredFields.isEmpty()) {
          return;
        } else { // has required fields
          throw new IllegalArgumentException(String.format("The required field(s) %s in ConversionData is not found in the empty JSON string", ConversionData.openapiRequiredFields.toString()));
        }
      }

      Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
      // check to see if the JSON string contains additional fields
      for (Entry<String, JsonElement> entry : entries) {
        if (!ConversionData.openapiFields.contains(entry.getKey())) {
          throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ConversionData` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
        }
      }
      if (jsonObj.get("biz_no") != null && !jsonObj.get("biz_no").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `biz_no` to be a primitive type in the JSON string but got `%s`", jsonObj.get("biz_no").toString()));
      }
      if (jsonObj.get("callback_ext_info") != null && !jsonObj.get("callback_ext_info").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `callback_ext_info` to be a primitive type in the JSON string but got `%s`", jsonObj.get("callback_ext_info").toString()));
      }
      if (jsonObj.get("conversion_amount") != null && !jsonObj.get("conversion_amount").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `conversion_amount` to be a primitive type in the JSON string but got `%s`", jsonObj.get("conversion_amount").toString()));
      }
      if (jsonObj.get("conversion_id") != null && !jsonObj.get("conversion_id").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `conversion_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("conversion_id").toString()));
      }
      if (jsonObj.get("conversion_type") != null && !jsonObj.get("conversion_type").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `conversion_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("conversion_type").toString()));
      }
      if (jsonObj.get("creative_id") != null && !jsonObj.get("creative_id").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `creative_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("creative_id").toString()));
      }
      if (jsonObj.get("data_id") != null && !jsonObj.get("data_id").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `data_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("data_id").toString()));
      }
      if (jsonObj.get("data_src_type") != null && !jsonObj.get("data_src_type").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `data_src_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("data_src_type").toString()));
      }
      if (jsonObj.get("group_id") != null && !jsonObj.get("group_id").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `group_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("group_id").toString()));
      }
      if (jsonObj.get("plan_id") != null && !jsonObj.get("plan_id").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `plan_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("plan_id").toString()));
      }
      if (jsonObj.get("principal_id") != null && !jsonObj.get("principal_id").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `principal_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("principal_id").toString()));
      }
      if (jsonObj.get("principal_tag") != null && !jsonObj.get("principal_tag").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `principal_tag` to be a primitive type in the JSON string but got `%s`", jsonObj.get("principal_tag").toString()));
      }
      JsonArray jsonArraypropertyList = jsonObj.getAsJsonArray("property_list");
      if (jsonArraypropertyList != null) {
        // ensure the json data is an array
        if (!jsonObj.get("property_list").isJsonArray()) {
          throw new IllegalArgumentException(String.format("Expected the field `property_list` to be an array in the JSON string but got `%s`", jsonObj.get("property_list").toString()));
        }

        // validate the optional field `property_list` (array)
        for (int i = 0; i < jsonArraypropertyList.size(); i++) {
          ConversionProperty.validateJsonObject(jsonArraypropertyList.get(i).getAsJsonObject());
        };
      }
      if (jsonObj.get("source") != null && !jsonObj.get("source").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source").toString()));
      }
      if (jsonObj.get("target_id") != null && !jsonObj.get("target_id").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `target_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("target_id").toString()));
      }
      if (jsonObj.get("target_type") != null && !jsonObj.get("target_type").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `target_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("target_type").toString()));
      }
      if (jsonObj.get("uuid") != null && !jsonObj.get("uuid").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("uuid").toString()));
      }
      if (jsonObj.get("uuid_type") != null && !jsonObj.get("uuid_type").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `uuid_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("uuid_type").toString()));
      }
  }

  public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
    @SuppressWarnings("unchecked")
    @Override
    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
       if (!ConversionData.class.isAssignableFrom(type.getRawType())) {
         return null; // this class only serializes 'ConversionData' and its subtypes
       }
       final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
       final TypeAdapter<ConversionData> thisAdapter
                        = gson.getDelegateAdapter(this, TypeToken.get(ConversionData.class));

       return (TypeAdapter<T>) new TypeAdapter<ConversionData>() {
           @Override
           public void write(JsonWriter out, ConversionData value) throws IOException {
             JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
             elementAdapter.write(out, obj);
           }

           @Override
           public ConversionData read(JsonReader in) throws IOException {
             JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
             validateJsonObject(jsonObj);
             return thisAdapter.fromJsonTree(jsonObj);
           }

       }.nullSafe();
    }
  }

 /**
  * Create an instance of ConversionData given an JSON string
  *
  * @param jsonString JSON string
  * @return An instance of ConversionData
  * @throws IOException if the JSON string is invalid with respect to ConversionData
  */
  public static ConversionData fromJson(String jsonString) throws IOException {
    return JSON.getGson().fromJson(jsonString, ConversionData.class);
  }

 /**
  * Convert an instance of ConversionData to an JSON string
  *
  * @return JSON string
  */
  public String toJson() {
    return JSON.getGson().toJson(this);
  }
}

