All Downloads are FREE. Search and download functionalities are using the official Maven repository.

openapitools.model.ParentClass Maven / Gradle / Ivy

There is a newer version: 1.24.2
Show newest version
/*
 * Product Base Definitions
 * This component represents the Open API interface of the accounting service. 
 *
 * The version of the OpenAPI document: 0.0.1
 * Contact: [email protected]
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


package openapitools.model;

import java.util.Objects;
import java.util.Map;
import java.util.HashMap;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import openapitools.model.BankAccount;
import org.openapitools.jackson.nullable.JsonNullable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.openapitools.jackson.nullable.JsonNullable;
import java.util.NoSuchElementException;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import openapitools.JSON;


/**
 * ParentClass
 */
@JsonPropertyOrder({
  ParentClass.JSON_PROPERTY_OBJECT_TYPE,
  ParentClass.JSON_PROPERTY_PARENT_ATTRIBUTE,
  ParentClass.JSON_PROPERTY_IBANS,
  ParentClass.JSON_PROPERTY_THE_BANK_ACCOUNT,
  ParentClass.JSON_PROPERTY_LEGACY_BANK_ACCOUNTS
})
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0")
@JsonIgnoreProperties(
  value = "objectType", // ignore manually set objectType, it will be automatically generated by Jackson during serialization
  allowSetters = true // allows the objectType to be set during deserialization
)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "objectType", visible = true)
@JsonSubTypes({
  @JsonSubTypes.Type(value = ChildA.class, name = "ChildA"),
  @JsonSubTypes.Type(value = ChildAA.class, name = "ChildAA"),
  @JsonSubTypes.Type(value = ChildB.class, name = "ChildB"),
  @JsonSubTypes.Type(value = ChildBB.class, name = "ChildBB"),
})

public class ParentClass {
  public static final String JSON_PROPERTY_OBJECT_TYPE = "objectType";
  private String objectType;

  public static final String JSON_PROPERTY_PARENT_ATTRIBUTE = "parentAttribute";
  private String parentAttribute;

  public static final String JSON_PROPERTY_IBANS = "ibans";
  private JsonNullable> ibans = JsonNullable.>undefined();

  public static final String JSON_PROPERTY_THE_BANK_ACCOUNT = "theBankAccount";
  private BankAccount theBankAccount;

  public static final String JSON_PROPERTY_LEGACY_BANK_ACCOUNTS = "legacyBankAccounts";
  @Deprecated
  private List legacyBankAccounts = new ArrayList<>();

  public ParentClass() { 
  }

  public ParentClass objectType(String objectType) {
    this.objectType = objectType;
    return this;
  }

  /**
   * Attribute is used as discriminator for inheritance between data types.
   * @return objectType
   */
  @javax.annotation.Nonnull
  @JsonProperty(JSON_PROPERTY_OBJECT_TYPE)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)

  public String getObjectType() {
    return objectType;
  }


  @JsonProperty(JSON_PROPERTY_OBJECT_TYPE)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)
  public void setObjectType(String objectType) {
    this.objectType = objectType;
  }


  public ParentClass parentAttribute(String parentAttribute) {
    this.parentAttribute = parentAttribute;
    return this;
  }

  /**
   * Get parentAttribute
   * @return parentAttribute
   */
  @javax.annotation.Nonnull
  @JsonProperty(JSON_PROPERTY_PARENT_ATTRIBUTE)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)

  public String getParentAttribute() {
    return parentAttribute;
  }


  @JsonProperty(JSON_PROPERTY_PARENT_ATTRIBUTE)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)
  public void setParentAttribute(String parentAttribute) {
    this.parentAttribute = parentAttribute;
  }


  public ParentClass ibans(List ibans) {
    this.ibans = JsonNullable.>of(ibans);
    return this;
  }

  public ParentClass addIbansItem(String ibansItem) {
    if (this.ibans == null || !this.ibans.isPresent()) {
      this.ibans = JsonNullable.>of(new ArrayList<>());
    }
    try {
      this.ibans.get().add(ibansItem);
    } catch (java.util.NoSuchElementException e) {
      // this can never happen, as we make sure above that the value is present
    }
    return this;
  }

  /**
   * Get ibans
   * @return ibans
   */
  @javax.annotation.Nullable
  @JsonIgnore

  public List getIbans() {
        return ibans.orElse(null);
  }

  @JsonProperty(JSON_PROPERTY_IBANS)
  @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

  public JsonNullable> getIbans_JsonNullable() {
    return ibans;
  }
  
  @JsonProperty(JSON_PROPERTY_IBANS)
  public void setIbans_JsonNullable(JsonNullable> ibans) {
    this.ibans = ibans;
  }

  public void setIbans(List ibans) {
    this.ibans = JsonNullable.>of(ibans);
  }


  public ParentClass theBankAccount(BankAccount theBankAccount) {
    this.theBankAccount = theBankAccount;
    return this;
  }

  /**
   * Get theBankAccount
   * @return theBankAccount
   */
  @javax.annotation.Nullable
  @JsonProperty(JSON_PROPERTY_THE_BANK_ACCOUNT)
  @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

  public BankAccount getTheBankAccount() {
    return theBankAccount;
  }


  @JsonProperty(JSON_PROPERTY_THE_BANK_ACCOUNT)
  @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
  public void setTheBankAccount(BankAccount theBankAccount) {
    this.theBankAccount = theBankAccount;
  }


  @Deprecated
  public ParentClass legacyBankAccounts(List legacyBankAccounts) {
    this.legacyBankAccounts = legacyBankAccounts;
    return this;
  }

  public ParentClass addLegacyBankAccountsItem(BankAccount legacyBankAccountsItem) {
    if (this.legacyBankAccounts == null) {
      this.legacyBankAccounts = new ArrayList<>();
    }
    this.legacyBankAccounts.add(legacyBankAccountsItem);
    return this;
  }

  /**
   * Association is still there be SemVer compliant. 
   * @return legacyBankAccounts
   * @deprecated
   */
  @Deprecated
  @javax.annotation.Nullable
  @JsonProperty(JSON_PROPERTY_LEGACY_BANK_ACCOUNTS)
  @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

  public List getLegacyBankAccounts() {
    return legacyBankAccounts;
  }


  @Deprecated
  @JsonProperty(JSON_PROPERTY_LEGACY_BANK_ACCOUNTS)
  @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
  public void setLegacyBankAccounts(List legacyBankAccounts) {
    this.legacyBankAccounts = legacyBankAccounts;
  }


  /**
   * Return true if this ParentClass object is equal to o.
   */
  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    ParentClass parentClass = (ParentClass) o;
    return Objects.equals(this.objectType, parentClass.objectType) &&
        Objects.equals(this.parentAttribute, parentClass.parentAttribute) &&
        equalsNullable(this.ibans, parentClass.ibans) &&
        Objects.equals(this.theBankAccount, parentClass.theBankAccount) &&
        Objects.equals(this.legacyBankAccounts, parentClass.legacyBankAccounts);
  }

  private static  boolean equalsNullable(JsonNullable a, JsonNullable b) {
    return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
  }

  @Override
  public int hashCode() {
    return Objects.hash(objectType, parentAttribute, hashCodeNullable(ibans), theBankAccount, legacyBankAccounts);
  }

  private static  int hashCodeNullable(JsonNullable a) {
    if (a == null) {
      return 1;
    }
    return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class ParentClass {\n");
    sb.append("    objectType: ").append(toIndentedString(objectType)).append("\n");
    sb.append("    parentAttribute: ").append(toIndentedString(parentAttribute)).append("\n");
    sb.append("    ibans: ").append(toIndentedString(ibans)).append("\n");
    sb.append("    theBankAccount: ").append(toIndentedString(theBankAccount)).append("\n");
    sb.append("    legacyBankAccounts: ").append(toIndentedString(legacyBankAccounts)).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    ");
  }

  static {
    // Initialize and register the discriminator mappings.
    Map> mappings = new HashMap<>();
    mappings.put("ChildA", ChildA.class);
    mappings.put("ChildAA", ChildAA.class);
    mappings.put("ChildB", ChildB.class);
    mappings.put("ChildBB", ChildBB.class);
    mappings.put("ParentClass", ParentClass.class);
    JSON.registerDiscriminator(ParentClass.class, "objectType", mappings);
  }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy