content: /*
   * 支付宝开放平台API
   * 支付宝开放平台v3协议文档
   *
   * The version of the OpenAPI document: 2025-08-26
   * 
   *
   * 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.ContributeDetail;
  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;
  
  /**
   * VoucherDetail
   */
  @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
  public class VoucherDetail {
    public static final String SERIALIZED_NAME_AMOUNT = "amount";
    @SerializedName(SERIALIZED_NAME_AMOUNT)
    private String amount;
  
    public static final String SERIALIZED_NAME_ID = "id";
    @SerializedName(SERIALIZED_NAME_ID)
    private String id;
  
    public static final String SERIALIZED_NAME_MEMO = "memo";
    @SerializedName(SERIALIZED_NAME_MEMO)
    private String memo;
  
    public static final String SERIALIZED_NAME_MERCHANT_CONTRIBUTE = "merchant_contribute";
    @SerializedName(SERIALIZED_NAME_MERCHANT_CONTRIBUTE)
    private String merchantContribute;
  
    public static final String SERIALIZED_NAME_NAME = "name";
    @SerializedName(SERIALIZED_NAME_NAME)
    private String name;
  
    public static final String SERIALIZED_NAME_OTHER_CONTRIBUTE = "other_contribute";
    @SerializedName(SERIALIZED_NAME_OTHER_CONTRIBUTE)
    private String otherContribute;
  
    public static final String SERIALIZED_NAME_OTHER_CONTRIBUTE_DETAIL = "other_contribute_detail";
    @SerializedName(SERIALIZED_NAME_OTHER_CONTRIBUTE_DETAIL)
    private List<ContributeDetail> otherContributeDetail = null;
  
    public static final String SERIALIZED_NAME_PURCHASE_ANT_CONTRIBUTE = "purchase_ant_contribute";
    @SerializedName(SERIALIZED_NAME_PURCHASE_ANT_CONTRIBUTE)
    private String purchaseAntContribute;
  
    public static final String SERIALIZED_NAME_PURCHASE_BUYER_CONTRIBUTE = "purchase_buyer_contribute";
    @SerializedName(SERIALIZED_NAME_PURCHASE_BUYER_CONTRIBUTE)
    private String purchaseBuyerContribute;
  
    public static final String SERIALIZED_NAME_PURCHASE_MERCHANT_CONTRIBUTE = "purchase_merchant_contribute";
    @SerializedName(SERIALIZED_NAME_PURCHASE_MERCHANT_CONTRIBUTE)
    private String purchaseMerchantContribute;
  
    public static final String SERIALIZED_NAME_TEMPLATE_ID = "template_id";
    @SerializedName(SERIALIZED_NAME_TEMPLATE_ID)
    private String templateId;
  
    public static final String SERIALIZED_NAME_TYPE = "type";
    @SerializedName(SERIALIZED_NAME_TYPE)
    private String type;
  
    public VoucherDetail() { 
    }
  
    public VoucherDetail amount(String amount) {
      
      this.amount = amount;
      return this;
    }
  
     /**
     * 优惠券面额，它应该会等于商家出资加上其他出资方出资
     * @return amount
    **/
    @javax.annotation.Nullable
    @ApiModelProperty(value = "优惠券面额，它应该会等于商家出资加上其他出资方出资")
  
    public String getAmount() {
      return amount;
    }
  
  
    public void setAmount(String amount) {
      this.amount = amount;
    }
  
  
    public VoucherDetail id(String id) {
      
      this.id = id;
      return this;
    }
  
     /**
     * 券id
     * @return id
    **/
    @javax.annotation.Nullable
    @ApiModelProperty(value = "券id")
  
    public String getId() {
      return id;
    }
  
  
    public void setId(String id) {
      this.id = id;
    }
  
  
    public VoucherDetail memo(String memo) {
      
      this.memo = memo;
      return this;
    }
  
     /**
     * 优惠券备注信息
     * @return memo
    **/
    @javax.annotation.Nullable
    @ApiModelProperty(value = "优惠券备注信息")
  
    public String getMemo() {
      return memo;
    }
  
  
    public void setMemo(String memo) {
      this.memo = memo;
    }
  
  
    public VoucherDetail merchantContribute(String merchantContribute) {
      
      this.merchantContribute = merchantContribute;
      return this;
    }
  
     /**
     * 商家出资（特指发起交易的商家出资金额）
     * @return merchantContribute
    **/
    @javax.annotation.Nullable
    @ApiModelProperty(value = "商家出资（特指发起交易的商家出资金额）")
  
    public String getMerchantContribute() {
      return merchantContribute;
    }
  
  
    public void setMerchantContribute(String merchantContribute) {
      this.merchantContribute = merchantContribute;
    }
  
  
    public VoucherDetail name(String name) {
      
      this.name = name;
      return this;
    }
  
     /**
     * 券名称
     * @return name
    **/
    @javax.annotation.Nullable
    @ApiModelProperty(value = "券名称")
  
    public String getName() {
      return name;
    }
  
  
    public void setName(String name) {
      this.name = name;
    }
  
  
    public VoucherDetail otherContribute(String otherContribute) {
      
      this.otherContribute = otherContribute;
      return this;
    }
  
     /**
     * 其他出资方出资金额，可能是支付宝，可能是品牌商，或者其他方，也可能是他们的一起出资
     * @return otherContribute
    **/
    @javax.annotation.Nullable
    @ApiModelProperty(value = "其他出资方出资金额，可能是支付宝，可能是品牌商，或者其他方，也可能是他们的一起出资")
  
    public String getOtherContribute() {
      return otherContribute;
    }
  
  
    public void setOtherContribute(String otherContribute) {
      this.otherContribute = otherContribute;
    }
  
  
    public VoucherDetail otherContributeDetail(List<ContributeDetail> otherContributeDetail) {
      
      this.otherContributeDetail = otherContributeDetail;
      return this;
    }
  
    public VoucherDetail addOtherContributeDetailItem(ContributeDetail otherContributeDetailItem) {
      if (this.otherContributeDetail == null) {
        this.otherContributeDetail = new ArrayList<>();
      }
      this.otherContributeDetail.add(otherContributeDetailItem);
      return this;
    }
  
     /**
     * 优惠券的其他出资方明细
     * @return otherContributeDetail
    **/
    @javax.annotation.Nullable
    @ApiModelProperty(value = "优惠券的其他出资方明细")
  
    public List<ContributeDetail> getOtherContributeDetail() {
      return otherContributeDetail;
    }
  
  
    public void setOtherContributeDetail(List<ContributeDetail> otherContributeDetail) {
      this.otherContributeDetail = otherContributeDetail;
    }
  
  
    public VoucherDetail purchaseAntContribute(String purchaseAntContribute) {
      
      this.purchaseAntContribute = purchaseAntContribute;
      return this;
    }
  
     /**
     * 如果使用的这张券是用户购买的，则该字段代表用户在购买这张券时平台优惠的金额
     * @return purchaseAntContribute
    **/
    @javax.annotation.Nullable
    @ApiModelProperty(value = "如果使用的这张券是用户购买的，则该字段代表用户在购买这张券时平台优惠的金额")
  
    public String getPurchaseAntContribute() {
      return purchaseAntContribute;
    }
  
  
    public void setPurchaseAntContribute(String purchaseAntContribute) {
      this.purchaseAntContribute = purchaseAntContribute;
    }
  
  
    public VoucherDetail purchaseBuyerContribute(String purchaseBuyerContribute) {
      
      this.purchaseBuyerContribute = purchaseBuyerContribute;
      return this;
    }
  
     /**
     * 如果使用的这张券是用户购买的，则该字段代表用户在购买这张券时用户实际付款的金额
     * @return purchaseBuyerContribute
    **/
    @javax.annotation.Nullable
    @ApiModelProperty(value = "如果使用的这张券是用户购买的，则该字段代表用户在购买这张券时用户实际付款的金额")
  
    public String getPurchaseBuyerContribute() {
      return purchaseBuyerContribute;
    }
  
  
    public void setPurchaseBuyerContribute(String purchaseBuyerContribute) {
      this.purchaseBuyerContribute = purchaseBuyerContribute;
    }
  
  
    public VoucherDetail purchaseMerchantContribute(String purchaseMerchantContribute) {
      
      this.purchaseMerchantContribute = purchaseMerchantContribute;
      return this;
    }
  
     /**
     * 如果使用的这张券是用户购买的，则该字段代表用户在购买这张券时商户优惠的金额
     * @return purchaseMerchantContribute
    **/
    @javax.annotation.Nullable
    @ApiModelProperty(value = "如果使用的这张券是用户购买的，则该字段代表用户在购买这张券时商户优惠的金额")
  
    public String getPurchaseMerchantContribute() {
      return purchaseMerchantContribute;
    }
  
  
    public void setPurchaseMerchantContribute(String purchaseMerchantContribute) {
      this.purchaseMerchantContribute = purchaseMerchantContribute;
    }
  
  
    public VoucherDetail templateId(String templateId) {
      
      this.templateId = templateId;
      return this;
    }
  
     /**
     * 券模板id
     * @return templateId
    **/
    @javax.annotation.Nullable
    @ApiModelProperty(value = "券模板id")
  
    public String getTemplateId() {
      return templateId;
    }
  
  
    public void setTemplateId(String templateId) {
      this.templateId = templateId;
    }
  
  
    public VoucherDetail type(String type) {
      
      this.type = type;
      return this;
    }
  
     /**
     * 券类型
     * @return type
    **/
    @javax.annotation.Nullable
    @ApiModelProperty(value = "券类型")
  
    public String getType() {
      return type;
    }
  
  
    public void setType(String type) {
      this.type = type;
    }
  
    /**
     * A container for additional, undeclared properties.
     * This is a holder for any undeclared properties as specified with
     * the 'additionalProperties' keyword in the OAS document.
     */
    private Map<String, Object> additionalProperties;
  
    /**
     * Set the additional (undeclared) property with the specified name and value.
     * If the property does not already exist, create it otherwise replace it.
     *
     * @param key name of the property
     * @param value value of the property
     * @return the VoucherDetail instance itself
     */
    public VoucherDetail putAdditionalProperty(String key, Object value) {
      if (this.additionalProperties == null) {
          this.additionalProperties = new HashMap<String, Object>();
      }
      this.additionalProperties.put(key, value);
      return this;
    }
  
    /**
     * Return the additional (undeclared) property.
     *
     * @return a map of objects
     */
    public Map<String, Object> getAdditionalProperties() {
      return additionalProperties;
    }
  
    /**
     * Return the additional (undeclared) property with the specified name.
     *
     * @param key name of the property
     * @return an object
     */
    public Object getAdditionalProperty(String key) {
      if (this.additionalProperties == null) {
          return null;
      }
      return this.additionalProperties.get(key);
    }
  
  
    @Override
    public boolean equals(Object o) {
      if (this == o) {
        return true;
      }
      if (o == null || getClass() != o.getClass()) {
        return false;
      }
      VoucherDetail voucherDetail = (VoucherDetail) o;
      return Objects.equals(this.amount, voucherDetail.amount) &&
          Objects.equals(this.id, voucherDetail.id) &&
          Objects.equals(this.memo, voucherDetail.memo) &&
          Objects.equals(this.merchantContribute, voucherDetail.merchantContribute) &&
          Objects.equals(this.name, voucherDetail.name) &&
          Objects.equals(this.otherContribute, voucherDetail.otherContribute) &&
          Objects.equals(this.otherContributeDetail, voucherDetail.otherContributeDetail) &&
          Objects.equals(this.purchaseAntContribute, voucherDetail.purchaseAntContribute) &&
          Objects.equals(this.purchaseBuyerContribute, voucherDetail.purchaseBuyerContribute) &&
          Objects.equals(this.purchaseMerchantContribute, voucherDetail.purchaseMerchantContribute) &&
          Objects.equals(this.templateId, voucherDetail.templateId) &&
          Objects.equals(this.type, voucherDetail.type)&&
          Objects.equals(this.additionalProperties, voucherDetail.additionalProperties);
    }
  
    @Override
    public int hashCode() {
      return Objects.hash(amount, id, memo, merchantContribute, name, otherContribute, otherContributeDetail, purchaseAntContribute, purchaseBuyerContribute, purchaseMerchantContribute, templateId, type, additionalProperties);
    }
  
    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder();
      sb.append("class VoucherDetail {\n");
      sb.append("    amount: ").append(toIndentedString(amount)).append("\n");
      sb.append("    id: ").append(toIndentedString(id)).append("\n");
      sb.append("    memo: ").append(toIndentedString(memo)).append("\n");
      sb.append("    merchantContribute: ").append(toIndentedString(merchantContribute)).append("\n");
      sb.append("    name: ").append(toIndentedString(name)).append("\n");
      sb.append("    otherContribute: ").append(toIndentedString(otherContribute)).append("\n");
      sb.append("    otherContributeDetail: ").append(toIndentedString(otherContributeDetail)).append("\n");
      sb.append("    purchaseAntContribute: ").append(toIndentedString(purchaseAntContribute)).append("\n");
      sb.append("    purchaseBuyerContribute: ").append(toIndentedString(purchaseBuyerContribute)).append("\n");
      sb.append("    purchaseMerchantContribute: ").append(toIndentedString(purchaseMerchantContribute)).append("\n");
      sb.append("    templateId: ").append(toIndentedString(templateId)).append("\n");
      sb.append("    type: ").append(toIndentedString(type)).append("\n");
      sb.append("    additionalProperties: ").append(toIndentedString(additionalProperties)).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("amount");
      openapiFields.add("id");
      openapiFields.add("memo");
      openapiFields.add("merchant_contribute");
      openapiFields.add("name");
      openapiFields.add("other_contribute");
      openapiFields.add("other_contribute_detail");
      openapiFields.add("purchase_ant_contribute");
      openapiFields.add("purchase_buyer_contribute");
      openapiFields.add("purchase_merchant_contribute");
      openapiFields.add("template_id");
      openapiFields.add("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 VoucherDetail
    */
    public static void validateJsonObject(JsonObject jsonObj) throws IOException {
        if (jsonObj == null) {
          if (VoucherDetail.openapiRequiredFields.isEmpty()) {
            return;
          } else { // has required fields
            throw new IllegalArgumentException(String.format("The required field(s) %s in VoucherDetail is not found in the empty JSON string", VoucherDetail.openapiRequiredFields.toString()));
          }
        }
        if (jsonObj.get("amount") != null && !jsonObj.get("amount").isJsonPrimitive()) {
          throw new IllegalArgumentException(String.format("Expected the field `amount` to be a primitive type in the JSON string but got `%s`", jsonObj.get("amount").toString()));
        }
        if (jsonObj.get("id") != null && !jsonObj.get("id").isJsonPrimitive()) {
          throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString()));
        }
        if (jsonObj.get("memo") != null && !jsonObj.get("memo").isJsonPrimitive()) {
          throw new IllegalArgumentException(String.format("Expected the field `memo` to be a primitive type in the JSON string but got `%s`", jsonObj.get("memo").toString()));
        }
        if (jsonObj.get("merchant_contribute") != null && !jsonObj.get("merchant_contribute").isJsonPrimitive()) {
          throw new IllegalArgumentException(String.format("Expected the field `merchant_contribute` to be a primitive type in the JSON string but got `%s`", jsonObj.get("merchant_contribute").toString()));
        }
        if (jsonObj.get("name") != null && !jsonObj.get("name").isJsonPrimitive()) {
          throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
        }
        if (jsonObj.get("other_contribute") != null && !jsonObj.get("other_contribute").isJsonPrimitive()) {
          throw new IllegalArgumentException(String.format("Expected the field `other_contribute` to be a primitive type in the JSON string but got `%s`", jsonObj.get("other_contribute").toString()));
        }
        JsonArray jsonArrayotherContributeDetail = jsonObj.getAsJsonArray("other_contribute_detail");
        if (jsonArrayotherContributeDetail != null) {
          // ensure the json data is an array
          if (!jsonObj.get("other_contribute_detail").isJsonArray()) {
            throw new IllegalArgumentException(String.format("Expected the field `other_contribute_detail` to be an array in the JSON string but got `%s`", jsonObj.get("other_contribute_detail").toString()));
          }
  
          // validate the optional field `other_contribute_detail` (array)
          for (int i = 0; i < jsonArrayotherContributeDetail.size(); i++) {
            ContributeDetail.validateJsonObject(jsonArrayotherContributeDetail.get(i).getAsJsonObject());
          };
        }
        if (jsonObj.get("purchase_ant_contribute") != null && !jsonObj.get("purchase_ant_contribute").isJsonPrimitive()) {
          throw new IllegalArgumentException(String.format("Expected the field `purchase_ant_contribute` to be a primitive type in the JSON string but got `%s`", jsonObj.get("purchase_ant_contribute").toString()));
        }
        if (jsonObj.get("purchase_buyer_contribute") != null && !jsonObj.get("purchase_buyer_contribute").isJsonPrimitive()) {
          throw new IllegalArgumentException(String.format("Expected the field `purchase_buyer_contribute` to be a primitive type in the JSON string but got `%s`", jsonObj.get("purchase_buyer_contribute").toString()));
        }
        if (jsonObj.get("purchase_merchant_contribute") != null && !jsonObj.get("purchase_merchant_contribute").isJsonPrimitive()) {
          throw new IllegalArgumentException(String.format("Expected the field `purchase_merchant_contribute` to be a primitive type in the JSON string but got `%s`", jsonObj.get("purchase_merchant_contribute").toString()));
        }
        if (jsonObj.get("template_id") != null && !jsonObj.get("template_id").isJsonPrimitive()) {
          throw new IllegalArgumentException(String.format("Expected the field `template_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("template_id").toString()));
        }
        if (jsonObj.get("type") != null && !jsonObj.get("type").isJsonPrimitive()) {
          throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString()));
        }
    }
  
    public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
      @SuppressWarnings("unchecked")
      @Override
      public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
         if (!VoucherDetail.class.isAssignableFrom(type.getRawType())) {
           return null; // this class only serializes 'VoucherDetail' and its subtypes
         }
         final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
         final TypeAdapter<VoucherDetail> thisAdapter
                          = gson.getDelegateAdapter(this, TypeToken.get(VoucherDetail.class));
  
         return (TypeAdapter<T>) new TypeAdapter<VoucherDetail>() {
             @Override
             public void write(JsonWriter out, VoucherDetail value) throws IOException {
               JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
               obj.remove("additionalProperties");
               // serialize additonal properties
               if (value.getAdditionalProperties() != null) {
                 for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
                   if (entry.getValue() instanceof String)
                     obj.addProperty(entry.getKey(), (String) entry.getValue());
                   else if (entry.getValue() instanceof Number)
                     obj.addProperty(entry.getKey(), (Number) entry.getValue());
                   else if (entry.getValue() instanceof Boolean)
                     obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
                   else if (entry.getValue() instanceof Character)
                     obj.addProperty(entry.getKey(), (Character) entry.getValue());
                   else {
                     obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
                   }
                 }
               }
               elementAdapter.write(out, obj);
             }
  
             @Override
             public VoucherDetail read(JsonReader in) throws IOException {
               JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
               validateJsonObject(jsonObj);
               // store additional fields in the deserialized instance
               VoucherDetail instance = thisAdapter.fromJsonTree(jsonObj);
               for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
                 if (!openapiFields.contains(entry.getKey())) {
                   if (entry.getValue().isJsonPrimitive()) { // primitive type
                     if (entry.getValue().getAsJsonPrimitive().isString())
                       instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
                     else if (entry.getValue().getAsJsonPrimitive().isNumber())
                       instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
                     else if (entry.getValue().getAsJsonPrimitive().isBoolean())
                       instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
                     else
                       throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
                   } else { // non-primitive type
                     instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
                   }
                 }
               }
               return instance;
             }
  
         }.nullSafe();
      }
    }
  
   /**
    * Create an instance of VoucherDetail given an JSON string
    *
    * @param jsonString JSON string
    * @return An instance of VoucherDetail
    * @throws IOException if the JSON string is invalid with respect to VoucherDetail
    */
    public static VoucherDetail fromJson(String jsonString) throws IOException {
      return JSON.getGson().fromJson(jsonString, VoucherDetail.class);
    }
  
   /**
    * Convert an instance of VoucherDetail to an JSON string
    *
    * @return JSON string
    */
    public String toJson() {
      return JSON.getGson().toJson(this);
    }
  }
  
  