groovy.lang

## Class EmptyRange<T extends java.lang.Comparable>

- java.lang.Object
- - java.util.AbstractCollection<E>
  - - java.util.AbstractList<T>
    - - groovy.lang.EmptyRange<T>

- All Implemented Interfaces:
    Range<T>, java.lang.Iterable<T>, java.util.Collection<T>, java.util.List<T>

      public class EmptyRange<T extends java.lang.Comparable>
      extends java.util.AbstractList<T>
      implements Range<T>

  Constructing Ranges like 0..<0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected T` | `at` The value at which the range originates (may be `null`).

    - ### Fields inherited from class java.util.AbstractList

      `modCount`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `EmptyRange(T at)` Creates a new `EmptyRange`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `add(T o)` Always throws `UnsupportedOperationException` for an empty range.
    `boolean` | `addAll(java.util.Collection<? extends T> c)` Always throws `UnsupportedOperationException` for an empty range.
    `boolean` | `addAll(int index, java.util.Collection<? extends T> c)` Always throws `UnsupportedOperationException` for an empty range.
    `boolean` | `containsWithinBounds(java.lang.Object o)` Never true for an empty range.
    `T` | `get(int index)` Always throws `IndexOutOfBoundsException` for an empty range.
    `T` | `getFrom()` The lower value in the range.
    `T` | `getTo()` The upper value in the range.
    `java.lang.String` | `inspect()`
    `boolean` | `isReverse()` Never true for an empty range.
    `T` | `remove(int index)` Always throws `UnsupportedOperationException` for an empty range.
    `boolean` | `remove(java.lang.Object o)` Always throws `UnsupportedOperationException` for an empty range.
    `boolean` | `removeAll(java.util.Collection<?> c)` Always throws `UnsupportedOperationException` for an empty range.
    `boolean` | `retainAll(java.util.Collection<?> c)` Always throws `UnsupportedOperationException` for an empty range.
    `T` | `set(int index, T element)` Always throws `UnsupportedOperationException` for an empty range.
    `int` | `size()` Always 0 for an empty range.
    `java.util.List<T>` | `step(int step)` Always returns an empty list for an empty range.
    `void` | `step(int step, Closure closure)` Always does nothing for an empty range.
    `java.lang.String` | `toString()`

    - ### Methods inherited from class java.util.AbstractList

      `add, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList`

    - ### Methods inherited from class java.util.AbstractCollection

      `contains, containsAll, isEmpty, toArray, toArray`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.List

      `add, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, replaceAll, sort, spliterator, subList, toArray, toArray`

    - ### Methods inherited from interface java.util.Collection

      `parallelStream, removeIf, stream`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach`

