public static <T extends Comparable<? super T>> Pair<T> getMinMax(T[] data) {
        if (data == null || data.length == 0) {
            return null;
        }
        T min = data[0];
        T max = data[0];
        for (int i = 1; i < data.length; i++) {
            if (min.compareTo(data[i]) > 0) {
                min = data[i];
            }
            if (max.compareTo(data[i]) < 0) {
                max = data[i];
            }
        }
        return new Pair<T>(min, max);
    }