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

org.zalando.riptide.faults.ClassificationStrategy Maven / Gradle / Ivy

package org.zalando.riptide.faults;

import java.util.List;
import java.util.function.Predicate;

import static com.google.common.base.Throwables.getCausalChain;
import static com.google.common.base.Throwables.getRootCause;

public interface ClassificationStrategy {

    boolean test(Throwable throwable, Predicate predicate);

    static ClassificationStrategy self() {
        return (throwable, predicate) ->
                predicate.test(throwable);
    }

    static ClassificationStrategy causalChain() {
        return (throwable, predicate) -> {
            @SuppressWarnings("UnstableApiUsage")
            final List chain = getCausalChain(throwable);
            return chain.stream().anyMatch(predicate);
        };
    }

    static ClassificationStrategy rootCause() {
        return (throwable, predicate) ->
                predicate.test(getRootCause(throwable));
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy