diff --git a/src/main/java/com/adyen/model/negativebalancewarningwebhooks/AbstractOpenApiSchema.java b/src/main/java/com/adyen/model/java/AbstractOpenApiSchema.java similarity index 98% rename from src/main/java/com/adyen/model/negativebalancewarningwebhooks/AbstractOpenApiSchema.java rename to src/main/java/com/adyen/model/java/AbstractOpenApiSchema.java index d248a2531..2e720d4df 100644 --- a/src/main/java/com/adyen/model/negativebalancewarningwebhooks/AbstractOpenApiSchema.java +++ b/src/main/java/com/adyen/model/java/AbstractOpenApiSchema.java @@ -9,7 +9,7 @@ * Do not edit the class manually. */ -package com.adyen.model.negativebalancewarningwebhooks; +package com.adyen.model.java; import com.fasterxml.jackson.annotation.JsonValue; import jakarta.ws.rs.core.GenericType; diff --git a/src/main/java/com/adyen/model/negativebalancewarningwebhooks/Amount.java b/src/main/java/com/adyen/model/java/Amount.java similarity index 69% rename from src/main/java/com/adyen/model/negativebalancewarningwebhooks/Amount.java rename to src/main/java/com/adyen/model/java/Amount.java index ed1518219..eb1335f07 100644 --- a/src/main/java/com/adyen/model/negativebalancewarningwebhooks/Amount.java +++ b/src/main/java/com/adyen/model/java/Amount.java @@ -9,8 +9,10 @@ * Do not edit the class manually. */ -package com.adyen.model.negativebalancewarningwebhooks; +package com.adyen.model.java; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -23,9 +25,21 @@ public class Amount { public static final String JSON_PROPERTY_CURRENCY = "currency"; private String currency; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetCurrency = false; + public static final String JSON_PROPERTY_VALUE = "value"; private Long value; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetValue = false; + + /** + * Sets whether attributes with null values should be explicitly included in the JSON payload. + * Default is false. + */ + @JsonIgnore private boolean includeNullValues = false; + public Amount() {} /** @@ -40,6 +54,7 @@ public Amount() {} */ public Amount currency(String currency) { this.currency = currency; + isSetCurrency = true; // mark as set return this; } @@ -71,6 +86,7 @@ public String getCurrency() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCurrency(String currency) { this.currency = currency; + isSetCurrency = true; // mark as set } /** @@ -83,6 +99,7 @@ public void setCurrency(String currency) { */ public Amount value(Long value) { this.value = value; + isSetValue = true; // mark as set return this; } @@ -110,6 +127,27 @@ public Long getValue() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setValue(Long value) { this.value = value; + isSetValue = true; // mark as set + } + + /** + * Configures whether null values are explicitly serialized in the JSON payload. Default is false. + */ + public Amount includeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + return this; + } + + /** Returns whether null values are explicitly serialized in the JSON payload. */ + public boolean isIncludeNullValues() { + return includeNullValues; + } + + /** + * Sets whether null values should be explicitly serialized in the JSON payload. Default is false. + */ + public void setIncludeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; } /** Return true if this Amount object is equal to o. */ @@ -123,12 +161,14 @@ public boolean equals(Object o) { } Amount amount = (Amount) o; return Objects.equals(this.currency, amount.currency) - && Objects.equals(this.value, amount.value); + && Objects.equals(this.isSetCurrency, amount.isSetCurrency) + && Objects.equals(this.value, amount.value) + && Objects.equals(this.isSetValue, amount.isSetValue); } @Override public int hashCode() { - return Objects.hash(currency, value); + return Objects.hash(currency, isSetCurrency, value, isSetValue); } @Override @@ -151,6 +191,33 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + /** Returns a map of properties to be merged into the JSON payload as explicit null values. */ + @JsonInclude(JsonInclude.Include.ALWAYS) + @JsonAnyGetter + public Map getExplicitNulls() { + if (!this.includeNullValues) { + return Collections.emptyMap(); + } + + Map nulls = new HashMap<>(); + + if (isSetCurrency) { + addIfNull(nulls, JSON_PROPERTY_CURRENCY, this.currency); + } + if (isSetValue) { + addIfNull(nulls, JSON_PROPERTY_VALUE, this.value); + } + + return nulls; + } + + // add to map when value is null + private void addIfNull(Map map, String key, Object value) { + if (value == null) { + map.put(key, null); + } + } + /** * Create an instance of Amount given an JSON string * diff --git a/src/main/java/com/adyen/model/negativebalancewarningwebhooks/NegativeBalanceCompensationWarningNotificationData.java b/src/main/java/com/adyen/model/java/NegativeBalanceCompensationWarningNotificationData.java similarity index 74% rename from src/main/java/com/adyen/model/negativebalancewarningwebhooks/NegativeBalanceCompensationWarningNotificationData.java rename to src/main/java/com/adyen/model/java/NegativeBalanceCompensationWarningNotificationData.java index db92ccaea..874e03aee 100644 --- a/src/main/java/com/adyen/model/negativebalancewarningwebhooks/NegativeBalanceCompensationWarningNotificationData.java +++ b/src/main/java/com/adyen/model/java/NegativeBalanceCompensationWarningNotificationData.java @@ -9,8 +9,10 @@ * Do not edit the class manually. */ -package com.adyen.model.negativebalancewarningwebhooks; +package com.adyen.model.java; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -33,27 +35,57 @@ public class NegativeBalanceCompensationWarningNotificationData { public static final String JSON_PROPERTY_ACCOUNT_HOLDER = "accountHolder"; private ResourceReference accountHolder; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetAccountHolder = false; + public static final String JSON_PROPERTY_AMOUNT = "amount"; private Amount amount; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetAmount = false; + public static final String JSON_PROPERTY_BALANCE_PLATFORM = "balancePlatform"; private String balancePlatform; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetBalancePlatform = false; + public static final String JSON_PROPERTY_CREATION_DATE = "creationDate"; private OffsetDateTime creationDate; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetCreationDate = false; + public static final String JSON_PROPERTY_ID = "id"; private String id; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetId = false; + public static final String JSON_PROPERTY_LIABLE_BALANCE_ACCOUNT_ID = "liableBalanceAccountId"; private String liableBalanceAccountId; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetLiableBalanceAccountId = false; + public static final String JSON_PROPERTY_NEGATIVE_BALANCE_SINCE = "negativeBalanceSince"; private OffsetDateTime negativeBalanceSince; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetNegativeBalanceSince = false; + public static final String JSON_PROPERTY_SCHEDULED_COMPENSATION_AT = "scheduledCompensationAt"; private OffsetDateTime scheduledCompensationAt; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetScheduledCompensationAt = false; + + /** + * Sets whether attributes with null values should be explicitly included in the JSON payload. + * Default is false. + */ + @JsonIgnore private boolean includeNullValues = false; + public NegativeBalanceCompensationWarningNotificationData() {} /** @@ -66,6 +98,7 @@ public NegativeBalanceCompensationWarningNotificationData() {} public NegativeBalanceCompensationWarningNotificationData accountHolder( ResourceReference accountHolder) { this.accountHolder = accountHolder; + isSetAccountHolder = true; // mark as set return this; } @@ -89,6 +122,7 @@ public ResourceReference getAccountHolder() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountHolder(ResourceReference accountHolder) { this.accountHolder = accountHolder; + isSetAccountHolder = true; // mark as set } /** @@ -100,6 +134,7 @@ public void setAccountHolder(ResourceReference accountHolder) { */ public NegativeBalanceCompensationWarningNotificationData amount(Amount amount) { this.amount = amount; + isSetAmount = true; // mark as set return this; } @@ -123,6 +158,7 @@ public Amount getAmount() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAmount(Amount amount) { this.amount = amount; + isSetAmount = true; // mark as set } /** @@ -135,6 +171,7 @@ public void setAmount(Amount amount) { public NegativeBalanceCompensationWarningNotificationData balancePlatform( String balancePlatform) { this.balancePlatform = balancePlatform; + isSetBalancePlatform = true; // mark as set return this; } @@ -158,6 +195,7 @@ public String getBalancePlatform() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBalancePlatform(String balancePlatform) { this.balancePlatform = balancePlatform; + isSetBalancePlatform = true; // mark as set } /** @@ -172,6 +210,7 @@ public void setBalancePlatform(String balancePlatform) { public NegativeBalanceCompensationWarningNotificationData creationDate( OffsetDateTime creationDate) { this.creationDate = creationDate; + isSetCreationDate = true; // mark as set return this; } @@ -199,6 +238,7 @@ public OffsetDateTime getCreationDate() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCreationDate(OffsetDateTime creationDate) { this.creationDate = creationDate; + isSetCreationDate = true; // mark as set } /** @@ -210,6 +250,7 @@ public void setCreationDate(OffsetDateTime creationDate) { */ public NegativeBalanceCompensationWarningNotificationData id(String id) { this.id = id; + isSetId = true; // mark as set return this; } @@ -233,6 +274,7 @@ public String getId() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setId(String id) { this.id = id; + isSetId = true; // mark as set } /** @@ -247,6 +289,7 @@ public void setId(String id) { public NegativeBalanceCompensationWarningNotificationData liableBalanceAccountId( String liableBalanceAccountId) { this.liableBalanceAccountId = liableBalanceAccountId; + isSetLiableBalanceAccountId = true; // mark as set return this; } @@ -274,6 +317,7 @@ public String getLiableBalanceAccountId() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setLiableBalanceAccountId(String liableBalanceAccountId) { this.liableBalanceAccountId = liableBalanceAccountId; + isSetLiableBalanceAccountId = true; // mark as set } /** @@ -286,6 +330,7 @@ public void setLiableBalanceAccountId(String liableBalanceAccountId) { public NegativeBalanceCompensationWarningNotificationData negativeBalanceSince( OffsetDateTime negativeBalanceSince) { this.negativeBalanceSince = negativeBalanceSince; + isSetNegativeBalanceSince = true; // mark as set return this; } @@ -309,6 +354,7 @@ public OffsetDateTime getNegativeBalanceSince() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setNegativeBalanceSince(OffsetDateTime negativeBalanceSince) { this.negativeBalanceSince = negativeBalanceSince; + isSetNegativeBalanceSince = true; // mark as set } /** @@ -322,6 +368,7 @@ public void setNegativeBalanceSince(OffsetDateTime negativeBalanceSince) { public NegativeBalanceCompensationWarningNotificationData scheduledCompensationAt( OffsetDateTime scheduledCompensationAt) { this.scheduledCompensationAt = scheduledCompensationAt; + isSetScheduledCompensationAt = true; // mark as set return this; } @@ -347,6 +394,28 @@ public OffsetDateTime getScheduledCompensationAt() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setScheduledCompensationAt(OffsetDateTime scheduledCompensationAt) { this.scheduledCompensationAt = scheduledCompensationAt; + isSetScheduledCompensationAt = true; // mark as set + } + + /** + * Configures whether null values are explicitly serialized in the JSON payload. Default is false. + */ + public NegativeBalanceCompensationWarningNotificationData includeNullValues( + boolean includeNullValues) { + this.includeNullValues = includeNullValues; + return this; + } + + /** Returns whether null values are explicitly serialized in the JSON payload. */ + public boolean isIncludeNullValues() { + return includeNullValues; + } + + /** + * Sets whether null values should be explicitly serialized in the JSON payload. Default is false. + */ + public void setIncludeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; } /** @@ -365,35 +434,64 @@ public boolean equals(Object o) { (NegativeBalanceCompensationWarningNotificationData) o; return Objects.equals( this.accountHolder, negativeBalanceCompensationWarningNotificationData.accountHolder) + && Objects.equals( + this.isSetAccountHolder, + negativeBalanceCompensationWarningNotificationData.isSetAccountHolder) && Objects.equals(this.amount, negativeBalanceCompensationWarningNotificationData.amount) + && Objects.equals( + this.isSetAmount, negativeBalanceCompensationWarningNotificationData.isSetAmount) && Objects.equals( this.balancePlatform, negativeBalanceCompensationWarningNotificationData.balancePlatform) + && Objects.equals( + this.isSetBalancePlatform, + negativeBalanceCompensationWarningNotificationData.isSetBalancePlatform) && Objects.equals( this.creationDate, negativeBalanceCompensationWarningNotificationData.creationDate) + && Objects.equals( + this.isSetCreationDate, + negativeBalanceCompensationWarningNotificationData.isSetCreationDate) && Objects.equals(this.id, negativeBalanceCompensationWarningNotificationData.id) + && Objects.equals(this.isSetId, negativeBalanceCompensationWarningNotificationData.isSetId) && Objects.equals( this.liableBalanceAccountId, negativeBalanceCompensationWarningNotificationData.liableBalanceAccountId) + && Objects.equals( + this.isSetLiableBalanceAccountId, + negativeBalanceCompensationWarningNotificationData.isSetLiableBalanceAccountId) && Objects.equals( this.negativeBalanceSince, negativeBalanceCompensationWarningNotificationData.negativeBalanceSince) + && Objects.equals( + this.isSetNegativeBalanceSince, + negativeBalanceCompensationWarningNotificationData.isSetNegativeBalanceSince) && Objects.equals( this.scheduledCompensationAt, - negativeBalanceCompensationWarningNotificationData.scheduledCompensationAt); + negativeBalanceCompensationWarningNotificationData.scheduledCompensationAt) + && Objects.equals( + this.isSetScheduledCompensationAt, + negativeBalanceCompensationWarningNotificationData.isSetScheduledCompensationAt); } @Override public int hashCode() { return Objects.hash( accountHolder, + isSetAccountHolder, amount, + isSetAmount, balancePlatform, + isSetBalancePlatform, creationDate, + isSetCreationDate, id, + isSetId, liableBalanceAccountId, + isSetLiableBalanceAccountId, negativeBalanceSince, - scheduledCompensationAt); + isSetNegativeBalanceSince, + scheduledCompensationAt, + isSetScheduledCompensationAt); } @Override @@ -428,6 +526,51 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + /** Returns a map of properties to be merged into the JSON payload as explicit null values. */ + @JsonInclude(JsonInclude.Include.ALWAYS) + @JsonAnyGetter + public Map getExplicitNulls() { + if (!this.includeNullValues) { + return Collections.emptyMap(); + } + + Map nulls = new HashMap<>(); + + if (isSetAccountHolder) { + addIfNull(nulls, JSON_PROPERTY_ACCOUNT_HOLDER, this.accountHolder); + } + if (isSetAmount) { + addIfNull(nulls, JSON_PROPERTY_AMOUNT, this.amount); + } + if (isSetBalancePlatform) { + addIfNull(nulls, JSON_PROPERTY_BALANCE_PLATFORM, this.balancePlatform); + } + if (isSetCreationDate) { + addIfNull(nulls, JSON_PROPERTY_CREATION_DATE, this.creationDate); + } + if (isSetId) { + addIfNull(nulls, JSON_PROPERTY_ID, this.id); + } + if (isSetLiableBalanceAccountId) { + addIfNull(nulls, JSON_PROPERTY_LIABLE_BALANCE_ACCOUNT_ID, this.liableBalanceAccountId); + } + if (isSetNegativeBalanceSince) { + addIfNull(nulls, JSON_PROPERTY_NEGATIVE_BALANCE_SINCE, this.negativeBalanceSince); + } + if (isSetScheduledCompensationAt) { + addIfNull(nulls, JSON_PROPERTY_SCHEDULED_COMPENSATION_AT, this.scheduledCompensationAt); + } + + return nulls; + } + + // add to map when value is null + private void addIfNull(Map map, String key, Object value) { + if (value == null) { + map.put(key, null); + } + } + /** * Create an instance of NegativeBalanceCompensationWarningNotificationData given an JSON string * diff --git a/src/main/java/com/adyen/model/negativebalancewarningwebhooks/NegativeBalanceCompensationWarningNotificationRequest.java b/src/main/java/com/adyen/model/java/NegativeBalanceCompensationWarningNotificationRequest.java similarity index 73% rename from src/main/java/com/adyen/model/negativebalancewarningwebhooks/NegativeBalanceCompensationWarningNotificationRequest.java rename to src/main/java/com/adyen/model/java/NegativeBalanceCompensationWarningNotificationRequest.java index 2add2d2cf..c66786ff8 100644 --- a/src/main/java/com/adyen/model/negativebalancewarningwebhooks/NegativeBalanceCompensationWarningNotificationRequest.java +++ b/src/main/java/com/adyen/model/java/NegativeBalanceCompensationWarningNotificationRequest.java @@ -9,9 +9,11 @@ * Do not edit the class manually. */ -package com.adyen.model.negativebalancewarningwebhooks; +package com.adyen.model.java; +import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -33,12 +35,21 @@ public class NegativeBalanceCompensationWarningNotificationRequest { public static final String JSON_PROPERTY_DATA = "data"; private NegativeBalanceCompensationWarningNotificationData data; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetData = false; + public static final String JSON_PROPERTY_ENVIRONMENT = "environment"; private String environment; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetEnvironment = false; + public static final String JSON_PROPERTY_TIMESTAMP = "timestamp"; private OffsetDateTime timestamp; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetTimestamp = false; + /** Type of webhook. */ public enum TypeEnum { BALANCEPLATFORM_NEGATIVEBALANCECOMPENSATIONWARNING_SCHEDULED( @@ -82,6 +93,15 @@ public static TypeEnum fromValue(String value) { public static final String JSON_PROPERTY_TYPE = "type"; private TypeEnum type; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetType = false; + + /** + * Sets whether attributes with null values should be explicitly included in the JSON payload. + * Default is false. + */ + @JsonIgnore private boolean includeNullValues = false; + public NegativeBalanceCompensationWarningNotificationRequest() {} /** @@ -94,6 +114,7 @@ public NegativeBalanceCompensationWarningNotificationRequest() {} public NegativeBalanceCompensationWarningNotificationRequest data( NegativeBalanceCompensationWarningNotificationData data) { this.data = data; + isSetData = true; // mark as set return this; } @@ -117,6 +138,7 @@ public NegativeBalanceCompensationWarningNotificationData getData() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setData(NegativeBalanceCompensationWarningNotificationData data) { this.data = data; + isSetData = true; // mark as set } /** @@ -129,6 +151,7 @@ public void setData(NegativeBalanceCompensationWarningNotificationData data) { */ public NegativeBalanceCompensationWarningNotificationRequest environment(String environment) { this.environment = environment; + isSetEnvironment = true; // mark as set return this; } @@ -154,6 +177,7 @@ public String getEnvironment() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setEnvironment(String environment) { this.environment = environment; + isSetEnvironment = true; // mark as set } /** @@ -165,6 +189,7 @@ public void setEnvironment(String environment) { */ public NegativeBalanceCompensationWarningNotificationRequest timestamp(OffsetDateTime timestamp) { this.timestamp = timestamp; + isSetTimestamp = true; // mark as set return this; } @@ -188,6 +213,7 @@ public OffsetDateTime getTimestamp() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setTimestamp(OffsetDateTime timestamp) { this.timestamp = timestamp; + isSetTimestamp = true; // mark as set } /** @@ -199,6 +225,7 @@ public void setTimestamp(OffsetDateTime timestamp) { */ public NegativeBalanceCompensationWarningNotificationRequest type(TypeEnum type) { this.type = type; + isSetType = true; // mark as set return this; } @@ -222,6 +249,28 @@ public TypeEnum getType() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; + isSetType = true; // mark as set + } + + /** + * Configures whether null values are explicitly serialized in the JSON payload. Default is false. + */ + public NegativeBalanceCompensationWarningNotificationRequest includeNullValues( + boolean includeNullValues) { + this.includeNullValues = includeNullValues; + return this; + } + + /** Returns whether null values are explicitly serialized in the JSON payload. */ + public boolean isIncludeNullValues() { + return includeNullValues; + } + + /** + * Sets whether null values should be explicitly serialized in the JSON payload. Default is false. + */ + public void setIncludeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; } /** @@ -239,16 +288,27 @@ public boolean equals(Object o) { negativeBalanceCompensationWarningNotificationRequest = (NegativeBalanceCompensationWarningNotificationRequest) o; return Objects.equals(this.data, negativeBalanceCompensationWarningNotificationRequest.data) + && Objects.equals( + this.isSetData, negativeBalanceCompensationWarningNotificationRequest.isSetData) && Objects.equals( this.environment, negativeBalanceCompensationWarningNotificationRequest.environment) + && Objects.equals( + this.isSetEnvironment, + negativeBalanceCompensationWarningNotificationRequest.isSetEnvironment) && Objects.equals( this.timestamp, negativeBalanceCompensationWarningNotificationRequest.timestamp) - && Objects.equals(this.type, negativeBalanceCompensationWarningNotificationRequest.type); + && Objects.equals( + this.isSetTimestamp, + negativeBalanceCompensationWarningNotificationRequest.isSetTimestamp) + && Objects.equals(this.type, negativeBalanceCompensationWarningNotificationRequest.type) + && Objects.equals( + this.isSetType, negativeBalanceCompensationWarningNotificationRequest.isSetType); } @Override public int hashCode() { - return Objects.hash(data, environment, timestamp, type); + return Objects.hash( + data, isSetData, environment, isSetEnvironment, timestamp, isSetTimestamp, type, isSetType); } @Override @@ -273,6 +333,39 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + /** Returns a map of properties to be merged into the JSON payload as explicit null values. */ + @JsonInclude(JsonInclude.Include.ALWAYS) + @JsonAnyGetter + public Map getExplicitNulls() { + if (!this.includeNullValues) { + return Collections.emptyMap(); + } + + Map nulls = new HashMap<>(); + + if (isSetData) { + addIfNull(nulls, JSON_PROPERTY_DATA, this.data); + } + if (isSetEnvironment) { + addIfNull(nulls, JSON_PROPERTY_ENVIRONMENT, this.environment); + } + if (isSetTimestamp) { + addIfNull(nulls, JSON_PROPERTY_TIMESTAMP, this.timestamp); + } + if (isSetType) { + addIfNull(nulls, JSON_PROPERTY_TYPE, this.type); + } + + return nulls; + } + + // add to map when value is null + private void addIfNull(Map map, String key, Object value) { + if (value == null) { + map.put(key, null); + } + } + /** * Create an instance of NegativeBalanceCompensationWarningNotificationRequest given an JSON * string diff --git a/src/main/java/com/adyen/model/negativebalancewarningwebhooks/Resource.java b/src/main/java/com/adyen/model/java/Resource.java similarity index 68% rename from src/main/java/com/adyen/model/negativebalancewarningwebhooks/Resource.java rename to src/main/java/com/adyen/model/java/Resource.java index 5e4717104..f9a46d921 100644 --- a/src/main/java/com/adyen/model/negativebalancewarningwebhooks/Resource.java +++ b/src/main/java/com/adyen/model/java/Resource.java @@ -9,8 +9,10 @@ * Do not edit the class manually. */ -package com.adyen.model.negativebalancewarningwebhooks; +package com.adyen.model.java; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -28,12 +30,27 @@ public class Resource { public static final String JSON_PROPERTY_BALANCE_PLATFORM = "balancePlatform"; private String balancePlatform; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetBalancePlatform = false; + public static final String JSON_PROPERTY_CREATION_DATE = "creationDate"; private OffsetDateTime creationDate; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetCreationDate = false; + public static final String JSON_PROPERTY_ID = "id"; private String id; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetId = false; + + /** + * Sets whether attributes with null values should be explicitly included in the JSON payload. + * Default is false. + */ + @JsonIgnore private boolean includeNullValues = false; + public Resource() {} /** @@ -44,6 +61,7 @@ public Resource() {} */ public Resource balancePlatform(String balancePlatform) { this.balancePlatform = balancePlatform; + isSetBalancePlatform = true; // mark as set return this; } @@ -67,6 +85,7 @@ public String getBalancePlatform() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBalancePlatform(String balancePlatform) { this.balancePlatform = balancePlatform; + isSetBalancePlatform = true; // mark as set } /** @@ -79,6 +98,7 @@ public void setBalancePlatform(String balancePlatform) { */ public Resource creationDate(OffsetDateTime creationDate) { this.creationDate = creationDate; + isSetCreationDate = true; // mark as set return this; } @@ -106,6 +126,7 @@ public OffsetDateTime getCreationDate() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCreationDate(OffsetDateTime creationDate) { this.creationDate = creationDate; + isSetCreationDate = true; // mark as set } /** @@ -116,6 +137,7 @@ public void setCreationDate(OffsetDateTime creationDate) { */ public Resource id(String id) { this.id = id; + isSetId = true; // mark as set return this; } @@ -139,6 +161,27 @@ public String getId() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setId(String id) { this.id = id; + isSetId = true; // mark as set + } + + /** + * Configures whether null values are explicitly serialized in the JSON payload. Default is false. + */ + public Resource includeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + return this; + } + + /** Returns whether null values are explicitly serialized in the JSON payload. */ + public boolean isIncludeNullValues() { + return includeNullValues; + } + + /** + * Sets whether null values should be explicitly serialized in the JSON payload. Default is false. + */ + public void setIncludeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; } /** Return true if this Resource object is equal to o. */ @@ -152,13 +195,17 @@ public boolean equals(Object o) { } Resource resource = (Resource) o; return Objects.equals(this.balancePlatform, resource.balancePlatform) + && Objects.equals(this.isSetBalancePlatform, resource.isSetBalancePlatform) && Objects.equals(this.creationDate, resource.creationDate) - && Objects.equals(this.id, resource.id); + && Objects.equals(this.isSetCreationDate, resource.isSetCreationDate) + && Objects.equals(this.id, resource.id) + && Objects.equals(this.isSetId, resource.isSetId); } @Override public int hashCode() { - return Objects.hash(balancePlatform, creationDate, id); + return Objects.hash( + balancePlatform, isSetBalancePlatform, creationDate, isSetCreationDate, id, isSetId); } @Override @@ -182,6 +229,36 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + /** Returns a map of properties to be merged into the JSON payload as explicit null values. */ + @JsonInclude(JsonInclude.Include.ALWAYS) + @JsonAnyGetter + public Map getExplicitNulls() { + if (!this.includeNullValues) { + return Collections.emptyMap(); + } + + Map nulls = new HashMap<>(); + + if (isSetBalancePlatform) { + addIfNull(nulls, JSON_PROPERTY_BALANCE_PLATFORM, this.balancePlatform); + } + if (isSetCreationDate) { + addIfNull(nulls, JSON_PROPERTY_CREATION_DATE, this.creationDate); + } + if (isSetId) { + addIfNull(nulls, JSON_PROPERTY_ID, this.id); + } + + return nulls; + } + + // add to map when value is null + private void addIfNull(Map map, String key, Object value) { + if (value == null) { + map.put(key, null); + } + } + /** * Create an instance of Resource given an JSON string * diff --git a/src/main/java/com/adyen/model/negativebalancewarningwebhooks/ResourceReference.java b/src/main/java/com/adyen/model/java/ResourceReference.java similarity index 67% rename from src/main/java/com/adyen/model/negativebalancewarningwebhooks/ResourceReference.java rename to src/main/java/com/adyen/model/java/ResourceReference.java index 1cb999a8c..a24b6f0be 100644 --- a/src/main/java/com/adyen/model/negativebalancewarningwebhooks/ResourceReference.java +++ b/src/main/java/com/adyen/model/java/ResourceReference.java @@ -9,8 +9,10 @@ * Do not edit the class manually. */ -package com.adyen.model.negativebalancewarningwebhooks; +package com.adyen.model.java; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -27,12 +29,27 @@ public class ResourceReference { public static final String JSON_PROPERTY_DESCRIPTION = "description"; private String description; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetDescription = false; + public static final String JSON_PROPERTY_ID = "id"; private String id; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetId = false; + public static final String JSON_PROPERTY_REFERENCE = "reference"; private String reference; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetReference = false; + + /** + * Sets whether attributes with null values should be explicitly included in the JSON payload. + * Default is false. + */ + @JsonIgnore private boolean includeNullValues = false; + public ResourceReference() {} /** @@ -43,6 +60,7 @@ public ResourceReference() {} */ public ResourceReference description(String description) { this.description = description; + isSetDescription = true; // mark as set return this; } @@ -66,6 +84,7 @@ public String getDescription() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setDescription(String description) { this.description = description; + isSetDescription = true; // mark as set } /** @@ -76,6 +95,7 @@ public void setDescription(String description) { */ public ResourceReference id(String id) { this.id = id; + isSetId = true; // mark as set return this; } @@ -99,6 +119,7 @@ public String getId() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setId(String id) { this.id = id; + isSetId = true; // mark as set } /** @@ -109,6 +130,7 @@ public void setId(String id) { */ public ResourceReference reference(String reference) { this.reference = reference; + isSetReference = true; // mark as set return this; } @@ -132,6 +154,27 @@ public String getReference() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setReference(String reference) { this.reference = reference; + isSetReference = true; // mark as set + } + + /** + * Configures whether null values are explicitly serialized in the JSON payload. Default is false. + */ + public ResourceReference includeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + return this; + } + + /** Returns whether null values are explicitly serialized in the JSON payload. */ + public boolean isIncludeNullValues() { + return includeNullValues; + } + + /** + * Sets whether null values should be explicitly serialized in the JSON payload. Default is false. + */ + public void setIncludeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; } /** Return true if this ResourceReference object is equal to o. */ @@ -145,13 +188,16 @@ public boolean equals(Object o) { } ResourceReference resourceReference = (ResourceReference) o; return Objects.equals(this.description, resourceReference.description) + && Objects.equals(this.isSetDescription, resourceReference.isSetDescription) && Objects.equals(this.id, resourceReference.id) - && Objects.equals(this.reference, resourceReference.reference); + && Objects.equals(this.isSetId, resourceReference.isSetId) + && Objects.equals(this.reference, resourceReference.reference) + && Objects.equals(this.isSetReference, resourceReference.isSetReference); } @Override public int hashCode() { - return Objects.hash(description, id, reference); + return Objects.hash(description, isSetDescription, id, isSetId, reference, isSetReference); } @Override @@ -175,6 +221,36 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + /** Returns a map of properties to be merged into the JSON payload as explicit null values. */ + @JsonInclude(JsonInclude.Include.ALWAYS) + @JsonAnyGetter + public Map getExplicitNulls() { + if (!this.includeNullValues) { + return Collections.emptyMap(); + } + + Map nulls = new HashMap<>(); + + if (isSetDescription) { + addIfNull(nulls, JSON_PROPERTY_DESCRIPTION, this.description); + } + if (isSetId) { + addIfNull(nulls, JSON_PROPERTY_ID, this.id); + } + if (isSetReference) { + addIfNull(nulls, JSON_PROPERTY_REFERENCE, this.reference); + } + + return nulls; + } + + // add to map when value is null + private void addIfNull(Map map, String key, Object value) { + if (value == null) { + map.put(key, null); + } + } + /** * Create an instance of ResourceReference given an JSON string * diff --git a/src/main/java/com/adyen/model/negativebalancewarningwebhooks/JSON.java b/src/main/java/com/adyen/model/negativebalancewarningwebhooks/JSON.java index 2673db028..abe09e65a 100644 --- a/src/main/java/com/adyen/model/negativebalancewarningwebhooks/JSON.java +++ b/src/main/java/com/adyen/model/negativebalancewarningwebhooks/JSON.java @@ -1,4 +1,4 @@ -package com.adyen.model.negativebalancewarningwebhooks; +package com.adyen.model.java; import com.adyen.serializer.ByteArrayDeserializer; import com.adyen.serializer.ByteArraySerializer; diff --git a/src/main/java/com/adyen/model/negativebalancewarningwebhooks/NegativeBalanceWarningWebhooksHandler.java b/src/main/java/com/adyen/model/negativebalancewarningwebhooks/NegativeBalanceWarningWebhooksHandler.java deleted file mode 100644 index 398a02235..000000000 --- a/src/main/java/com/adyen/model/negativebalancewarningwebhooks/NegativeBalanceWarningWebhooksHandler.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Negative balance compensation warning - * - * The version of the OpenAPI document: 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 com.adyen.model.negativebalancewarningwebhooks; - -import java.util.Optional; -import java.util.logging.Logger; - -/** - * Handler for processing NegativeBalanceWarningWebhooks. - * - *

This class provides functionality to deserialize the payload of NegativeBalanceWarningWebhooks - * events. - */ -public class NegativeBalanceWarningWebhooksHandler { - - private static final Logger LOG = - Logger.getLogger(NegativeBalanceWarningWebhooksHandler.class.getName()); - - private final String payload; - - /** - * Constructs a new handler for the given webhook payload - * - * @param payload the raw JSON payload from the webhook - */ - public NegativeBalanceWarningWebhooksHandler(String payload) { - this.payload = payload; - } - - /** - * Attempts to deserialize the webhook payload into a - * NegativeBalanceCompensationWarningNotificationRequest - * - * @return an Optional containing the deserialized object, or empty if deserialization fails - */ - public Optional - getNegativeBalanceCompensationWarningNotificationRequest() { - - var optionalNegativeBalanceCompensationWarningNotificationRequest = - getOptionalField(NegativeBalanceCompensationWarningNotificationRequest.class); - - if (optionalNegativeBalanceCompensationWarningNotificationRequest.isPresent()) { - // verify event type - for (var value : NegativeBalanceCompensationWarningNotificationRequest.TypeEnum.values()) { - if (value.equals( - optionalNegativeBalanceCompensationWarningNotificationRequest.get().getType())) { - // found matching event type - return optionalNegativeBalanceCompensationWarningNotificationRequest; - } - } - } - - return Optional.empty(); - } - - /** - * Deserializes the payload into the specified class type. - * - * @param clazz the class to deserialize into - * @param the type of the class - * @return an Optional containing the deserialized object, or empty if an error occurs - */ - private Optional getOptionalField(Class clazz) { - try { - T val = JSON.getMapper().readValue(payload, clazz); - return Optional.ofNullable(val); - } catch (Exception e) { - // an error has occurred during deserialization (object not found, deserialization error) - LOG.warning("Object not found or unexpected error trying to access: " + clazz.getName()); - LOG.warning("Deserialization error: " + e.getMessage()); - return Optional.empty(); - } - } -}