Skip to content

Commit

Permalink
Merge pull request eugenp#12381 from thibaultfaure/improvements/BAEL-…
Browse files Browse the repository at this point in the history
…5180-sealed-classes

BAEL-5180 improvement on the article about sealed class
  • Loading branch information
davidmartinezbarua authored Jul 8, 2022
2 parents bc96056 + 33667c6 commit d485928
Show file tree
Hide file tree
Showing 12 changed files with 3 additions and 3 deletions.
1 change: 0 additions & 1 deletion core-java-modules/core-java-15/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ This module contains articles about Java 15.
### Relevant articles

- [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)
1 change: 1 addition & 0 deletions core-java-modules/core-java-17/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
- [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)
- [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)
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ public static void createInstances() {
public void givenCar_whenUsingReflectionAPI_thenSuperClassIsSealed() {
Assertions.assertThat(car.getClass().isSealed()).isEqualTo(false);
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()));
}

@Test
public void givenTruck_whenUsingReflectionAPI_thenSuperClassIsSealed() {
Assertions.assertThat(truck.getClass().isSealed()).isEqualTo(false);
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()));
}

Expand Down

0 comments on commit d485928

Please sign in to comment.