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

com.github.markozajc.ef.consumer.execpt.EBooleanConsumer Maven / Gradle / Ivy

package com.github.markozajc.ef.consumer.execpt;

import static com.github.markozajc.ef.Utilities.asUnchecked;

import com.github.markozajc.ef.consumer.BooleanConsumer;

/**
 * Variant of {@link BooleanConsumer} capable of throwing a generic
 * {@link Throwable}.
 *
 * @author Marko Zajc
 *
 * @param 
 *            {@link Throwable} type
 */
@FunctionalInterface
public interface EBooleanConsumer extends BooleanConsumer {

	@Override
	default void accept(boolean p) {
		try {
			acceptChecked(p);
		} catch (Throwable e) { // NOSONAR can't catch generic exceptions
			throw asUnchecked(e);
		}
	}

	/**
	 * Same as {@link #accept(boolean)}, but throws a checked exception.
	 *
	 * @param p
	 *            the input argument
	 *
	 * @throws E
	 *             the defined exception type
	 */
	void acceptChecked(boolean p) throws E;

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy