|
| 1 | +/* |
| 2 | + * Tokenization webhooks |
| 3 | + * |
| 4 | + * The version of the OpenAPI document: 1 |
| 5 | + * |
| 6 | + * |
| 7 | + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). |
| 8 | + * https://openapi-generator.tech |
| 9 | + * Do not edit the class manually. |
| 10 | + */ |
| 11 | + |
| 12 | +package com.adyen.model.tokenizationwebhooks; |
| 13 | + |
| 14 | +import com.fasterxml.jackson.annotation.JsonValue; |
| 15 | +import jakarta.ws.rs.core.GenericType; |
| 16 | +import java.util.Map; |
| 17 | +import java.util.Objects; |
| 18 | + |
| 19 | +/** Abstract class for oneOf,anyOf schemas defined in OpenAPI spec */ |
| 20 | +public abstract class AbstractOpenApiSchema { |
| 21 | + |
| 22 | + // store the actual instance of the schema/object |
| 23 | + private Object instance; |
| 24 | + |
| 25 | + // is nullable |
| 26 | + private Boolean isNullable; |
| 27 | + |
| 28 | + // schema type (e.g. oneOf, anyOf) |
| 29 | + private final String schemaType; |
| 30 | + |
| 31 | + /** |
| 32 | + * @param schemaType the schema type |
| 33 | + * @param isNullable whether the instance is nullable |
| 34 | + */ |
| 35 | + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { |
| 36 | + this.schemaType = schemaType; |
| 37 | + this.isNullable = isNullable; |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object |
| 42 | + * |
| 43 | + * @return an instance of the actual schema/object |
| 44 | + */ |
| 45 | + public abstract Map<String, GenericType<?>> getSchemas(); |
| 46 | + |
| 47 | + /** |
| 48 | + * Get the actual instance |
| 49 | + * |
| 50 | + * @return an instance of the actual schema/object |
| 51 | + */ |
| 52 | + @JsonValue |
| 53 | + public Object getActualInstance() { |
| 54 | + return instance; |
| 55 | + } |
| 56 | + |
| 57 | + /** |
| 58 | + * Set the actual instance |
| 59 | + * |
| 60 | + * @param instance the actual instance of the schema/object |
| 61 | + */ |
| 62 | + public void setActualInstance(Object instance) { |
| 63 | + this.instance = instance; |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf |
| 68 | + * schema as well |
| 69 | + * |
| 70 | + * @return an instance of the actual schema/object |
| 71 | + */ |
| 72 | + public Object getActualInstanceRecursively() { |
| 73 | + return getActualInstanceRecursively(this); |
| 74 | + } |
| 75 | + |
| 76 | + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { |
| 77 | + if (object.getActualInstance() == null) { |
| 78 | + return null; |
| 79 | + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { |
| 80 | + return getActualInstanceRecursively((AbstractOpenApiSchema) object.getActualInstance()); |
| 81 | + } else { |
| 82 | + return object.getActualInstance(); |
| 83 | + } |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * Get the schema type (e.g. anyOf, oneOf) |
| 88 | + * |
| 89 | + * @return the schema type |
| 90 | + */ |
| 91 | + public String getSchemaType() { |
| 92 | + return schemaType; |
| 93 | + } |
| 94 | + |
| 95 | + @Override |
| 96 | + public String toString() { |
| 97 | + StringBuilder sb = new StringBuilder(); |
| 98 | + sb.append("class ").append(getClass()).append(" {\n"); |
| 99 | + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); |
| 100 | + sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); |
| 101 | + sb.append(" schemaType: ").append(toIndentedString(schemaType)).append("\n"); |
| 102 | + sb.append("}"); |
| 103 | + return sb.toString(); |
| 104 | + } |
| 105 | + |
| 106 | + /** |
| 107 | + * Convert the given object to string with each line indented by 4 spaces (except the first line). |
| 108 | + */ |
| 109 | + private String toIndentedString(Object o) { |
| 110 | + if (o == null) { |
| 111 | + return "null"; |
| 112 | + } |
| 113 | + return o.toString().replace("\n", "\n "); |
| 114 | + } |
| 115 | + |
| 116 | + public boolean equals(Object o) { |
| 117 | + if (this == o) { |
| 118 | + return true; |
| 119 | + } |
| 120 | + if (o == null || getClass() != o.getClass()) { |
| 121 | + return false; |
| 122 | + } |
| 123 | + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; |
| 124 | + return Objects.equals(this.instance, a.instance) |
| 125 | + && Objects.equals(this.isNullable, a.isNullable) |
| 126 | + && Objects.equals(this.schemaType, a.schemaType); |
| 127 | + } |
| 128 | + |
| 129 | + @Override |
| 130 | + public int hashCode() { |
| 131 | + return Objects.hash(instance, isNullable, schemaType); |
| 132 | + } |
| 133 | + |
| 134 | + /** |
| 135 | + * Is nullable |
| 136 | + * |
| 137 | + * @return true if it's nullable |
| 138 | + */ |
| 139 | + public Boolean isNullable() { |
| 140 | + if (Boolean.TRUE.equals(isNullable)) { |
| 141 | + return Boolean.TRUE; |
| 142 | + } else { |
| 143 | + return Boolean.FALSE; |
| 144 | + } |
| 145 | + } |
| 146 | +} |
0 commit comments