Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {}

/**
Expand All @@ -36,6 +47,7 @@ public BalancePlatformNotificationResponse() {}
*/
public BalancePlatformNotificationResponse notificationResponse(String notificationResponse) {
this.notificationResponse = notificationResponse;
isSetNotificationResponse = true; // mark as set
return this;
}

Expand Down Expand Up @@ -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. */
Expand All @@ -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
Expand All @@ -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<String, Object> getExplicitNulls() {
if (!this.includeNullValues) {
return Collections.emptyMap();
}

Map<String, Object> 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<String, Object> map, String key, Object value) {
if (value == null) {
map.put(key, null);
}
}
Comment on lines +163 to +167
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The addIfNull method is duplicated across several model classes (e.g., ReportNotificationData, ReportNotificationRequest, Resource, ResourceReference). To improve maintainability and adhere to the DRY (Don't Repeat Yourself) principle, consider extracting this method into a common utility class or a shared base class that these models could extend. Since this is auto-generated code, this might require a change in the code generation template.


/**
* Create an instance of BalancePlatformNotificationResponse given an JSON string
*
Expand Down
Loading
Loading