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();
}