|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.degreedays.time.DayRange
public final class DayRange
Specifies a range of one or more days.
Instances of this class are immutable. You can safely reuse them and call them from multiple threads at once.
Constructor Summary | |
---|---|
DayRange(Day first,
Day last)
Constructs a DayRange object that starts on the specified
first day and ends on the specified last day. |
Method Summary | |
---|---|
boolean |
contains(Day testDay)
Returns true if the specified Day is fully
contained within this DayRange ; false
otherwise. |
boolean |
contains(DayRange testRange)
Returns true if the specified DayRange is
contained within this DayRange ; false
otherwise. |
Day |
dayAt(int zeroBasedIndex)
Returns the non-null Day at the specified zero-based index
within this DayRange . |
int |
dayCount()
Returns the number of days covered by this DayRange (always
1 or more). |
boolean |
equals(java.lang.Object o)
Returns true if o is a DayRange
covering exactly the same days as this DayRange ;
false otherwise. |
Day |
first()
Returns the non-null first Day in this
DayRange . |
MaybeEmptyDayRanges |
fullCalendarMonthsWithin()
|
MaybeEmptyDayRanges |
fullCalendarYearsWithin()
|
MaybeEmptyDayRanges |
fullMonthsWithin(StartOfMonth startOfMonth)
|
DayRanges |
fullOrPartialCalendarMonthsWithin()
|
DayRanges |
fullOrPartialCalendarYearsWithin()
|
DayRanges |
fullOrPartialMonthsWithin(StartOfMonth startOfMonth)
|
DayRanges |
fullOrPartialWeeksWithin(DayOfWeek firstDayOfWeek)
|
DayRanges |
fullOrPartialYearsWithin(StartOfYear startOfYear)
|
MaybeEmptyDayRanges |
fullWeeksWithin(DayOfWeek firstDayOfWeek)
|
MaybeEmptyDayRanges |
fullYearsWithin(StartOfYear startOfYear)
|
DayRange |
greedyUnion(Day dayToIncludeInUnion)
Returns the non-null DayRange that includes all the days
within this DayRange , the specified Day , and
any days between. |
DayRange |
greedyUnion(DayRange rangeToIncludeInUnion)
Returns the non-null DayRange that includes all the days
within this DayRange , the specified DayRange ,
and any days between. |
int |
hashCode()
Overridden to ensure consistency with equals . |
int |
indexOf(Day day)
Returns the index of the specified Day within this
DayRange , or -1 if it is not contained by this
DayRange . |
DayRange |
intersectionOrNull(DayRange intersectWith)
Returns a DayRange covering the days that are contained
within both this DayRange and the specified
DayRange , or null if there is no such
intersection. |
Day |
last()
Returns the non-null last Day in this DayRange . |
DayRanges |
toDailyDayRanges()
|
java.lang.String |
toString()
Returns a non-null, non-empty string representation of this object for logging and debugging purposes. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DayRange(Day first, Day last)
DayRange
object that starts on the specified
first
day and ends on the specified last
day.
If first
and last
represent the same day, the
range will cover that day only.
first
- the first day that the DayRange
should include.
Cannot be null
.last
- the last day that the DayRange
should include.
Cannot be null
, and must be equal to or later than
first
.
java.lang.NullPointerException
- if first
or
last
is null
.
java.lang.IllegalArgumentException
- if first
is after
last
.Day.to(Day)
Method Detail |
---|
public Day first()
Day
in this
DayRange
.
public Day last()
Day
in this DayRange
.
public int dayCount()
DayRange
(always
1 or more).
public Day dayAt(int zeroBasedIndex)
Day
at the specified zero-based index
within this DayRange
.
zeroBasedIndex
- the index of the Day
to return. Must
be greater than or equal to zero and less than dayCount()
.
Day
at the specified index.
java.lang.IndexOutOfBoundsException
- if zeroBasedIndex
is less
than zero or greater than or equal to dayCount()
.indexOf(Day)
public boolean contains(Day testDay)
true
if the specified Day
is fully
contained within this DayRange
; false
otherwise.
testDay
- the Day
to test for containment within this
DayRange
.
true
if testDay
is equal to or after
the first()
day of this DayRange
, and equal
to or before the last()
day of this
DayRange
; false
otherwise.
java.lang.NullPointerException
- if testDay
is
null
.public boolean contains(DayRange testRange)
true
if the specified DayRange
is
contained within this DayRange
; false
otherwise.
testRange
- the DayRange
to test for containment within
this DayRange
.
true
if the first day of testRange
is
equal to or after the first day of this DayRange
,
and the last day of testRange
is equal to or before
the last day of this DayRange
; false
otherwise.
java.lang.NullPointerException
- if testRange
is
null
.public int indexOf(Day day)
Day
within this
DayRange
, or -1 if it is not contained by this
DayRange
.
day
- the Day
to return the index of.
java.lang.NullPointerException
- if day
is
null
.dayAt(int)
public DayRange intersectionOrNull(DayRange intersectWith)
DayRange
covering the days that are contained
within both this DayRange
and the specified
DayRange
, or null
if there is no such
intersection.
By definition, a.intersectionOrNull(b)
will always give the
same result as b.intersectionOrNull(a)
, provided neither
a
nor b
are null
.
intersectWith
- the other DayRange
that the
intersection should be calculated from (together with this
DayRange
). Cannot be null
.
java.lang.NullPointerException
- if intersectWith
is
null
.public DayRange greedyUnion(DayRange rangeToIncludeInUnion)
DayRange
that includes all the days
within this DayRange
, the specified DayRange
,
and any days between.
This method is "greedy" because, if there is a gap between this
DayRange
and rangeToIncludeInUnion
, that gap
will be included in the returned DayRange
.
rangeToIncludeInUnion
- the non-null DayRange
that the
returned DayRange
should include (together with this
DayRange
and any days between).
DayRange
that includes all the days within this
DayRange
, rangeToIncludeInUnion
, and
any days between.
java.lang.NullPointerException
- if rangeToIncludeInUnion
is
null
.public DayRange greedyUnion(Day dayToIncludeInUnion)
DayRange
that includes all the days
within this DayRange
, the specified Day
, and
any days between.
This method is "greedy" because, if there is a gap between this
DayRange
and dayToIncludeInUnion
, that gap will
be included in the returned DayRange
.
dayToIncludeInUnion
- the non-null Day
that the
returned DayRange
should include (together with this
DayRange
and any days between).
DayRange
that includes all the days within this
DayRange
, dayToIncludeInUnion
, and any
days between.
java.lang.NullPointerException
- if dayToIncludeInUnion
is
null
.public MaybeEmptyDayRanges fullWeeksWithin(DayOfWeek firstDayOfWeek)
public MaybeEmptyDayRanges fullMonthsWithin(StartOfMonth startOfMonth)
public MaybeEmptyDayRanges fullCalendarMonthsWithin()
public MaybeEmptyDayRanges fullYearsWithin(StartOfYear startOfYear)
public MaybeEmptyDayRanges fullCalendarYearsWithin()
public DayRanges fullOrPartialWeeksWithin(DayOfWeek firstDayOfWeek)
public DayRanges fullOrPartialMonthsWithin(StartOfMonth startOfMonth)
public DayRanges fullOrPartialCalendarMonthsWithin()
public DayRanges fullOrPartialYearsWithin(StartOfYear startOfYear)
public DayRanges fullOrPartialCalendarYearsWithin()
public DayRanges toDailyDayRanges()
public boolean equals(java.lang.Object o)
true
if o
is a DayRange
covering exactly the same days as this DayRange
;
false
otherwise.
equals
in class java.lang.Object
public int hashCode()
equals
.
hashCode
in class java.lang.Object
public java.lang.String toString()
The exact details of the representation are unspecified and subject to change.
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |