Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save spmallette/b78226680f108dd714f983c34069bcd2 to your computer and use it in GitHub Desktop.
Save spmallette/b78226680f108dd714f983c34069bcd2 to your computer and use it in GitHub Desktop.
public static Number min(final Number a, final Number b) {
return isNonValue(a) ? b :
isNonValue(b) ? a :
getHelper(getHighestCommonNumberClass(a, b)).min.apply(a, b);
}
public static Comparable min(final Comparable a, final Comparable b) {
if (a instanceof Number && b instanceof Number) {
return min((Number) a, (Number) b);
}
return isNonValue(a) ? b :
isNonValue(b) ? a :
a.compareTo(b) < 0 ? a : b;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment