Class AbstractInterval<E extends Comparable<E>,ME extends AbstractInterval<E,ME>>

java.lang.Object
gw.lang.reflect.interval.AbstractInterval<E,ME>
All Implemented Interfaces:
IInterval<E,ME>
Direct Known Subclasses:
ComparableInterval, IterableInterval

public abstract class AbstractInterval<E extends Comparable<E>,ME extends AbstractInterval<E,ME>> extends Object implements IInterval<E,ME>
  • Field Details

    • _left

      private final E extends Comparable<E> _left
    • _right

      private final E extends Comparable<E> _right
    • _bLeftClosed

      private final boolean _bLeftClosed
    • _bRightClosed

      private final boolean _bRightClosed
    • _bReverse

      private final boolean _bReverse
  • Constructor Details

    • AbstractInterval

      public AbstractInterval(E left, E right)
    • AbstractInterval

      public AbstractInterval(E left, E right, boolean bLeftClosed, boolean bRightClosed, boolean bReverse)
  • Method Details

    • checkArgs

      private void checkArgs(E left, E right)
    • getLeftEndpoint

      public E getLeftEndpoint()
      Specified by:
      getLeftEndpoint in interface IInterval<E extends Comparable<E>,ME extends AbstractInterval<E,ME>>
      Returns:
      The left endpoint of this interval where the left <= right
    • getRightEndpoint

      public E getRightEndpoint()
      Specified by:
      getRightEndpoint in interface IInterval<E extends Comparable<E>,ME extends AbstractInterval<E,ME>>
      Returns:
      The right endpoint of this interval where the left <= right
    • isLeftClosed

      public boolean isLeftClosed()
      Specified by:
      isLeftClosed in interface IInterval<E extends Comparable<E>,ME extends AbstractInterval<E,ME>>
      Returns:
      True if this interval includes the left endpoint. E.g., x >= foo indicates a left-closed interval starting with and including foo. Conversely, x > foo is said to be left-open because the interface starts with, but excludes foo i.e., there is no minimum value defined in the interval, rather the interval is open with foo as the limit of minimum values.
    • isRightClosed

      public boolean isRightClosed()
      Specified by:
      isRightClosed in interface IInterval<E extends Comparable<E>,ME extends AbstractInterval<E,ME>>
      Returns:
      True if this interval includes the right endpoint. E.g., x <= foo indicates a right-closed interval ending with and including foo. Conversely, x < foo is said to be right-open because the interface ends with, but excludes foo i.e., there is no maximum value defined in the interval, rather the interval is open with foo as the limit of maximum values.
    • contains

      public boolean contains(E e)
      Specified by:
      contains in interface IInterval<E extends Comparable<E>,ME extends AbstractInterval<E,ME>>
      Parameters:
      e - An element to test
      Returns:
      True if elem is a proper element in the set of elements defining this interval.
    • contains

      public boolean contains(ME interval)
      Specified by:
      contains in interface IInterval<E extends Comparable<E>,ME extends AbstractInterval<E,ME>>
      Parameters:
      interval - An interval to test for containment
      Returns:
      True if interval's endpoints are proper elements in the set of elements defining this interval.
    • isReverse

      public boolean isReverse()
      Specified by:
      isReverse in interface IInterval<E extends Comparable<E>,ME extends AbstractInterval<E,ME>>
      Returns:
      True if this interval iterates from the right by default e.g., if the interval is specified in reverse order: 10..1, Gosu will create a reverse intervall
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object