Merge pull request #12381 from thibaultfaure/improvements/BAEL-5180-sealed-classes

BAEL-5180 improvement on the article about sealed class
This commit is contained in:
davidmartinezbarua 2022-07-08 14:34:02 -03:00 committed by GitHub
commit 39296fbf57
12 changed files with 3 additions and 3 deletions

View File

@ -5,4 +5,3 @@ This module contains articles about Java 15.
### Relevant articles ### Relevant articles
- [Hidden Classes in Java 15](https://www.baeldung.com/java-hidden-classes) - [Hidden Classes in Java 15](https://www.baeldung.com/java-hidden-classes)
- [Sealed Classes and Interfaces in Java 15](https://www.baeldung.com/java-sealed-classes-interfaces)

View File

@ -5,3 +5,4 @@
- [Introduction to HexFormat in Java 17](https://www.baeldung.com/java-hexformat) - [Introduction to HexFormat in Java 17](https://www.baeldung.com/java-hexformat)
- [New Features in Java 17](https://www.baeldung.com/java-17-new-features) - [New Features in Java 17](https://www.baeldung.com/java-17-new-features)
- [Random Number Generators in Java 17](https://www.baeldung.com/java-17-random-number-generators) - [Random Number Generators in Java 17](https://www.baeldung.com/java-17-random-number-generators)
- [Sealed Classes and Interfaces in Java 17](https://www.baeldung.com/java-sealed-classes-interfaces)

View File

@ -21,7 +21,7 @@ public class VehicleUnitTest {
public void givenCar_whenUsingReflectionAPI_thenSuperClassIsSealed() { public void givenCar_whenUsingReflectionAPI_thenSuperClassIsSealed() {
Assertions.assertThat(car.getClass().isSealed()).isEqualTo(false); Assertions.assertThat(car.getClass().isSealed()).isEqualTo(false);
Assertions.assertThat(car.getClass().getSuperclass().isSealed()).isEqualTo(true); Assertions.assertThat(car.getClass().getSuperclass().isSealed()).isEqualTo(true);
Assertions.assertThat(car.getClass().getSuperclass().permittedSubclasses()) Assertions.assertThat(car.getClass().getSuperclass().getPermittedSubclasses())
.contains(ClassDesc.of(car.getClass().getCanonicalName())); .contains(ClassDesc.of(car.getClass().getCanonicalName()));
} }
@ -29,7 +29,7 @@ public class VehicleUnitTest {
public void givenTruck_whenUsingReflectionAPI_thenSuperClassIsSealed() { public void givenTruck_whenUsingReflectionAPI_thenSuperClassIsSealed() {
Assertions.assertThat(truck.getClass().isSealed()).isEqualTo(false); Assertions.assertThat(truck.getClass().isSealed()).isEqualTo(false);
Assertions.assertThat(truck.getClass().getSuperclass().isSealed()).isEqualTo(true); Assertions.assertThat(truck.getClass().getSuperclass().isSealed()).isEqualTo(true);
Assertions.assertThat(truck.getClass().getSuperclass().permittedSubclasses()) Assertions.assertThat(truck.getClass().getSuperclass().getPermittedSubclasses())
.contains(ClassDesc.of(truck.getClass().getCanonicalName())); .contains(ClassDesc.of(truck.getClass().getCanonicalName()));
} }