/*
 * Michelin North America Order-to-Cash APIs
 * These APIs will help you to do business transactions with Michelin.  <br><br><b>Authentication details:</b><br> <br><u>Option A:</u> OAuth2 Client Credentials (recommended) <br><u>Option B:</u> API Key + Basic Authentication (not recommended) <br><br>To request your access, please contact your representative. <br><br>Our services are based on the EDIWHEEL standards. <br>You can find more information on the <a href=\"https://www.ediwheel.com/\" target=\"_blank\">EDIWHEEL website</a>. 
 *
 * The version of the OpenAPI document: 1.0.1
 * 
 *
 * 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.michelin.adk.amn.o2c.model;

import java.util.Objects;
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 com.michelin.adk.amn.o2c.model.EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleAllowanceOrChargeInner;
import com.michelin.adk.amn.o2c.model.EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleArticleDescriptionInner;
import com.michelin.adk.amn.o2c.model.EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleArticleIdentification;
import com.michelin.adk.amn.o2c.model.EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleConsignee;
import com.michelin.adk.amn.o2c.model.EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleInvoicedQuantity;
import com.michelin.adk.amn.o2c.model.EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleLineItemTotalAmount;
import com.michelin.adk.amn.o2c.model.EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleLineNote;
import com.michelin.adk.amn.o2c.model.EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticlePriceDetails;
import com.michelin.adk.amn.o2c.model.EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleTaxDetailsInner;
import com.michelin.adk.amn.o2c.model.EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleTracingInformationInner;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
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 com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.michelin.adk.amn.JSON;

/**
 * EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle
 */
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.12.0")
public class EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle {
  public static final String SERIALIZED_NAME_ARTICLE_IDENTIFICATION = "articleIdentification";
  @SerializedName(SERIALIZED_NAME_ARTICLE_IDENTIFICATION)
  @javax.annotation.Nonnull
  private EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleArticleIdentification articleIdentification;

  public static final String SERIALIZED_NAME_ARTICLE_DESCRIPTION = "articleDescription";
  @SerializedName(SERIALIZED_NAME_ARTICLE_DESCRIPTION)
  @javax.annotation.Nonnull
  private List<EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleArticleDescriptionInner> articleDescription = new ArrayList<>();

  public static final String SERIALIZED_NAME_INVOICED_QUANTITY = "invoicedQuantity";
  @SerializedName(SERIALIZED_NAME_INVOICED_QUANTITY)
  @javax.annotation.Nullable
  private EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleInvoicedQuantity invoicedQuantity;

  public static final String SERIALIZED_NAME_PRICE_DETAILS = "priceDetails";
  @SerializedName(SERIALIZED_NAME_PRICE_DETAILS)
  @javax.annotation.Nonnull
  private EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticlePriceDetails priceDetails;

  public static final String SERIALIZED_NAME_TAX_DETAILS = "taxDetails";
  @SerializedName(SERIALIZED_NAME_TAX_DETAILS)
  @javax.annotation.Nullable
  private List<EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleTaxDetailsInner> taxDetails = new ArrayList<>();

  public static final String SERIALIZED_NAME_ALLOWANCE_OR_CHARGE = "allowanceOrCharge";
  @SerializedName(SERIALIZED_NAME_ALLOWANCE_OR_CHARGE)
  @javax.annotation.Nullable
  private List<EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleAllowanceOrChargeInner> allowanceOrCharge = new ArrayList<>();

  public static final String SERIALIZED_NAME_LINE_ITEM_TOTAL_AMOUNT = "lineItemTotalAmount";
  @SerializedName(SERIALIZED_NAME_LINE_ITEM_TOTAL_AMOUNT)
  @javax.annotation.Nullable
  private EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleLineItemTotalAmount lineItemTotalAmount;

  public static final String SERIALIZED_NAME_CONSIGNEE = "consignee";
  @SerializedName(SERIALIZED_NAME_CONSIGNEE)
  @javax.annotation.Nullable
  private EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleConsignee consignee;

  public static final String SERIALIZED_NAME_TRACING_INFORMATION = "tracingInformation";
  @SerializedName(SERIALIZED_NAME_TRACING_INFORMATION)
  @javax.annotation.Nullable
  private List<EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleTracingInformationInner> tracingInformation = new ArrayList<>();

