Enum Class Proposition.Operator
- All Implemented Interfaces:
Serializable, Comparable<Proposition.Operator>, Constable
- Enclosing class:
Proposition
An operator defines the behavior of a
proposition.- Author:
- Stephen G. Ware
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionAn operator that is true just when all of its arguments are true (and is true if it has no arguments)An operator that requires at least 1 argument and is true just when all of its arguments are the sameAn operator that requires exactly 1 argument and is true just when its argument is false and false just when its argument is trueAn operator that is true just when one of its arguments is true (and is false if it has no arguments) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Valueevaluate(Expression[] arguments, State state) Evaluates the truth value of a proposition whose operator is this operator and whose arguments are the given arguments in a given state.toString()protected voidvalidate(Expression[] arguments) Checks whether this operator can be applied to the given arguments.static Proposition.OperatorReturns the enum constant of this class with the specified name.static Proposition.Operator[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
EQUALS
An operator that requires at least 1 argument and is true just when all of its arguments are the same -
NOT
An operator that requires exactly 1 argument and is true just when its argument is false and false just when its argument is true -
AND
An operator that is true just when all of its arguments are true (and is true if it has no arguments) -
OR
An operator that is true just when one of its arguments is true (and is false if it has no arguments)
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
toString
- Overrides:
toStringin classEnum<Proposition.Operator>
-
validate
Checks whether this operator can be applied to the given arguments. Some operators require a certain number or type of arguments. This method is used to check whether a proposition is valid according to those rules. This method should throw an exception if this operator cannot be applied to the given arguments.- Parameters:
arguments- the potential arguments this operator may be applied to- Throws:
IllegalArgumentException- if the arguments do not meet the requirements of this operator
-
evaluate
Evaluates the truth value of a proposition whose operator is this operator and whose arguments are the given arguments in a given state.
-