Class DiscreteDomain.IntegerDomain

java.lang.Object
com.google.common.collect.DiscreteDomain<Integer>
com.google.common.collect.DiscreteDomain.IntegerDomain
All Implemented Interfaces:
Serializable
Enclosing class:
DiscreteDomain<C extends Comparable>

private static final class DiscreteDomain.IntegerDomain extends DiscreteDomain<Integer> implements Serializable
  • Field Details

  • Constructor Details

    • IntegerDomain

      IntegerDomain()
  • Method Details

    • next

      @CheckForNull public Integer next(Integer value)
      Description copied from class: DiscreteDomain
      Returns the unique least value of type C that is greater than value, or null if none exists. Inverse operation to DiscreteDomain.previous(C).
      Specified by:
      next in class DiscreteDomain<Integer>
      Parameters:
      value - any value of type C
      Returns:
      the least value greater than value, or null if value is maxValue()
    • previous

      @CheckForNull public Integer previous(Integer value)
      Description copied from class: DiscreteDomain
      Returns the unique greatest value of type C that is less than value, or null if none exists. Inverse operation to DiscreteDomain.next(C).
      Specified by:
      previous in class DiscreteDomain<Integer>
      Parameters:
      value - any value of type C
      Returns:
      the greatest value less than value, or null if value is minValue()
    • offset

      Integer offset(Integer origin, long distance)
      Description copied from class: DiscreteDomain
      Returns, conceptually, "origin + distance", or equivalently, the result of calling DiscreteDomain.next(C) on origin distance times.
      Overrides:
      offset in class DiscreteDomain<Integer>
    • distance

      public long distance(Integer start, Integer end)
      Description copied from class: DiscreteDomain
      Returns a signed value indicating how many nested invocations of DiscreteDomain.next(C) (if positive) or DiscreteDomain.previous(C) (if negative) are needed to reach end starting from start. For example, if end = next(next(next(start))), then distance(start, end) == 3 and distance(end, start) == -3. As well, distance(a, a) is always zero.

      Note that this function is necessarily well-defined for any discrete type.

      Specified by:
      distance in class DiscreteDomain<Integer>
      Returns:
      the distance as described above, or Long.MIN_VALUE or Long.MAX_VALUE if the distance is too small or too large, respectively.
    • minValue

      public Integer minValue()
      Description copied from class: DiscreteDomain
      Returns the minimum value of type C, if it has one. The minimum value is the unique value for which Comparable.compareTo(Object) never returns a positive value for any input of type C.

      The default implementation throws NoSuchElementException.

      Overrides:
      minValue in class DiscreteDomain<Integer>
      Returns:
      the minimum value of type C; never null
    • maxValue

      public Integer maxValue()
      Description copied from class: DiscreteDomain
      Returns the maximum value of type C, if it has one. The maximum value is the unique value for which Comparable.compareTo(Object) never returns a negative value for any input of type C.

      The default implementation throws NoSuchElementException.

      Overrides:
      maxValue in class DiscreteDomain<Integer>
      Returns:
      the maximum value of type C; never null
    • readResolve

      private Object readResolve()
    • toString

      public String toString()
      Overrides:
      toString in class Object