org.mockito.ThrowingConsumer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockito-core Show documentation
Show all versions of mockito-core Show documentation
Mock objects library for java
/*
* Copyright (c) 2023 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito;
import java.util.function.Consumer;
@SuppressWarnings("FunctionalInterfaceMethodChanged")
@FunctionalInterface
public interface ThrowingConsumer extends Consumer {
@Override
default void accept(final T input) {
try {
acceptThrows(input);
} catch (final RuntimeException | AssertionError e) {
throw e;
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
void acceptThrows(T input) throws Throwable;
}