@@ -223,18 +223,20 @@ private Layers createLayers() {
223
223
/**
224
224
* Base class for specs that control the layers to which a category of content should
225
225
* belong.
226
+ *
227
+ * @param <S> the type of {@link IntoLayerSpec} used by this spec
226
228
*/
227
- public abstract static class IntoLayersSpec implements Serializable {
229
+ public abstract static class IntoLayersSpec < S extends IntoLayerSpec > implements Serializable {
228
230
229
231
private final List <IntoLayerSpec > intoLayers ;
230
232
231
- private final Function <String , IntoLayerSpec > specFactory ;
233
+ private final Function <String , S > specFactory ;
232
234
233
235
boolean isEmpty () {
234
236
return this .intoLayers .isEmpty ();
235
237
}
236
238
237
- IntoLayersSpec (Function <String , IntoLayerSpec > specFactory , IntoLayerSpec ... spec ) {
239
+ IntoLayersSpec (Function <String , S > specFactory , IntoLayerSpec ... spec ) {
238
240
this .intoLayers = new ArrayList <>(Arrays .asList (spec ));
239
241
this .specFactory = specFactory ;
240
242
}
@@ -247,8 +249,8 @@ public void intoLayer(String layer, Closure<?> closure) {
247
249
intoLayer (layer , Closures .asAction (closure ));
248
250
}
249
251
250
- public void intoLayer (String layer , Action <IntoLayerSpec > action ) {
251
- IntoLayerSpec spec = this .specFactory .apply (layer );
252
+ public void intoLayer (String layer , Action <S > action ) {
253
+ S spec = this .specFactory .apply (layer );
252
254
action .execute (spec );
253
255
this .intoLayers .add (spec );
254
256
}
@@ -384,7 +386,7 @@ ContentSelector<Library> asLibrarySelector(Function<String, ContentFilter<Librar
384
386
* An {@link IntoLayersSpec} that controls the layers to which application classes and
385
387
* resources belong.
386
388
*/
387
- public static class ApplicationSpec extends IntoLayersSpec {
389
+ public static class ApplicationSpec extends IntoLayersSpec < IntoLayerSpec > {
388
390
389
391
/**
390
392
* Creates a new {@code ApplicationSpec} with the given {@code contents}.
@@ -413,7 +415,7 @@ public IntoLayerSpec apply(String layer) {
413
415
/**
414
416
* An {@link IntoLayersSpec} that controls the layers to which dependencies belong.
415
417
*/
416
- public static class DependenciesSpec extends IntoLayersSpec implements Serializable {
418
+ public static class DependenciesSpec extends IntoLayersSpec < DependenciesIntoLayerSpec > implements Serializable {
417
419
418
420
/**
419
421
* Creates a new {@code DependenciesSpec} with the given {@code contents}.
@@ -428,10 +430,11 @@ List<ContentSelector<Library>> asSelectors() {
428
430
(spec ) -> ((DependenciesIntoLayerSpec ) spec ).asLibrarySelector (LibraryContentFilter ::new ));
429
431
}
430
432
431
- private static final class IntoLayerSpecFactory implements Function <String , IntoLayerSpec >, Serializable {
433
+ private static final class IntoLayerSpecFactory
434
+ implements Function <String , DependenciesIntoLayerSpec >, Serializable {
432
435
433
436
@ Override
434
- public IntoLayerSpec apply (String layer ) {
437
+ public DependenciesIntoLayerSpec apply (String layer ) {
435
438
return new DependenciesIntoLayerSpec (layer );
436
439
}
437
440
0 commit comments