9
9
+
10
10
[source,java,indent=0,subs="verbatim,quotes"]
11
11
----
12
- @Component
13
- public class MovieRecommender {
12
+ @Component
13
+ public class MovieRecommender {
14
14
15
- private final String catalog;
15
+ private final String catalog;
16
16
17
- public MovieRecommender(@Value("${catalog.name}") String catalog) {
18
- this.catalog = catalog;
19
- }
20
- }
17
+ public MovieRecommender(@Value("${catalog.name}") String catalog) {
18
+ this.catalog = catalog;
19
+ }
20
+ }
21
21
----
22
22
23
23
Kotlin::
37
37
+
38
38
[source,java,indent=0,subs="verbatim,quotes"]
39
39
----
40
- @Configuration
41
- @PropertySource("classpath:application.properties")
42
- public class AppConfig { }
40
+ @Configuration
41
+ @PropertySource("classpath:application.properties")
42
+ public class AppConfig { }
43
43
----
44
44
45
45
Kotlin::
@@ -56,7 +56,7 @@ And the following `application.properties` file:
56
56
57
57
[source,java,indent=0,subs="verbatim,quotes"]
58
58
----
59
- catalog.name=MovieCatalog
59
+ catalog.name=MovieCatalog
60
60
----
61
61
62
62
In that case, the `catalog` parameter and field will be equal to the `MovieCatalog` value.
@@ -119,15 +119,15 @@ Java::
119
119
+
120
120
[source,java,indent=0,subs="verbatim,quotes"]
121
121
----
122
- @Component
123
- public class MovieRecommender {
122
+ @Component
123
+ public class MovieRecommender {
124
124
125
- private final String catalog;
125
+ private final String catalog;
126
126
127
- public MovieRecommender(@Value("${catalog.name:defaultCatalog}") String catalog) {
128
- this.catalog = catalog;
129
- }
130
- }
127
+ public MovieRecommender(@Value("${catalog.name:defaultCatalog}") String catalog) {
128
+ this.catalog = catalog;
129
+ }
130
+ }
131
131
----
132
132
133
133
Kotlin::
@@ -150,16 +150,16 @@ Java::
150
150
+
151
151
[source,java,indent=0,subs="verbatim,quotes"]
152
152
----
153
- @Configuration
154
- public class AppConfig {
153
+ @Configuration
154
+ public class AppConfig {
155
155
156
- @Bean
157
- public ConversionService conversionService() {
158
- DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService();
159
- conversionService.addConverter(new MyCustomConverter());
160
- return conversionService;
161
- }
162
- }
156
+ @Bean
157
+ public ConversionService conversionService() {
158
+ DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService();
159
+ conversionService.addConverter(new MyCustomConverter());
160
+ return conversionService;
161
+ }
162
+ }
163
163
----
164
164
165
165
Kotlin::
@@ -188,15 +188,15 @@ Java::
188
188
+
189
189
[source,java,indent=0,subs="verbatim,quotes"]
190
190
----
191
- @Component
192
- public class MovieRecommender {
191
+ @Component
192
+ public class MovieRecommender {
193
193
194
- private final String catalog;
194
+ private final String catalog;
195
195
196
- public MovieRecommender(@Value("#{systemProperties['user.catalog'] + 'Catalog' }") String catalog) {
197
- this.catalog = catalog;
198
- }
199
- }
196
+ public MovieRecommender(@Value("#{systemProperties['user.catalog'] + 'Catalog' }") String catalog) {
197
+ this.catalog = catalog;
198
+ }
199
+ }
200
200
----
201
201
202
202
Kotlin::
@@ -217,16 +217,16 @@ Java::
217
217
+
218
218
[source,java,indent=0,subs="verbatim,quotes"]
219
219
----
220
- @Component
221
- public class MovieRecommender {
220
+ @Component
221
+ public class MovieRecommender {
222
222
223
- private final Map<String, Integer> countOfMoviesPerCatalog;
223
+ private final Map<String, Integer> countOfMoviesPerCatalog;
224
224
225
- public MovieRecommender(
226
- @Value("#{{'Thriller': 100, 'Comedy': 300}}") Map<String, Integer> countOfMoviesPerCatalog) {
227
- this.countOfMoviesPerCatalog = countOfMoviesPerCatalog;
228
- }
229
- }
225
+ public MovieRecommender(
226
+ @Value("#{{'Thriller': 100, 'Comedy': 300}}") Map<String, Integer> countOfMoviesPerCatalog) {
227
+ this.countOfMoviesPerCatalog = countOfMoviesPerCatalog;
228
+ }
229
+ }
230
230
----
231
231
232
232
Kotlin::
0 commit comments