< prev index next >

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

Print this page

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

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

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