EmptyRange (Groovy 2.4.3)
Date: 2015-03-23

groovy.lang

## Class EmptyRange

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

- All Implemented Interfaces:
    Range, Iterable, Collection, List

      public class EmptyRange
      extends AbstractList
      implements Range

  Constructing Ranges like 0..<0
  Author:
    Dierk Koenig, Edwin Tellman

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Comparable` | `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(Comparable at)` Creates a new `EmptyRange`.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `add(Object o)` Always throws `UnsupportedOperationException` for an empty range.
    `boolean` | `addAll(Collection c)` Always throws `UnsupportedOperationException` for an empty range.
    `boolean` | `addAll(int index, Collection c)` Always throws `UnsupportedOperationException` for an empty range.
    `boolean` | `containsWithinBounds(Object o)` Never true for an empty range.
    `Object` | `get(int index)` Always throws `IndexOutOfBoundsException` for an empty range.
    `Comparable` | `getFrom()` The lower value in the range.
    `Comparable` | `getTo()` The upper value in the range.
    `String` | `inspect()`
    `boolean` | `isReverse()` Never true for an empty range.
    `Object` | `remove(int index)` Always throws `UnsupportedOperationException` for an empty range.
    `boolean` | `remove(Object o)` Always throws `UnsupportedOperationException` for an empty range.
    `boolean` | `removeAll(Collection c)` Always throws `UnsupportedOperationException` for an empty range.
    `boolean` | `retainAll(Collection c)` Always throws `UnsupportedOperationException` for an empty range.
    `Object` | `set(int index, Object element)` Always throws `UnsupportedOperationException` for an empty range.
    `int` | `size()` Always 0 for an empty range.
    `List` | `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.
    `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, subList, toArray, toArray`

- - ### Field Detail

    - #### at

          protected Comparable at

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

  - ### Constructor Detail

    - #### EmptyRange

          public EmptyRange(Comparable at)

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

  - ### Method Detail

    - #### getFrom

          public Comparable getFrom()

      The lower value in the range.
      Specified by:
        `getFrom` in interface `Range`
      Returns:
        the lower value in the range.

    - #### getTo

          public Comparable getTo()

      The upper value in the range.
      Specified by:
        `getTo` in interface `Range`
      Returns:
        the upper value in the range

    - #### isReverse

          public boolean isReverse()

      Never true for an empty range.
      Specified by:
        `isReverse` in interface `Range`
      Returns:
        `false`

    - #### containsWithinBounds

          public boolean containsWithinBounds(Object o)

      Never true for an empty range.
      Specified by:
        `containsWithinBounds` in interface `Range`
      Parameters:
        `o` - the object to check against the boundaries of the range
      Returns:
        `false`

    - #### inspect

          public String inspect()

      Specified by:
        `inspect` in interface `Range`
      Returns:
        the verbose `String` representation of this `Range` as would be typed into a console to create the `Range` instance

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `AbstractCollection`

    - #### size

          public int size()

      Always 0 for an empty range.
      Specified by:
        `size` in interface `Collection`
      Specified by:
        `size` in interface `List`
      Specified by:
        `size` in class `AbstractCollection`
      Returns:
        0

    - #### get

          public Object get(int index)

      Always throws `IndexOutOfBoundsException` for an empty range.
      Specified by:
        `get` in interface `List`
      Specified by:
        `get` in class `AbstractList`
      Throws:
        `IndexOutOfBoundsException` - always

    - #### add

          public boolean add(Object o)

      Always throws `UnsupportedOperationException` for an empty range.
      Specified by:
        `add` in interface `Collection`
      Specified by:
        `add` in interface `List`
      Overrides:
        `add` in class `AbstractList`
      Throws:
        `UnsupportedOperationException` - always

    - #### addAll

          public boolean addAll(int index,
                       Collection c)

      Always throws `UnsupportedOperationException` for an empty range.
      Specified by:
        `addAll` in interface `List`
      Overrides:
        `addAll` in class `AbstractList`
      Throws:
        `UnsupportedOperationException`

    - #### addAll

          public boolean addAll(Collection c)

      Always throws `UnsupportedOperationException` for an empty range.
      Specified by:
        `addAll` in interface `Collection`
      Specified by:
        `addAll` in interface `List`
      Overrides:
        `addAll` in class `AbstractCollection`
      Throws:
        `UnsupportedOperationException`

    - #### remove

          public boolean remove(Object o)

      Always throws `UnsupportedOperationException` for an empty range.
      Specified by:
        `remove` in interface `Collection`
      Specified by:
        `remove` in interface `List`
      Overrides:
        `remove` in class `AbstractCollection`
      Throws:
        `UnsupportedOperationException`

    - #### remove

          public Object remove(int index)

      Always throws `UnsupportedOperationException` for an empty range.
      Specified by:
        `remove` in interface `List`
      Overrides:
        `remove` in class `AbstractList`
      Throws:
        `UnsupportedOperationException`

    - #### removeAll

          public boolean removeAll(Collection c)

      Always throws `UnsupportedOperationException` for an empty range.
      Specified by:
        `removeAll` in interface `Collection`
      Specified by:
        `removeAll` in interface `List`
      Overrides:
        `removeAll` in class `AbstractCollection`
      Throws:
        `UnsupportedOperationException`

    - #### retainAll

          public boolean retainAll(Collection c)

      Always throws `UnsupportedOperationException` for an empty range.
      Specified by:
        `retainAll` in interface `Collection`
      Specified by:
        `retainAll` in interface `List`
      Overrides:
        `retainAll` in class `AbstractCollection`
      Throws:
        `UnsupportedOperationException`

    - #### set

          public Object set(int index,
                   Object element)

      Always throws `UnsupportedOperationException` for an empty range.
      Specified by:
        `set` in interface `List`
      Overrides:
        `set` in class `AbstractList`
      Throws:
        `UnsupportedOperationException`

    - #### step

          public void step(int step,
                  Closure closure)

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

    - #### step

          public List step(int step)

      Always returns an empty list for an empty range.
      Specified by:
        `step` in interface `Range`
      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.