Class HistoricChronology.YearRule
- All Implemented Interfaces:
Serializable, Comparable<CalendricalRule<?>>, Comparator<Calendrical>
- Enclosing class:
HistoricChronology
-
Nested Class Summary
Nested classes/interfaces inherited from class DateTimeFieldRule
DateTimeFieldRule.TextStore -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final HistoricChronologyThe chronology.private static final longA serialization identifier for this class. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Integerderive(Calendrical calendrical) Derives the value of this rule from a calendrical.protected voidmerge(CalendricalMerger merger) Merges this field with other fields to form higher level fields.Methods inherited from class DateTimeFieldRule
checkValue, checkValue, convertFractionToInt, convertIntToFraction, convertIntToValue, convertValueToInt, createTextStores, getInt, getInteger, getLargestMinimumValue, getMaximumValue, getMaximumValue, getMinimumValue, getMinimumValue, getSmallestMaximumValue, getText, getTextStore, isFixedValueSet, isValidValue, isValidValueMethods inherited from class CalendricalRule
compare, compareTo, deriveValueFor, deriveValueFrom, equals, getChronology, getID, getName, getPeriodRange, getPeriodUnit, getReifiedType, getValue, getValueChecked, hashCode, interpret, reify, toStringMethods inherited from interface Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
chrono
The chronology. -
serialVersionUID
private static final long serialVersionUIDA serialization identifier for this class.- See Also:
-
-
Constructor Details
-
YearRule
Constructor.
-
-
Method Details
-
derive
Description copied from class:CalendricalRuleDerives the value of this rule from a calendrical.This method derives the value for this field from other fields in the calendrical without directly querying the calendrical for the value.
For example, if this field is quarter-of-year, then the value can be derived from month-of-year.
The implementation only needs to derive the value based on its immediate parents. The use of
Calendrical.get(CalendricalRule)will extract any further parents on demand.A typical implementation of this method obtains the parent value and performs a calculation. For example, here is a simple implementation for the quarter-of-year field:
Integer moyVal = calendrical.get(ISOChronology.monthOfYearRule()); return (moyVal != null ? ((moyVal - 1) % 4) + 1) : null;
This method is designed to be overridden in subclasses. The subclass implementation must be thread-safe. The subclass implementation must not request the value of this rule from the specified calendrical, otherwise a stack overflow error will occur.
- Overrides:
derivein classCalendricalRule<Integer>- Parameters:
calendrical- the calendrical to derive from, not null- Returns:
- the derived value, null if unable to derive
-
merge
Description copied from class:CalendricalRuleMerges this field with other fields to form higher level fields.The aim of this method is to assist in the process of extracting the most date-time information possible from a map of field-value pairs. The merging process is controlled by the mutable merger instance and the input and output of the this merge are held there.
Subclasses that override this method may use methods on the merger to obtain the values to merge. The value is guaranteed to be available for this field if this method is called.
If the override successfully merged some fields then the following must be performed. The merged field must be stored using
CalendricalMerger.storeMerged(CalendricalRule, T). Each field used in the merge must be marked as being used by callingCalendricalMerger.removeProcessed(CalendricalRule).An example to merge two fields into one - hour of AM/PM and AM/PM:
Integer hapVal = merger.getValue(ISOChronology.hourOfAmPmRule()); if (hapVal != null) { AmPmOfDay amPm = merger.getValue(this); int hourOfDay = MathUtils.safeAdd(MathUtils.safeMultiply(amPm, 12), hapVal); merger.storeMerged(ISOChronology.hourOfDayRule(), hourOfDay); merger.removeProcessed(this); merger.removeProcessed(ISOChronology.hourOfAmPmRule()); }- Overrides:
mergein classCalendricalRule<Integer>- Parameters:
merger- the merger instance controlling the merge process, not null
-