/*
 * 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 main} modules. */
public final class MainSources {

  public static MainSources of() {
    return new MainSources(JavaRelease.ofRuntime(), SourceUnits.of());
  }

  public MainSources with(JavaRelease release) {
    return new MainSources(release, units);
  }

  public MainSources with(SourceUnits units) {
    return new MainSources(release, units);
  }

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

  private final JavaRelease release;
  private final SourceUnits units;

  public MainSources(JavaRelease release, SourceUnits units) {
    this.release = release;
    this.units = units;
  }

  public JavaRelease release() {
    return release;
  }

  public SourceUnits units() {
    return units;
  }
}

@@ -666,222 +666,381 @@
 t;%0A%0A
-/** Source set of %7B@code main%7D modules. */%0Apublic final class MainSources %7B%0A%0A  public static MainSources of() %7B%0A    return new MainSources(JavaRelease.ofRuntime(), SourceUnits.of());%0A  %7D%0A%0A  public MainSources with(
+import de.sormuras.bach.internal.Factory;%0Aimport de.sormuras.bach.internal.Factory.Kind;%0A%0A/** Source set of %7B@code main%7D modules. */%0Apublic final class MainSources %7B%0A%0A  private final JavaRelease release;%0A  private final SourceUnitMap units;%0A%0A  public MainSources(JavaRelease release, SourceUnitMap units) %7B%0A    this.release = release;%0A    this.units = units;%0A  %7D%0A%0A  public 
 Java
@@ -1054,16 +1054,17 @@
  release
+(
 ) %7B%0A    
@@ -1074,72 +1074,31 @@
 urn 
-new MainSources(release, units);%0A  %7D%0A%0A  public MainSources with(
+release;%0A  %7D%0A%0A  public 
 Sour
@@ -1095,39 +1095,42 @@
 ublic SourceUnit
-s
+Map
  units
+(
 ) %7B%0A    return n
@@ -1131,40 +1131,14 @@
 turn
- new MainSources(release,
  units
-)
 ;%0A  
@@ -1146,351 +1146,582 @@
 %0A%0A  
-public MainSources with(SourceUnit unit) %7B%0A    return with(units.with(unit));%0A  %7D%0A%0A  private final JavaRelease release;%0A  private final SourceUnits
+//%0A  // Configuration API%0A  //%0A%0A  @Factory%0A  public static MainSources of() %7B%0A    return new MainSources(JavaRelease.ofRuntime(), SourceUnitMap.of());%0A  %7D%0A%0A  @Factory(Kind.SETTER)%0A  public MainSources release(JavaRelease release) %7B%0A    return new MainSources(release,
  units
+)
 ;%0A
-%0A  public MainSources(JavaRelease release, SourceUnits units) %7B%0A    this.release = release;%0A    this.units = units;%0A  %7D%0A%0A  public JavaRelease release() %7B%0A    return release;%0A  %7D%0A%0A  public 
+  %7D%0A%0A  @Factory(Kind.SETTER)%0A  public MainSources release(int feature) %7B%0A    return release(JavaRelease.of(feature));%0A  %7D%0A%0A  @Factory(Kind.SETTER)%0A  public MainSources units(SourceUnitMap units) %7B%0A    return new MainSources(release, units);%0A  %7D%0A%0A  @Factory(Kind.OPERATOR)%0A  public MainSources with(
 Sour
@@ -1726,24 +1726,29 @@
 urceUnit
-s u
+... moreU
 nits
-(
 ) %7B%0A    
@@ -1755,20 +1755,43 @@
 return units
+(units.with(moreUnits))
 ;%0A  %7D%0A%7D%0A

Clean up MainSources's API and member order