Package limn.components.date
Record Class DateRange
java.lang.Object
java.lang.Record
limn.components.date.DateRange
- Record Components:
start- the first day of the period, includedend- the last day of the period, included; never beforestart
A period between two days, both ends included.
Normalized on construction, so start() is never after end(): a range is a
span of days rather than a record of which end the user clicked first, and a widget that let the
two disagree would make every reader of a range write the same three-line swap.
A half-made range is not one. While a person is picking a period the calendar holds an
anchor and a preview, and neither is a DateRange;
CalendarView.selectedRange() answers null until the second end is chosen. That is
the whole reason both components here are non-null: a type whose end may be missing is a
type every caller has to null-check for a state that is never published.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanlongdays()end()Returns the value of theendrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static DateRangeThe period between two days, in whichever order they arrive.static DateRangeA period of one day.start()Returns the value of thestartrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Method Details
-
of
The period between two days, in whichever order they arrive. This is what a calendar builds from an anchor and the day the second click landed on, and dragging a selection backwards is ordinary rather than an error.- Parameters:
a- one endb- the other- Returns:
- the period covering both, ends included
-
ofDay
A period of one day. -
contains
- Parameters:
day- a day, ornull- Returns:
- whether it falls inside this period, both ends included;
falsefornull, so a caller holding an unset value needs no guard of its own
-
days
public long days()- Returns:
- how many days the period covers, counting both ends; never less than 1
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
start
Returns the value of thestartrecord component.- Returns:
- the value of the
startrecord component
-
end
Returns the value of theendrecord component.- Returns:
- the value of the
endrecord component
-