package net.emaze.dysfunctional.order;

import java.util.Comparator;

/**
 *
 * @author rferranti
 */
public enum Order {

    LT(-1), EQ(0), GT(1);
    private int order;

    Order(int order) {
        this.order = order;
    }

    public int order() {
        return order;
    }

    public boolean isLte() {
        return this == LT || this == EQ;
    }

    public boolean isGte() {
        return this == GT || this == EQ;
    }

    public static Order of(int order) {
        return Order.values()[order + 1];
    }

    public static <T> Order of(Comparator<T> comparator, T lhs, T rhs) {
        return Order.values()[comparator.compare(lhs, rhs) + 1];
    }
}

@@ -491,41 +491,30 @@
 urn 
-Order.values()%5Border + 1%5D
+provide(order)
 ;%0A    %7D%0A
 %0A   
@@ -501,33 +501,37 @@
 e(order);%0A    %7D%0A
+    
 %0A
-
     public stati
@@ -606,23 +606,16 @@
 urn 
-Order.values()%5B
+provide(
 comp
@@ -642,14 +642,235 @@
 rhs)
- + 1%5D;
+);%0A    %7D%0A    %0A    private static Order provide(int index) %7B%0A        if(index == 0) %7B%0A            return EQ;%0A        %7D%0A        else if(index %3E 0) %7B%0A            return GT;%0A        %7D%0A        else %7B%0A            return LT;%0A        %7D
 %0A   

comparators may return negative and positive integers