added @ConstructorBinding annotation
This commit is contained in:
@@ -1,26 +1,24 @@
|
||||
package io.reflectoring.staticdata;
|
||||
|
||||
public class Quote {
|
||||
import org.springframework.boot.context.properties.ConstructorBinding;
|
||||
|
||||
private String text;
|
||||
private String author;
|
||||
@ConstructorBinding
|
||||
class Quote {
|
||||
|
||||
public Quote() {
|
||||
private final String text;
|
||||
private final String author;
|
||||
|
||||
public Quote(String text, String author) {
|
||||
this.text = text;
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,15 +7,15 @@ import java.util.List;
|
||||
|
||||
@Component
|
||||
@ConfigurationProperties("static")
|
||||
public class QuotesProperties {
|
||||
class QuotesProperties {
|
||||
|
||||
private final List<Quote> quotes;
|
||||
|
||||
public QuotesProperties(List<Quote> quotes) {
|
||||
QuotesProperties(List<Quote> quotes) {
|
||||
this.quotes = quotes;
|
||||
}
|
||||
|
||||
public List<Quote> getQuotes() {
|
||||
List<Quote> getQuotes() {
|
||||
return this.quotes;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,13 +10,13 @@ import java.util.Random;
|
||||
|
||||
@Configuration
|
||||
@EnableScheduling
|
||||
public class RandomQuotePrinter {
|
||||
class RandomQuotePrinter {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(RandomQuotePrinter.class);
|
||||
private final Random random = new Random();
|
||||
private final QuotesProperties quotesProperties;
|
||||
|
||||
public RandomQuotePrinter(QuotesProperties quotesProperties) {
|
||||
RandomQuotePrinter(QuotesProperties quotesProperties) {
|
||||
this.quotesProperties = quotesProperties;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package io.reflectoring.staticdata;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
|
||||
@SpringBootApplication
|
||||
public class StaticApplication {
|
||||
|
||||
Reference in New Issue
Block a user