mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8263668: Update java.time to use instanceof pattern variable
Reviewed-by: lancea, ryadav, naoto, rriggs, dfuchs, scolebourne, chegar
This commit is contained in:
parent
a93d911954
commit
28af31db34
34 changed files with 129 additions and 176 deletions
|
@ -199,11 +199,11 @@ final class ChronoPeriodImpl
|
|||
*/
|
||||
private ChronoPeriodImpl validateAmount(TemporalAmount amount) {
|
||||
Objects.requireNonNull(amount, "amount");
|
||||
if (amount instanceof ChronoPeriodImpl == false) {
|
||||
if (!(amount instanceof ChronoPeriodImpl)) {
|
||||
throw new DateTimeException("Unable to obtain ChronoPeriod from TemporalAmount: " + amount.getClass());
|
||||
}
|
||||
ChronoPeriodImpl period = (ChronoPeriodImpl) amount;
|
||||
if (chrono.equals(period.getChronology()) == false) {
|
||||
if (!(chrono.equals(period.getChronology()))) {
|
||||
throw new ClassCastException("Chronology mismatch, expected: " + chrono.getId() + ", actual: " + period.getChronology().getId());
|
||||
}
|
||||
return period;
|
||||
|
@ -320,12 +320,9 @@ final class ChronoPeriodImpl
|
|||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof ChronoPeriodImpl) {
|
||||
ChronoPeriodImpl other = (ChronoPeriodImpl) obj;
|
||||
return years == other.years && months == other.months &&
|
||||
days == other.days && chrono.equals(other.chrono);
|
||||
}
|
||||
return false;
|
||||
return (obj instanceof ChronoPeriodImpl other)
|
||||
&& years == other.years && months == other.months
|
||||
&& days == other.days && chrono.equals(other.chrono);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue