Enum Conjunction

java.lang.Object
java.lang.Enum<Conjunction>
io.github.mmm.base.lang.Conjunction
All Implemented Interfaces:
Serializable, Comparable<Conjunction>, java.lang.constant.Constable

public enum Conjunction extends Enum<Conjunction>
Enum with the common boolean conjunction operators AND, OR, NAND, and NOR.
Since:
1.0.0
  • Enum Constant Details

    • AND

      public static final Conjunction AND
      This conjunction is true if and only if all arguments are true.
    • OR

      public static final Conjunction OR
      This conjunction is true if and only if at least one argument is true.
    • NAND

      public static final Conjunction NAND
      This is the negation of AND. It is only true if at least one argument is false.
    • NOR

      public static final Conjunction NOR
      This is the negation of OR. It is only true if all arguments are false .
    • XOR

      public static final Conjunction XOR
      This conjunction is true if and only if two arguments differ (exactly one of two arguments if true).
    • EQ

      public static final Conjunction EQ
      This conjunction is true if and only if two arguments equal.
  • Method Details

    • values

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

      public static Conjunction valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified name
      NullPointerException - if the argument is null
    • eval

      public abstract boolean eval(boolean arg1, boolean arg2)
      This method evaluates this conjunction for the given boolean arguments.
      Parameters:
      arg1 - the first argument.
      arg2 - the second argument.
      Returns:
      the result of this conjunction applied to the given two arguments.
    • isNegating

      public abstract boolean isNegating()
      Returns:
      true if this Conjunction is negating the final result and therefore not left-associative, false otherwise.
    • eval

      public boolean eval(boolean... arguments)
      Evaluates this Conjunction for the given boolean arguments.
      ATTENTION: The result is NOT the same as a applying the Conjunction left-associative as binary operation because a negation is applied to the final result. Example: NOR(a, b, c) = !(OR(a, b, c)) what is not the same as NOR(NOR(a, b), c).
      Parameters:
      arguments - the boolean values to evaluate.
      Returns:
      the result of this Conjunction applied to the given arguments.
    • evalEmpty

      public abstract boolean evalEmpty()
      Returns:
      the result of eval(boolean...) for no argument (an empty argument array).
    • getSyntax

      public String getSyntax()
      Returns:
      the syntax used for technical representation (e.g. '&&' for AND).
    • getName

      public String getName()
      Returns:
      the name and string representation (e.g. "and" for AND).
    • negate

      public abstract Conjunction negate()
      Returns:
      the negation of this Conjunction that evaluates to the negated result.
    • toString

      public String toString()
      Overrides:
      toString in class Enum<Conjunction>
    • ofSyntax

      public static Conjunction ofSyntax(String syntax)
      Parameters:
      syntax - the syntax of the requested Conjunction.
      Returns:
      the requested Conjunction or null if no such Conjunction exists.
    • ofName

      public static Conjunction ofName(String name)
      Parameters:
      name - is the name of the requested Conjunction.
      Returns:
      the requested Conjunction or null if no such Conjunction exists.