com.github.andyshao.util.ThrowableComparator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Gear Show documentation
Show all versions of Gear Show documentation
Enhance and formating the coding of JDK
The newest version!
package com.github.andyshao.util;
import com.github.andyshao.lang.Convert;
import com.github.andyshao.util.stream.ThrowableException;
import java.util.Comparator;
/**
*
* Title:
* Descript:
* Copyright: Copryright(c) Jun 13, 2019
* Encoding: UNIX UTF-8
*
* @author Andy.Shao
*
* @param the type of objects that may be compared by this comparator
* @see ExceptionableComparator
* @see Comparator
* @deprecated repeated
*/
@Deprecated(since = "5.0.0.RELEASE")
public interface ThrowableComparator {
/**
* compare
* @param o1 one
* @param o2 two
* @return compare result
* @throws Throwable any error
*/
int compare(T o1, T o2) throws Throwable;
/**
* to {@link ExceptionableComparator}
* @return {@link ExceptionableComparator}
* @param data type
*/
static Convert, ExceptionableComparator> toExceptionableComparator() {
return input -> {
return (o1, o2) -> {
try {
return input.compare(o1, o2);
} catch (Throwable e) {
throw ThrowableException.convertToException(e);
}
};
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy