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

com.github.markozajc.ef.predicate.except.ELongPredicate Maven / Gradle / Ivy

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

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

import com.github.markozajc.ef.predicate.LongPredicate;

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

	@Override
	default boolean test(long p) {
		try {
			return testChecked(p);
		} catch (Throwable e) { // NOSONAR can't catch generic exceptions
			throw asUnchecked(e);
		}
	}

	/**
	 * Same as {@link #test(long)}, but throws a checked exception.
	 *
	 * @param p
	 *            the input argument
	 *
	 * @return {@code true} if the input argument matches the predicate, otherwise
	 *         {@code false}
	 *
	 * @throws E
	 *             the defined exception type
	 */
	boolean testChecked(long p) throws E;

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy