/*
 * Lethean Blockchain API
 * OpenAPI for Lethean Blockchain
 *
 * The version of the OpenAPI document: 6.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 org.openapitools.client.model;

import java.util.Objects;
import java.util.Locale;
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 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 java.util.Locale;

import invalidPackageName.JSON;

/**
 * TransactionOutputModel
 */
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-10-19T15:35:02.750468+01:00[Europe/London]", comments = "Generator version: 7.16.0")
public class TransactionOutputModel {
  public static final String SERIALIZED_NAME_AMOUNT = "amount";
  @SerializedName(SERIALIZED_NAME_AMOUNT)
  @javax.annotation.Nullable
  private Integer amount;

  public static final String SERIALIZED_NAME_GLOBAL_INDEX = "global_index";
  @SerializedName(SERIALIZED_NAME_GLOBAL_INDEX)
  @javax.annotation.Nullable
  private Integer globalIndex;

  public static final String SERIALIZED_NAME_IS_SPENT = "is_spent";
  @SerializedName(SERIALIZED_NAME_IS_SPENT)
  @javax.annotation.Nullable
  private Boolean isSpent;

  public static final String SERIALIZED_NAME_MINIMUM_SIGS = "minimum_sigs";
  @SerializedName(SERIALIZED_NAME_MINIMUM_SIGS)
  @javax.annotation.Nullable
  private Integer minimumSigs;

  public static final String SERIALIZED_NAME_PUB_KEYS = "pub_keys";
  @SerializedName(SERIALIZED_NAME_PUB_KEYS)
  @javax.annotation.Nullable
  private List<String> pubKeys = new ArrayList<>();

  public TransactionOutputModel() {
  }

  public TransactionOutputModel amount(@javax.annotation.Nullable Integer amount) {
    this.amount = amount;
    return this;
  }

  /**
   * Get amount
   * @return amount
   */
  @javax.annotation.Nullable
  public Integer getAmount() {
    return amount;
  }

  public void setAmount(@javax.annotation.Nullable Integer amount) {
    this.amount = amount;
  }


  public TransactionOutputModel globalIndex(@javax.annotation.Nullable Integer globalIndex) {
    this.globalIndex = globalIndex;
    return this;
  }

  /**
   * Get globalIndex
   * @return globalIndex
   */
  @javax.annotation.Nullable
  public Integer getGlobalIndex() {
    return globalIndex;
  }

  public void setGlobalIndex(@javax.annotation.Nullable Integer globalIndex) {
    this.globalIndex = globalIndex;
  }


  public TransactionOutputModel isSpent(@javax.annotation.Nullable Boolean isSpent) {
    this.isSpent = isSpent;
    return this;
  }

  /**
   * Get isSpent
   * @return isSpent
   */
  @javax.annotation.Nullable
  public Boolean getIsSpent() {
    return isSpent;
  }

  public void setIsSpent(@javax.annotation.Nullable Boolean isSpent) {
    this.isSpent = isSpent;
  }


  public TransactionOutputModel minimumSigs(@javax.annotation.Nullable Integer minimumSigs) {
    this.minimumSigs = minimumSigs;
    return this;
  }

  /**
   * Get minimumSigs
   * minimum: 0
   * maximum: 4294967295
   * @return minimumSigs
   */
  @javax.annotation.Nullable
  public Integer getMinimumSigs() {
    return minimumSigs;
  }

  public void setMinimumSigs(@javax.annotation.Nullable Integer minimumSigs) {
    this.minimumSigs = minimumSigs;
  }


  public TransactionOutputModel pubKeys(@javax.annotation.Nullable List<String> pubKeys) {
    this.pubKeys = pubKeys;
    return this;
  }

  public TransactionOutputModel addPubKeysItem(String pubKeysItem) {
    if (this.pubKeys == null) {
      this.pubKeys = new ArrayList<>();
    }
    this.pubKeys.add(pubKeysItem);
    return this;
  }

  /**
   * Get pubKeys
   * @return pubKeys
   */
  @javax.annotation.Nullable
  public List<String> getPubKeys() {
    return pubKeys;
  }

  public void setPubKeys(@javax.annotation.Nullable List<String> pubKeys) {
    this.pubKeys = pubKeys;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    TransactionOutputModel transactionOutputModel = (TransactionOutputModel) o;
    return Objects.equals(this.amount, transactionOutputModel.amount) &&
        Objects.equals(this.globalIndex, transactionOutputModel.globalIndex) &&
        Objects.equals(this.isSpent, transactionOutputModel.isSpent) &&
        Objects.equals(this.minimumSigs, transactionOutputModel.minimumSigs) &&
        Objects.equals(this.pubKeys, transactionOutputModel.pubKeys);
  }

  @Override
  public int hashCode() {
    return Objects.hash(amount, globalIndex, isSpent, minimumSigs, pubKeys);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class TransactionOutputModel {\n");
    sb.append("    amount: ").append(toIndentedString(amount)).append("\n");
    sb.append("    globalIndex: ").append(toIndentedString(globalIndex)).append("\n");
    sb.append("    isSpent: ").append(toIndentedString(isSpent)).append("\n");
    sb.append("    minimumSigs: ").append(toIndentedString(minimumSigs)).append("\n");
    sb.append("    pubKeys: ").append(toIndentedString(pubKeys)).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>(Arrays.asList("amount", "global_index", "is_spent", "minimum_sigs", "pub_keys"));

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

  /**
   * 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 TransactionOutputModel
   */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!TransactionOutputModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in TransactionOutputModel is not found in the empty JSON string", TransactionOutputModel.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 (!TransactionOutputModel.openapiFields.contains(entry.getKey())) {
          throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TransactionOutputModel` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      // ensure the optional json data is an array if present
      if (jsonObj.get("pub_keys") != null && !jsonObj.get("pub_keys").isJsonNull() && !jsonObj.get("pub_keys").isJsonArray()) {
        throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `pub_keys` to be an array in the JSON string but got `%s`", jsonObj.get("pub_keys").toString()));
      }
  }

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

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

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

       }.nullSafe();
    }
  }

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

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

