mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8265746: Update java.time to use instanceof pattern variable (part II)
Reviewed-by: dfuchs, lancea, rriggs, chegar, naoto
This commit is contained in:
parent
a85f6cbbaa
commit
45c5da0fd3
20 changed files with 104 additions and 152 deletions
|
@ -199,10 +199,9 @@ final class ChronoPeriodImpl
|
|||
*/
|
||||
private ChronoPeriodImpl validateAmount(TemporalAmount amount) {
|
||||
Objects.requireNonNull(amount, "amount");
|
||||
if (!(amount instanceof ChronoPeriodImpl)) {
|
||||
if (!(amount instanceof ChronoPeriodImpl period)) {
|
||||
throw new DateTimeException("Unable to obtain ChronoPeriod from TemporalAmount: " + amount.getClass());
|
||||
}
|
||||
ChronoPeriodImpl period = (ChronoPeriodImpl) amount;
|
||||
if (!(chrono.equals(period.getChronology()))) {
|
||||
throw new ClassCastException("Chronology mismatch, expected: " + chrono.getId() + ", actual: " + period.getChronology().getId());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue