/*
 * Bach - Java Shell Builder
 * Copyright (C) 2020 Christian Stein
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package de.sormuras.bach.project;

/** A set of sources. */
public final class Sources {

  public static Sources of() {
    return new Sources(MainSources.of(), TestSources.of(), TestPreview.of());
  }

  public Sources with(MainSources main) {
    return new Sources(main, test, preview);
  }

  public Sources with(TestSources test) {
    return new Sources(main, test, preview);
  }

  public Sources with(TestPreview preview) {
    return new Sources(main, test, preview);
  }

  private final MainSources main;
  private final TestSources test;
  private final TestPreview preview;

  public Sources(MainSources main, TestSources test, TestPreview preview) {
    this.main = main;
    this.test = test;
    this.preview = preview;
  }

  public MainSources main() {
    return main;
  }

  public TestSources test() {
    return test;
  }

  public TestPreview preview() {
    return preview;
  }

  public boolean isEmpty() {
    return main().units().isEmpty() && test().units().isEmpty() && preview().units().isEmpty();
  }
}

@@ -666,108 +666,285 @@
 t;%0A%0A
-/** A set of sources. */%0Apublic final class Sources %7B%0A%0A  public static Sources of() %7B%0A    return new
+import de.sormuras.bach.internal.Factory;%0Aimport de.sormuras.bach.internal.Factory.Kind;%0A%0A/** A set of sources. */%0Apublic final class Sources %7B%0A%0A  private final MainSources mainSources;%0A  private final TestSources testSources;%0A  private final TestPreview testPreview;%0A%0A  public
  Sou
@@ -955,29 +955,36 @@
 (MainSources
-.of()
+ mainSources
 , TestSource
@@ -984,21 +984,28 @@
 tSources
-.of()
+ testSources
 , TestPr
@@ -1013,38 +1013,45 @@
 view
-.of());%0A  %7D%0A%0A  public 
+ testPreview) %7B%0A    this.main
 Sources 
 with
@@ -1050,14 +1050,11 @@
 ces 
-with(M
+= m
 ainS
@@ -1063,60 +1063,80 @@
 rces
- main) %7B%0A    return new Sources(main, test, p
+;%0A    this.testSources = testSources;%0A    this.testPreview = testP
 review
-)
 ;%0A  
@@ -1143,32 +1143,36 @@
 %7D%0A%0A  public 
+Main
 Sources 
 with(TestSou
@@ -1163,29 +1163,20 @@
 ces 
-with(Test
+main
 Sources
- test
+(
 ) %7B%0A
@@ -1190,40 +1190,85 @@
 urn 
-new Sources(main, test, preview)
+mainSources;%0A  %7D%0A%0A  public TestSources testSources() %7B%0A    return testSources
 ;%0A  
@@ -1283,21 +1283,8 @@
 lic 
-Sources with(
 Test
@@ -1283,39 +1283,44 @@
 lic TestPreview 
-p
+testP
 review
+(
 ) %7B%0A    return n
@@ -1321,41 +1321,20 @@
 turn
- new Sources(main,
  test
-, p
+P
 review
-)
 ;%0A  
@@ -1342,111 +1342,188 @@
 %0A%0A  
-private final MainSources main;%0A  private final TestSources test;%0A  private final TestPreview preview;%0A
+//%0A  // Configuration API%0A  //%0A%0A  @Factory%0A  public static Sources of() %7B%0A    return new Sources(MainSources.of(), TestSources.of(), TestPreview.of());%0A  %7D%0A%0A  @Factory(Kind.SETTER)
 %0A  p
@@ -1527,32 +1527,44 @@
   public Sources
+ mainSources
 (MainSources mai
@@ -1568,127 +1568,110 @@
 main
-, Test
 Sources
- test, TestPreview preview) %7B%0A    this.main = main;%0A    this.test = test;%0A    this.preview = preview;%0A  %7D%0A
+) %7B%0A    return new Sources(mainSources, testSources, testPreview);%0A  %7D%0A%0A  @Factory(Kind.SETTER)
 %0A  p
@@ -1672,36 +1672,32 @@
 R)%0A  public 
-Main
 Sources 
 main() %7B%0A   
@@ -1688,49 +1688,84 @@
 ces 
-main() %7B%0A    return main;%0A  %7D%0A%0A  public T
+testSources(TestSources testSources) %7B%0A    return new Sources(mainSources, t
 estS
@@ -1774,49 +1774,82 @@
 rces
+,
  test
-() %7B%0A    return test;%0A  %7D%0A%0A  public 
+Preview);%0A  %7D%0A%0A  @Factory(Kind.SETTER)%0A  public Sources testPreview(
 Test
@@ -1856,24 +1856,27 @@
 Preview 
-p
+testP
 review
-(
 ) %7B%0A    
@@ -1886,22 +1886,92 @@
 urn 
-p
+new Sources(mainSources, testSources, testP
 review
+)
 ;%0A  %7D%0A%0A
+  //%0A  // Normal API%0A  //%0A%0A
   pu
@@ -2010,18 +2010,23 @@
 urn main
-()
+Sources
 .units()
@@ -2039,16 +2039,24 @@
 ty()
+%0A       
  && test
 ().u
@@ -2051,18 +2051,23 @@
  && test
-()
+Sources
 .units()
@@ -2080,21 +2080,31 @@
 ty()
- && p
+%0A        && testP
 review
-()
 .uni

Clean up Sources' API and member order