  public static final String SERIALIZED_NAME_LINE_NOTE = "lineNote";
  @SerializedName(SERIALIZED_NAME_LINE_NOTE)
  @javax.annotation.Nullable
  private EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleLineNote lineNote;

  public static final String SERIALIZED_NAME_COUNTRY_OF_ORIGIN = "countryOfOrigin";
  @SerializedName(SERIALIZED_NAME_COUNTRY_OF_ORIGIN)
  @javax.annotation.Nullable
  private String countryOfOrigin;

  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle() {
  }

  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle articleIdentification(@javax.annotation.Nonnull EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleArticleIdentification articleIdentification) {
    this.articleIdentification = articleIdentification;
    return this;
  }

  /**
   * Get articleIdentification
   * @return articleIdentification
   */
  @javax.annotation.Nonnull
  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleArticleIdentification getArticleIdentification() {
    return articleIdentification;
  }

  public void setArticleIdentification(@javax.annotation.Nonnull EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleArticleIdentification articleIdentification) {
    this.articleIdentification = articleIdentification;
  }


  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle articleDescription(@javax.annotation.Nonnull List<EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleArticleDescriptionInner> articleDescription) {
    this.articleDescription = articleDescription;
    return this;
  }

  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle addArticleDescriptionItem(EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleArticleDescriptionInner articleDescriptionItem) {
    if (this.articleDescription == null) {
      this.articleDescription = new ArrayList<>();
    }
    this.articleDescription.add(articleDescriptionItem);
    return this;
  }

  /**
   * Get articleDescription
   * @return articleDescription
   */
  @javax.annotation.Nonnull
  public List<EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleArticleDescriptionInner> getArticleDescription() {
    return articleDescription;
  }

  public void setArticleDescription(@javax.annotation.Nonnull List<EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleArticleDescriptionInner> articleDescription) {
    this.articleDescription = articleDescription;
  }


  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle invoicedQuantity(@javax.annotation.Nullable EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleInvoicedQuantity invoicedQuantity) {
    this.invoicedQuantity = invoicedQuantity;
    return this;
  }

  /**
   * Get invoicedQuantity
   * @return invoicedQuantity
   */
  @javax.annotation.Nullable
  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleInvoicedQuantity getInvoicedQuantity() {
    return invoicedQuantity;
  }

  public void setInvoicedQuantity(@javax.annotation.Nullable EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleInvoicedQuantity invoicedQuantity) {
    this.invoicedQuantity = invoicedQuantity;
  }


  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle priceDetails(@javax.annotation.Nonnull EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticlePriceDetails priceDetails) {
    this.priceDetails = priceDetails;
    return this;
  }

  /**
   * Get priceDetails
   * @return priceDetails
   */
  @javax.annotation.Nonnull
  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticlePriceDetails getPriceDetails() {
    return priceDetails;
  }

  public void setPriceDetails(@javax.annotation.Nonnull EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticlePriceDetails priceDetails) {
    this.priceDetails = priceDetails;
  }


  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle taxDetails(@javax.annotation.Nullable List<EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleTaxDetailsInner> taxDetails) {
    this.taxDetails = taxDetails;
    return this;
  }

  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle addTaxDetailsItem(EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleTaxDetailsInner taxDetailsItem) {
    if (this.taxDetails == null) {
      this.taxDetails = new ArrayList<>();
    }
    this.taxDetails.add(taxDetailsItem);
    return this;
  }

  /**
   * Get taxDetails
   * @return taxDetails
   */
  @javax.annotation.Nullable
  public List<EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleTaxDetailsInner> getTaxDetails() {
    return taxDetails;
  }

  public void setTaxDetails(@javax.annotation.Nullable List<EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleTaxDetailsInner> taxDetails) {
    this.taxDetails = taxDetails;
  }


  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle allowanceOrCharge(@javax.annotation.Nullable List<EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleAllowanceOrChargeInner> allowanceOrCharge) {
    this.allowanceOrCharge = allowanceOrCharge;
    return this;
  }

  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle addAllowanceOrChargeItem(EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleAllowanceOrChargeInner allowanceOrChargeItem) {
    if (this.allowanceOrCharge == null) {
      this.allowanceOrCharge = new ArrayList<>();
    }
    this.allowanceOrCharge.add(allowanceOrChargeItem);
    return this;
  }

