/*
 * 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;

/** Source set of {@code test-preview} modules. */
public final class TestPreview {

  public static TestPreview of() {
    return new TestPreview(SourceUnits.of());
  }

  public TestPreview with(SourceUnits units) {
    return new TestPreview(units);
  }

  public TestPreview with(SourceUnit unit) {
    return with(units.with(unit));
  }

  private final SourceUnits units;

  public TestPreview(SourceUnits units) {
    this.units = units;
  }

  public SourceUnits units() {
    return units;
  }
}

@@ -666,205 +666,303 @@
 t;%0A%0A
-/** Source set of %7B@code test-preview%7D modules. */%0Apublic final class TestPreview %7B%0A%0A  public static TestPreview of() %7B%0A    return new TestPreview(SourceUnits.of());%0A  %7D%0A%0A  public TestPreview with(
+import de.sormuras.bach.internal.Factory;%0Aimport de.sormuras.bach.internal.Factory.Kind;%0A%0A/** Source set of %7B@code test-preview%7D modules. */%0Apublic final class TestPreview %7B%0A%0A  private final SourceUnitMap units;%0A%0A  public TestPreview(SourceUnitMap units) %7B%0A    this.units = units;%0A  %7D%0A%0A  public 
 Sour
@@ -959,39 +959,42 @@
 ublic SourceUnit
-s
+Map
  units
+(
 ) %7B%0A    return n
@@ -996,30 +996,13 @@
 urn 
-new TestPreview(
 units
-)
 ;%0A  
@@ -1010,126 +1010,162 @@
 %0A%0A  
-public TestPreview with(SourceUnit unit) %7B%0A    return with(units.with(unit));%0A  %7D%0A%0A  private final SourceUnits units;%0A
+//%0A  // Configuration API%0A  //%0A%0A  @Factory%0A  public static TestPreview of() %7B%0A    return new TestPreview(SourceUnitMap.of());%0A  %7D%0A%0A  @Factory(Kind.SETTER)
 %0A  p
@@ -1173,32 +1173,38 @@
 blic TestPreview
+ units
 (SourceUnits uni
@@ -1194,25 +1194,27 @@
 s(SourceUnit
-s
+Map
  units) %7B%0A  
@@ -1215,34 +1215,45 @@
 ) %7B%0A    
-this.units = 
+return new TestPreview(
 units
+)
 ;%0A  %7D%0A%0A 
@@ -1245,39 +1245,82 @@
 (units);%0A  %7D%0A%0A  
-public 
+@Factory(Kind.OPERATOR)%0A  public TestPreview with(
 SourceUnits unit
@@ -1317,16 +1317,21 @@
 Unit
-s u
+... moreU
 nits
-(
 ) %7B%0A
@@ -1342,20 +1342,43 @@
 return units
+(units.with(moreUnits))
 ;%0A  %7D%0A%7D%0A

Clean up TestPreview's API and member order