Java Number Max Value max(T v1, T v2, int nullSupport)

Here you can find the source of max(T v1, T v2, int nullSupport)

Description

max

License

Apache License

Declaration

public static <T extends Comparable<T>> T max(T v1, T v2, int nullSupport) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static final int NULL_IS_MAXIMUM = 0;

    public static <T extends Comparable<T>> T max(T v1, T v2, int nullSupport) {
        if (v1 == v2)
            return v1;
        if (v1 == null) {
            return nullSupport == NULL_IS_MAXIMUM ? v1 : v2;
        }/*from w  w  w . j a v  a2s. c o m*/
        if (v2 == null) {
            return nullSupport == NULL_IS_MAXIMUM ? v2 : v1;
        }
        int v = v1.compareTo(v2);
        return (v < 0) ? v2 : v1;
    }
}

Related

  1. max(T a, T b)
  2. max(T a, T b)
  3. max(T c1, T c2)
  4. max(T c1, T c2)
  5. max(T v1, T v2)
  6. max2(double a, double b)
  7. max2(int a, int b)
  8. max255(float val)
  9. max3(double a, double b, double c)