/*
 * 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.Arrays;

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;

/**
 * PosEntryModel
 */
@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 PosEntryModel {
  public static final String SERIALIZED_NAME_AMOUNT = "amount";
  @SerializedName(SERIALIZED_NAME_AMOUNT)
  @javax.annotation.Nullable
  private Integer amount;

  public static final String SERIALIZED_NAME_G_INDEX = "g_index";
  @SerializedName(SERIALIZED_NAME_G_INDEX)
  @javax.annotation.Nullable
  private Integer gIndex;

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

  public static final String SERIALIZED_NAME_BLOCK_TIMESTAMP = "block_timestamp";
  @SerializedName(SERIALIZED_NAME_BLOCK_TIMESTAMP)
  @javax.annotation.Nullable
  private Integer blockTimestamp;

  public static final String SERIALIZED_NAME_STAKE_UNLOCK_TIME = "stake_unlock_time";
  @SerializedName(SERIALIZED_NAME_STAKE_UNLOCK_TIME)
  @javax.annotation.Nullable
  private Integer stakeUnlockTime;

  public static final String SERIALIZED_NAME_TX_ID = "tx_id";
  @SerializedName(SERIALIZED_NAME_TX_ID)
  @javax.annotation.Nullable
  private String txId;

  public static final String SERIALIZED_NAME_TX_OUT_INDEX = "tx_out_index";
  @SerializedName(SERIALIZED_NAME_TX_OUT_INDEX)
  @javax.annotation.Nullable
  private Integer txOutIndex;

  public static final String SERIALIZED_NAME_WALLET_INDEX = "wallet_index";
  @SerializedName(SERIALIZED_NAME_WALLET_INDEX)
  @javax.annotation.Nullable
  private Integer walletIndex;

  public PosEntryModel() {
  }

  public PosEntryModel 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 PosEntryModel gIndex(@javax.annotation.Nullable Integer gIndex) {
    this.gIndex = gIndex;
    return this;
  }

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

  public void setgIndex(@javax.annotation.Nullable Integer gIndex) {
    this.gIndex = gIndex;
  }


  public PosEntryModel keyimage(@javax.annotation.Nullable String keyimage) {
    this.keyimage = keyimage;
    return this;
  }

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

  public void setKeyimage(@javax.annotation.Nullable String keyimage) {
    this.keyimage = keyimage;
  }


  public PosEntryModel blockTimestamp(@javax.annotation.Nullable Integer blockTimestamp) {
    this.blockTimestamp = blockTimestamp;
    return this;
  }

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

  public void setBlockTimestamp(@javax.annotation.Nullable Integer blockTimestamp) {
    this.blockTimestamp = blockTimestamp;
  }


  public PosEntryModel stakeUnlockTime(@javax.annotation.Nullable Integer stakeUnlockTime) {
    this.stakeUnlockTime = stakeUnlockTime;
    return this;
  }

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

  public void setStakeUnlockTime(@javax.annotation.Nullable Integer stakeUnlockTime) {
    this.stakeUnlockTime = stakeUnlockTime;
  }


  public PosEntryModel txId(@javax.annotation.Nullable String txId) {
    this.txId = txId;
    return this;
  }

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

  public void setTxId(@javax.annotation.Nullable String txId) {
    this.txId = txId;
  }


  public PosEntryModel txOutIndex(@javax.annotation.Nullable Integer txOutIndex) {
    this.txOutIndex = txOutIndex;
    return this;
  }

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

  public void setTxOutIndex(@javax.annotation.Nullable Integer txOutIndex) {
    this.txOutIndex = txOutIndex;
  }


  public PosEntryModel walletIndex(@javax.annotation.Nullable Integer walletIndex) {
    this.walletIndex = walletIndex;
    return this;
  }

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

  public void setWalletIndex(@javax.annotation.Nullable Integer walletIndex) {
    this.walletIndex = walletIndex;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    PosEntryModel posEntryModel = (PosEntryModel) o;
    return Objects.equals(this.amount, posEntryModel.amount) &&
        Objects.equals(this.gIndex, posEntryModel.gIndex) &&
        Objects.equals(this.keyimage, posEntryModel.keyimage) &&
        Objects.equals(this.blockTimestamp, posEntryModel.blockTimestamp) &&
        Objects.equals(this.stakeUnlockTime, posEntryModel.stakeUnlockTime) &&
        Objects.equals(this.txId, posEntryModel.txId) &&
        Objects.equals(this.txOutIndex, posEntryModel.txOutIndex) &&
        Objects.equals(this.walletIndex, posEntryModel.walletIndex);
  }

  @Override
  public int hashCode() {
    return Objects.hash(amount, gIndex, keyimage, blockTimestamp, stakeUnlockTime, txId, txOutIndex, walletIndex);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class PosEntryModel {\n");
    sb.append("    amount: ").append(toIndentedString(amount)).append("\n");
    sb.append("    gIndex: ").append(toIndentedString(gIndex)).append("\n");
    sb.append("    keyimage: ").append(toIndentedString(keyimage)).append("\n");
    sb.append("    blockTimestamp: ").append(toIndentedString(blockTimestamp)).append("\n");
    sb.append("    stakeUnlockTime: ").append(toIndentedString(stakeUnlockTime)).append("\n");
    sb.append("    txId: ").append(toIndentedString(txId)).append("\n");
    sb.append("    txOutIndex: ").append(toIndentedString(txOutIndex)).append("\n");
    sb.append("    walletIndex: ").append(toIndentedString(walletIndex)).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", "g_index", "keyimage", "block_timestamp", "stake_unlock_time", "tx_id", "tx_out_index", "wallet_index"));

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

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

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

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

       }.nullSafe();
    }
  }

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

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

