All TemporalField instances have a valid range of values.
For example, the ISO day-of-month runs from 1 to somewhere between 28 and 31.
This class captures that valid range.
It is important to be aware of the limitations of this class. Only the minimum and maximum values are provided. It is possible for there to be invalid values within the outer range. For example, a weird field may have valid values of 1, 2, 4, 6, 7, thus have a range of '1 - 7', despite the fact that values 3 and 5 are invalid.
Instances of this class are not tied to a specific field.
Implementation Specification
This class is immutable and thread-safe.
| Modifier and Type | Field and Description |
|---|---|
| private final long | |
| private final long | |
| private final long | |
| private final long | |
| private static final long | serialVersionUID
Serialization version. |
| Access | Constructor and Description |
|---|---|
| private | ValueRange(long
the smallest minimum value minSmallest, long the largest minimum value minLargest, long the smallest minimum value maxSmallest, long the largest minimum value maxLargest)Restrictive constructor. |
| Modifier and Type | Method and Description |
|---|---|
| public int | Returns: the value that was passed inthe value to check value, TemporalField the field being checked, may be null field)Checks that the specified value is valid and fits in an |
| public long | Returns: the value that was passed inthe value to check value, TemporalField the field being checked, may be null field)Checks that the specified value is valid. |
| public boolean | Returns: true if this is equal to the other rangethe object to check, null returns false obj)Overrides java. Checks if this range is equal to another range. |
| private String | |
| public long | Returns: the largest possible minimum value for this fieldGets the largest possible minimum value that the field can take. |
| public long | Returns: the maximum value for this fieldGets the maximum value that the field can take. |
| public long | Returns: the minimum value for this fieldGets the minimum value that the field can take. |
| public long | Returns: the smallest possible maximum value for this fieldGets the smallest possible maximum value that the field can take. |
| public int | Returns: a suitable hash codeOverrides java. A hash code for this range. |
| public boolean | |
| public boolean | Returns: true if a valid value always fits in anintChecks if all values in the range fit in an |
| public boolean | Returns: true if the value is valid and fits in anintthe value to check value)Checks if the value is within the valid range and that all values
in the range fit in an |
| public boolean | Returns: true if the value is validthe value to check value)Checks if the value is within the valid range. |
| public static ValueRange | Returns: the ValueRange for min, max, not nullthe minimum value min, long the maximum value max)Obtains a fixed value range. |
| public static ValueRange | Returns: the ValueRange for min, smallest max, largest max, not nullthe minimum value min, long the smallest maximum value maxSmallest, long the largest maximum value maxLargest)Obtains a variable value range. |
| public static ValueRange | Returns: the ValueRange for smallest min, largest min, smallest max, largest max, not nullthe smallest minimum value minSmallest, long the largest minimum value minLargest, long the smallest maximum value maxSmallest, long the largest maximum value maxLargest)Obtains a fully variable value range. |
| private void | readObject(ObjectInputStream
the stream to read s)Restore the state of an ValueRange from the stream. |
| public String | Returns: a string representation of this range, not nullOverrides java. Outputs this range as a |
| maxLargest | back to summary |
|---|---|
| private final long maxLargest | |
| maxSmallest | back to summary |
|---|---|
| private final long maxSmallest | |
| minLargest | back to summary |
|---|---|
| private final long minLargest | |
| minSmallest | back to summary |
|---|---|
| private final long minSmallest | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serialization version. | |
| ValueRange | back to summary |
|---|---|
| private ValueRange(long minSmallest, long minLargest, long maxSmallest, long maxLargest) Restrictive constructor.
| |
| checkValidIntValue | back to summary |
|---|---|
| public int checkValidIntValue(long value, TemporalField field) Checks that the specified value is valid and fits in an
This validates that the value is within the valid range of values and that
all valid values are within the bounds of an
| |
| checkValidValue | back to summary |
|---|---|
| public long checkValidValue(long value, TemporalField field) Checks that the specified value is valid. This validates that the value is within the valid range of values. The field is only used to improve the error message.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Checks if this range is equal to another range.
The comparison is based on the four values, minimum, largest minimum,
smallest maximum and maximum.
Only objects of type | |
| genInvalidFieldMessage | back to summary |
|---|---|
| private String genInvalidFieldMessage(TemporalField field, long value) | |
| getLargestMinimum | back to summary |
|---|---|
| public long getLargestMinimum() Gets the largest possible minimum value that the field can take. For example, the ISO day-of-month always starts at 1. The largest minimum is therefore 1.
| |
| getMaximum | back to summary |
|---|---|
| public long getMaximum() Gets the maximum value that the field can take. For example, the ISO day-of-month runs to between 28 and 31 days. The maximum is therefore 31.
| |
| getMinimum | back to summary |
|---|---|
| public long getMinimum() Gets the minimum value that the field can take. For example, the ISO day-of-month always starts at 1. The minimum is therefore 1.
| |
| getSmallestMaximum | back to summary |
|---|---|
| public long getSmallestMaximum() Gets the smallest possible maximum value that the field can take. For example, the ISO day-of-month runs to between 28 and 31 days. The smallest maximum is therefore 28.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. A hash code for this range.
| |
| isFixed | back to summary |
|---|---|
| public boolean isFixed() Is the value range fixed and fully known. For example, the ISO day-of-month runs from 1 to between 28 and 31. Since there is uncertainty about the maximum value, the range is not fixed. However, for the month of January, the range is always 1 to 31, thus it is fixed.
| |
| isIntValue | back to summary |
|---|---|
| public boolean isIntValue() Checks if all values in the range fit in an
This checks that all valid values are within the bounds of an
For example, the ISO month-of-year has values from 1 to 12, which fits in an
This implementation uses
| |
| isValidIntValue | back to summary |
|---|---|
| public boolean isValidIntValue(long value) Checks if the value is within the valid range and that all values
in the range fit in an
This method combines
| |
| isValidValue | back to summary |
|---|---|
| public boolean isValidValue(long value) Checks if the value is within the valid range. This checks that the value is within the stored range of values.
| |
| of | back to summary |
|---|---|
| public static ValueRange of(long min, long max) Obtains a fixed value range. This factory obtains a range where the minimum and maximum values are fixed. For example, the ISO month-of-year always runs from 1 to 12.
| |
| of | back to summary |
|---|---|
| public static ValueRange of(long min, long maxSmallest, long maxLargest) Obtains a variable value range. This factory obtains a range where the minimum value is fixed and the maximum value may vary. For example, the ISO day-of-month always starts at 1, but ends between 28 and 31.
| |
| of | back to summary |
|---|---|
| public static ValueRange of(long minSmallest, long minLargest, long maxSmallest, long maxLargest) Obtains a fully variable value range. This factory obtains a range where both the minimum and maximum value may vary.
| |
| readObject | back to summary |
|---|---|
| private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException, InvalidObjectException Restore the state of an ValueRange from the stream. Check that the values are valid.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Outputs this range as a The format will be '{min}/{largestMin} - {smallestMax}/{max}', where the largestMin or smallestMax sections may be omitted, together with associated slash, if they are the same as the min or max. | |