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

com.github.markozajc.ef.runnable.except.ERunnable Maven / Gradle / Ivy

package com.github.markozajc.ef.runnable.except;

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

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

	@Override
	default void run() {
		try {
			runChecked();
		} catch (Throwable e) { // NOSONAR can't catch generic exceptions
			throw asUnchecked(e);
		}
	}

	/**
	 * Same as {@link #run()}, but throws a checked exception.
	 *
	 * @throws E
	 *             the defined exception type
	 */
	void runChecked() throws E;

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy