|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
169 | 169 | * The {@code equals} method should be used for comparisons.
|
170 | 170 | *
|
171 | 171 | * @implSpec
|
172 |
| - * This abstract class has two implementations, both of which are immutable and thread-safe. |
173 |
| - * One implementation models region-based IDs, the other is {@code ZoneOffset} modelling |
174 |
| - * offset-based IDs. This difference is visible in serialization. |
| 172 | + * This abstract sealed class permits two implementations, both of which are immutable and |
| 173 | + * thread-safe. One implementation models region-based IDs, the other is {@code ZoneOffset} |
| 174 | + * modelling offset-based IDs. This difference is visible in serialization. |
175 | 175 | *
|
176 | 176 | * @since 1.8
|
177 | 177 | */
|
178 | 178 | @jdk.internal.ValueBased
|
179 |
| -public abstract class ZoneId implements Serializable { |
| 179 | +public abstract sealed class ZoneId implements Serializable permits ZoneOffset, ZoneRegion { |
180 | 180 |
|
181 | 181 | /**
|
182 | 182 | * A map of zone overrides to enable the short time-zone names to be used.
|
@@ -471,11 +471,7 @@ public static ZoneId from(TemporalAccessor temporal) {
|
471 | 471 | /**
|
472 | 472 | * Constructor only accessible within the package.
|
473 | 473 | */
|
474 |
| - ZoneId() { |
475 |
| - if (getClass() != ZoneOffset.class && getClass() != ZoneRegion.class) { |
476 |
| - throw new AssertionError("Invalid subclass"); |
477 |
| - } |
478 |
| - } |
| 474 | + ZoneId() {} |
479 | 475 |
|
480 | 476 | //-----------------------------------------------------------------------
|
481 | 477 | /**
|
|
0 commit comments