Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

enum for GT, GTE, EQ, LT, LTE operators

Tags:

java

Is there a Java enum anywhere in the Java libraries for greater-than, greater-than-or-equal, equal, less-than-or-equal, less-than comparisons?

like image 512
Marcus Junius Brutus Avatar asked Jan 23 '14 19:01

Marcus Junius Brutus


1 Answers

It doesn't appear to be one. Fortunately, it's not too difficult to put one together.

public enum Comparison {
    EQ("="), GTE(">="), GT(">"), LT("<"), LTE("<=");
    
    private final String value;
    
    private Comparison(String text) {
        this.value = text;
    }
    
    public String getValue() {
        return this.value;
    }
}
like image 169
Alan B. Dee Avatar answered Nov 15 '22 01:11

Alan B. Dee