1111
1212package com .adyen .model .balancecontrol ;
1313
14+ import com .fasterxml .jackson .annotation .JsonAnyGetter ;
1415import com .fasterxml .jackson .annotation .JsonCreator ;
16+ import com .fasterxml .jackson .annotation .JsonIgnore ;
1517import com .fasterxml .jackson .annotation .JsonInclude ;
1618import com .fasterxml .jackson .annotation .JsonProperty ;
1719import com .fasterxml .jackson .annotation .JsonPropertyOrder ;
@@ -34,18 +36,33 @@ public class BalanceTransferRequest {
3436 public static final String JSON_PROPERTY_AMOUNT = "amount" ;
3537 private Amount amount ;
3638
39+ /** Mark when the attribute has been explicitly set. */
40+ private boolean isSetAmount = false ;
41+
3742 public static final String JSON_PROPERTY_DESCRIPTION = "description" ;
3843 private String description ;
3944
45+ /** Mark when the attribute has been explicitly set. */
46+ private boolean isSetDescription = false ;
47+
4048 public static final String JSON_PROPERTY_FROM_MERCHANT = "fromMerchant" ;
4149 private String fromMerchant ;
4250
51+ /** Mark when the attribute has been explicitly set. */
52+ private boolean isSetFromMerchant = false ;
53+
4354 public static final String JSON_PROPERTY_REFERENCE = "reference" ;
4455 private String reference ;
4556
57+ /** Mark when the attribute has been explicitly set. */
58+ private boolean isSetReference = false ;
59+
4660 public static final String JSON_PROPERTY_TO_MERCHANT = "toMerchant" ;
4761 private String toMerchant ;
4862
63+ /** Mark when the attribute has been explicitly set. */
64+ private boolean isSetToMerchant = false ;
65+
4966 /**
5067 * The type of balance transfer. Possible values: **tax**, **fee**, **terminalSale**, **credit**,
5168 * **debit**, and **adjustment**.
@@ -101,6 +118,15 @@ public static TypeEnum fromValue(String value) {
101118 public static final String JSON_PROPERTY_TYPE = "type" ;
102119 private TypeEnum type ;
103120
121+ /** Mark when the attribute has been explicitly set. */
122+ private boolean isSetType = false ;
123+
124+ /**
125+ * Sets whether attributes with null values should be explicitly included in the JSON payload.
126+ * Default is false.
127+ */
128+ @ JsonIgnore private boolean includeNullValues = false ;
129+
104130 public BalanceTransferRequest () {}
105131
106132 /**
@@ -111,6 +137,7 @@ public BalanceTransferRequest() {}
111137 */
112138 public BalanceTransferRequest amount (Amount amount ) {
113139 this .amount = amount ;
140+ isSetAmount = true ; // mark as set
114141 return this ;
115142 }
116143
@@ -134,6 +161,7 @@ public Amount getAmount() {
134161 @ JsonInclude (value = JsonInclude .Include .USE_DEFAULTS )
135162 public void setAmount (Amount amount ) {
136163 this .amount = amount ;
164+ isSetAmount = true ; // mark as set
137165 }
138166
139167 /**
@@ -147,6 +175,7 @@ public void setAmount(Amount amount) {
147175 */
148176 public BalanceTransferRequest description (String description ) {
149177 this .description = description ;
178+ isSetDescription = true ; // mark as set
150179 return this ;
151180 }
152181
@@ -176,6 +205,7 @@ public String getDescription() {
176205 @ JsonInclude (value = JsonInclude .Include .USE_DEFAULTS )
177206 public void setDescription (String description ) {
178207 this .description = description ;
208+ isSetDescription = true ; // mark as set
179209 }
180210
181211 /**
@@ -187,6 +217,7 @@ public void setDescription(String description) {
187217 */
188218 public BalanceTransferRequest fromMerchant (String fromMerchant ) {
189219 this .fromMerchant = fromMerchant ;
220+ isSetFromMerchant = true ; // mark as set
190221 return this ;
191222 }
192223
@@ -212,6 +243,7 @@ public String getFromMerchant() {
212243 @ JsonInclude (value = JsonInclude .Include .USE_DEFAULTS )
213244 public void setFromMerchant (String fromMerchant ) {
214245 this .fromMerchant = fromMerchant ;
246+ isSetFromMerchant = true ; // mark as set
215247 }
216248
217249 /**
@@ -224,6 +256,7 @@ public void setFromMerchant(String fromMerchant) {
224256 */
225257 public BalanceTransferRequest reference (String reference ) {
226258 this .reference = reference ;
259+ isSetReference = true ; // mark as set
227260 return this ;
228261 }
229262
@@ -251,6 +284,7 @@ public String getReference() {
251284 @ JsonInclude (value = JsonInclude .Include .USE_DEFAULTS )
252285 public void setReference (String reference ) {
253286 this .reference = reference ;
287+ isSetReference = true ; // mark as set
254288 }
255289
256290 /**
@@ -262,6 +296,7 @@ public void setReference(String reference) {
262296 */
263297 public BalanceTransferRequest toMerchant (String toMerchant ) {
264298 this .toMerchant = toMerchant ;
299+ isSetToMerchant = true ; // mark as set
265300 return this ;
266301 }
267302
@@ -287,6 +322,7 @@ public String getToMerchant() {
287322 @ JsonInclude (value = JsonInclude .Include .USE_DEFAULTS )
288323 public void setToMerchant (String toMerchant ) {
289324 this .toMerchant = toMerchant ;
325+ isSetToMerchant = true ; // mark as set
290326 }
291327
292328 /**
@@ -299,6 +335,7 @@ public void setToMerchant(String toMerchant) {
299335 */
300336 public BalanceTransferRequest type (TypeEnum type ) {
301337 this .type = type ;
338+ isSetType = true ; // mark as set
302339 return this ;
303340 }
304341
@@ -326,6 +363,27 @@ public TypeEnum getType() {
326363 @ JsonInclude (value = JsonInclude .Include .USE_DEFAULTS )
327364 public void setType (TypeEnum type ) {
328365 this .type = type ;
366+ isSetType = true ; // mark as set
367+ }
368+
369+ /**
370+ * Configures whether null values are explicitly serialized in the JSON payload. Default is false.
371+ */
372+ public BalanceTransferRequest includeNullValues (boolean includeNullValues ) {
373+ this .includeNullValues = includeNullValues ;
374+ return this ;
375+ }
376+
377+ /** Returns whether null values are explicitly serialized in the JSON payload. */
378+ public boolean isIncludeNullValues () {
379+ return includeNullValues ;
380+ }
381+
382+ /**
383+ * Sets whether null values should be explicitly serialized in the JSON payload. Default is false.
384+ */
385+ public void setIncludeNullValues (boolean includeNullValues ) {
386+ this .includeNullValues = includeNullValues ;
329387 }
330388
331389 /** Return true if this BalanceTransferRequest object is equal to o. */
@@ -339,16 +397,34 @@ public boolean equals(Object o) {
339397 }
340398 BalanceTransferRequest balanceTransferRequest = (BalanceTransferRequest ) o ;
341399 return Objects .equals (this .amount , balanceTransferRequest .amount )
400+ && Objects .equals (this .isSetAmount , balanceTransferRequest .isSetAmount )
342401 && Objects .equals (this .description , balanceTransferRequest .description )
402+ && Objects .equals (this .isSetDescription , balanceTransferRequest .isSetDescription )
343403 && Objects .equals (this .fromMerchant , balanceTransferRequest .fromMerchant )
404+ && Objects .equals (this .isSetFromMerchant , balanceTransferRequest .isSetFromMerchant )
344405 && Objects .equals (this .reference , balanceTransferRequest .reference )
406+ && Objects .equals (this .isSetReference , balanceTransferRequest .isSetReference )
345407 && Objects .equals (this .toMerchant , balanceTransferRequest .toMerchant )
346- && Objects .equals (this .type , balanceTransferRequest .type );
408+ && Objects .equals (this .isSetToMerchant , balanceTransferRequest .isSetToMerchant )
409+ && Objects .equals (this .type , balanceTransferRequest .type )
410+ && Objects .equals (this .isSetType , balanceTransferRequest .isSetType );
347411 }
348412
349413 @ Override
350414 public int hashCode () {
351- return Objects .hash (amount , description , fromMerchant , reference , toMerchant , type );
415+ return Objects .hash (
416+ amount ,
417+ isSetAmount ,
418+ description ,
419+ isSetDescription ,
420+ fromMerchant ,
421+ isSetFromMerchant ,
422+ reference ,
423+ isSetReference ,
424+ toMerchant ,
425+ isSetToMerchant ,
426+ type ,
427+ isSetType );
352428 }
353429
354430 @ Override
@@ -375,6 +451,45 @@ private String toIndentedString(Object o) {
375451 return o .toString ().replace ("\n " , "\n " );
376452 }
377453
454+ /** Returns a map of properties to be merged into the JSON payload as explicit null values. */
455+ @ JsonInclude (JsonInclude .Include .ALWAYS )
456+ @ JsonAnyGetter
457+ public Map <String , Object > getExplicitNulls () {
458+ if (!this .includeNullValues ) {
459+ return Collections .emptyMap ();
460+ }
461+
462+ Map <String , Object > nulls = new HashMap <>();
463+
464+ if (isSetAmount ) {
465+ addIfNull (nulls , JSON_PROPERTY_AMOUNT , this .amount );
466+ }
467+ if (isSetDescription ) {
468+ addIfNull (nulls , JSON_PROPERTY_DESCRIPTION , this .description );
469+ }
470+ if (isSetFromMerchant ) {
471+ addIfNull (nulls , JSON_PROPERTY_FROM_MERCHANT , this .fromMerchant );
472+ }
473+ if (isSetReference ) {
474+ addIfNull (nulls , JSON_PROPERTY_REFERENCE , this .reference );
475+ }
476+ if (isSetToMerchant ) {
477+ addIfNull (nulls , JSON_PROPERTY_TO_MERCHANT , this .toMerchant );
478+ }
479+ if (isSetType ) {
480+ addIfNull (nulls , JSON_PROPERTY_TYPE , this .type );
481+ }
482+
483+ return nulls ;
484+ }
485+
486+ // add to map when value is null
487+ private void addIfNull (Map <String , Object > map , String key , Object value ) {
488+ if (value == null ) {
489+ map .put (key , null );
490+ }
491+ }
492+
378493 /**
379494 * Create an instance of BalanceTransferRequest given an JSON string
380495 *
0 commit comments