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

info.solidsoft.mockito.java8.ThrowingPredicate Maven / Gradle / Ivy

Go to download

Mockito add-ons leveraging Java 8 and lambda expressions to make mocking even more compact

The newest version!
/*
 * Copyright (C) 2018 Mockito contributors.
 *
 * Licensed under the Apache License, Version 2.0.
 */
package info.solidsoft.mockito.java8;

import org.mockito.Incubating;

import java.util.function.Predicate;

import static info.solidsoft.mockito.java8.SneakyThrow.sneakyRethrow;

@FunctionalInterface
@Incubating
public interface ThrowingPredicate {

    boolean test(T t) throws Exception;

    default Predicate uncheck() {
        return t -> {
            try {
                return this.test(t);
            } catch (Exception e) {
                return sneakyRethrow(e);
            }
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy