Home Reference Source
public class | source

ValueRange

The range of valid values for a date-time field.

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 that fact that values 3 and 5 are invalid.

Instances of this class are not tied to a specific field.

Static Method Summary

Static Public Methods
public static

of(): *

Method Summary

Public Methods
public

checkValidIntValue(value: number, field: TemporalField): number

Checks that the specified value is valid and fits in an int.

public

checkValidValue(value: number, field: TemporalField): *

public

equals(other: *): boolean

Checks if this range is equal to another range.

public

hashCode(): number

A hash code for this range.

public

isFixed(): boolean

Is the value range fixed and fully known.

public

isIntValue(): *

Checks if all values in the range fit in an int.

public

isValidIntValue(value: number): *

Checks if the value is within the valid range and that all values in the range fit in an int.

public

isValidValue(value: *): boolean

public

largestMinimum(): number

public

maximum(): number

public

minimum(): number

public

smallestMaximum(): number

public

toString(): *

Static Public Methods

public static of(): * source

Return:

*

Public Methods

public checkValidIntValue(value: number, field: TemporalField): number source

Checks that the specified value is valid and fits in an int.

This validates that the value is within the valid range of values and that all valid values are within the bounds of an int. The field is only used to improve the error message.

Params:

NameTypeAttributeDescription
value number

the value to check

field TemporalField

the field being checked, may be null

Return:

number

the value that was passed in

See:

public checkValidValue(value: number, field: TemporalField): * source

Params:

NameTypeAttributeDescription
value number
field TemporalField

Return:

*

public equals(other: *): boolean source

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 ValueRange are compared, other types return false.

Params:

NameTypeAttributeDescription
other *

the object to check, null returns false

Return:

boolean

true if this is equal to the other range

public hashCode(): number source

A hash code for this range.

Return:

number

a suitable hash code

public isFixed(): boolean source

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.

Return:

boolean

true if the set of values is fixed

public isIntValue(): * source

Checks if all values in the range fit in an int.

This checks that all valid values are within the bounds of an int.

For example, the ISO month-of-year has values from 1 to 12, which fits in an int. By comparison, ISO nano-of-day runs from 1 to 86,400,000,000,000 which does not fit in an int.

This implementation uses getMinimum and getMaximum.

Return:

*

boolean if a valid value always fits in an int

public isValidIntValue(value: number): * source

Checks if the value is within the valid range and that all values in the range fit in an int.

This method combines isIntValue and isValidValue.

Params:

NameTypeAttributeDescription
value number

the value to check

Return:

*

true if the value is valid and fits in an int

public isValidValue(value: *): boolean source

Params:

NameTypeAttributeDescription
value *

Return:

boolean

public largestMinimum(): number source

Return:

number

public maximum(): number source

Return:

number

public minimum(): number source

Return:

number

public smallestMaximum(): number source

Return:

number

public toString(): * source

Return:

*