18
18
* Pump pump = ...
19
19
*
20
20
* BeanScope scope = BeanScope.builder()
21
- * .withBean (pump)
21
+ * .bean (pump)
22
22
* .build();
23
23
*
24
24
* CoffeeMaker coffeeMaker = scope.get(CoffeeMaker.class);
@@ -41,7 +41,7 @@ public interface BeanScopeBuilder {
41
41
* // automatically closed via try with resources
42
42
*
43
43
* BeanScope scope = BeanScope.builder()
44
- * .withShutdownHook (true)
44
+ * .shutdownHook (true)
45
45
* .build());
46
46
*
47
47
* // on JVM shutdown the preDestroy lifecycle methods are executed
@@ -50,7 +50,15 @@ public interface BeanScopeBuilder {
50
50
*
51
51
* @return This BeanScopeBuilder
52
52
*/
53
- BeanScopeBuilder withShutdownHook (boolean shutdownHook );
53
+ BeanScopeBuilder shutdownHook (boolean shutdownHook );
54
+
55
+ /**
56
+ * Deprecated - migrate to shutdownHook().
57
+ */
58
+ @ Deprecated
59
+ default BeanScopeBuilder withShutdownHook (boolean shutdownHook ) {
60
+ return shutdownHook (shutdownHook );
61
+ }
54
62
55
63
/**
56
64
* Specify the modules to include in dependency injection.
@@ -63,7 +71,7 @@ public interface BeanScopeBuilder {
63
71
* <pre>{@code
64
72
*
65
73
* BeanScope scope = BeanScope.builder()
66
- * .withModules (new CustomModule())
74
+ * .modules (new CustomModule())
67
75
* .build());
68
76
*
69
77
* CoffeeMaker coffeeMaker = scope.get(CoffeeMaker.class);
@@ -74,7 +82,15 @@ public interface BeanScopeBuilder {
74
82
* @param modules The modules that we want to include in dependency injection.
75
83
* @return This BeanScopeBuilder
76
84
*/
77
- BeanScopeBuilder withModules (Module ... modules );
85
+ BeanScopeBuilder modules (Module ... modules );
86
+
87
+ /**
88
+ * Deprecated - migrate to modules()
89
+ */
90
+ @ Deprecated
91
+ default BeanScopeBuilder withModules (Module ... modules ) {
92
+ return modules (modules );
93
+ }
78
94
79
95
/**
80
96
* Supply a bean to the scope that will be used instead of any
@@ -91,7 +107,7 @@ public interface BeanScopeBuilder {
91
107
* Grinder grinder = ...
92
108
*
93
109
* BeanScope scope = BeanScope.builder()
94
- * .withBeans (pump, grinder)
110
+ * .beans (pump, grinder)
95
111
* .build();
96
112
*
97
113
* CoffeeMaker coffeeMaker = scope.get(CoffeeMaker.class);
@@ -103,7 +119,15 @@ public interface BeanScopeBuilder {
103
119
* for the bean or the interface(s) it implements
104
120
* @return This BeanScopeBuilder
105
121
*/
106
- BeanScopeBuilder withBeans (Object ... beans );
122
+ BeanScopeBuilder beans (Object ... beans );
123
+
124
+ /**
125
+ * Deprecated - migrate to beans().
126
+ */
127
+ @ Deprecated
128
+ default BeanScopeBuilder withBeans (Object ... beans ) {
129
+ return beans (beans );
130
+ }
107
131
108
132
/**
109
133
* Add a supplied bean instance with the given injection type (typically an interface type).
@@ -113,7 +137,7 @@ public interface BeanScopeBuilder {
113
137
* Pump externalDependency = ...
114
138
*
115
139
* try (BeanScope scope = BeanScope.builder()
116
- * .withBean (Pump.class, externalDependency)
140
+ * .bean (Pump.class, externalDependency)
117
141
* .build()) {
118
142
*
119
143
* CoffeeMaker coffeeMaker = scope.get(CoffeeMaker.class);
@@ -128,7 +152,15 @@ public interface BeanScopeBuilder {
128
152
* @param type The dependency injection type this bean is target for
129
153
* @param bean The supplied bean instance to use for injection
130
154
*/
131
- <D > BeanScopeBuilder withBean (Class <D > type , D bean );
155
+ <D > BeanScopeBuilder bean (Class <D > type , D bean );
156
+
157
+ /**
158
+ * Deprecated - migrate to bean().
159
+ */
160
+ @ Deprecated
161
+ default <D > BeanScopeBuilder withBean (Class <D > type , D bean ) {
162
+ return bean (type , bean );
163
+ }
132
164
133
165
/**
134
166
* Add a supplied bean instance with the given name and injection type.
@@ -137,7 +169,15 @@ public interface BeanScopeBuilder {
137
169
* @param type The dependency injection type this bean is target for
138
170
* @param bean The supplied bean instance to use for injection
139
171
*/
140
- <D > BeanScopeBuilder withBean (String name , Class <D > type , D bean );
172
+ <D > BeanScopeBuilder bean (String name , Class <D > type , D bean );
173
+
174
+ /**
175
+ * Deprecated - migrate to bean().
176
+ */
177
+ @ Deprecated
178
+ default <D > BeanScopeBuilder withBean (String name , Class <D > type , D bean ) {
179
+ return bean (name , type , bean );
180
+ }
141
181
142
182
/**
143
183
* Add a supplied bean instance with the given name and generic type.
@@ -146,23 +186,47 @@ public interface BeanScopeBuilder {
146
186
* @param type The dependency injection type this bean is target for
147
187
* @param bean The supplied bean instance to use for injection
148
188
*/
149
- <D > BeanScopeBuilder withBean (String name , Type type , D bean );
189
+ <D > BeanScopeBuilder bean (String name , Type type , D bean );
190
+
191
+ /**
192
+ * Deprecated - migrate to bean().
193
+ */
194
+ @ Deprecated
195
+ default <D > BeanScopeBuilder withBean (String name , Type type , D bean ) {
196
+ return bean (name , type , bean );
197
+ }
150
198
151
199
/**
152
200
* Add a supplied bean instance with a generic type.
153
201
*
154
202
* @param type The dependency injection type this bean is target for
155
203
* @param bean The supplied bean instance to use for injection
156
204
*/
157
- <D > BeanScopeBuilder withBean (Type type , D bean );
205
+ <D > BeanScopeBuilder bean (Type type , D bean );
206
+
207
+ /**
208
+ * Deprecated - migrate to bean().
209
+ */
210
+ @ Deprecated
211
+ default <D > BeanScopeBuilder withBean (Type type , D bean ) {
212
+ return bean (type , bean );
213
+ }
158
214
159
215
/**
160
216
* Use the given BeanScope as the parent. This becomes an additional
161
217
* source of beans that can be wired and accessed in this scope.
162
218
*
163
219
* @param parent The BeanScope that acts as the parent
164
220
*/
165
- BeanScopeBuilder withParent (BeanScope parent );
221
+ BeanScopeBuilder parent (BeanScope parent );
222
+
223
+ /**
224
+ * Deprecated - migrate to parent().
225
+ */
226
+ @ Deprecated
227
+ default BeanScopeBuilder withParent (BeanScope parent ) {
228
+ return parent (parent );
229
+ }
166
230
167
231
/**
168
232
* Use the given BeanScope as the parent additionally specifying if beans
@@ -172,7 +236,15 @@ public interface BeanScopeBuilder {
172
236
* @param parentOverride When false do not add beans that already exist on the parent.
173
237
* When true add beans regardless of whether they exist in the parent scope.
174
238
*/
175
- BeanScopeBuilder withParent (BeanScope parent , boolean parentOverride );
239
+ BeanScopeBuilder parent (BeanScope parent , boolean parentOverride );
240
+
241
+ /**
242
+ * Deprecated - migrate to parent().
243
+ */
244
+ @ Deprecated
245
+ default BeanScopeBuilder withParent (BeanScope parent , boolean parentOverride ) {
246
+ return parent (parent , parentOverride );
247
+ }
176
248
177
249
/**
178
250
* Extend the builder to support testing using mockito with
@@ -206,8 +278,8 @@ interface ForTesting extends BeanScopeBuilder {
206
278
*
207
279
* try (BeanScope scope = BeanScope.builder()
208
280
* .forTesting()
209
- * .withMock (Pump.class)
210
- * .withMock (Grinder.class)
281
+ * .mock (Pump.class)
282
+ * .mock (Grinder.class)
211
283
* .build()) {
212
284
*
213
285
*
@@ -221,7 +293,15 @@ interface ForTesting extends BeanScopeBuilder {
221
293
*
222
294
* }</pre>
223
295
*/
224
- BeanScopeBuilder .ForTesting withMock (Class <?> type );
296
+ BeanScopeBuilder .ForTesting mock (Class <?> type );
297
+
298
+ /**
299
+ * Deprecated - migrate to mock().
300
+ */
301
+ @ Deprecated
302
+ default BeanScopeBuilder .ForTesting withMock (Class <?> type ) {
303
+ return mock (type );
304
+ }
225
305
226
306
/**
227
307
* Register as a Mockito mock with a qualifier name.
@@ -230,16 +310,24 @@ interface ForTesting extends BeanScopeBuilder {
230
310
*
231
311
* try (BeanScope scope = BeanScope.builder()
232
312
* .forTesting()
233
- * .withMock (Store.class, "red")
234
- * .withMock (Store.class, "blue")
313
+ * .mock (Store.class, "red")
314
+ * .mock (Store.class, "blue")
235
315
* .build()) {
236
316
*
237
317
* ...
238
318
* }
239
319
*
240
320
* }</pre>
241
321
*/
242
- BeanScopeBuilder .ForTesting withMock (Class <?> type , String name );
322
+ BeanScopeBuilder .ForTesting mock (Class <?> type , String name );
323
+
324
+ /**
325
+ * Deprecated - migrate to mock().
326
+ */
327
+ @ Deprecated
328
+ default BeanScopeBuilder .ForTesting withMock (Class <?> type , String name ) {
329
+ return mock (type , name );
330
+ }
243
331
244
332
/**
245
333
* Use a mockito mock when injecting this bean type additionally
@@ -249,8 +337,8 @@ interface ForTesting extends BeanScopeBuilder {
249
337
*
250
338
* try (BeanScope scope = BeanScope.builder()
251
339
* .forTesting()
252
- * .withMock (Pump.class)
253
- * .withMock (Grinder.class, grinder -> {
340
+ * .mock (Pump.class)
341
+ * .mock (Grinder.class, grinder -> {
254
342
*
255
343
* // setup the mock
256
344
* when(grinder.grindBeans()).thenReturn("stub response");
@@ -268,7 +356,15 @@ interface ForTesting extends BeanScopeBuilder {
268
356
*
269
357
* }</pre>
270
358
*/
271
- <D > BeanScopeBuilder .ForTesting withMock (Class <D > type , Consumer <D > consumer );
359
+ <D > BeanScopeBuilder .ForTesting mock (Class <D > type , Consumer <D > consumer );
360
+
361
+ /**
362
+ * Deprecated - migrate to mock().
363
+ */
364
+ @ Deprecated
365
+ default <D > BeanScopeBuilder .ForTesting withMock (Class <D > type , Consumer <D > consumer ) {
366
+ return mock (type , consumer );
367
+ }
272
368
273
369
/**
274
370
* Use a mockito spy when injecting this bean type.
@@ -277,7 +373,7 @@ interface ForTesting extends BeanScopeBuilder {
277
373
*
278
374
* try (BeanScope scope = BeanScope.builder()
279
375
* .forTesting()
280
- * .withSpy (Pump.class)
376
+ * .spy (Pump.class)
281
377
* .build()) {
282
378
*
283
379
* // setup spy here ...
@@ -294,7 +390,15 @@ interface ForTesting extends BeanScopeBuilder {
294
390
*
295
391
* }</pre>
296
392
*/
297
- BeanScopeBuilder .ForTesting withSpy (Class <?> type );
393
+ BeanScopeBuilder .ForTesting spy (Class <?> type );
394
+
395
+ /**
396
+ * Deprecated - migrate to spy().
397
+ */
398
+ @ Deprecated
399
+ default BeanScopeBuilder .ForTesting withSpy (Class <?> type ) {
400
+ return spy (type );
401
+ }
298
402
299
403
/**
300
404
* Register a Mockito spy with a qualifier name.
@@ -303,16 +407,24 @@ interface ForTesting extends BeanScopeBuilder {
303
407
*
304
408
* try (BeanScope scope = BeanScope.builder()
305
409
* .forTesting()
306
- * .withSpy (Store.class, "red")
307
- * .withSpy (Store.class, "blue")
410
+ * .spy (Store.class, "red")
411
+ * .spy (Store.class, "blue")
308
412
* .build()) {
309
413
*
310
414
* ...
311
415
* }
312
416
*
313
417
* }</pre>
314
418
*/
315
- BeanScopeBuilder .ForTesting withSpy (Class <?> type , String name );
419
+ BeanScopeBuilder .ForTesting spy (Class <?> type , String name );
420
+
421
+ /**
422
+ * Deprecated - migrate to spy().
423
+ */
424
+ @ Deprecated
425
+ default BeanScopeBuilder .ForTesting withSpy (Class <?> type , String name ) {
426
+ return spy (type , name );
427
+ }
316
428
317
429
/**
318
430
* Use a mockito spy when injecting this bean type additionally
@@ -322,7 +434,7 @@ interface ForTesting extends BeanScopeBuilder {
322
434
*
323
435
* try (BeanScope scope = BeanScope.builder()
324
436
* .forTesting()
325
- * .withSpy (Pump.class, pump -> {
437
+ * .spy (Pump.class, pump -> {
326
438
* // setup the spy
327
439
* doNothing().when(pump).pumpWater();
328
440
* })
@@ -342,7 +454,15 @@ interface ForTesting extends BeanScopeBuilder {
342
454
*
343
455
* }</pre>
344
456
*/
345
- <D > BeanScopeBuilder .ForTesting withSpy (Class <D > type , Consumer <D > consumer );
457
+ <D > BeanScopeBuilder .ForTesting spy (Class <D > type , Consumer <D > consumer );
458
+
459
+ /**
460
+ * Deprecated - migrate to spy().
461
+ */
462
+ @ Deprecated
463
+ default <D > BeanScopeBuilder .ForTesting withSpy (Class <D > type , Consumer <D > consumer ) {
464
+ return spy (type , consumer );
465
+ }
346
466
347
467
}
348
468
}
0 commit comments