com.kibocommerce.sdk.inventory.models.ItemQuantity Maven / Gradle / Ivy
The newest version!
/*
* Inventory
* Swagger JSON for inventory apis
*
* The version of the OpenAPI document: 1.0.0
*
*
* 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.kibocommerce.sdk.inventory.models;
import java.util.Objects;
import java.util.Arrays;
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.HashMap;
import java.util.Map;
import java.io.Serializable;
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.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import com.kibocommerce.sdk.common.JSON;
/**
* Item Quantity Model
*/
@ApiModel(description = "Item Quantity Model")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class ItemQuantity implements Serializable {
private static final long serialVersionUID = 1L;
public static final String SERIALIZED_NAME_PART_NUMBER = "partNumber";
@SerializedName(SERIALIZED_NAME_PART_NUMBER)
private String partNumber;
public static final String SERIALIZED_NAME_UPC = "upc";
@SerializedName(SERIALIZED_NAME_UPC)
private String upc;
public static final String SERIALIZED_NAME_SKU = "sku";
@SerializedName(SERIALIZED_NAME_SKU)
private String sku;
public static final String SERIALIZED_NAME_QUANTITY = "quantity";
@SerializedName(SERIALIZED_NAME_QUANTITY)
private Integer quantity;
public static final String SERIALIZED_NAME_TAGS = "tags";
@SerializedName(SERIALIZED_NAME_TAGS)
private Map tags = null;
public ItemQuantity() {
}
public ItemQuantity partNumber(String partNumber) {
this.partNumber = partNumber;
return this;
}
/**
* Part/Product Number
* @return partNumber
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "Part/Product Number")
public String getPartNumber() {
return partNumber;
}
public void setPartNumber(String partNumber) {
this.partNumber = partNumber;
}
public ItemQuantity upc(String upc) {
this.upc = upc;
return this;
}
/**
* Universal Product Code
* @return upc
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "Universal Product Code")
public String getUpc() {
return upc;
}
public void setUpc(String upc) {
this.upc = upc;
}
public ItemQuantity sku(String sku) {
this.sku = sku;
return this;
}
/**
* Stock Keeping Unit
* @return sku
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "Stock Keeping Unit")
public String getSku() {
return sku;
}
public void setSku(String sku) {
this.sku = sku;
}
public ItemQuantity quantity(Integer quantity) {
this.quantity = quantity;
return this;
}
/**
* Quantity
* @return quantity
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "Quantity")
public Integer getQuantity() {
return quantity;
}
public void setQuantity(Integer quantity) {
this.quantity = quantity;
}
public ItemQuantity tags(Map tags) {
this.tags = tags;
return this;
}
public ItemQuantity putTagsItem(String key, String tagsItem) {
if (this.tags == null) {
this.tags = new HashMap<>();
}
this.tags.put(key, tagsItem);
return this;
}
/**
* Associative Map of <String, String> for tagCategoryName => tagName
* @return tags
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "Associative Map of for tagCategoryName => tagName")
public Map getTags() {
return tags;
}
public void setTags(Map tags) {
this.tags = tags;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ItemQuantity itemQuantity = (ItemQuantity) o;
return Objects.equals(this.partNumber, itemQuantity.partNumber) &&
Objects.equals(this.upc, itemQuantity.upc) &&
Objects.equals(this.sku, itemQuantity.sku) &&
Objects.equals(this.quantity, itemQuantity.quantity) &&
Objects.equals(this.tags, itemQuantity.tags);
}
@Override
public int hashCode() {
return Objects.hash(partNumber, upc, sku, quantity, tags);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ItemQuantity {\n");
sb.append(" partNumber: ").append(toIndentedString(partNumber)).append("\n");
sb.append(" upc: ").append(toIndentedString(upc)).append("\n");
sb.append(" sku: ").append(toIndentedString(sku)).append("\n");
sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n");
sb.append(" tags: ").append(toIndentedString(tags)).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 openapiFields;
public static HashSet openapiRequiredFields;
static {
// a set of all properties/fields (JSON key names)
openapiFields = new HashSet();
openapiFields.add("partNumber");
openapiFields.add("upc");
openapiFields.add("sku");
openapiFields.add("quantity");
openapiFields.add("tags");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
}
/**
* 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 ItemQuantity
*/
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
if (jsonObj == null) {
if (!ItemQuantity.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
throw new IllegalArgumentException(String.format("The required field(s) %s in ItemQuantity is not found in the empty JSON string", ItemQuantity.openapiRequiredFields.toString()));
}
}
// Set> entries = jsonObj.entrySet();
// check to see if the JSON string contains additional fields
// for (Entry entry : entries) {
// if (!ItemQuantity.openapiFields.contains(entry.getKey())) {
// throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ItemQuantity` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
// }
// }
if ((jsonObj.get("partNumber") != null && !jsonObj.get("partNumber").isJsonNull()) && !jsonObj.get("partNumber").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `partNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("partNumber").toString()));
}
if ((jsonObj.get("upc") != null && !jsonObj.get("upc").isJsonNull()) && !jsonObj.get("upc").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `upc` to be a primitive type in the JSON string but got `%s`", jsonObj.get("upc").toString()));
}
if ((jsonObj.get("sku") != null && !jsonObj.get("sku").isJsonNull()) && !jsonObj.get("sku").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `sku` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sku").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!ItemQuantity.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'ItemQuantity' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(ItemQuantity.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, ItemQuantity value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public ItemQuantity read(JsonReader in) throws IOException {
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
validateJsonObject(jsonObj);
return thisAdapter.fromJsonTree(jsonObj);
}
}.nullSafe();
}
}
/**
* Create an instance of ItemQuantity given an JSON string
*
* @param jsonString JSON string
* @return An instance of ItemQuantity
* @throws IOException if the JSON string is invalid with respect to ItemQuantity
*/
public static ItemQuantity fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, ItemQuantity.class);
}
/**
* Convert an instance of ItemQuantity to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}