Package: groovy.lang

## [Java] Class ObjectRange

- groovy.lang.ObjectRange

- All Implemented Interfaces and Traits:
    Range

      public class ObjectRange
      extends AbstractList

  Represents an inclusive list of objects from a value to a value using comparators.

  Note: This class is similar to IntRange. If you make any changes to this class, you might consider making parallel changes to IntRange.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `ObjectRange (Comparable from, Comparable to)` Creates a new ObjectRange.
    `ObjectRange (Comparable smaller, Comparable larger, boolean reverse)` Creates a new ObjectRange assumes smaller <= larger, else behavior is undefined.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected void` | `checkBoundaryCompatibility()` throws IllegalArgumentException if to and from are incompatible, meaning they e.g.
    `` | `protected int` | `compareTo(Comparable first, Comparable second)`
    `` | `boolean` | `contains(Object value)` Iterates over all values and returns true if one value matches.
    `` | `boolean` | `containsWithinBounds(Object value)` Checks whether a value is between the from and to values of a Range
    `` | `protected Object` | `decrement(Object value)` Decrements by one
    `` | `boolean` | `equals(Object that)`
    `` | `boolean` | `equals(ObjectRange that)` Compares an ObjectRange to another ObjectRange.
    `` | `Comparable` | `get(int index)`
    `` | `Comparable` | `getFrom()`
    `` | `Comparable` | `getTo()`
    `` | `protected Object` | `increment(Object value)` Increments by one
    `` | `String` | `inspect()`
    `` | `boolean` | `isReverse()`
    `` | `Iterator<Comparable>` | `iterator()` {@inheritDoc}
    `` | `int` | `size()`
    `` | `void` | `step(int step, Closure closure)`
    `` | `List<Comparable>` | `step(int step)`
    `` | `List<Comparable>` | `subList(int fromIndex, int toIndex)`
    `` | `String` | `toString()`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class AbstractList` | `add, add, remove, get, equals, hashCode, indexOf, clear, lastIndexOf, subList, iterator, addAll, set, listIterator, listIterator, remove, toString, isEmpty, contains, size, toArray, toArray, addAll, containsAll, retainAll, removeAll, wait, wait, wait, getClass, notify, notifyAll, toArray, spliterator, stream, removeIf, parallelStream, forEach, replaceAll, sort`

- - ### Constructor Detail

    - #### public ObjectRange(Comparable from, Comparable to)

      Creates a new ObjectRange. Creates a reversed range if `from` < `to`.

      Parameters:
        `from` - the first value in the range.
        `to` - the last value in the range.

    - #### public ObjectRange(Comparable smaller, Comparable larger, boolean reverse)

      Creates a new ObjectRange assumes smaller <= larger, else behavior is undefined. Caution: Prefer the other constructor when in doubt.

      Optimized Constructor avoiding initial computation of comparison.

  - ### Method Detail

    - #### protected void checkBoundaryCompatibility()

      throws IllegalArgumentException if to and from are incompatible, meaning they e.g. (likely) produce infinite sequences. Called at construction time, subclasses may override cautiously (using only members to and from).

    - #### protected int compareTo(Comparable first, Comparable second)

    - #### @Override public boolean contains(Object value)

      Iterates over all values and returns true if one value matches.

      See Also:
        containsWithinBounds(Object)

    - #### @Override public boolean containsWithinBounds(Object value)

      Checks whether a value is between the from and to values of a Range

      Parameters:
        `value` - the value of interest
      Returns:
        true if the value is within the bounds

    - #### protected Object decrement(Object value)

      Decrements by one

      Parameters:
        `value` - the value to decrement
      Returns:
        the decremented value

    - #### public boolean equals(Object that)

    - #### public boolean equals(ObjectRange that)

      Compares an ObjectRange to another ObjectRange.

      Parameters:
        `that` - the object to check equality with
      Returns:
        `true` if the ranges are equal

    - #### @Override public Comparable get(int index)

    - #### @Override public Comparable getFrom()

    - #### @Override public Comparable getTo()

    - #### protected Object increment(Object value)

      Increments by one

      Parameters:
        `value` - the value to increment
      Returns:
        the incremented value

    - #### @Override public String inspect()

    - #### @Override public boolean isReverse()

    - #### @Override public Iterator<Comparable> iterator()

      {@inheritDoc}

    - #### @Override public int size()

    - #### @Override public void step(int step, Closure closure)

    - #### @Override public List<Comparable> step(int step)

    - #### @Override public List<Comparable> subList(int fromIndex, int toIndex)

    - #### public String toString()