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

io.sphere.sdk.payments.commands.updateactions.SetCustomer Maven / Gradle / Ivy

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

import io.sphere.sdk.commands.UpdateActionImpl;
import io.sphere.sdk.customers.Customer;
import io.sphere.sdk.models.Reference;
import io.sphere.sdk.models.Referenceable;
import io.sphere.sdk.payments.Payment;

import javax.annotation.Nullable;
import java.util.Optional;

/**
 * Sets the reference to the customer. If not defined, the reference is unset.
 *
 * {@doc.gen intro}
 *
 * {@include.example io.sphere.sdk.payments.commands.PaymentUpdateCommandTest#setCustomer()}
 *
 * @see Payment
 */
public final class SetCustomer extends UpdateActionImpl {
    @Nullable
    private final Reference customer;

    private SetCustomer(final Reference customer) {
        super("setCustomer");
        this.customer = customer;
    }

    public static SetCustomer of(@Nullable final Referenceable customer) {
        final Reference customerReference = Optional.ofNullable(customer).map(x -> x.toReference()).orElse(null);
        return new SetCustomer(customerReference);
    }

    @Nullable
    public Reference getCustomer() {
        return customer;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy