T - generic type of time context compatible to ChronoEntityV - generic type of elment valuepublic interface ElementRule<T,V>
Represents the rule of a chronological element how to calculate or to manipulate its context-dependent temporal value.
Element rules will be searched by Time4J according to following criteria:
Chronology
together with its associated chronological element. For each chronology
and each element instance there is exactly one rule instance. In most
cases it is an inner class of the temporal type in question. BasicElement
and if the element supports the chronology. If yes then its internal
rule will be evaluated. RuleNotFoundException will be thrown. Chronology.Builder.appendElement(ChronoElement,ElementRule),
BasicElement.derive(Chronology)| Modifier and Type | Method and Description |
|---|---|
ChronoElement<?> |
getChildAtCeiling(T context)
Yields the child element whose value is to be set to the maximum
value.
|
ChronoElement<?> |
getChildAtFloor(T context)
Yields the child element whose value is to be set to the minimum
value.
|
V |
getMaximum(T context)
Yields the maximum value suitable for given chronological
context.
|
V |
getMinimum(T context)
Yields the minimum value suitable for given chronological
context.
|
V |
getValue(T context)
Yields the current value of associated element in given
chronological context.
|
boolean |
isValid(T context,
V value)
Queries if given value is valid for the element associated with this
rule in given context.
|
T |
withValue(T context,
V value,
boolean lenient)
Determines the new value of the associated element in given
chronological context and yields the result.
|
V getValue(T context)
Yields the current value of associated element in given chronological context.
Will be called by ChronoEntity.get(ChronoElement).
If the element associated with this rule is a primary element which directly represents a part of the state of an entity then any implementation will request the value directly from the state, otherwise derive from context using a specific logic. The term primary refers to if the context itself stores the value.
context - time context to be evaluatednull)V getMinimum(T context)
Yields the minimum value suitable for given chronological context.
Will be called by ChronoEntity.getMinimum(ChronoElement).
ATTENTION: Defining a minimum and maximum does not imply a continuum between minimum and maximum without any gaps, see for example summer time switches or hebrew leap months. Furthermore, a chronologically ascending order cannot be guaranteed.
context - time context to be evaluatedgetMaximum(T)V getMaximum(T context)
Yields the maximum value suitable for given chronological context.
Will be called by ChronoEntity.getMaximum(ChronoElement).
ATTENTION: Defining a minimum and maximum does not imply a continuum between minimum and maximum without any gaps, see for example summer time switches or hebrew leap months. Furthermore, a chronologically ascending order cannot be guaranteed.
context - time context to be evaluatedgetMinimum(T)boolean isValid(T context, V value)
Queries if given value is valid for the element associated with this rule in given context.
Will be called by ChronoEntity.isValid(ChronoElement, V). A numerical overflow causing
an ArithmeticException will usually not be checked.
context - time context to be evaluatedvalue - candidate value to be validated (optional)true if valid else falseT withValue(T context, V value, boolean lenient)
Determines the new value of the associated element in given chronological context and yields the result.
Will be called by ChronoEntity.with(ChronoElement, V). The third parameter is in most
cases only relevant if the value type is no enum type but for example
an integer type. The lenient mode causes the tolerant interpretation
of invalid values like 31st of April as 1st of May. This mode is only
active if an element is either explicitly declared as lenient or if
the method StdOperator.setLenient() is used.
context - time context to be evaluatedvalue - new element value (optional)lenient - leniency modeIllegalArgumentException - if given value is out of range or
not valid dependent on the given time contextArithmeticException - in case of numerical overflowisValid(T, V),
StdOperator.setLenient(Object, ChronoElement),
ChronoElement.isLenient(),
ProportionalElement.setLenient(Number)ChronoElement<?> getChildAtFloor(T context)
Yields the child element whose value is to be set to the minimum value.
The access to this method only happens indirectly in the class
StdOperator.
context - time context to be evaluatednull if not availableStdOperator.atFloor(ChronoElement)ChronoElement<?> getChildAtCeiling(T context)
Yields the child element whose value is to be set to the maximum value.
The access to this method only happens indirectly in the class
StdOperator.
context - time context to be evaluatednull if not availableStdOperator.atCeiling(ChronoElement)Copyright © 2014–2015. All rights reserved.