All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fj.Ordering Maven / Gradle / Ivy

Go to download

Functional Java is an open source library that supports closures for the Java programming language

There is a newer version: 5.0
Show newest version
package fj;

/**
 * The comparison of two instances of a type may have one of three orderings; less than, equal or
 * greater than.
 *
 * @version %build.number%
 */
public enum Ordering {
  /**
   * Less than.
   */
  LT,

  /**
   * Equal.
   */
  EQ,

  /**
   * Greater than.
   */
  GT;

  public int toInt() { return ordinal() - 1 ; }

  public Ordering reverse() {
    switch (this) {
      case LT: return GT;
      case GT: return LT;
    }
    return EQ;
  }

  public static Ordering fromInt(int cmp) {
    return cmp == 0 ? EQ : cmp > 0 ? GT : LT;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy