Class CustomerPaymentAccountEndpoint.PaymentAccountUpdate
- java.lang.Object
-
- com.broadleafcommerce.customer.web.endpoint.CustomerPaymentAccountEndpoint.PaymentAccountUpdate
-
- Enclosing class:
- CustomerPaymentAccountEndpoint
public static class CustomerPaymentAccountEndpoint.PaymentAccountUpdate extends Object
A custom DTO that is intended for the specific purpose of supporting PATCH forPaymentAccount
.It is important to note that the combined usage of
@Nullable
andOptional
for the fields is entirely intentional.. Since there is no way to distinguish between a value not being supplied and being updated tonull
, this mechanism is necessary.If the request JSON does not have a particular field's key, the field in this DTO will deserialize to
null
. If the request JSON does have the field's key but the value is null, the field in this DTO will deserialize toOptional.empty()
.An earlier, alternate implementation relied on a single
Map<String, Object>
"updateFields" property to achieve the same distinction between unsupplied and null, but this approach had the flaw of not being able to take advantage of Jackson's automatic type-safe deserialization. With the current approach, Jackson can understand the declared types and automatically verify and convert the fields to the appropriate types.Another important note is that the use of
@Data
and@Setter
withAccessLevel#PRIVATE
is intentional. This is required for getting the behavior we want from Jackson on deserialization, while still maintaining@Value
-like immutability. If we were to use@Value
, Jackson would always set unsupplied keys toOptional.empty()
. However, when we use@Data
, it seems that Jackson simply does not call the setters for the fields with unsupplied keys, which leaves them null (giving us our desired behavior).For
paymentGatewayProperties
, only keys present will be added or updated. If the caller wants to remove an entry, they should supply a blank value for the key.
-
-
Constructor Summary
Constructors Constructor Description PaymentAccountUpdate()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
canEqual(Object other)
boolean
equals(Object o)
Optional<String>
getAddressLine1()
Optional<String>
getAddressLine2()
Optional<String>
getAddressLine3()
Optional<String>
getCity()
Optional<String>
getCountry()
Optional<String>
getCounty()
Optional<Boolean>
getDeactivated()
Map<String,String>
getDisplayAttributes()
Only keys present will be added or updated.Optional<String>
getDisplayName()
Optional<Integer>
getExpirationMonth()
Optional<Integer>
getExpirationYear()
Optional<String>
getFullName()
Optional<String>
getNameOnAccount()
Map<String,String>
getPaymentGatewayProperties()
Only keys present will be added or updated.Optional<Phone>
getPhonePrimary()
Optional<Phone>
getPhoneSecondary()
Optional<String>
getPostalCode()
Optional<String>
getStateProvinceRegion()
int
hashCode()
String
toString()
-
-
-
Method Detail
-
getPaymentGatewayProperties
public Map<String,String> getPaymentGatewayProperties()
Only keys present will be added or updated. If the caller wants to remove an entry, they should supply a blank value for the key.
-
getDisplayAttributes
public Map<String,String> getDisplayAttributes()
Only keys present will be added or updated. If the caller wants to remove an entry, they should supply a blank value for the key.
-
canEqual
protected boolean canEqual(Object other)
-
-