aboutsummaryrefslogtreecommitdiffstats
path: root/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/editor/Comparables.java
blob: b6fea7ad972619332d37afb92361cc78f4966ff3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

package com.yahoo.vespa.hosted.node.admin.task.util.editor;

/**
 * @author hakon
 */
public class Comparables {
    public static <T extends Comparable<T>> T min(T first, T second) {
        if (first.compareTo(second) < 0) {
            return first;
        } else {
            return second;
        }
    }

    public static <T extends Comparable<T>> T max(T first, T second) {
        if (first.compareTo(second) < 0) {
            return second;
        } else {
            return first;
        }
    }
}