Package groovy.lang

Class ObjectRange

All Implemented Interfaces:
Range<Comparable>, Iterable<Comparable>, Collection<Comparable>, List<Comparable>

public class ObjectRange
extends AbstractList<Comparable>
implements Range<Comparable>
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 Details

    • ObjectRange

      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.
    • ObjectRange

      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 Details