Skip to content
Open
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
71 changes: 69 additions & 2 deletions src/main/java/com/adyen/model/balancecontrol/Amount.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

package com.adyen.model.balancecontrol;

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,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() {}

/**
Expand All @@ -38,6 +52,7 @@ public Amount() {}
*/
public Amount currency(String currency) {
this.currency = currency;
isSetCurrency = true; // mark as set
return this;
}

Expand Down Expand Up @@ -65,6 +80,7 @@ public String getCurrency() {
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setCurrency(String currency) {
this.currency = currency;
isSetCurrency = true; // mark as set
}

/**
Expand All @@ -77,6 +93,7 @@ public void setCurrency(String currency) {
*/
public Amount value(Long value) {
this.value = value;
isSetValue = true; // mark as set
return this;
}

Expand Down Expand Up @@ -104,6 +121,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. */
Expand All @@ -117,12 +155,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
Expand All @@ -145,6 +185,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<String, Object> getExplicitNulls() {
if (!this.includeNullValues) {
return Collections.emptyMap();
}

Map<String, Object> 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<String, Object> map, String key, Object value) {
if (value == null) {
map.put(key, null);
}
}

/**
* Create an instance of Amount given an JSON string
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

package com.adyen.model.balancecontrol;

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;
Expand All @@ -34,18 +36,33 @@ public class BalanceTransferRequest {
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_DESCRIPTION = "description";
private String description;

/** Mark when the attribute has been explicitly set. */
private boolean isSetDescription = false;

public static final String JSON_PROPERTY_FROM_MERCHANT = "fromMerchant";
private String fromMerchant;

/** Mark when the attribute has been explicitly set. */
private boolean isSetFromMerchant = false;

public static final String JSON_PROPERTY_REFERENCE = "reference";
private String reference;

/** Mark when the attribute has been explicitly set. */
private boolean isSetReference = false;

public static final String JSON_PROPERTY_TO_MERCHANT = "toMerchant";
private String toMerchant;

/** Mark when the attribute has been explicitly set. */
private boolean isSetToMerchant = false;

/**
* The type of balance transfer. Possible values: **tax**, **fee**, **terminalSale**, **credit**,
* **debit**, and **adjustment**.
Expand Down Expand Up @@ -101,6 +118,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 BalanceTransferRequest() {}

/**
Expand All @@ -111,6 +137,7 @@ public BalanceTransferRequest() {}
*/
public BalanceTransferRequest amount(Amount amount) {
this.amount = amount;
isSetAmount = true; // mark as set
return this;
}

Expand All @@ -134,6 +161,7 @@ public Amount getAmount() {
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setAmount(Amount amount) {
this.amount = amount;
isSetAmount = true; // mark as set
}

/**
Expand All @@ -147,6 +175,7 @@ public void setAmount(Amount amount) {
*/
public BalanceTransferRequest description(String description) {
this.description = description;
isSetDescription = true; // mark as set
return this;
}

Expand Down Expand Up @@ -176,6 +205,7 @@ public String getDescription() {
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setDescription(String description) {
this.description = description;
isSetDescription = true; // mark as set
}

/**
Expand All @@ -187,6 +217,7 @@ public void setDescription(String description) {
*/
public BalanceTransferRequest fromMerchant(String fromMerchant) {
this.fromMerchant = fromMerchant;
isSetFromMerchant = true; // mark as set
return this;
}

Expand All @@ -212,6 +243,7 @@ public String getFromMerchant() {
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setFromMerchant(String fromMerchant) {
this.fromMerchant = fromMerchant;
isSetFromMerchant = true; // mark as set
}

/**
Expand All @@ -224,6 +256,7 @@ public void setFromMerchant(String fromMerchant) {
*/
public BalanceTransferRequest reference(String reference) {
this.reference = reference;
isSetReference = true; // mark as set
return this;
}

Expand Down Expand Up @@ -251,6 +284,7 @@ public String getReference() {
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setReference(String reference) {
this.reference = reference;
isSetReference = true; // mark as set
}

/**
Expand All @@ -262,6 +296,7 @@ public void setReference(String reference) {
*/
public BalanceTransferRequest toMerchant(String toMerchant) {
this.toMerchant = toMerchant;
isSetToMerchant = true; // mark as set
return this;
}

Expand All @@ -287,6 +322,7 @@ public String getToMerchant() {
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setToMerchant(String toMerchant) {
this.toMerchant = toMerchant;
isSetToMerchant = true; // mark as set
}

/**
Expand All @@ -299,6 +335,7 @@ public void setToMerchant(String toMerchant) {
*/
public BalanceTransferRequest type(TypeEnum type) {
this.type = type;
isSetType = true; // mark as set
return this;
}

Expand Down Expand Up @@ -326,6 +363,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 BalanceTransferRequest 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 BalanceTransferRequest object is equal to o. */
Expand All @@ -339,16 +397,34 @@ public boolean equals(Object o) {
}
BalanceTransferRequest balanceTransferRequest = (BalanceTransferRequest) o;
return Objects.equals(this.amount, balanceTransferRequest.amount)
&& Objects.equals(this.isSetAmount, balanceTransferRequest.isSetAmount)
&& Objects.equals(this.description, balanceTransferRequest.description)
&& Objects.equals(this.isSetDescription, balanceTransferRequest.isSetDescription)
&& Objects.equals(this.fromMerchant, balanceTransferRequest.fromMerchant)
&& Objects.equals(this.isSetFromMerchant, balanceTransferRequest.isSetFromMerchant)
&& Objects.equals(this.reference, balanceTransferRequest.reference)
&& Objects.equals(this.isSetReference, balanceTransferRequest.isSetReference)
&& Objects.equals(this.toMerchant, balanceTransferRequest.toMerchant)
&& Objects.equals(this.type, balanceTransferRequest.type);
&& Objects.equals(this.isSetToMerchant, balanceTransferRequest.isSetToMerchant)
&& Objects.equals(this.type, balanceTransferRequest.type)
&& Objects.equals(this.isSetType, balanceTransferRequest.isSetType);
}

@Override
public int hashCode() {
return Objects.hash(amount, description, fromMerchant, reference, toMerchant, type);
return Objects.hash(
amount,
isSetAmount,
description,
isSetDescription,
fromMerchant,
isSetFromMerchant,
reference,
isSetReference,
toMerchant,
isSetToMerchant,
type,
isSetType);
}

@Override
Expand All @@ -375,6 +451,45 @@ 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 (isSetAmount) {
addIfNull(nulls, JSON_PROPERTY_AMOUNT, this.amount);
}
if (isSetDescription) {
addIfNull(nulls, JSON_PROPERTY_DESCRIPTION, this.description);
}
if (isSetFromMerchant) {
addIfNull(nulls, JSON_PROPERTY_FROM_MERCHANT, this.fromMerchant);
}
if (isSetReference) {
addIfNull(nulls, JSON_PROPERTY_REFERENCE, this.reference);
}
if (isSetToMerchant) {
addIfNull(nulls, JSON_PROPERTY_TO_MERCHANT, this.toMerchant);
}
if (isSetType) {
addIfNull(nulls, JSON_PROPERTY_TYPE, this.type);
}

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);
}
}

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