Updates from PR comments
This commit is contained in:
parent
b610c4d304
commit
4164ff6a03
|
@ -51,8 +51,8 @@
|
|||
<configuration>
|
||||
<release>${maven.compiler.release}</release>
|
||||
<compilerArgs>--enable-preview</compilerArgs>
|
||||
<source>14</source>
|
||||
<target>14</target>
|
||||
<source>15</source>
|
||||
<target>15</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
|
|
@ -3,13 +3,15 @@ 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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,10 @@ package com.baeldung.whatsnew.sealedclasses;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
public non-sealed class Employee extends Person {
|
||||
|
||||
public non-sealed class Employee extends Person
|
||||
{
|
||||
public Date getHiredDate()
|
||||
{
|
||||
return new Date();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
package com.baeldung.whatsnew.sealedclasses;
|
||||
|
||||
public final class Manager extends Person {
|
||||
public final class Manager extends Person
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue