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

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

package io.sphere.sdk.reviews.commands.updateactions;

import io.sphere.sdk.commands.UpdateActionImpl;
import io.sphere.sdk.customers.Customer;
import io.sphere.sdk.models.Referenceable;
import io.sphere.sdk.models.ResourceIdentifiable;
import io.sphere.sdk.models.ResourceIdentifier;
import io.sphere.sdk.reviews.Review;

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

/**
 * Sets/unsets the customer belonging to a review.
 *
 * {@include.example io.sphere.sdk.reviews.commands.ReviewUpdateCommandTest#setCustomer()}
 */
public class SetCustomer extends UpdateActionImpl {
    @Nullable
    private final ResourceIdentifier customer;

    private SetCustomer(@Nullable final ResourceIdentifier customer) {
        super("setCustomer");
        this.customer = customer;
    }

    public static SetCustomer of(@Nullable final Referenceable customer) {
        final ResourceIdentifier resourceIdentifier = Optional.ofNullable(customer)
                .map(ResourceIdentifiable::toResourceIdentifier)
                .orElse(null);
        return new SetCustomer(resourceIdentifier);
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy