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

com.machinezoo.noexception.throwing.ThrowingComparator Maven / Gradle / Ivy

Go to download

Makes exception handling concise and beautiful, yet architecturally clean and flexible.

There is a newer version: 1.9.1
Show newest version
// Part of NoException: https://noexception.machinezoo.com
package com.machinezoo.noexception.throwing;

import com.machinezoo.noexception.*;

/**
 * Variation of {@link Comparator} that allows throwing checked exceptions.
 * {@code ThrowingComparator} is usually implemented by a lambda
 * and passed to {@link CheckedExceptionHandler#comparator(ThrowingComparator)}.
 * See noexception tutorial.
 * 
 * @param 
 *            see {@link Comparator}
 * @see CheckedExceptionHandler#comparator(ThrowingComparator)
 * @see Comparator
 */
@FunctionalInterface public interface ThrowingComparator {
	/**
	 * Variation of {@link Comparator#compare(Object, Object)} that allows throwing checked exceptions.
	 * 
	 * @param left
	 *            see {@link Comparator#compare(Object, Object)}
	 * @param right
	 *            see {@link Comparator#compare(Object, Object)}
	 * @return see {@link Comparator#compare(Object, Object)}
	 * @throws Exception
	 *             if unable to complete
	 * @see CheckedExceptionHandler#comparator(ThrowingComparator)
	 * @see Comparator#compare(Object, Object)
	 */
	int compare(T left, T right) throws Exception;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy