Skip to content

Commit 6667bcd

Browse files
committed
added @ConstructorBinding annotation
1 parent 5975aff commit 6667bcd

4 files changed

Lines changed: 16 additions & 19 deletions

File tree

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
package io.reflectoring.staticdata;
22

3-
public class Quote {
3+
import org.springframework.boot.context.properties.ConstructorBinding;
44

5-
private String text;
6-
private String author;
5+
@ConstructorBinding
6+
class Quote {
77

8-
public Quote() {
8+
private final String text;
9+
private final String author;
10+
11+
public Quote(String text, String author) {
12+
this.text = text;
13+
this.author = author;
914
}
1015

11-
public String getText() {
16+
String getText() {
1217
return text;
1318
}
1419

15-
public String getAuthor() {
20+
String getAuthor() {
1621
return author;
1722
}
1823

19-
public void setText(String text) {
20-
this.text = text;
21-
}
22-
23-
public void setAuthor(String author) {
24-
this.author = author;
25-
}
2624
}

spring-boot/static/src/main/java/io/reflectoring/staticdata/QuotesProperties.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
@Component
99
@ConfigurationProperties("static")
10-
public class QuotesProperties {
10+
class QuotesProperties {
1111

1212
private final List<Quote> quotes;
1313

14-
public QuotesProperties(List<Quote> quotes) {
14+
QuotesProperties(List<Quote> quotes) {
1515
this.quotes = quotes;
1616
}
1717

18-
public List<Quote> getQuotes() {
18+
List<Quote> getQuotes() {
1919
return this.quotes;
2020
}
2121

spring-boot/static/src/main/java/io/reflectoring/staticdata/RandomQuotePrinter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
@Configuration
1212
@EnableScheduling
13-
public class RandomQuotePrinter {
13+
class RandomQuotePrinter {
1414

1515
private static final Logger logger = LoggerFactory.getLogger(RandomQuotePrinter.class);
1616
private final Random random = new Random();
1717
private final QuotesProperties quotesProperties;
1818

19-
public RandomQuotePrinter(QuotesProperties quotesProperties) {
19+
RandomQuotePrinter(QuotesProperties quotesProperties) {
2020
this.quotesProperties = quotesProperties;
2121
}
2222

spring-boot/static/src/main/java/io/reflectoring/staticdata/StaticApplication.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
5-
import org.springframework.boot.context.properties.EnableConfigurationProperties;
65

76
@SpringBootApplication
87
public class StaticApplication {

0 commit comments

Comments
 (0)