  /**
   * Get allowanceOrCharge
   * @return allowanceOrCharge
   */
  @javax.annotation.Nullable
  public List<EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleAllowanceOrChargeInner> getAllowanceOrCharge() {
    return allowanceOrCharge;
  }

  public void setAllowanceOrCharge(@javax.annotation.Nullable List<EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleAllowanceOrChargeInner> allowanceOrCharge) {
    this.allowanceOrCharge = allowanceOrCharge;
  }


  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle lineItemTotalAmount(@javax.annotation.Nullable EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleLineItemTotalAmount lineItemTotalAmount) {
    this.lineItemTotalAmount = lineItemTotalAmount;
    return this;
  }

  /**
   * Get lineItemTotalAmount
   * @return lineItemTotalAmount
   */
  @javax.annotation.Nullable
  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleLineItemTotalAmount getLineItemTotalAmount() {
    return lineItemTotalAmount;
  }

  public void setLineItemTotalAmount(@javax.annotation.Nullable EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleLineItemTotalAmount lineItemTotalAmount) {
    this.lineItemTotalAmount = lineItemTotalAmount;
  }


  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle consignee(@javax.annotation.Nullable EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleConsignee consignee) {
    this.consignee = consignee;
    return this;
  }

  /**
   * Get consignee
   * @return consignee
   */
  @javax.annotation.Nullable
  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleConsignee getConsignee() {
    return consignee;
  }

  public void setConsignee(@javax.annotation.Nullable EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleConsignee consignee) {
    this.consignee = consignee;
  }


  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle tracingInformation(@javax.annotation.Nullable List<EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleTracingInformationInner> tracingInformation) {
    this.tracingInformation = tracingInformation;
    return this;
  }

  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle addTracingInformationItem(EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleTracingInformationInner tracingInformationItem) {
    if (this.tracingInformation == null) {
      this.tracingInformation = new ArrayList<>();
    }
    this.tracingInformation.add(tracingInformationItem);
    return this;
  }

  /**
   * Get tracingInformation
   * @return tracingInformation
   */
  @javax.annotation.Nullable
  public List<EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleTracingInformationInner> getTracingInformation() {
    return tracingInformation;
  }

  public void setTracingInformation(@javax.annotation.Nullable List<EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleTracingInformationInner> tracingInformation) {
    this.tracingInformation = tracingInformation;
  }


  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle lineNote(@javax.annotation.Nullable EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleLineNote lineNote) {
    this.lineNote = lineNote;
    return this;
  }

  /**
   * Get lineNote
   * @return lineNote
   */
  @javax.annotation.Nullable
  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleLineNote getLineNote() {
    return lineNote;
  }

  public void setLineNote(@javax.annotation.Nullable EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleLineNote lineNote) {
    this.lineNote = lineNote;
  }


  public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle countryOfOrigin(@javax.annotation.Nullable String countryOfOrigin) {
    this.countryOfOrigin = countryOfOrigin;
    return this;
  }

  /**
   * Get countryOfOrigin
   * @return countryOfOrigin
   */
  @javax.annotation.Nullable
  public String getCountryOfOrigin() {
    return countryOfOrigin;
  }

  public void setCountryOfOrigin(@javax.annotation.Nullable String countryOfOrigin) {
    this.countryOfOrigin = countryOfOrigin;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle edIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle = (EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle) o;
    return Objects.equals(this.articleIdentification, edIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle.articleIdentification) &&
        Objects.equals(this.articleDescription, edIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle.articleDescription) &&
        Objects.equals(this.invoicedQuantity, edIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle.invoicedQuantity) &&
        Objects.equals(this.priceDetails, edIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle.priceDetails) &&
        Objects.equals(this.taxDetails, edIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle.taxDetails) &&
        Objects.equals(this.allowanceOrCharge, edIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle.allowanceOrCharge) &&
        Objects.equals(this.lineItemTotalAmount, edIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle.lineItemTotalAmount) &&
        Objects.equals(this.consignee, edIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle.consignee) &&
        Objects.equals(this.tracingInformation, edIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle.tracingInformation) &&
        Objects.equals(this.lineNote, edIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle.lineNote) &&
        Objects.equals(this.countryOfOrigin, edIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle.countryOfOrigin);
  }

