Enum Class Relation

java.lang.Object
java.lang.Enum<Relation>
org.skriptlang.skript.lang.comparator.Relation
All Implemented Interfaces:
Serializable, Comparable<Relation>, Constable

public enum Relation extends Enum<Relation>
Represents a relation between two objects.
  • Enum Constant Details

    • EQUAL

      public static final Relation EQUAL
    • NOT_EQUAL

      public static final Relation NOT_EQUAL
    • GREATER

      public static final Relation GREATER
    • GREATER_OR_EQUAL

      public static final Relation GREATER_OR_EQUAL
    • SMALLER

      public static final Relation SMALLER
    • SMALLER_OR_EQUAL

      public static final Relation SMALLER_OR_EQUAL
  • Method Details

    • values

      public static Relation[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Relation valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • get

      public static Relation get(boolean b)
      Parameters:
      b - The boolean to get a Relation from.
      Returns:
      EQUAL if 'b' is true else NOT_EQUAL
    • get

      public static Relation get(int i)
      Parameters:
      i - The int to get a Relation from.
      Returns:
      EQUAL if 'i' is equal to 0, GREATER if 'i' is greater than 0, SMALLER if 'i' is less than 0
    • get

      public static Relation get(double d)
      Parameters:
      d - The double to get a Relation from.
      Returns:
      EQUAL if 'd' is equal to 0, GREATER if 'd' is greater than 0, SMALLER if 'd' is less than 0
    • isImpliedBy

      public boolean isImpliedBy(Relation other)
      Test whether this Relation is fulfilled if another is, i.e. if the parameter 'other' fulfils X rel Y, then this Relation fulfils X rel Y as well.
      Parameters:
      other - The Relation to compare with.
      Returns:
      Whether this Relation is part of the given Relation, e.g. GREATER_OR_EQUAL.isImpliedBy(EQUAL) returns true.
    • isImpliedBy

      public boolean isImpliedBy(Relation... others)
      Parameters:
      others - The Relations to compare with.
      Returns:
      True if isImpliedBy(Relation) is true for any of the provided Relations.
    • toString

      public String toString()
      Returns this Relation's string representation, which is similar to "equal to" or "greater than".
      Overrides:
      toString in class Enum<Relation>
    • getInverse

      public Relation getInverse()
      Returns:
      The inverse of this Relation, i.e if this Relation fulfils X rel Y, then the returned Relation fulfils !(X rel Y).
    • getSwitched

      public Relation getSwitched()
      Returns:
      The Relation which has switched arguments, i.e. if this Relation fulfils X rel Y, then the returned Relation fulfils Y rel X.
    • getRelation

      public int getRelation()
      Returns:
      An int relating to the value of this Relation.
      0 if EQUAL or NOT_EQUAL
      1 if GREATER or GREATER_OR_EQUAL
      -1 if SMALLER or SMALLER_OR_EQUAL