From 567a63cb7da115bfa85690dc1c94dcbb67b8e3f5 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Fri, 20 Nov 2020 07:49:50 -0700 Subject: [PATCH] Update formatting --- core-java-modules/core-java-15/pom.xml | 4 ++-- .../java/com/baeldung/whatsnew/records/Person.java | 9 +++------ .../baeldung/whatsnew/sealedclasses/Employee.java | 6 ++---- .../com/baeldung/whatsnew/sealedclasses/Manager.java | 3 +-- .../com/baeldung/whatsnew/sealedclasses/Person.java | 12 ++++-------- 5 files changed, 12 insertions(+), 22 deletions(-) diff --git a/core-java-modules/core-java-15/pom.xml b/core-java-modules/core-java-15/pom.xml index c6f1454078..df8aeafca9 100644 --- a/core-java-modules/core-java-15/pom.xml +++ b/core-java-modules/core-java-15/pom.xml @@ -51,8 +51,8 @@ ${maven.compiler.release} --enable-preview - 15 - 15 + 14 + 14 diff --git a/core-java-modules/core-java-15/src/main/java/com/baeldung/whatsnew/records/Person.java b/core-java-modules/core-java-15/src/main/java/com/baeldung/whatsnew/records/Person.java index 67d3151440..74cf5edf9c 100644 --- a/core-java-modules/core-java-15/src/main/java/com/baeldung/whatsnew/records/Person.java +++ b/core-java-modules/core-java-15/src/main/java/com/baeldung/whatsnew/records/Person.java @@ -3,15 +3,12 @@ package com.baeldung.whatsnew.records; /** * Java record with a header indicating 2 fields. */ -public record Person(String name, int age) -{ +public record Person(String name, int age) { /** * Public constructor that does some basic validation. */ - public Person - { - if (age < 0) - { + public Person { + if (age < 0) { throw new IllegalArgumentException("Age cannot be negative"); } } diff --git a/core-java-modules/core-java-15/src/main/java/com/baeldung/whatsnew/sealedclasses/Employee.java b/core-java-modules/core-java-15/src/main/java/com/baeldung/whatsnew/sealedclasses/Employee.java index 72ef75cb7c..ec85c371b7 100644 --- a/core-java-modules/core-java-15/src/main/java/com/baeldung/whatsnew/sealedclasses/Employee.java +++ b/core-java-modules/core-java-15/src/main/java/com/baeldung/whatsnew/sealedclasses/Employee.java @@ -2,10 +2,8 @@ package com.baeldung.whatsnew.sealedclasses; import java.util.Date; -public non-sealed class Employee extends Person -{ - public Date getHiredDate() - { +public non-sealed class Employee extends Person { + public Date getHiredDate() { return new Date(); } } diff --git a/core-java-modules/core-java-15/src/main/java/com/baeldung/whatsnew/sealedclasses/Manager.java b/core-java-modules/core-java-15/src/main/java/com/baeldung/whatsnew/sealedclasses/Manager.java index 87cbcf2673..79c50b057e 100644 --- a/core-java-modules/core-java-15/src/main/java/com/baeldung/whatsnew/sealedclasses/Manager.java +++ b/core-java-modules/core-java-15/src/main/java/com/baeldung/whatsnew/sealedclasses/Manager.java @@ -1,5 +1,4 @@ package com.baeldung.whatsnew.sealedclasses; -public final class Manager extends Person -{ +public final class Manager extends Person { } diff --git a/core-java-modules/core-java-15/src/main/java/com/baeldung/whatsnew/sealedclasses/Person.java b/core-java-modules/core-java-15/src/main/java/com/baeldung/whatsnew/sealedclasses/Person.java index d4beb64867..2a52bc1a73 100644 --- a/core-java-modules/core-java-15/src/main/java/com/baeldung/whatsnew/sealedclasses/Person.java +++ b/core-java-modules/core-java-15/src/main/java/com/baeldung/whatsnew/sealedclasses/Person.java @@ -2,23 +2,19 @@ package com.baeldung.whatsnew.sealedclasses; import java.util.Date; -public sealed class Person permits Employee, Manager -{ +public sealed class Person permits Employee, Manager { /** * Demonstration of pattern matching for instanceof * * @param person A Person object * @return */ - public static void patternMatchingDemo(Person person) - { - if(person instanceof Employee employee) - { + public static void patternMatchingDemo(Person person) { + if(person instanceof Employee employee) { Date hiredDate = employee.getHiredDate(); } - if(person instanceof Employee employee && employee.getHiredDate() != null) - { + if(person instanceof Employee employee && employee.getHiredDate() != null) { Date hiredDate = employee.getHiredDate(); } }