Java Utililty Methods Number Max Value

List of utility methods to do Number Max Value

Description

The list of methods to do Number Max Value are organized into topic(s).

Method

Stringmax(String name)
_more_
return " max(" + validName(name) + ")";
Stringmax(String s)
String promotion - returns either the given string or empty string (if given string is null).
return s == null ? "" : s;
Tmax(T a, T b)
Generalized version of Math.max
if (a.compareTo(b) <= 0)
    return b;
return a;
Tmax(T a, T b)
Compares two objects finding the maximum.
if (a != null && b != null) {
    return a.compareTo(b) >= 0 ? a : b;
if (a == null) {
    if (b == null) {
        return null;
    } else {
        return b;
...
Tmax(T c1, T c2)
Null safe comparison of Comparables.
if (c1 != null && c2 != null) {
    return c1.compareTo(c2) >= 0 ? c1 : c2;
} else {
    return c1 != null ? c1 : c2;
Tmax(T c1, T c2)
Gets maximal value between given two.
if (c1 == c2)
    return c1;
if (c1 == null)
    return c2;
if (c2 == null)
    return c1;
return c1.compareTo(c2) >= 0 ? c1 : c2;
Tmax(T v1, T v2)
max
return v1.compareTo(v2) < 0 ? v2 : v1;
Tmax(T v1, T v2, int nullSupport)
max
if (v1 == v2)
    return v1;
if (v1 == null) {
    return nullSupport == NULL_IS_MAXIMUM ? v1 : v2;
if (v2 == null) {
    return nullSupport == NULL_IS_MAXIMUM ? v2 : v1;
int v = v1.compareTo(v2);
return (v < 0) ? v2 : v1;
doublemax2(double a, double b)
max
return a > b ? a : b;
intmax2(int a, int b)
max
if (a > b)
    return a;
return b;