static AccountingChronology create(DayOfWeek endsOn, Month end, boolean inLastWeek, AccountingYearDivision division, int leapWeekInMonth) {
        if (endsOn == null || end == null || division == null || leapWeekInMonth == 0) {
            throw new IllegalStateException("AccountingCronology cannot be built: "
                    + (endsOn == null ? "| ending day-of-week |" : "")
                    + (end == null ? "| month ending in/nearest to |" : "")
                    + (division == null ? "| how year divided |" : "")
                    + (leapWeekInMonth == 0 ? "| leap-week month |" : "")
                    + " not set.");
        }
        if (!division.getMonthsInYearRange().isValidValue(leapWeekInMonth)) {
            throw new IllegalStateException("Leap week cannot not be placed in non-existent month " + leapWeekInMonth
                    + ", range is [" + division.getMonthsInYearRange() + "].");
        }

        // Derive cached information.
        LocalDate endingLimit = inLastWeek ? LocalDate.of(0, end, 1).with(TemporalAdjusters.lastDayOfMonth()) :
                LocalDate.of(0, end, 1).with(TemporalAdjusters.lastDayOfMonth()).plusDays(3);
        LocalDate yearZeroEnd = endingLimit.with(TemporalAdjusters.previousOrSame(endsOn));
        int yearZeroDifference = (int) yearZeroEnd.until(endingLimit, ChronoUnit.DAYS);
        // Longest/shortest month lengths and related
        int longestMonthLength = 0;
        int shortestMonthLength = Integer.MAX_VALUE;
        for (int month = 1; month <= division.getMonthsInYearRange().getMaximum(); month++) {
            int monthLength = division.getWeeksInMonth(month);
            shortestMonthLength = Math.min(shortestMonthLength, monthLength);
            longestMonthLength = Math.max(longestMonthLength, monthLength + (month == leapWeekInMonth ? 1 : 0));
        }
        ValueRange alignedWeekOfMonthRange = ValueRange.of(1, shortestMonthLength, longestMonthLength);
        ValueRange dayOfMonthRange = ValueRange.of(1, shortestMonthLength * 7, longestMonthLength * 7);
        int daysToEpoch = Math.toIntExact(0 - yearZeroEnd.plusDays(1).toEpochDay());

        return new AccountingChronology(endsOn, end, inLastWeek, division, leapWeekInMonth, yearZeroDifference, alignedWeekOfMonthRange, dayOfMonthRange, daysToEpoch);
    }
static AccountingChronology create ( DayOfWeek endsOn , Month end , boolean inLastWeek , AccountingYearDivision division , int leapWeekInMonth ) { if ( endsOn == null || end == null || division == null || leapWeekInMonth == 0 ) { throw new IllegalStateException ( "AccountingCronology cannot be built: " + ( endsOn == null ? "| ending day-of-week |" : "" ) + ( end == null ? "| month ending in/nearest to |" : "" ) + ( division == null ? "| how year divided |" : "" ) + ( leapWeekInMonth == 0 ? "| leap-week month |" : "" ) + " not set." ) ; } if ( ! division . getMonthsInYearRange ( ) . isValidValue ( leapWeekInMonth ) ) { throw new IllegalStateException ( "Leap week cannot not be placed in non-existent month " + leapWeekInMonth + ", range is [" + division . getMonthsInYearRange ( ) + "]." ) ; } LocalDate endingLimit = inLastWeek ? LocalDate . of ( 0 , end , 1 ) . with ( TemporalAdjusters . lastDayOfMonth ( ) ) : LocalDate . of ( 0 , end , 1 ) . with ( TemporalAdjusters . lastDayOfMonth ( ) ) . plusDays ( 3 ) ; LocalDate yearZeroEnd = endingLimit . with ( TemporalAdjusters . previousOrSame ( endsOn ) ) ; int yearZeroDifference = ( int ) yearZeroEnd . until ( endingLimit , ChronoUnit . DAYS ) ; int longestMonthLength = 0 ; int shortestMonthLength = Integer . MAX_VALUE ; for ( int month = 1 ; month <= division . getMonthsInYearRange ( ) . getMaximum ( ) ; month ++ ) { int monthLength = division . getWeeksInMonth ( month ) ; shortestMonthLength = Math . min ( shortestMonthLength , monthLength ) ; longestMonthLength = Math . max ( longestMonthLength , monthLength + ( month == leapWeekInMonth ? 1 : 0 ) ) ; } ValueRange alignedWeekOfMonthRange = ValueRange . of ( 1 , shortestMonthLength , longestMonthLength ) ; ValueRange dayOfMonthRange = ValueRange . of ( 1 , shortestMonthLength * 7 , longestMonthLength * 7 ) ; int daysToEpoch = Math . toIntExact ( 0 - yearZeroEnd . plusDays ( 1 ) . toEpochDay ( ) ) ; return new AccountingChronology ( endsOn , end , inLastWeek , division , leapWeekInMonth , yearZeroDifference , alignedWeekOfMonthRange , dayOfMonthRange , daysToEpoch ) ; }
Creates an {@code AccountingChronology} validating the input.
Package private as only meant to be called from the builder.

@param endsOn  The day-of-week a given year ends on.
@param end The  month-end the year is based on.
@param inLastWeek  Whether the year ends in the last week of the month, or nearest the end-of-month.
@param division  How the year is divided.
@param leapWeekInMonth  The month in which the leap-week resides.
@return The created Chronology, not null.
@throws DateTimeException if the chronology cannot be built.