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

info.solidsoft.mockito.java8.ThrowingConsumer 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.Consumer;

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

@FunctionalInterface
@Incubating
public interface ThrowingConsumer {

    void accept(T t) throws Exception;

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy