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

com.github.tadukoo.util.functional.predicate.ThrowingPredicate4 Maven / Gradle / Ivy

There is a newer version: 0.6.1-Beta
Show newest version
package com.github.tadukoo.util.functional.predicate;

/**
 * A predicate that takes four arguments, returns a boolean,
 * and may throw a {@link Throwable}.
 *
 * @param  The 1st input argument type for the predicate
 * @param  The 2nd input argument type for the predicate
 * @param  The 3rd input argument type for the predicate
 * @param  The 4th input argument type for the predicate
 * @param  The type of {@link Throwable} thrown by the predicate
 * 
 * @author Logan Ferree (Tadukoo)
 * @version 0.1-Alpha-SNAPSHOT
 */
@FunctionalInterface
public interface ThrowingPredicate4{
	
	/**
	 * Takes four arguments and returns a boolean.
	 * 
	 * @param a The 1st argument
	 * @param b The 2nd argument
	 * @param c The 3rd argument
	 * @param d The 4th argument
	 * @return A boolean
	 * @throws T Determined by the predicate, not required
	 */
	boolean test(A a, B b, C c, D d) throws T;
	
	/**
	 * Creates a ThrowingPredicate4 that will test the arguments with this ThrowingPredicate4
	 * and with the given ThrowingPredicate4, returning true only if both results are true.
	 * 
	 * @param other The other ThrowingPredicate4 to test the arguments on
	 * @return The ThrowingPredicate4 that results from composing this one and the given one
	 */
	default ThrowingPredicate4 and(
			ThrowingPredicate4 other){
		return (a, b, c, d) -> this.test(a, b, c, d) && other.test(a, b, c, d);
	}
	
	/**
	 * Creates a ThrowingPredicate4 that will test the arguments with this ThrowingPredicate4
	 * and with the given ThrowingPredicate4, returning true if either result is true.
	 * 
	 * @param other The other ThrowingPredicate4 to test the arguments on
	 * @return The ThrowingPredicate4 that results from composing this one and the given one
	 */
	default ThrowingPredicate4 or(
			ThrowingPredicate4 other){
		return (a, b, c, d) -> this.test(a, b, c, d) || other.test(a, b, c, d);
	}
	
	/**
	 * Creates a ThrowingPredicate4 that will return the opposite result of this ThrowingPredicate4.
	 * 
	 * @return A negated version of this ThrowingPredicate4
	 */
	default ThrowingPredicate4 negate(){
		return (a, b, c, d) -> !this.test(a, b, c, d);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy