diff --git a/src/main/java/com/adyen/model/reportwebhooks/AbstractOpenApiSchema.java b/src/main/java/com/adyen/model/java/AbstractOpenApiSchema.java similarity index 98% rename from src/main/java/com/adyen/model/reportwebhooks/AbstractOpenApiSchema.java rename to src/main/java/com/adyen/model/java/AbstractOpenApiSchema.java index 839373b6a..39dfbfd48 100644 --- a/src/main/java/com/adyen/model/reportwebhooks/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.reportwebhooks; +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/reportwebhooks/BalancePlatformNotificationResponse.java b/src/main/java/com/adyen/model/java/BalancePlatformNotificationResponse.java similarity index 66% rename from src/main/java/com/adyen/model/reportwebhooks/BalancePlatformNotificationResponse.java rename to src/main/java/com/adyen/model/java/BalancePlatformNotificationResponse.java index ab2375333..a98b9ac88 100644 --- a/src/main/java/com/adyen/model/reportwebhooks/BalancePlatformNotificationResponse.java +++ b/src/main/java/com/adyen/model/java/BalancePlatformNotificationResponse.java @@ -9,8 +9,10 @@ * Do not edit the class manually. */ -package com.adyen.model.reportwebhooks; +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,6 +25,15 @@ public class BalancePlatformNotificationResponse { public static final String JSON_PROPERTY_NOTIFICATION_RESPONSE = "notificationResponse"; private String notificationResponse; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetNotificationResponse = false; + + /** + * Sets whether attributes with null values should be explicitly included in the JSON payload. + * Default is false. + */ + @JsonIgnore private boolean includeNullValues = false; + public BalancePlatformNotificationResponse() {} /** @@ -36,6 +47,7 @@ public BalancePlatformNotificationResponse() {} */ public BalancePlatformNotificationResponse notificationResponse(String notificationResponse) { this.notificationResponse = notificationResponse; + isSetNotificationResponse = true; // mark as set return this; } @@ -63,6 +75,27 @@ public String getNotificationResponse() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setNotificationResponse(String notificationResponse) { this.notificationResponse = notificationResponse; + isSetNotificationResponse = true; // mark as set + } + + /** + * Configures whether null values are explicitly serialized in the JSON payload. Default is false. + */ + public BalancePlatformNotificationResponse 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 BalancePlatformNotificationResponse object is equal to o. */ @@ -77,12 +110,15 @@ public boolean equals(Object o) { BalancePlatformNotificationResponse balancePlatformNotificationResponse = (BalancePlatformNotificationResponse) o; return Objects.equals( - this.notificationResponse, balancePlatformNotificationResponse.notificationResponse); + this.notificationResponse, balancePlatformNotificationResponse.notificationResponse) + && Objects.equals( + this.isSetNotificationResponse, + balancePlatformNotificationResponse.isSetNotificationResponse); } @Override public int hashCode() { - return Objects.hash(notificationResponse); + return Objects.hash(notificationResponse, isSetNotificationResponse); } @Override @@ -106,6 +142,30 @@ 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 (isSetNotificationResponse) { + addIfNull(nulls, JSON_PROPERTY_NOTIFICATION_RESPONSE, this.notificationResponse); + } + + 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 BalancePlatformNotificationResponse given an JSON string * diff --git a/src/main/java/com/adyen/model/reportwebhooks/ReportNotificationData.java b/src/main/java/com/adyen/model/java/ReportNotificationData.java similarity index 76% rename from src/main/java/com/adyen/model/reportwebhooks/ReportNotificationData.java rename to src/main/java/com/adyen/model/java/ReportNotificationData.java index c3b1033a0..09d916834 100644 --- a/src/main/java/com/adyen/model/reportwebhooks/ReportNotificationData.java +++ b/src/main/java/com/adyen/model/java/ReportNotificationData.java @@ -9,8 +9,10 @@ * Do not edit the class manually. */ -package com.adyen.model.reportwebhooks; +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 ReportNotificationData { 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_BALANCE_ACCOUNT = "balanceAccount"; private ResourceReference balanceAccount; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetBalanceAccount = 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_DOWNLOAD_URL = "downloadUrl"; private String downloadUrl; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetDownloadUrl = false; + public static final String JSON_PROPERTY_FILE_NAME = "fileName"; private String fileName; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetFileName = 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_REPORT_TYPE = "reportType"; private String reportType; + /** Mark when the attribute has been explicitly set. */ + private boolean isSetReportType = false; + + /** + * Sets whether attributes with null values should be explicitly included in the JSON payload. + * Default is false. + */ + @JsonIgnore private boolean includeNullValues = false; + public ReportNotificationData() {} /** @@ -64,6 +96,7 @@ public ReportNotificationData() {} */ public ReportNotificationData accountHolder(ResourceReference accountHolder) { this.accountHolder = accountHolder; + isSetAccountHolder = true; // mark as set return this; } @@ -87,6 +120,7 @@ public ResourceReference getAccountHolder() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setAccountHolder(ResourceReference accountHolder) { this.accountHolder = accountHolder; + isSetAccountHolder = true; // mark as set } /** @@ -97,6 +131,7 @@ public void setAccountHolder(ResourceReference accountHolder) { */ public ReportNotificationData balanceAccount(ResourceReference balanceAccount) { this.balanceAccount = balanceAccount; + isSetBalanceAccount = true; // mark as set return this; } @@ -120,6 +155,7 @@ public ResourceReference getBalanceAccount() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBalanceAccount(ResourceReference balanceAccount) { this.balanceAccount = balanceAccount; + isSetBalanceAccount = true; // mark as set } /** @@ -130,6 +166,7 @@ public void setBalanceAccount(ResourceReference balanceAccount) { */ public ReportNotificationData balancePlatform(String balancePlatform) { this.balancePlatform = balancePlatform; + isSetBalancePlatform = true; // mark as set return this; } @@ -153,6 +190,7 @@ public String getBalancePlatform() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setBalancePlatform(String balancePlatform) { this.balancePlatform = balancePlatform; + isSetBalancePlatform = true; // mark as set } /** @@ -165,6 +203,7 @@ public void setBalancePlatform(String balancePlatform) { */ public ReportNotificationData creationDate(OffsetDateTime creationDate) { this.creationDate = creationDate; + isSetCreationDate = true; // mark as set return this; } @@ -192,6 +231,7 @@ public OffsetDateTime getCreationDate() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCreationDate(OffsetDateTime creationDate) { this.creationDate = creationDate; + isSetCreationDate = true; // mark as set } /** @@ -206,6 +246,7 @@ public void setCreationDate(OffsetDateTime creationDate) { */ public ReportNotificationData downloadUrl(String downloadUrl) { this.downloadUrl = downloadUrl; + isSetDownloadUrl = true; // mark as set return this; } @@ -237,6 +278,7 @@ public String getDownloadUrl() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setDownloadUrl(String downloadUrl) { this.downloadUrl = downloadUrl; + isSetDownloadUrl = true; // mark as set } /** @@ -247,6 +289,7 @@ public void setDownloadUrl(String downloadUrl) { */ public ReportNotificationData fileName(String fileName) { this.fileName = fileName; + isSetFileName = true; // mark as set return this; } @@ -270,6 +313,7 @@ public String getFileName() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setFileName(String fileName) { this.fileName = fileName; + isSetFileName = true; // mark as set } /** @@ -280,6 +324,7 @@ public void setFileName(String fileName) { */ public ReportNotificationData id(String id) { this.id = id; + isSetId = true; // mark as set return this; } @@ -303,6 +348,7 @@ public String getId() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setId(String id) { this.id = id; + isSetId = true; // mark as set } /** @@ -322,6 +368,7 @@ public void setId(String id) { */ public ReportNotificationData reportType(String reportType) { this.reportType = reportType; + isSetReportType = true; // mark as set return this; } @@ -363,6 +410,27 @@ public String getReportType() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setReportType(String reportType) { this.reportType = reportType; + isSetReportType = true; // mark as set + } + + /** + * Configures whether null values are explicitly serialized in the JSON payload. Default is false. + */ + public ReportNotificationData 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 ReportNotificationData object is equal to o. */ @@ -376,26 +444,42 @@ public boolean equals(Object o) { } ReportNotificationData reportNotificationData = (ReportNotificationData) o; return Objects.equals(this.accountHolder, reportNotificationData.accountHolder) + && Objects.equals(this.isSetAccountHolder, reportNotificationData.isSetAccountHolder) && Objects.equals(this.balanceAccount, reportNotificationData.balanceAccount) + && Objects.equals(this.isSetBalanceAccount, reportNotificationData.isSetBalanceAccount) && Objects.equals(this.balancePlatform, reportNotificationData.balancePlatform) + && Objects.equals(this.isSetBalancePlatform, reportNotificationData.isSetBalancePlatform) && Objects.equals(this.creationDate, reportNotificationData.creationDate) + && Objects.equals(this.isSetCreationDate, reportNotificationData.isSetCreationDate) && Objects.equals(this.downloadUrl, reportNotificationData.downloadUrl) + && Objects.equals(this.isSetDownloadUrl, reportNotificationData.isSetDownloadUrl) && Objects.equals(this.fileName, reportNotificationData.fileName) + && Objects.equals(this.isSetFileName, reportNotificationData.isSetFileName) && Objects.equals(this.id, reportNotificationData.id) - && Objects.equals(this.reportType, reportNotificationData.reportType); + && Objects.equals(this.isSetId, reportNotificationData.isSetId) + && Objects.equals(this.reportType, reportNotificationData.reportType) + && Objects.equals(this.isSetReportType, reportNotificationData.isSetReportType); } @Override public int hashCode() { return Objects.hash( accountHolder, + isSetAccountHolder, balanceAccount, + isSetBalanceAccount, balancePlatform, + isSetBalancePlatform, creationDate, + isSetCreationDate, downloadUrl, + isSetDownloadUrl, fileName, + isSetFileName, id, - reportType); + isSetId, + reportType, + isSetReportType); } @Override @@ -424,6 +508,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 (isSetBalanceAccount) { + addIfNull(nulls, JSON_PROPERTY_BALANCE_ACCOUNT, this.balanceAccount); + } + if (isSetBalancePlatform) { + addIfNull(nulls, JSON_PROPERTY_BALANCE_PLATFORM, this.balancePlatform); + } + if (isSetCreationDate) { + addIfNull(nulls, JSON_PROPERTY_CREATION_DATE, this.creationDate); + } + if (isSetDownloadUrl) { + addIfNull(nulls, JSON_PROPERTY_DOWNLOAD_URL, this.downloadUrl); + } + if (isSetFileName) { + addIfNull(nulls, JSON_PROPERTY_FILE_NAME, this.fileName); + } + if (isSetId) { + addIfNull(nulls, JSON_PROPERTY_ID, this.id); + } + if (isSetReportType) { + addIfNull(nulls, JSON_PROPERTY_REPORT_TYPE, this.reportType); + } + + 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 ReportNotificationData given an JSON string * diff --git a/src/main/java/com/adyen/model/reportwebhooks/ReportNotificationRequest.java b/src/main/java/com/adyen/model/java/ReportNotificationRequest.java similarity index 72% rename from src/main/java/com/adyen/model/reportwebhooks/ReportNotificationRequest.java rename to src/main/java/com/adyen/model/java/ReportNotificationRequest.java index 048d5fc8c..48966bbb9 100644 --- a/src/main/java/com/adyen/model/reportwebhooks/ReportNotificationRequest.java +++ b/src/main/java/com/adyen/model/java/ReportNotificationRequest.java @@ -9,9 +9,11 @@ * Do not edit the class manually. */ -package com.adyen.model.reportwebhooks; +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 ReportNotificationRequest { public static final String JSON_PROPERTY_DATA = "data"; private ReportNotificationData 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_REPORT_CREATED(String.valueOf("balancePlatform.report.created")); @@ -81,6 +92,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 ReportNotificationRequest() {} /** @@ -91,6 +111,7 @@ public ReportNotificationRequest() {} */ public ReportNotificationRequest data(ReportNotificationData data) { this.data = data; + isSetData = true; // mark as set return this; } @@ -114,6 +135,7 @@ public ReportNotificationData getData() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setData(ReportNotificationData data) { this.data = data; + isSetData = true; // mark as set } /** @@ -125,6 +147,7 @@ public void setData(ReportNotificationData data) { */ public ReportNotificationRequest environment(String environment) { this.environment = environment; + isSetEnvironment = true; // mark as set return this; } @@ -150,6 +173,7 @@ public String getEnvironment() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setEnvironment(String environment) { this.environment = environment; + isSetEnvironment = true; // mark as set } /** @@ -160,6 +184,7 @@ public void setEnvironment(String environment) { */ public ReportNotificationRequest timestamp(OffsetDateTime timestamp) { this.timestamp = timestamp; + isSetTimestamp = true; // mark as set return this; } @@ -183,6 +208,7 @@ public OffsetDateTime getTimestamp() { @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setTimestamp(OffsetDateTime timestamp) { this.timestamp = timestamp; + isSetTimestamp = true; // mark as set } /** @@ -193,6 +219,7 @@ public void setTimestamp(OffsetDateTime timestamp) { */ public ReportNotificationRequest type(TypeEnum type) { this.type = type; + isSetType = true; // mark as set return this; } @@ -216,6 +243,27 @@ 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 ReportNotificationRequest 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 ReportNotificationRequest object is equal to o. */ @@ -229,14 +277,19 @@ public boolean equals(Object o) { } ReportNotificationRequest reportNotificationRequest = (ReportNotificationRequest) o; return Objects.equals(this.data, reportNotificationRequest.data) + && Objects.equals(this.isSetData, reportNotificationRequest.isSetData) && Objects.equals(this.environment, reportNotificationRequest.environment) + && Objects.equals(this.isSetEnvironment, reportNotificationRequest.isSetEnvironment) && Objects.equals(this.timestamp, reportNotificationRequest.timestamp) - && Objects.equals(this.type, reportNotificationRequest.type); + && Objects.equals(this.isSetTimestamp, reportNotificationRequest.isSetTimestamp) + && Objects.equals(this.type, reportNotificationRequest.type) + && Objects.equals(this.isSetType, reportNotificationRequest.isSetType); } @Override public int hashCode() { - return Objects.hash(data, environment, timestamp, type); + return Objects.hash( + data, isSetData, environment, isSetEnvironment, timestamp, isSetTimestamp, type, isSetType); } @Override @@ -261,6 +314,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 ReportNotificationRequest given an JSON string * diff --git a/src/main/java/com/adyen/model/reportwebhooks/Resource.java b/src/main/java/com/adyen/model/java/Resource.java similarity index 68% rename from src/main/java/com/adyen/model/reportwebhooks/Resource.java rename to src/main/java/com/adyen/model/java/Resource.java index 68ccb752a..7adde9a9b 100644 --- a/src/main/java/com/adyen/model/reportwebhooks/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.reportwebhooks; +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/reportwebhooks/ResourceReference.java b/src/main/java/com/adyen/model/java/ResourceReference.java similarity index 67% rename from src/main/java/com/adyen/model/reportwebhooks/ResourceReference.java rename to src/main/java/com/adyen/model/java/ResourceReference.java index 23373433d..73f0fd88e 100644 --- a/src/main/java/com/adyen/model/reportwebhooks/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.reportwebhooks; +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/reportwebhooks/JSON.java b/src/main/java/com/adyen/model/reportwebhooks/JSON.java index 5b5159e6c..abe09e65a 100644 --- a/src/main/java/com/adyen/model/reportwebhooks/JSON.java +++ b/src/main/java/com/adyen/model/reportwebhooks/JSON.java @@ -1,4 +1,4 @@ -package com.adyen.model.reportwebhooks; +package com.adyen.model.java; import com.adyen.serializer.ByteArrayDeserializer; import com.adyen.serializer.ByteArraySerializer; diff --git a/src/main/java/com/adyen/model/reportwebhooks/ReportWebhooksHandler.java b/src/main/java/com/adyen/model/reportwebhooks/ReportWebhooksHandler.java deleted file mode 100644 index db670fdf9..000000000 --- a/src/main/java/com/adyen/model/reportwebhooks/ReportWebhooksHandler.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Report webhooks - * - * 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.reportwebhooks; - -import java.util.Optional; -import java.util.logging.Logger; - -/** - * Handler for processing ReportWebhooks. - * - *

This class provides functionality to deserialize the payload of ReportWebhooks events. - */ -public class ReportWebhooksHandler { - - private static final Logger LOG = Logger.getLogger(ReportWebhooksHandler.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 ReportWebhooksHandler(String payload) { - this.payload = payload; - } - - /** - * Attempts to deserialize the webhook payload into a ReportNotificationRequest - * - * @return an Optional containing the deserialized object, or empty if deserialization fails - */ - public Optional getReportNotificationRequest() { - - var optionalReportNotificationRequest = getOptionalField(ReportNotificationRequest.class); - - if (optionalReportNotificationRequest.isPresent()) { - // verify event type - for (var value : ReportNotificationRequest.TypeEnum.values()) { - if (value.equals(optionalReportNotificationRequest.get().getType())) { - // found matching event type - return optionalReportNotificationRequest; - } - } - } - - 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(); - } - } -}