Package com.google.common.collect
Class DiscreteDomain<C extends Comparable>
- java.lang.Object
- 
- com.google.common.collect.DiscreteDomain<C>
 
- 
 @GwtCompatible public abstract class DiscreteDomain<C extends Comparable> extends Object A descriptor for a discreteComparabledomain such as allIntegerinstances. A discrete domain is one that supports the three basic operations:next(C),previous(C)anddistance(C, C), according to their specifications. The methodsminValue()andmaxValue()should also be overridden for bounded types.A discrete domain always represents the entire set of values of its type; it cannot represent partial domains such as "prime integers" or "strings of length 5." See the Guava User Guide section on DiscreteDomain.- Since:
- 10.0
- Author:
- Kevin Bourrillion
 
- 
- 
Constructor SummaryConstructors Modifier Constructor Description protectedDiscreteDomain()Constructor for use by subclasses.
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static DiscreteDomain<BigInteger>bigIntegers()Returns the discrete domain for values of typeBigInteger.abstract longdistance(C start, C end)Returns a signed value indicating how many nested invocations ofnext(C)(if positive) orprevious(C)(if negative) are needed to reachendstarting fromstart.static DiscreteDomain<Integer>integers()Returns the discrete domain for values of typeInteger.static DiscreteDomain<Long>longs()Returns the discrete domain for values of typeLong.CmaxValue()Returns the maximum value of typeC, if it has one.CminValue()Returns the minimum value of typeC, if it has one.abstract Cnext(C value)Returns the unique least value of typeCthat is greater thanvalue, ornullif none exists.abstract Cprevious(C value)Returns the unique greatest value of typeCthat is less thanvalue, ornullif none exists.
 
- 
- 
- 
Constructor Detail- 
DiscreteDomainprotected DiscreteDomain() Constructor for use by subclasses.
 
- 
 - 
Method Detail- 
integerspublic static DiscreteDomain<Integer> integers() Returns the discrete domain for values of typeInteger.- Since:
- 14.0 (since 10.0 as DiscreteDomains.integers())
 
 - 
longspublic static DiscreteDomain<Long> longs() Returns the discrete domain for values of typeLong.- Since:
- 14.0 (since 10.0 as DiscreteDomains.longs())
 
 - 
bigIntegerspublic static DiscreteDomain<BigInteger> bigIntegers() Returns the discrete domain for values of typeBigInteger.- Since:
- 15.0
 
 - 
nextpublic abstract C next(C value) Returns the unique least value of typeCthat is greater thanvalue, ornullif none exists. Inverse operation toprevious(C).- Parameters:
- value- any value of type- C
- Returns:
- the least value greater than value, ornullifvalueismaxValue()
 
 - 
previouspublic abstract C previous(C value) Returns the unique greatest value of typeCthat is less thanvalue, ornullif none exists. Inverse operation tonext(C).- Parameters:
- value- any value of type- C
- Returns:
- the greatest value less than value, ornullifvalueisminValue()
 
 - 
distancepublic abstract long distance(C start, C end) Returns a signed value indicating how many nested invocations ofnext(C)(if positive) orprevious(C)(if negative) are needed to reachendstarting fromstart. For example, ifend = next(next(next(start))), thendistance(start, end) == 3anddistance(end, start) == -3. As well,distance(a, a)is always zero.Note that this function is necessarily well-defined for any discrete type. - Returns:
- the distance as described above, or Long.MIN_VALUEorLong.MAX_VALUEif the distance is too small or too large, respectively.
 
 - 
minValue@CanIgnoreReturnValue public C minValue() Returns the minimum value of typeC, if it has one. The minimum value is the unique value for whichComparable.compareTo(Object)never returns a positive value for any input of typeC.The default implementation throws NoSuchElementException.- Returns:
- the minimum value of type C; never null
- Throws:
- NoSuchElementException- if the type has no (practical) minimum value; for example,- BigInteger
 
 - 
maxValue@CanIgnoreReturnValue public C maxValue() Returns the maximum value of typeC, if it has one. The maximum value is the unique value for whichComparable.compareTo(Object)never returns a negative value for any input of typeC.The default implementation throws NoSuchElementException.- Returns:
- the maximum value of type C; never null
- Throws:
- NoSuchElementException- if the type has no (practical) maximum value; for example,- BigInteger
 
 
- 
 
-