Skip to content

Commit e03c1e1

Browse files
committed
Use a Java record for Greeting class
1 parent 9ed2813 commit e03c1e1

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

README.adoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ The `id` field is a unique identifier for the greeting, and `content` is the tex
9090
representation of the greeting.
9191

9292
To model the greeting representation, create a resource representation class. To do so,
93-
provide a plain old Java object with fields, constructors, and accessors for the `id` and
94-
`content` data, as the following listing (from
93+
provide a Java record class for the `id` and `content` data, as the following listing (from
9594
`src/main/java/com/example/restservice/Greeting.java`) shows:
9695

9796
[source,java]
Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
11
package com.example.restservice;
22

3-
public class Greeting {
4-
5-
private final long id;
6-
private final String content;
7-
8-
public Greeting(long id, String content) {
9-
this.id = id;
10-
this.content = content;
11-
}
12-
13-
public long getId() {
14-
return id;
15-
}
16-
17-
public String getContent() {
18-
return content;
19-
}
20-
}
3+
public record Greeting(long id, String content) { }

0 commit comments

Comments
 (0)