< prev index next >

## src/java.base/share/classes/java/time/temporal/WeekFields.java

Print this page

     342      *
     343      * @param firstDayOfWeek  the first day of the week, not null
     344      * @param minimalDaysInFirstWeek  the minimal number of days in the first week, from 1 to 7
     345      * @throws IllegalArgumentException if the minimal days value is invalid
     346      */
     347     private WeekFields(DayOfWeek firstDayOfWeek, int minimalDaysInFirstWeek) {
     348         Objects.requireNonNull(firstDayOfWeek, "firstDayOfWeek");
     349         if (minimalDaysInFirstWeek < 1 || minimalDaysInFirstWeek > 7) {
     350             throw new IllegalArgumentException("Minimal number of days is invalid");
     351         }
     352         this.firstDayOfWeek = firstDayOfWeek;
     353         this.minimalDays = minimalDaysInFirstWeek;
     354     }
     355
     356     //-----------------------------------------------------------------------
     357     /**
     358      * Restore the state of a WeekFields from the stream.
     359      * Check that the values are valid.
     360      *
     361      * @param s the stream to read

     362      * @throws InvalidObjectException if the serialized object has an invalid
     363      *     value for firstDayOfWeek or minimalDays.
     364      * @throws ClassNotFoundException if a class cannot be resolved
     365      */
     366     @java.io.Serial
     367     private void readObject(ObjectInputStream s)
     368          throws IOException, ClassNotFoundException, InvalidObjectException
     369     {
     370         s.defaultReadObject();
     371         if (firstDayOfWeek == null) {
     372             throw new InvalidObjectException("firstDayOfWeek is null");
     373         }
     374
     375         if (minimalDays < 1 || minimalDays > 7) {
     376             throw new InvalidObjectException("Minimal number of days is invalid");
     377         }
     378     }
     379
     380     /**
     381      * Return the singleton WeekFields associated with the
     342      *
     343      * @param firstDayOfWeek  the first day of the week, not null
     344      * @param minimalDaysInFirstWeek  the minimal number of days in the first week, from 1 to 7
     345      * @throws IllegalArgumentException if the minimal days value is invalid
     346      */
     347     private WeekFields(DayOfWeek firstDayOfWeek, int minimalDaysInFirstWeek) {
     348         Objects.requireNonNull(firstDayOfWeek, "firstDayOfWeek");
     349         if (minimalDaysInFirstWeek < 1 || minimalDaysInFirstWeek > 7) {
     350             throw new IllegalArgumentException("Minimal number of days is invalid");
     351         }
     352         this.firstDayOfWeek = firstDayOfWeek;
     353         this.minimalDays = minimalDaysInFirstWeek;
     354     }
     355
     356     //-----------------------------------------------------------------------
     357     /**
     358      * Restore the state of a WeekFields from the stream.
     359      * Check that the values are valid.
     360      *
     361      * @param s the stream to read
     362      * @throws IOException if an I/O error occurs
     363      * @throws InvalidObjectException if the serialized object has an invalid
     364      *     value for firstDayOfWeek or minimalDays.
     365      * @throws ClassNotFoundException if a class cannot be resolved
     366      */
     367     @java.io.Serial
     368     private void readObject(ObjectInputStream s)
     369          throws IOException, ClassNotFoundException, InvalidObjectException
     370     {
     371         s.defaultReadObject();
     372         if (firstDayOfWeek == null) {
     373             throw new InvalidObjectException("firstDayOfWeek is null");
     374         }
     375
     376         if (minimalDays < 1 || minimalDays > 7) {
     377             throw new InvalidObjectException("Minimal number of days is invalid");
     378         }
     379     }
     380
     381     /**
     382      * Return the singleton WeekFields associated with the

< prev index next >