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

com.github.davidmoten.aws.lw.client.internal.ExceptionFactoryExtended Maven / Gradle / Ivy

Go to download

Lightweight client for all AWS services (but still with useful builders and XML parser)

The newest version!
package com.github.davidmoten.aws.lw.client.internal;

import java.util.Optional;
import java.util.function.Function;
import java.util.function.Predicate;

import com.github.davidmoten.aws.lw.client.ExceptionFactory;
import com.github.davidmoten.aws.lw.client.Response;

public class ExceptionFactoryExtended implements ExceptionFactory {

    private final ExceptionFactory factory;
    private final Predicate predicate;
    private final Function function;

    public ExceptionFactoryExtended(ExceptionFactory factory, Predicate predicate, Function function) {
        this.factory = factory;
        this.predicate = predicate;
        this.function = function;
    }

    @Override
    public Optional create(Response response) {
        if (predicate.test(response)) {
            return Optional.of(function.apply(response));
        } else {
            return factory.create(response);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy