Package org.zkoss.zul
Class LocalDateRange
- java.lang.Object
-
- org.zkoss.zul.LocalDateRange
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<LocalDateRange>
public final class LocalDateRange extends java.lang.Object implements java.io.Serializable, java.lang.Comparable<LocalDateRange>
An immutableLocalDate-based range, thejava.timecounterpart toDateRange. SeeDateRangefor full semantics — same null handling, same non-swapping policy, same comparison contract.- Since:
- 10.4.0
- Author:
- peaker
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LocalDateRange(java.time.LocalDate begin, java.time.LocalDate end)Constructs a new range.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(LocalDateRange o)booleancontains(java.time.LocalDate value)Inclusive containment test, null-safe.booleanequals(java.lang.Object o)java.time.LocalDategetBegin()java.util.OptionalLonggetDays()Returns the inclusive day count wrapped in anOptionalLong.java.time.LocalDategetEnd()inthashCode()booleanisClosed()booleanisEmpty()booleanisOpenEnd()booleanisOpenStart()static LocalDateRangeof(java.time.LocalDate begin, java.time.LocalDate end)Static factory equivalent toLocalDateRange(LocalDate, LocalDate).booleanoverlaps(LocalDateRange other)Null-safe overlap test, treatingnullends as unbounded.java.lang.StringtoString()
-
-
-
Method Detail
-
of
public static LocalDateRange of(java.time.LocalDate begin, java.time.LocalDate end)
Static factory equivalent toLocalDateRange(LocalDate, LocalDate).- Parameters:
begin- the begin date, ornullend- the end date, ornull- Returns:
- a new
LocalDateRange
-
getBegin
public java.time.LocalDate getBegin()
- Returns:
- the begin date, or
null
-
getEnd
public java.time.LocalDate 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
public boolean contains(java.time.LocalDate value)
Inclusive containment test, null-safe.nullends are unbounded.- Parameters:
value- the date to test, may benull- Returns:
trueifvalueis in the range
-
getDays
public java.util.OptionalLong 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
public boolean overlaps(LocalDateRange other)
Null-safe overlap test, treatingnullends as unbounded.- Parameters:
other- the other range- Returns:
trueif the two share at least one day
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
compareTo
public int compareTo(LocalDateRange o)
- Specified by:
compareToin interfacejava.lang.Comparable<LocalDateRange>
-
-