All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sphere.sdk.customers.commands.updateactions.RemoveAddress Maven / Gradle / Ivy

There is a newer version: 1.0.0-M26
Show newest version
package io.sphere.sdk.customers.commands.updateactions;

import io.sphere.sdk.commands.UpdateActionImpl;
import io.sphere.sdk.customers.Customer;
import io.sphere.sdk.models.Address;

import static java.lang.String.format;

/**
 * Removes the address with the given ID from the customer's addresses.
 *
 *  {@doc.gen intro}
 *
 * {@include.example io.sphere.sdk.customers.commands.CustomerUpdateCommandTest#removeAddress()}
 *
 * @see Customer
 */
public class RemoveAddress extends UpdateActionImpl {
    private final String addressId;

    private RemoveAddress(final String addressId) {
        super("removeAddress");
        this.addressId = addressId;
    }

    public static RemoveAddress of(final String addressId) {
        return new RemoveAddress(addressId);
    }

    public static RemoveAddress of(final Address address) {
        if (address.getId() == null) {
            throw new IllegalArgumentException(format("The address %s should have an id.", address));
        }
        return of(address.getId());
    }

    public String getAddressId() {
        return addressId;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy