Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8280470

Confusing instanceof check in HijrahChronology.range

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P5 P5
    • 19
    • 18, 19
    • core-libs
    • b07

      Parameter type is already known to be 'ChronoField'. There is no sense to use instanceof check.

          public ValueRange range(ChronoField field) {
              checkCalendarInit();
              if (field instanceof ChronoField) {
                  ChronoField f = field;
                  return switch (f) {
                      case DAY_OF_MONTH -> ValueRange.of(1, 1, getMinimumMonthLength(), getMaximumMonthLength());
                      case DAY_OF_YEAR -> ValueRange.of(1, getMaximumDayOfYear());
                      case ALIGNED_WEEK_OF_MONTH -> ValueRange.of(1, 5);
                      case YEAR, YEAR_OF_ERA -> ValueRange.of(getMinimumYear(), getMaximumYear());
                      case ERA -> ValueRange.of(1, 1);
                      default -> field.range();
                  };
              }
              return field.range();
          }

            aturbanov Andrey Turbanov
            aturbanov Andrey Turbanov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: