Class IntInterval


  • public final class IntInterval
    extends Object
    Integer interval. Hold a couple of integer values A and B, where A <= B.

    Both bounds are inclusive.

    Value object.

    Author:
    Leonid Bushuev
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int a
      The left bound of the interval.
      int b
      The right bound of the interval.
    • Constructor Summary

      Constructors 
      Constructor Description
      IntInterval​(int ab)
      Constructs a zero-length interval, where both bounds are same.
      IntInterval​(int a, int b)
      Constructs an interval.
    • Field Detail

      • a

        public final int a
        The left bound of the interval.
      • b

        public final int b
        The right bound of the interval.
    • Constructor Detail

      • IntInterval

        public IntInterval​(int a,
                           int b)
        Constructs an interval.
        Parameters:
        a - the left bound.
        b - the right bound.
      • IntInterval

        public IntInterval​(int ab)
        Constructs a zero-length interval, where both bounds are same.
        Parameters:
        ab - the value for both a and b.
    • Method Detail

      • contains

        public boolean contains​(int x)
        Checks whether the given value is in the interval (both interval bounds are inclusive).
        Parameters:
        x - value to check.
        Returns:
        true if the given value is in the interval.
      • getA

        public int getA()
        Getter for a to allow using it in JSP.
        Returns:
        the left bound of the interval.
      • getB

        public int getB()
        Getter for b to allow using it in JSP.
        Returns:
        the right bound of the interval.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object