Skip to content

Commit 9f95885

Browse files
committed
Update formatting
1 parent 2b32684 commit 9f95885

5 files changed

Lines changed: 12 additions & 22 deletions

File tree

core-java-modules/core-java-15/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
<configuration>
5252
<release>${maven.compiler.release}</release>
5353
<compilerArgs>--enable-preview</compilerArgs>
54-
<source>15</source>
55-
<target>15</target>
54+
<source>14</source>
55+
<target>14</target>
5656
</configuration>
5757
</plugin>
5858
<plugin>

core-java-modules/core-java-15/src/main/java/com/baeldung/whatsnew/records/Person.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
/**
44
* Java record with a header indicating 2 fields.
55
*/
6-
public record Person(String name, int age)
7-
{
6+
public record Person(String name, int age) {
87
/**
98
* Public constructor that does some basic validation.
109
*/
11-
public Person
12-
{
13-
if (age < 0)
14-
{
10+
public Person {
11+
if (age < 0) {
1512
throw new IllegalArgumentException("Age cannot be negative");
1613
}
1714
}

core-java-modules/core-java-15/src/main/java/com/baeldung/whatsnew/sealedclasses/Employee.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
import java.util.Date;
44

5-
public non-sealed class Employee extends Person
6-
{
7-
public Date getHiredDate()
8-
{
5+
public non-sealed class Employee extends Person {
6+
public Date getHiredDate() {
97
return new Date();
108
}
119
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
package com.baeldung.whatsnew.sealedclasses;
22

3-
public final class Manager extends Person
4-
{
3+
public final class Manager extends Person {
54
}

core-java-modules/core-java-15/src/main/java/com/baeldung/whatsnew/sealedclasses/Person.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,19 @@
22

33
import java.util.Date;
44

5-
public sealed class Person permits Employee, Manager
6-
{
5+
public sealed class Person permits Employee, Manager {
76
/**
87
* Demonstration of pattern matching for instanceof
98
*
109
* @param person A Person object
1110
* @return
1211
*/
13-
public static void patternMatchingDemo(Person person)
14-
{
15-
if(person instanceof Employee employee)
16-
{
12+
public static void patternMatchingDemo(Person person) {
13+
if(person instanceof Employee employee) {
1714
Date hiredDate = employee.getHiredDate();
1815
}
1916

20-
if(person instanceof Employee employee && employee.getHiredDate() != null)
21-
{
17+
if(person instanceof Employee employee && employee.getHiredDate() != null) {
2218
Date hiredDate = employee.getHiredDate();
2319
}
2420
}

0 commit comments

Comments
 (0)