- - ### Field Detail

    - #### at

          protected T extends java.lang.Comparable at

      The value at which the range originates (may be `null`).

  - ### Constructor Detail

    - #### EmptyRange

          public EmptyRange(T at)

      Creates a new `EmptyRange`.
      Parameters:
        `at` - the value at which the range starts (may be `null`).

  - ### Method Detail

    - #### getFrom

          public T getFrom()

      The lower value in the range.
      Specified by:
        `getFrom` in interface `Range<T extends java.lang.Comparable>`
      Returns:
        the lower value in the range.

    - #### getTo

          public T getTo()

      The upper value in the range.
      Specified by:
        `getTo` in interface `Range<T extends java.lang.Comparable>`
      Returns:
        the upper value in the range

    - #### isReverse

          public boolean isReverse()

      Never true for an empty range.
      Specified by:
        `isReverse` in interface `Range<T extends java.lang.Comparable>`
      Returns:
        `false`

    - #### containsWithinBounds

          public boolean containsWithinBounds(java.lang.Object o)

      Never true for an empty range.
      Specified by:
        `containsWithinBounds` in interface `Range<T extends java.lang.Comparable>`
      Parameters:
        `o` - the object to check against the boundaries of the range
      Returns:
        `false`

    - #### inspect

          public java.lang.String inspect()

      Specified by:
        `inspect` in interface `Range<T extends java.lang.Comparable>`
      Returns:
        the verbose `String` representation of this `Range` as would be typed into a console to create the `Range` instance

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.util.AbstractCollection<T extends java.lang.Comparable>`

    - #### size

          public int size()

      Always 0 for an empty range.
      Specified by:
        `size` in interface `java.util.Collection<T extends java.lang.Comparable>`
      Specified by:
        `size` in interface `java.util.List<T extends java.lang.Comparable>`
      Specified by:
        `size` in class `java.util.AbstractCollection<T extends java.lang.Comparable>`
      Returns:
        0

    - #### get

          public T get(int index)

      Always throws `IndexOutOfBoundsException` for an empty range.
      Specified by:
        `get` in interface `java.util.List<T extends java.lang.Comparable>`
      Specified by:
        `get` in class `java.util.AbstractList<T extends java.lang.Comparable>`
      Throws:
        `java.lang.IndexOutOfBoundsException` - always

    - #### add

          public boolean add(T o)

      Always throws `UnsupportedOperationException` for an empty range.
      Specified by:
        `add` in interface `java.util.Collection<T extends java.lang.Comparable>`
      Specified by:
        `add` in interface `java.util.List<T extends java.lang.Comparable>`
      Overrides:
        `add` in class `java.util.AbstractList<T extends java.lang.Comparable>`
      Throws:
        `java.lang.UnsupportedOperationException` - always

    - #### addAll

          public boolean addAll(int index,
                                java.util.Collection<? extends T> c)

      Always throws `UnsupportedOperationException` for an empty range.
      Specified by:
        `addAll` in interface `java.util.List<T extends java.lang.Comparable>`
      Overrides:
        `addAll` in class `java.util.AbstractList<T extends java.lang.Comparable>`
      Throws:
        `java.lang.UnsupportedOperationException`

    - #### addAll

          public boolean addAll(java.util.Collection<? extends T> c)

      Always throws `UnsupportedOperationException` for an empty range.
      Specified by:
        `addAll` in interface `java.util.Collection<T extends java.lang.Comparable>`
      Specified by:
        `addAll` in interface `java.util.List<T extends java.lang.Comparable>`
      Overrides:
        `addAll` in class `java.util.AbstractCollection<T extends java.lang.Comparable>`
      Throws:
        `java.lang.UnsupportedOperationException`

    - #### remove

          public boolean remove(java.lang.Object o)

      Always throws `UnsupportedOperationException` for an empty range.
      Specified by:
        `remove` in interface `java.util.Collection<T extends java.lang.Comparable>`
      Specified by:
        `remove` in interface `java.util.List<T extends java.lang.Comparable>`
      Overrides:
        `remove` in class `java.util.AbstractCollection<T extends java.lang.Comparable>`
      Throws:
        `java.lang.UnsupportedOperationException`

    - #### remove

          public T remove(int index)

      Always throws `UnsupportedOperationException` for an empty range.
      Specified by:
        `remove` in interface `java.util.List<T extends java.lang.Comparable>`
      Overrides:
        `remove` in class `java.util.AbstractList<T extends java.lang.Comparable>`
      Throws:
        `java.lang.UnsupportedOperationException`

    - #### removeAll

          public boolean removeAll(java.util.Collection<?> c)

      Always throws `UnsupportedOperationException` for an empty range.
      Specified by:
        `removeAll` in interface `java.util.Collection<T extends java.lang.Comparable>`
      Specified by:
        `removeAll` in interface `java.util.List<T extends java.lang.Comparable>`
      Overrides:
        `removeAll` in class `java.util.AbstractCollection<T extends java.lang.Comparable>`
      Throws:
        `java.lang.UnsupportedOperationException`

    - #### retainAll

          public boolean retainAll(java.util.Collection<?> c)

      Always throws `UnsupportedOperationException` for an empty range.
      Specified by:
        `retainAll` in interface `java.util.Collection<T extends java.lang.Comparable>`
      Specified by:
        `retainAll` in interface `java.util.List<T extends java.lang.Comparable>`
      Overrides:
        `retainAll` in class `java.util.AbstractCollection<T extends java.lang.Comparable>`
      Throws:
        `java.lang.UnsupportedOperationException`

    - #### set

          public T set(int index,
                       T element)

      Always throws `UnsupportedOperationException` for an empty range.
      Specified by:
        `set` in interface `java.util.List<T extends java.lang.Comparable>`
      Overrides:
        `set` in class `java.util.AbstractList<T extends java.lang.Comparable>`
      Throws:
        `java.lang.UnsupportedOperationException`

    - #### step

          public void step(int step,
                           Closure closure)

      Always does nothing for an empty range.
      Specified by:
        `step` in interface `Range<T extends java.lang.Comparable>`
      Parameters:
        `step` - the amount by which to step. If negative, steps through the range backwards.
        `closure` - the `Closure` to call

    - #### step

          public java.util.List<T> step(int step)

      Always returns an empty list for an empty range.
      Specified by:
        `step` in interface `Range<T extends java.lang.Comparable>`
      Parameters:
        `step` - the amount by which to step. If negative, steps through the range backwards.
      Returns:
        the list formed by stepping through the range by the indicated interval.