Class ArityRange


  • public final class ArityRange
    extends java.lang.Object
    The ArityRange 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.
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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.
    • Method Detail

      • isWithinRange

        public boolean isWithinRange​(int value)
        Checks whether the specified value falls within the range of allowed values.
        Parameters:
        value - Number of operands.
        Returns:
        true if value is in the range or false otherwise.