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

com.commercetools.sunrise.myaccount.WithRequiredCustomer Maven / Gradle / Ivy

The newest version!
package com.commercetools.sunrise.myaccount;

import io.sphere.sdk.customers.Customer;
import play.libs.concurrent.HttpExecution;
import play.mvc.Result;

import java.util.concurrent.CompletionStage;
import java.util.function.Function;

public interface WithRequiredCustomer {

    CustomerFinder getCustomerFinder();

    default CompletionStage requireCustomer(final Function> nextAction) {
        return getCustomerFinder().get()
                .thenComposeAsync(customer -> customer
                                .map(nextAction)
                                .orElseGet(this::handleNotFoundCustomer),
                        HttpExecution.defaultContext());
    }

    CompletionStage handleNotFoundCustomer();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy