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

net.openhft.chronicle.testframework.function.ThrowingConsumer Maven / Gradle / Ivy

There is a newer version: 2.26ea0
Show newest version
package net.openhft.chronicle.testframework.function;

import net.openhft.chronicle.testframework.internal.VanillaThrowingConsumer;

import java.util.function.Consumer;

import static java.util.Objects.requireNonNull;

/**
 * Represents an operation that accepts a single input argument and returns no
 * result and that can throw an Exception. Unlike most other functional interfaces, {@code Consumer} is expected
 * to operate via side-effects.
 *
 * 

This is a functional interface * whose functional method is {@link #accept(Object)}. * * @param the type of the input to the operation */ @FunctionalInterface public interface ThrowingConsumer { /** * Performs this operation on the given argument. * * @param t the input argument * @throws X if an exception occurs */ void accept(T t) throws X; /** * Creates and returns a new Consumer that will wrap any exceptions thrown by the * provided {@code throwingConsumer} in a {@link ThrowingConsumerException} * @param throwingConsumer to wrap (non-null) * @param consumed type * @return a wrapped Consumer */ static Consumer of(final ThrowingConsumer throwingConsumer) { requireNonNull(throwingConsumer); return new VanillaThrowingConsumer<>(throwingConsumer); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy