com.github.andyshao.lang.ComparableOperation 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.lang;
import java.util.Comparator;
/**
*
*
* Title:
* Descript:
* Copyright: Copryright(c) Apr 11, 2019
* Encoding: UNIX UTF-8
*
* @author Andy.Shao
*
*/
public final class ComparableOperation {
private ComparableOperation() {}
/**
* Reverse {@link java.util.Comparator}
* @param comparaRet compare result
* @return reverse result
*/
public static final int reversed(int comparaRet) {
if(comparaRet < 0) return 1;
else if(comparaRet > 0) return -1;
else return 0;
}
/**
* Reveese {@link Comparator}
* @param origin origin {@link Comparator}
* @return reverse {@link Comparator}
* @param data type
*/
public static final Comparator reverse(Comparator origin) {
return (o1, o2) -> reversed(origin.compare(o1, o2));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy