Package adams.core

Class Range.SubRange

    • Field Detail

      • m_From

        protected Integer m_From
        the "from" (0-based).
      • m_To

        protected Integer m_To
        the "to" (0-based).
    • Constructor Detail

      • SubRange

        public SubRange​(int from)
        Initializes the sub-range as single number (0-based).
        Parameters:
        from - the single number of the sub-range
      • SubRange

        public SubRange​(int from,
                        Integer to)
        Initializes the sub-range as range between (0-based) numbers.
        Parameters:
        from - the start of the sub-range (incl)
        to - the end of the sub-range (incl)
    • Method Detail

      • getFrom

        public Integer getFrom()
        Returns the "from" part of the sub-range.
        Returns:
        the from
      • hasTo

        public boolean hasTo()
        Returns whether a "to" is available.
        Returns:
        true if a "to" is available
      • getTo

        public Integer getTo()
        Returns the "to" of the sub-range.
        Returns:
        the "to", null if not set
      • isInRange

        public boolean isInRange​(int index)
        Checks whether the given index is within the limits of the sub-range.
        Parameters:
        index - the (0-based) index to check
        Returns:
        true if within range
      • compareTo

        public int compareTo​(Range.SubRange o)
        Compares this subrange with the specified subrange for order. Returns a negative integer, zero, or a positive integer as this subrange is less than, equal to, or greater than the specified subrange. Uses the "from" as point of comparison and if those are equal, then the "to" (if available).
        Specified by:
        compareTo in interface Comparable<Range.SubRange>
        Parameters:
        o - the subrange to be compared.
        Returns:
        a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
      • equals

        public boolean equals​(Object obj)
        Indicates whether some other object is "equal to" this one.
        Overrides:
        equals in class Object
        Parameters:
        obj - the reference object with which to compare.
        Returns:
        true if this object is the same as the obj argument; false otherwise.
      • toString

        public String toString()
        Returns a string representation of the sub-range.
        Overrides:
        toString in class Object
        Returns:
        the representation