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

io.sphere.sdk.carts.commands.updateactions.SetCustomerId Maven / Gradle / Ivy

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

import io.sphere.sdk.carts.Cart;
import io.sphere.sdk.commands.UpdateActionImpl;
import io.sphere.sdk.customers.Customer;
import io.sphere.sdk.models.Referenceable;

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

/**
 

Sets an existing customer ID for a cart.

The customer ID can be unset by calling {@link SetCustomerId#of(String)} with {@code null}. {@doc.gen intro} {@include.example io.sphere.sdk.carts.commands.CartUpdateCommandTest#setCustomerId()} */ public class SetCustomerId extends UpdateActionImpl { @Nullable private final String customerId; private SetCustomerId(@Nullable final String customerId) { super("setCustomerId"); this.customerId = customerId; } public static SetCustomerId of(@Nullable final String customerId) { return new SetCustomerId(customerId); } public static SetCustomerId empty() { return new SetCustomerId(null); } public static SetCustomerId ofCustomer(@Nullable final Referenceable customer) { return of(Optional.ofNullable(customer).map(c -> c.toReference().getId()).orElse(null)); } @Nullable public String getCustomerId() { return customerId; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy