ValueRange

The range of valid values for a date-time field. !(p) All {@link 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. !(p) 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 that fact that values 3 and 5 are invalid. !(p) Instances of this class are not tied to a specific field.

@implSpec This class is immutable and thread-safe.

@since 1.8

Members

Functions

checkValidIntValue
int checkValidIntValue(long value, TemporalField field)

Checks that the specified value is valid and fits _in an {@code int}. !(p) This validates that the value is within the valid range of values and that all valid values are within the bounds of an {@code int}. The field is only used to improve the error message.

checkValidValue
long checkValidValue(long value, TemporalField field)

Checks that the specified value is valid. !(p) This validates that the value is within the valid range of values. The field is only used to improve the error message.

getLargestMinimum
long getLargestMinimum()

Gets the largest possible minimum value that the field can take. !(p) For example, the ISO day-of-month always starts at 1. The largest minimum is therefore 1.

getMaximum
long getMaximum()

Gets the maximum value that the field can take. !(p) For example, the ISO day-of-month runs to between 28 and 31 days. The maximum is therefore 31.

getMinimum
long getMinimum()

Gets the minimum value that the field can take. !(p) For example, the ISO day-of-month always starts at 1. The minimum is therefore 1.

getSmallestMaximum
long getSmallestMaximum()

Gets the smallest possible maximum value that the field can take. !(p) For example, the ISO day-of-month runs to between 28 and 31 days. The smallest maximum is therefore 28.

isFixed
bool isFixed()

Is the value range fixed and fully known. !(p) 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
bool isIntValue()

Checks if all values _in the range fit _in an {@code int}. !(p) This checks that all valid values are within the bounds of an {@code int}. !(p) For example, the ISO month-of-year has values from 1 to 12, which fits _in an {@code int}. By comparison, ISO nano-of-day runs from 1 to 86,400,000,000,000 which does not fit _in an {@code int}. !(p) This implementation uses {@link #getMinimum()} and {@link #getMaximum()}.

isValidIntValue
bool isValidIntValue(long value)

Checks if the value is within the valid range and that all values _in the range fit _in an {@code int}. !(p) This method combines {@link #isIntValue()} and {@link #isValidValue(long)}.

isValidValue
bool isValidValue(long value)

Checks if the value is within the valid range. !(p) This checks that the value is within the stored range of values.

opEquals
bool opEquals(Object obj)

Checks if this range is equal to another range. !(p) The comparison is based on the four values, minimum, largest minimum, smallest maximum and maximum. Only objects of type {@code ValueRange} are compared, other types return false.

toHash
size_t toHash()

A hash code for this range.

toString
string toString()

Outputs this range as a {@code string}. !(p) 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.

Static functions

of
ValueRange of(long min, long max)

Obtains a fixed value range. !(p) 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
ValueRange of(long min, long maxSmallest, long maxLargest)

Obtains a variable value range. !(p) 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
ValueRange of(long minSmallest, long minLargest, long maxSmallest, long maxLargest)

Obtains a fully variable value range. !(p) This factory obtains a range where both the minimum and maximum value may vary.

Meta