< prev index next >

src/java.base/share/classes/java/time/chrono/ChronoLocalDateImpl.java

Print this page

125  *
126  * <h2>Adding Calendars</h2>
127  * <p> The set of calendars is extensible by defining a subclass of {@link ChronoLocalDate}
128  * to represent a date instance and an implementation of {@code Chronology}
129  * to be the factory for the ChronoLocalDate subclass.
130  * </p>
131  * <p> To permit the discovery of the additional calendar types the implementation of
132  * {@code Chronology} must be registered as a Service implementing the {@code Chronology} interface
133  * in the {@code META-INF/Services} file as per the specification of {@link java.util.ServiceLoader}.
134  * The subclass must function according to the {@code Chronology} class description and must provide its
135  * {@link java.time.chrono.Chronology#getId() chronlogy ID} and {@link Chronology#getCalendarType() calendar type}. </p>
136  *
137  * @implSpec
138  * This abstract class must be implemented with care to ensure other classes operate correctly.
139  * All implementations that can be instantiated must be final, immutable and thread-safe.
140  * Subclasses should be Serializable wherever possible.
141  *
142  * @param <D> the ChronoLocalDate of this date-time
143  * @since 1.8
144  */

145 abstract class ChronoLocalDateImpl<D extends ChronoLocalDate>
146         implements ChronoLocalDate, Temporal, TemporalAdjuster, Serializable {
147 
148     /**
149      * Serialization version.
150      */
151     @java.io.Serial
152     private static final long serialVersionUID = 6282433883239719096L;
153 
154     /**
155      * Casts the {@code Temporal} to {@code ChronoLocalDate} ensuring it bas the specified chronology.
156      *
157      * @param chrono  the chronology to check for, not null
158      * @param temporal  a date-time to cast, not null
159      * @return the date-time checked and cast to {@code ChronoLocalDate}, not null
160      * @throws ClassCastException if the date-time cannot be cast to ChronoLocalDate
161      *  or the chronology is not equal this Chronology
162      */
163     static <D extends ChronoLocalDate> D ensureValid(Chronology chrono, Temporal temporal) {
164         @SuppressWarnings("unchecked")

125  *
126  * <h2>Adding Calendars</h2>
127  * <p> The set of calendars is extensible by defining a subclass of {@link ChronoLocalDate}
128  * to represent a date instance and an implementation of {@code Chronology}
129  * to be the factory for the ChronoLocalDate subclass.
130  * </p>
131  * <p> To permit the discovery of the additional calendar types the implementation of
132  * {@code Chronology} must be registered as a Service implementing the {@code Chronology} interface
133  * in the {@code META-INF/Services} file as per the specification of {@link java.util.ServiceLoader}.
134  * The subclass must function according to the {@code Chronology} class description and must provide its
135  * {@link java.time.chrono.Chronology#getId() chronlogy ID} and {@link Chronology#getCalendarType() calendar type}. </p>
136  *
137  * @implSpec
138  * This abstract class must be implemented with care to ensure other classes operate correctly.
139  * All implementations that can be instantiated must be final, immutable and thread-safe.
140  * Subclasses should be Serializable wherever possible.
141  *
142  * @param <D> the ChronoLocalDate of this date-time
143  * @since 1.8
144  */
145 @jdk.internal.MigratedValueClass
146 abstract class ChronoLocalDateImpl<D extends ChronoLocalDate>
147         implements ChronoLocalDate, Temporal, TemporalAdjuster, Serializable {
148 
149     /**
150      * Serialization version.
151      */
152     @java.io.Serial
153     private static final long serialVersionUID = 6282433883239719096L;
154 
155     /**
156      * Casts the {@code Temporal} to {@code ChronoLocalDate} ensuring it bas the specified chronology.
157      *
158      * @param chrono  the chronology to check for, not null
159      * @param temporal  a date-time to cast, not null
160      * @return the date-time checked and cast to {@code ChronoLocalDate}, not null
161      * @throws ClassCastException if the date-time cannot be cast to ChronoLocalDate
162      *  or the chronology is not equal this Chronology
163      */
164     static <D extends ChronoLocalDate> D ensureValid(Chronology chrono, Temporal temporal) {
165         @SuppressWarnings("unchecked")
< prev index next >