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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
30 changes: 18 additions & 12 deletions src/main/java/com/adyen/model/acswebhooks/Amount.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ public Amount() {}

/**
* The three-character [ISO currency
* code](https://docs.adyen.com/development-resources/currency-codes#currency-codes).
* code](https://docs.adyen.com/development-resources/currency-codes#currency-codes) of the
* amount.
*
* @param currency The three-character [ISO currency
* code](https://docs.adyen.com/development-resources/currency-codes#currency-codes).
* code](https://docs.adyen.com/development-resources/currency-codes#currency-codes) of the
* amount.
* @return the current {@code Amount} instance, allowing for method chaining
*/
public Amount currency(String currency) {
Expand All @@ -43,10 +45,12 @@ public Amount currency(String currency) {

/**
* The three-character [ISO currency
* code](https://docs.adyen.com/development-resources/currency-codes#currency-codes).
* code](https://docs.adyen.com/development-resources/currency-codes#currency-codes) of the
* amount.
*
* @return currency The three-character [ISO currency
* code](https://docs.adyen.com/development-resources/currency-codes#currency-codes).
* code](https://docs.adyen.com/development-resources/currency-codes#currency-codes) of the
* amount.
*/
@JsonProperty(JSON_PROPERTY_CURRENCY)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
Expand All @@ -56,10 +60,12 @@ public String getCurrency() {

/**
* The three-character [ISO currency
* code](https://docs.adyen.com/development-resources/currency-codes#currency-codes).
* code](https://docs.adyen.com/development-resources/currency-codes#currency-codes) of the
* amount.
*
* @param currency The three-character [ISO currency
* code](https://docs.adyen.com/development-resources/currency-codes#currency-codes).
* code](https://docs.adyen.com/development-resources/currency-codes#currency-codes) of the
* amount.
*/
@JsonProperty(JSON_PROPERTY_CURRENCY)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
Expand All @@ -68,10 +74,10 @@ public void setCurrency(String currency) {
}

/**
* The amount of the transaction, in [minor
* The numeric value of the amount, in [minor
* units](https://docs.adyen.com/development-resources/currency-codes#minor-units).
*
* @param value The amount of the transaction, in [minor
* @param value The numeric value of the amount, in [minor
* units](https://docs.adyen.com/development-resources/currency-codes#minor-units).
* @return the current {@code Amount} instance, allowing for method chaining
*/
Expand All @@ -81,10 +87,10 @@ public Amount value(Long value) {
}

/**
* The amount of the transaction, in [minor
* The numeric value of the amount, in [minor
* units](https://docs.adyen.com/development-resources/currency-codes#minor-units).
*
* @return value The amount of the transaction, in [minor
* @return value The numeric value of the amount, in [minor
* units](https://docs.adyen.com/development-resources/currency-codes#minor-units).
*/
@JsonProperty(JSON_PROPERTY_VALUE)
Expand All @@ -94,10 +100,10 @@ public Long getValue() {
}

/**
* The amount of the transaction, in [minor
* The numeric value of the amount, in [minor
* units](https://docs.adyen.com/development-resources/currency-codes#minor-units).
*
* @param value The amount of the transaction, in [minor
* @param value The numeric value of the amount, in [minor
* units](https://docs.adyen.com/development-resources/currency-codes#minor-units).
*/
@JsonProperty(JSON_PROPERTY_VALUE)
Expand Down
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
Loading