8265746: Update java.time to use instanceof pattern variable (part II)

Reviewed-by: dfuchs, lancea, rriggs, chegar, naoto
This commit is contained in:
Patrick Concannon 2021-04-26 08:32:20 +00:00
parent a85f6cbbaa
commit 45c5da0fd3
20 changed files with 104 additions and 152 deletions

View file

@ -514,17 +514,16 @@ public final class JapaneseDate
//-----------------------------------------------------------------------
@Override
public JapaneseDate with(TemporalField field, long newValue) {
if (field instanceof ChronoField) {
ChronoField f = (ChronoField) field;
if (getLong(f) == newValue) { // getLong() validates for supported fields
if (field instanceof ChronoField chronoField) {
if (getLong(chronoField) == newValue) { // getLong() validates for supported fields
return this;
}
switch (f) {
switch (chronoField) {
case YEAR_OF_ERA:
case YEAR:
case ERA: {
int nvalue = getChronology().range(f).checkValidIntValue(newValue, f);
switch (f) {
int nvalue = getChronology().range(chronoField).checkValidIntValue(newValue, chronoField);
switch (chronoField) {
case YEAR_OF_ERA:
return this.withYear(nvalue);
case YEAR: