|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface PeriodProvider
Provides access to a period of time, such as '2 Years and 5 Months'.
PeriodProvider is a simple interface that provides uniform access to any object that can provide access to a period.
The implementation of PeriodProvider
may be mutable.
The result of toPeriodFields()
, however, is immutable.
When implementing an API that accepts a PeriodProvider
as a parameter,
it is important to convert the input to a PeriodFields
once and once only.
It is recommended that this is done at the top of the method before other processing.
This is necessary to handle the case where the implementation of the provider is
mutable and changes in value between two calls to toPeriodFields()
.
The recommended way to convert a DateProvider to a LocalDate is using
PeriodFields.of(PeriodProvider)
as this method provides additional null checking.
This interface makes no guarantees about the thread-safety or immutability of implementations.
Method Summary | |
---|---|
PeriodFields |
toPeriodFields()
Returns an instance of PeriodFields initialized from the
state of this object. |
Method Detail |
---|
PeriodFields toPeriodFields()
PeriodFields
initialized from the
state of this object.
This method will take the period represented by this object and return
an equivalent PeriodFields
.
The amount stored for a unit in the result may be zero.
If this object is already a PeriodFields
then it is simply returned.
Implementations must ensure that calls to this method are thread-safe. An immutable implementation will naturally provide this guarantee.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |