Package ru.ispras.fortress.calculator
Class ArityRange
- java.lang.Object
-
- ru.ispras.fortress.calculator.ArityRange
-
public final class ArityRange extends java.lang.Object
TheArityRange
class is used to specify a possible arity of an operator (unary, binary, etc.). It is possible for an operator to be unary and binary at the same time or to have an unlimited number of operands. The Range class allows specifying a range for the allowed number of operands.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ArityRange.Bound
The Bound enumeration contains constants for specifying most common bounds for the range of allowed operand numbers.
-
Field Summary
Fields Modifier and Type Field Description static ArityRange
BINARY
Binary operator range.static ArityRange
BINARY_UNBOUNDED
Range for operators that can have two (binary) or an unbounded number of operands.static ArityRange
TERNARY
Ternary operator range.static ArityRange
UNARY
Unary operator range.static ArityRange
UNARY_BINARY
Range for operators that can be unary and binary at the same time.static ArityRange
UNARY_UNBOUNDED
Range for operators that can have one (unary) or an unbounded number of operands.
-
Constructor Summary
Constructors Constructor Description ArityRange(int min, int max)
Creates a range basing on the specified boundary values.ArityRange(ArityRange.Bound min, ArityRange.Bound max)
Creates a range basing on the specified bounds.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isWithinRange(int value)
Checks whether the specified value falls within the range of allowed values.
-
-
-
Field Detail
-
UNARY
public static final ArityRange UNARY
Unary operator range.
-
BINARY
public static final ArityRange BINARY
Binary operator range.
-
TERNARY
public static final ArityRange TERNARY
Ternary operator range.
-
UNARY_BINARY
public static final ArityRange UNARY_BINARY
Range for operators that can be unary and binary at the same time.
-
UNARY_UNBOUNDED
public static final ArityRange UNARY_UNBOUNDED
Range for operators that can have one (unary) or an unbounded number of operands.
-
BINARY_UNBOUNDED
public static final ArityRange BINARY_UNBOUNDED
Range for operators that can have two (binary) or an unbounded number of operands.
-
-
Constructor Detail
-
ArityRange
public ArityRange(ArityRange.Bound min, ArityRange.Bound max)
Creates a range basing on the specified bounds.- Parameters:
min
- Lower bound.max
- Upper bound.
-
ArityRange
public ArityRange(int min, int max)
Creates a range basing on the specified boundary values.- Parameters:
min
- Lower boundary value.max
- Upper boundary value.- Throws:
java.lang.IllegalArgumentException
- if the range is specified incorrectly.
-
-