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

kikaha.uworkers.core.FailureExchange Maven / Gradle / Ivy

package kikaha.uworkers.core;

import kikaha.uworkers.api.Exchange;
import kikaha.uworkers.api.Response;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.util.function.BiConsumer;

/**
 * Represents a failure while retrieving an {@link Exchange} from
 * the {@link EndpointInboxSupplier}.
 */
@Slf4j
@RequiredArgsConstructor
public class FailureExchange implements Exchange {

    final Throwable failure;

    @Override
    public  RESP response() {
        throw failure();
    }

    @Override
    public  RESP responseAs(Class targetClass) {
        throw failure();
    }

    @Override
    public Response then(BiConsumer listener) {
        throw failure();
    }

    @Override
    public  REQ request() {
        throw failure();
    }

    @Override
    public  REQ requestAs(Class targetClass) throws IOException {
        throw failure();
    }

    @Override
    public  Exchange reply(RESP response) {
        throw failure();
    }

    @Override
    public Exchange reply(Throwable error) {
        throw failure();
    }

    private RuntimeException failure(){
        return new IllegalStateException( failure );
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy