8263668: Update java.time to use instanceof pattern variable

Reviewed-by: lancea, ryadav, naoto, rriggs, dfuchs, scolebourne, chegar
This commit is contained in:
Patrick Concannon 2021-04-22 10:17:43 +00:00
parent a93d911954
commit 28af31db34
34 changed files with 129 additions and 176 deletions

View file

@ -1178,9 +1178,9 @@ public final class OffsetTime
@Override
public long until(Temporal endExclusive, TemporalUnit unit) {
OffsetTime end = OffsetTime.from(endExclusive);
if (unit instanceof ChronoUnit) {
if (unit instanceof ChronoUnit chronoUnit) {
long nanosUntil = end.toEpochNano() - toEpochNano(); // no overflow
switch ((ChronoUnit) unit) {
switch (chronoUnit) {
case NANOS: return nanosUntil;
case MICROS: return nanosUntil / 1000;
case MILLIS: return nanosUntil / 1000_000;
@ -1360,11 +1360,9 @@ public final class OffsetTime
if (this == obj) {
return true;
}
if (obj instanceof OffsetTime) {
OffsetTime other = (OffsetTime) obj;
return time.equals(other.time) && offset.equals(other.offset);
}
return false;
return (obj instanceof OffsetTime other)
&& time.equals(other.time)
&& offset.equals(other.offset);
}
/**