Package org.zkoss.zul
Class LocalDateRange
java.lang.Object
org.zkoss.zul.LocalDateRange
- All Implemented Interfaces:
Serializable,Comparable<LocalDateRange>
public final class LocalDateRange
extends Object
implements Serializable, Comparable<LocalDateRange>
An immutable
LocalDate-based range, the java.time counterpart
to DateRange. See DateRange for full semantics — same null
handling, same non-swapping policy, same comparison contract.- Since:
- 11.0.0
- Author:
- peaker
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbooleanInclusive containment test, null-safe.booleangetBegin()getDays()Returns the inclusive day count wrapped in anOptionalLong.getEnd()inthashCode()booleanisClosed()booleanisEmpty()booleanbooleanstatic LocalDateRangeStatic factory equivalent toLocalDateRange(LocalDate, LocalDate).booleanoverlaps(LocalDateRange other) Null-safe overlap test, treatingnullends as unbounded.toString()
-
Constructor Details
-
LocalDateRange
Constructs a new range. Either end may benull.- Parameters:
begin- the begin date (inclusive), ornullend- the end date (inclusive), ornull
-
-
Method Details
-
of
Static factory equivalent toLocalDateRange(LocalDate, LocalDate).- Parameters:
begin- the begin date, ornullend- the end date, ornull- Returns:
- a new
LocalDateRange
-
getBegin
- Returns:
- the begin date, or
null
-
getEnd
- Returns:
- the end date, or
null
-
isEmpty
public boolean isEmpty()- Returns:
trueif both ends arenull.
-
isOpenStart
public boolean isOpenStart()- Returns:
trueif onlybeginisnull.
-
isOpenEnd
public boolean isOpenEnd()- Returns:
trueif onlyendisnull.
-
isClosed
public boolean isClosed()- Returns:
trueif both ends are non-null.
-
contains
Inclusive containment test, null-safe.nullends are unbounded.- Parameters:
value- the date to test, may benull- Returns:
trueifvalueis in the range
-
getDays
Returns the inclusive day count wrapped in anOptionalLong. Same-day closed range returnsOptionalLong.of(1); inverted closed ranges return a non-positive value (this class does not auto- swap). ReturnsOptionalLong.empty()for non-closed ranges so callers must explicitly handle the open-ended case (no more sentinel value collisions with legitimate inverted-range counts).- Returns:
- the inclusive day count for closed ranges, or
OptionalLong.empty()when either endpoint is null
-
overlaps
Null-safe overlap test, treatingnullends as unbounded.- Parameters:
other- the other range- Returns:
trueif the two share at least one day
-
equals
-
hashCode
public int hashCode() -
toString
-
compareTo
- Specified by:
compareToin interfaceComparable<LocalDateRange>
-