  @Override
  public int hashCode() {
    return Objects.hash(articleIdentification, articleDescription, invoicedQuantity, priceDetails, taxDetails, allowanceOrCharge, lineItemTotalAmount, consignee, tracingInformation, lineNote, countryOfOrigin);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle {\n");
    sb.append("    articleIdentification: ").append(toIndentedString(articleIdentification)).append("\n");
    sb.append("    articleDescription: ").append(toIndentedString(articleDescription)).append("\n");
    sb.append("    invoicedQuantity: ").append(toIndentedString(invoicedQuantity)).append("\n");
    sb.append("    priceDetails: ").append(toIndentedString(priceDetails)).append("\n");
    sb.append("    taxDetails: ").append(toIndentedString(taxDetails)).append("\n");
    sb.append("    allowanceOrCharge: ").append(toIndentedString(allowanceOrCharge)).append("\n");
    sb.append("    lineItemTotalAmount: ").append(toIndentedString(lineItemTotalAmount)).append("\n");
    sb.append("    consignee: ").append(toIndentedString(consignee)).append("\n");
    sb.append("    tracingInformation: ").append(toIndentedString(tracingInformation)).append("\n");
    sb.append("    lineNote: ").append(toIndentedString(lineNote)).append("\n");
    sb.append("    countryOfOrigin: ").append(toIndentedString(countryOfOrigin)).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("articleIdentification");
    openapiFields.add("articleDescription");
    openapiFields.add("invoicedQuantity");
    openapiFields.add("priceDetails");
    openapiFields.add("taxDetails");
    openapiFields.add("allowanceOrCharge");
    openapiFields.add("lineItemTotalAmount");
    openapiFields.add("consignee");
    openapiFields.add("tracingInformation");
    openapiFields.add("lineNote");
    openapiFields.add("countryOfOrigin");

    // a set of required properties/fields (JSON key names)
    openapiRequiredFields = new HashSet<String>();
    openapiRequiredFields.add("articleIdentification");
    openapiRequiredFields.add("articleDescription");
    openapiRequiredFields.add("priceDetails");
  }

  /**
   * Validates the JSON Element and throws an exception if issues found
   *
   * @param jsonElement JSON Element
   * @throws IOException if the JSON Element is invalid with respect to EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle
   */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle is not found in the empty JSON string", EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle.openapiRequiredFields.toString()));
        }
      }

      Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
      // check to see if the JSON string contains additional fields
      for (Map.Entry<String, JsonElement> entry : entries) {
        if (!EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle.openapiFields.contains(entry.getKey())) {
          throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
        }
      }

      // check to make sure all required properties/fields are present in the JSON string
      for (String requiredField : EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle.openapiRequiredFields) {
        if (jsonElement.getAsJsonObject().get(requiredField) == null) {
          throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      // validate the required field `articleIdentification`
      EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleArticleIdentification.validateJsonElement(jsonObj.get("articleIdentification"));
      // ensure the json data is an array
      if (!jsonObj.get("articleDescription").isJsonArray()) {
        throw new IllegalArgumentException(String.format("Expected the field `articleDescription` to be an array in the JSON string but got `%s`", jsonObj.get("articleDescription").toString()));
      }

      JsonArray jsonArrayarticleDescription = jsonObj.getAsJsonArray("articleDescription");
      // validate the required field `articleDescription` (array)
      for (int i = 0; i < jsonArrayarticleDescription.size(); i++) {
        EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleArticleDescriptionInner.validateJsonElement(jsonArrayarticleDescription.get(i));
      };
      // validate the optional field `invoicedQuantity`
      if (jsonObj.get("invoicedQuantity") != null && !jsonObj.get("invoicedQuantity").isJsonNull()) {
        EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleInvoicedQuantity.validateJsonElement(jsonObj.get("invoicedQuantity"));
      }
      // validate the required field `priceDetails`
      EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticlePriceDetails.validateJsonElement(jsonObj.get("priceDetails"));
      if (jsonObj.get("taxDetails") != null && !jsonObj.get("taxDetails").isJsonNull()) {
        JsonArray jsonArraytaxDetails = jsonObj.getAsJsonArray("taxDetails");
        if (jsonArraytaxDetails != null) {
          // ensure the json data is an array
          if (!jsonObj.get("taxDetails").isJsonArray()) {
            throw new IllegalArgumentException(String.format("Expected the field `taxDetails` to be an array in the JSON string but got `%s`", jsonObj.get("taxDetails").toString()));
          }

          // validate the optional field `taxDetails` (array)
          for (int i = 0; i < jsonArraytaxDetails.size(); i++) {
            EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleTaxDetailsInner.validateJsonElement(jsonArraytaxDetails.get(i));
          };
        }
      }
      if (jsonObj.get("allowanceOrCharge") != null && !jsonObj.get("allowanceOrCharge").isJsonNull()) {
        JsonArray jsonArrayallowanceOrCharge = jsonObj.getAsJsonArray("allowanceOrCharge");
        if (jsonArrayallowanceOrCharge != null) {
          // ensure the json data is an array
          if (!jsonObj.get("allowanceOrCharge").isJsonArray()) {
            throw new IllegalArgumentException(String.format("Expected the field `allowanceOrCharge` to be an array in the JSON string but got `%s`", jsonObj.get("allowanceOrCharge").toString()));
          }

          // validate the optional field `allowanceOrCharge` (array)
          for (int i = 0; i < jsonArrayallowanceOrCharge.size(); i++) {
            EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleAllowanceOrChargeInner.validateJsonElement(jsonArrayallowanceOrCharge.get(i));
          };
        }
      }
      // validate the optional field `lineItemTotalAmount`
      if (jsonObj.get("lineItemTotalAmount") != null && !jsonObj.get("lineItemTotalAmount").isJsonNull()) {
        EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleLineItemTotalAmount.validateJsonElement(jsonObj.get("lineItemTotalAmount"));
      }
      // validate the optional field `consignee`
      if (jsonObj.get("consignee") != null && !jsonObj.get("consignee").isJsonNull()) {
        EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleConsignee.validateJsonElement(jsonObj.get("consignee"));
      }
      if (jsonObj.get("tracingInformation") != null && !jsonObj.get("tracingInformation").isJsonNull()) {
        JsonArray jsonArraytracingInformation = jsonObj.getAsJsonArray("tracingInformation");
        if (jsonArraytracingInformation != null) {
          // ensure the json data is an array
          if (!jsonObj.get("tracingInformation").isJsonArray()) {
            throw new IllegalArgumentException(String.format("Expected the field `tracingInformation` to be an array in the JSON string but got `%s`", jsonObj.get("tracingInformation").toString()));
          }

          // validate the optional field `tracingInformation` (array)
          for (int i = 0; i < jsonArraytracingInformation.size(); i++) {
            EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleTracingInformationInner.validateJsonElement(jsonArraytracingInformation.get(i));
          };
        }
      }
      // validate the optional field `lineNote`
      if (jsonObj.get("lineNote") != null && !jsonObj.get("lineNote").isJsonNull()) {
        EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticleLineNote.validateJsonElement(jsonObj.get("lineNote"));
      }
      if ((jsonObj.get("countryOfOrigin") != null && !jsonObj.get("countryOfOrigin").isJsonNull()) && !jsonObj.get("countryOfOrigin").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `countryOfOrigin` to be a primitive type in the JSON string but got `%s`", jsonObj.get("countryOfOrigin").toString()));
      }
  }

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

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

           @Override
           public EDIWheelB34InvoiceListResponseInvoiceInnerLineLevelInnerArticle read(JsonReader in) throws IOException {
             JsonElement jsonElement = elementAdapter.read(in);
             validateJsonElement(jsonElement);
             return thisAdapter.fromJsonTree(jsonElement);
           }

       }.nullSafe();
    }
  }

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

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

