Class CustomerUpdateActionUtils
- java.lang.Object
-
- com.commercetools.sync.customers.utils.CustomerUpdateActionUtils
-
public final class CustomerUpdateActionUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CUSTOMER_NUMBER_EXISTS_WARNING
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildAddAddressUpdateActions(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theList
of aCustomerDraft.getAddresses()
and aCustomer.getAddresses()
.static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildAddBillingAddressUpdateActions(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theList
of aCustomer.getBillingAddresses()
and aCustomerDraft.getBillingAddresses()
.static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildAddShippingAddressUpdateActions(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theList
of aCustomer.getShippingAddresses()
and aCustomerDraft.getShippingAddresses()
.static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildAddStoreUpdateActions(java.util.List<io.sphere.sdk.models.KeyReference<io.sphere.sdk.stores.Store>> oldStores, java.util.List<io.sphere.sdk.models.ResourceIdentifier<io.sphere.sdk.stores.Store>> newStores)
Compares theList
ofStore
KeyReference
s andStore
ResourceIdentifier
s of aCustomerDraft
and aCustomer
.static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildAllAddressUpdateActions(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares the addresses of aCustomer
and aCustomerDraft
.static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildChangeAddressUpdateActions(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theList
of aCustomerDraft.getAddresses()
and aCustomer.getAddresses()
.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildChangeEmailUpdateAction(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theemail
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"changeEmail"
UpdateAction
.static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildRemoveAddressUpdateActions(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theList
of aCustomerDraft.getAddresses()
and aCustomer.getAddresses()
.static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildRemoveBillingAddressUpdateActions(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theList
of aCustomer.getBillingAddresses()
and aCustomerDraft.getBillingAddresses()
.static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildRemoveShippingAddressUpdateActions(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theList
of aCustomer.getShippingAddresses()
and aCustomerDraft.getShippingAddresses()
.static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildRemoveStoreUpdateActions(java.util.List<io.sphere.sdk.models.KeyReference<io.sphere.sdk.stores.Store>> oldStores, java.util.List<io.sphere.sdk.models.ResourceIdentifier<io.sphere.sdk.stores.Store>> newStores)
Compares theList
ofStore
KeyReference
s andStore
ResourceIdentifier
s of aCustomerDraft
and aCustomer
.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildSetCompanyNameUpdateAction(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares thecompanyName
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setCompanyName"
UpdateAction
.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildSetCustomerGroupUpdateAction(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theCustomerGroup
references of an oldCustomer
and newCustomerDraft
.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildSetCustomerNumberUpdateAction(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer, CustomerSyncOptions syncOptions)
Compares thecustomerNumber
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setCustomerNumber"
UpdateAction
.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildSetDateOfBirthUpdateAction(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares thedateOfBirth
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setDateOfBirth"
UpdateAction
.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildSetDefaultBillingAddressUpdateAction(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theCustomer.getDefaultBillingAddress()
andCustomerDraft.getDefaultBillingAddress()
.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildSetDefaultShippingAddressUpdateAction(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theCustomer.getDefaultShippingAddress()
andCustomerDraft.getDefaultShippingAddress()
.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildSetExternalIdUpdateAction(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theexternalId
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setExternalId"
UpdateAction
.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildSetFirstNameUpdateAction(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares thefirstName
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setFirstName"
UpdateAction
.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildSetLastNameUpdateAction(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares thelastName
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setLastName"
UpdateAction
.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildSetLocaleUpdateAction(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares thelocale
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setLocale"
UpdateAction
.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildSetMiddleNameUpdateAction(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares themiddleName
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setMiddleName"
UpdateAction
.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildSetSalutationUpdateAction(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares thesalutation
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"SetSalutation"
UpdateAction
.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildSetTitleUpdateAction(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares thetitle
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setTitle"
UpdateAction
.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildSetVatIdUpdateAction(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares thevatId
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setVatId"
UpdateAction
.static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>>
buildStoreUpdateActions(io.sphere.sdk.customers.Customer oldCustomer, io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares the stores of aCustomer
and aCustomerDraft
.
-
-
-
Field Detail
-
CUSTOMER_NUMBER_EXISTS_WARNING
public static final java.lang.String CUSTOMER_NUMBER_EXISTS_WARNING
- See Also:
- Constant Field Values
-
-
Method Detail
-
buildChangeEmailUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildChangeEmailUpdateAction(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theemail
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"changeEmail"
UpdateAction
. If bothCustomer
andCustomerDraft
have the sameemail
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new email.- Returns:
- optional containing update action or empty optional if emails are identical.
-
buildSetFirstNameUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildSetFirstNameUpdateAction(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares thefirstName
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setFirstName"
UpdateAction
. If bothCustomer
andCustomerDraft
have the samefirstName
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new first name.- Returns:
- optional containing update action or empty optional if first names are identical.
-
buildSetLastNameUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildSetLastNameUpdateAction(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares thelastName
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setLastName"
UpdateAction
. If bothCustomer
andCustomerDraft
have the samelastName
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new last name.- Returns:
- optional containing update action or empty optional if last names are identical.
-
buildSetMiddleNameUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildSetMiddleNameUpdateAction(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares themiddleName
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setMiddleName"
UpdateAction
. If bothCustomer
andCustomerDraft
have the samemiddleName
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new middle name.- Returns:
- optional containing update action or empty optional if middle names are identical.
-
buildSetTitleUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildSetTitleUpdateAction(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares thetitle
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setTitle"
UpdateAction
. If bothCustomer
andCustomerDraft
have the sametitle
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new title.- Returns:
- optional containing update action or empty optional if titles are identical.
-
buildSetSalutationUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildSetSalutationUpdateAction(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares thesalutation
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"SetSalutation"
UpdateAction
. If bothCustomer
andCustomerDraft
have the samesalutation
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the Customer that should be updated.newCustomer
- the Customer draft that contains the new salutation.- Returns:
- optional containing update action or empty optional if salutations are identical.
-
buildSetCustomerNumberUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildSetCustomerNumberUpdateAction(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer, @Nonnull CustomerSyncOptions syncOptions)
Compares thecustomerNumber
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setCustomerNumber"
UpdateAction
. If bothCustomer
andCustomerDraft
have the samecustomerNumber
values, then no update action is needed and empty optional will be returned.Note: Customer number should be unique across a project. Once it's set it cannot be changed. For this case, warning callback will be triggered and an empty optional will be returned.
- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new customer number.syncOptions
- responsible for supplying the sync options to the sync utility method. It is used for triggering the warning callback when trying to change an existing customer number.- Returns:
- optional containing update action or empty optional if customer numbers are identical.
-
buildSetExternalIdUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildSetExternalIdUpdateAction(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theexternalId
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setExternalId"
UpdateAction
. If bothCustomer
andCustomerDraft
have the sameexternalId
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new external id.- Returns:
- optional containing update action or empty optional if external ids are identical.
-
buildSetCompanyNameUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildSetCompanyNameUpdateAction(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares thecompanyName
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setCompanyName"
UpdateAction
. If bothCustomer
andCustomerDraft
have the samecompanyName
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new company name.- Returns:
- optional containing update action or empty optional if company names are identical.
-
buildSetDateOfBirthUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildSetDateOfBirthUpdateAction(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares thedateOfBirth
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setDateOfBirth"
UpdateAction
. If bothCustomer
andCustomerDraft
have the samedateOfBirth
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new date of birth.- Returns:
- optional containing update action or empty optional if dates of birth are identical.
-
buildSetVatIdUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildSetVatIdUpdateAction(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares thevatId
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setVatId"
UpdateAction
. If bothCustomer
andCustomerDraft
have the samevatId
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new vat id.- Returns:
- optional containing update action or empty optional if vat ids are identical.
-
buildSetLocaleUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildSetLocaleUpdateAction(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares thelocale
values of aCustomer
and aCustomerDraft
and returns anOptional
of update action, which would contain the"setLocale"
UpdateAction
. If bothCustomer
andCustomerDraft
have the samelocale
values, then no update action is needed and empty optional will be returned.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft that contains the new locale.- Returns:
- optional containing update action or empty optional if locales are identical.
-
buildSetCustomerGroupUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildSetCustomerGroupUpdateAction(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theCustomerGroup
references of an oldCustomer
and newCustomerDraft
. If they are different - returnSetCustomerGroup
update action.If the old value is set, but the new one is empty - the command will unset the customer group.
- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft with newCustomerGroup
reference.- Returns:
- An optional with
SetCustomerGroup
update action.
-
buildStoreUpdateActions
@Nonnull public static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildStoreUpdateActions(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares the stores of aCustomer
and aCustomerDraft
. It returns aList
ofUpdateAction
<Customer
> as a result. If no update action is needed, for example in case where both theCustomer
and theCustomerDraft
have the identical stores, an emptyList
is returned.Note: Null values of the stores are filtered out.
- Parameters:
oldCustomer
- the customer which should be updated.newCustomer
- the customer draft where we get the new data.- Returns:
- A list of customer store-related update actions.
-
buildRemoveStoreUpdateActions
@Nonnull public static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildRemoveStoreUpdateActions(@Nonnull java.util.List<io.sphere.sdk.models.KeyReference<io.sphere.sdk.stores.Store>> oldStores, @Nonnull java.util.List<io.sphere.sdk.models.ResourceIdentifier<io.sphere.sdk.stores.Store>> newStores)
Compares theList
ofStore
KeyReference
s andStore
ResourceIdentifier
s of aCustomerDraft
and aCustomer
. It returns aList
ofRemoveStore
update actions as a result, if the old store needs to be removed from a customer to have the same set of stores as the new customer. If both theCustomer
and theCustomerDraft
have the same set of stores, then no update actions are needed and hence an emptyList
is returned.Note: Null values of the stores are filtered out.
- Parameters:
oldStores
- the stores which should be updated.newStores
- the stores where we get the new store.- Returns:
- A list containing the update actions or an empty list if the store references are identical.
-
buildAddStoreUpdateActions
@Nonnull public static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildAddStoreUpdateActions(@Nonnull java.util.List<io.sphere.sdk.models.KeyReference<io.sphere.sdk.stores.Store>> oldStores, @Nonnull java.util.List<io.sphere.sdk.models.ResourceIdentifier<io.sphere.sdk.stores.Store>> newStores)
Compares theList
ofStore
KeyReference
s andStore
ResourceIdentifier
s of aCustomerDraft
and aCustomer
. It returns aList
ofAddStore
update actions as a result, if the old store needs to be added to a customer to have the same set of stores as the new customer. If both theCustomer
and theCustomerDraft
have the same set of stores, then no update actions are needed and hence an emptyList
is returned.Note: Null values of the stores are filtered out.
- Parameters:
oldStores
- the stores which should be updated.newStores
- the stores where we get the new store.- Returns:
- A list containing the update actions or an empty list if the store references are identical.
-
buildAllAddressUpdateActions
@Nonnull public static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildAllAddressUpdateActions(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares the addresses of aCustomer
and aCustomerDraft
. It returns aList
ofUpdateAction
<Customer
> as a result. If both theCustomer
and theCustomerDraft
have the same set of addresses, then no update actions are needed and hence an emptyList
is returned.- Parameters:
oldCustomer
- the customer which should be updated.newCustomer
- the customer draft where we get the new data.- Returns:
- A list of customer address-related update actions.
-
buildRemoveAddressUpdateActions
@Nonnull public static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildRemoveAddressUpdateActions(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theList
of aCustomerDraft.getAddresses()
and aCustomer.getAddresses()
. It returns aList
ofRemoveAddress
update actions as a result, if the old address needs to be removed from theoldCustomer
to have the same set of addresses as thenewCustomer
. If both theCustomer
and theCustomerDraft
have the same set of addresses, then no update actions are needed and hence an emptyList
is returned.Notes:
- Addresses are matching by their keys.
- Null values of the new addresses are filtered out.
- Address values without keys are filtered out.
- Parameters:
oldCustomer
- the customer which should be updated.newCustomer
- the customer draft where we get the new addresses.- Returns:
- A list containing the update actions or an empty list if the addresses are identical.
-
buildChangeAddressUpdateActions
@Nonnull public static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildChangeAddressUpdateActions(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theList
of aCustomerDraft.getAddresses()
and aCustomer.getAddresses()
. It returns aList
ofChangeAddress
update actions as a result, if the old address needs to be changed/updated from theoldCustomer
to have the same set of addresses as thenewCustomer
. If both theCustomer
and theCustomerDraft
have the same set of addresses, then no update actions are needed and hence an emptyList
is returned.Notes:
- Addresses are matching by their keys.
- Null values of the new addresses are filtered out.
- Address values without keys are filtered out.
- Parameters:
oldCustomer
- the customer which should be updated.newCustomer
- the customer draft where we get the new addresses.- Returns:
- A list containing the update actions or an empty list if the addresses are identical.
-
buildAddAddressUpdateActions
@Nonnull public static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildAddAddressUpdateActions(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theList
of aCustomerDraft.getAddresses()
and aCustomer.getAddresses()
. It returns aList
ofAddAddress
update actions as a result, if the new address needs to be added to have the same set of addresses as thenewCustomer
. If both theCustomer
and theCustomerDraft
have the same set of addresses, then no update actions are needed and hence an emptyList
is returned.Notes:
- Addresses are matching by their keys.
- Null values of the new addresses are filtered out.
- Address values without keys are filtered out.
- Parameters:
oldCustomer
- the customer which should be updated.newCustomer
- the customer draft where we get the new addresses.- Returns:
- A list containing the update actions or an empty list if the addresses are identical.
-
buildSetDefaultShippingAddressUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildSetDefaultShippingAddressUpdateAction(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theCustomer.getDefaultShippingAddress()
andCustomerDraft.getDefaultShippingAddress()
. If they are different - returnSetDefaultShippingAddress
update action. If the old shipping address is set, but the new one is empty - the command will unset the default shipping address.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft with new default shipping address.- Returns:
- An optional with
SetDefaultShippingAddress
update action.
-
buildSetDefaultBillingAddressUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildSetDefaultBillingAddressUpdateAction(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theCustomer.getDefaultBillingAddress()
andCustomerDraft.getDefaultBillingAddress()
. If they are different - returnSetDefaultBillingAddress
update action. If the old billing address id value is set, but the new one is empty - the command will unset the default billing address.- Parameters:
oldCustomer
- the customer that should be updated.newCustomer
- the customer draft with new default billing address.- Returns:
- An optional with
SetDefaultBillingAddress
update action.
-
buildAddShippingAddressUpdateActions
@Nonnull public static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildAddShippingAddressUpdateActions(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theList
of aCustomer.getShippingAddresses()
and aCustomerDraft.getShippingAddresses()
. It returns aList
ofAddShippingAddressId
update actions as a result, if the new shipping address needs to be added to have the same set of addresses as thenewCustomer
. If both theCustomer
and theCustomerDraft
have the same set of shipping addresses, then no update actions are needed and hence an emptyList
is returned.Notes:
- Addresses are matching by their keys.
- Old address values without keys are filtered out.
- Each address in the new addresses list satisfies the following conditions:
- It is not null
- It has a key which is not blank (null/empty)
IllegalArgumentException
will be thrown.
- Parameters:
oldCustomer
- the customer which should be updated.newCustomer
- the customer draft where we get the new shipping addresses.- Returns:
- A list containing the update actions or an empty list if the shipping addresses are identical.
-
buildRemoveShippingAddressUpdateActions
@Nonnull public static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildRemoveShippingAddressUpdateActions(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theList
of aCustomer.getShippingAddresses()
and aCustomerDraft.getShippingAddresses()
. It returns aList
ofRemoveShippingAddressId
update actions as a result, if the old shipping address needs to be removed to have the same set of addresses as thenewCustomer
. If both theCustomer
and theCustomerDraft
have the same set of shipping addresses, then no update actions are needed and hence an emptyList
is returned.Notes:
- Addresses are matching by their keys.
- Old shipping addresses without keys will be removed.
- Each address in the new addresses list satisfies the following conditions:
- It exists in the given index.
- It has a key which is not blank (null/empty)
IllegalArgumentException
will be thrown.
- Parameters:
oldCustomer
- the customer which should be updated.newCustomer
- the customer draft where we get the new shipping addresses.- Returns:
- A list containing the update actions or an empty list if the shipping addresses are identical.
-
buildAddBillingAddressUpdateActions
@Nonnull public static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildAddBillingAddressUpdateActions(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theList
of aCustomer.getBillingAddresses()
and aCustomerDraft.getBillingAddresses()
. It returns aList
ofAddBillingAddressId
update actions as a result, if the new billing address needs to be added to have the same set of addresses as thenewCustomer
. If both theCustomer
and theCustomerDraft
have the same set of billing addresses, then no update actions are needed and hence an emptyList
is returned.Notes:
- Addresses are matching by their keys.
- Old address values without keys are filtered out.
- Each address in the new addresses list satisfies the following conditions:
- It is not null
- It has a key which is not blank (null/empty)
IllegalArgumentException
will be thrown.
- Parameters:
oldCustomer
- the customer which should be updated.newCustomer
- the customer draft where we get the new billing addresses.- Returns:
- A list containing the update actions or an empty list if the billing addresses are identical.
-
buildRemoveBillingAddressUpdateActions
@Nonnull public static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.customers.Customer>> buildRemoveBillingAddressUpdateActions(@Nonnull io.sphere.sdk.customers.Customer oldCustomer, @Nonnull io.sphere.sdk.customers.CustomerDraft newCustomer)
Compares theList
of aCustomer.getBillingAddresses()
and aCustomerDraft.getBillingAddresses()
. It returns aList
ofRemoveBillingAddressId
update actions as a result, if the old billing address needs to be removed to have the same set of addresses as thenewCustomer
. If both theCustomer
and theCustomerDraft
have the same set of billing addresses, then no update actions are needed and hence an emptyList
is returned.Notes:
- Addresses are matching by their keys.
- Null values of the old addresses are filtered out.
- Old shipping address values without keys are filtered out.
- Each address in the new addresses list satisfies the following conditions:
- It exists in the given index.
- It has a key which is not blank (null/empty)
IllegalArgumentException
will be thrown.
- Parameters:
oldCustomer
- the customer which should be updated.newCustomer
- the customer draft where we get the new shipping addresses.- Returns:
- A list containing the update actions or an empty list if the shipping addresses are identical.
-
-