|
|
|
@ -175,18 +175,20 @@ public abstract class LayeredSpec {
|
|
|
|
|
/**
|
|
|
|
|
* Base class for specs that control the layers to which a category of content should
|
|
|
|
|
* belong.
|
|
|
|
|
*
|
|
|
|
|
* @param <S> the type of {@link IntoLayerSpec} used by this spec
|
|
|
|
|
*/
|
|
|
|
|
public abstract static class IntoLayersSpec implements Serializable {
|
|
|
|
|
public abstract static class IntoLayersSpec<S extends IntoLayerSpec> implements Serializable {
|
|
|
|
|
|
|
|
|
|
private final List<IntoLayerSpec> intoLayers;
|
|
|
|
|
|
|
|
|
|
private final Function<String, IntoLayerSpec> specFactory;
|
|
|
|
|
private final Function<String, S> specFactory;
|
|
|
|
|
|
|
|
|
|
boolean isEmpty() {
|
|
|
|
|
return this.intoLayers.isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IntoLayersSpec(Function<String, IntoLayerSpec> specFactory, IntoLayerSpec... spec) {
|
|
|
|
|
IntoLayersSpec(Function<String, S> specFactory, IntoLayerSpec... spec) {
|
|
|
|
|
this.intoLayers = new ArrayList<>(Arrays.asList(spec));
|
|
|
|
|
this.specFactory = specFactory;
|
|
|
|
|
}
|
|
|
|
@ -195,8 +197,8 @@ public abstract class LayeredSpec {
|
|
|
|
|
this.intoLayers.add(this.specFactory.apply(layer));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void intoLayer(String layer, Action<IntoLayerSpec> action) {
|
|
|
|
|
IntoLayerSpec spec = this.specFactory.apply(layer);
|
|
|
|
|
public void intoLayer(String layer, Action<S> action) {
|
|
|
|
|
S spec = this.specFactory.apply(layer);
|
|
|
|
|
action.execute(spec);
|
|
|
|
|
this.intoLayers.add(spec);
|
|
|
|
|
}
|
|
|
|
@ -330,7 +332,7 @@ public abstract class LayeredSpec {
|
|
|
|
|
* An {@link IntoLayersSpec} that controls the layers to which application classes and
|
|
|
|
|
* resources belong.
|
|
|
|
|
*/
|
|
|
|
|
public static class ApplicationSpec extends IntoLayersSpec {
|
|
|
|
|
public static class ApplicationSpec extends IntoLayersSpec<IntoLayerSpec> {
|
|
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
|
public ApplicationSpec() {
|
|
|
|
@ -364,7 +366,7 @@ public abstract class LayeredSpec {
|
|
|
|
|
/**
|
|
|
|
|
* An {@link IntoLayersSpec} that controls the layers to which dependencies belong.
|
|
|
|
|
*/
|
|
|
|
|
public static class DependenciesSpec extends IntoLayersSpec implements Serializable {
|
|
|
|
|
public static class DependenciesSpec extends IntoLayersSpec<DependenciesIntoLayerSpec> implements Serializable {
|
|
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
|
public DependenciesSpec() {
|
|
|
|
@ -384,10 +386,11 @@ public abstract class LayeredSpec {
|
|
|
|
|
(spec) -> ((DependenciesIntoLayerSpec) spec).asLibrarySelector(LibraryContentFilter::new));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static final class IntoLayerSpecFactory implements Function<String, IntoLayerSpec>, Serializable {
|
|
|
|
|
private static final class IntoLayerSpecFactory
|
|
|
|
|
implements Function<String, DependenciesIntoLayerSpec>, Serializable {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public IntoLayerSpec apply(String layer) {
|
|
|
|
|
public DependenciesIntoLayerSpec apply(String layer) {
|
|
|
|
|
return new DependenciesIntoLayerSpec(layer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|