class WritableCRCompilationUnit {

  private static final Logger LOGGER = LoggerFactory.getLogger(WritableCRCompilationUnit.class);

  private final List<GeneratorResult.ClassResult> classResults;
  private final String basePackage;

  WritableCRCompilationUnit(List<GeneratorResult.ClassResult> classResults, String basePackage) {
    this.classResults = classResults;
    this.basePackage = basePackage;
  }

  public List<GeneratorResult.ClassResult> getClassResults() {
    return classResults;
  }

  public void writeAllJavaClasses(File basePath) {<FILL_FUNCTION_BODY>}

  private void writeToFile(File file, String str) throws IOException {
    if (file.exists()) {
      LOGGER.warn("File {} already exists, overwriting", file.getAbsolutePath());
    }
    try (FileWriter fileWriter = new FileWriter(file);
        PrintWriter printWriter = new PrintWriter(fileWriter)) {
      printWriter.println(str);
    }
  }

  private static File createFolders(String pkg, File folder) {
    Path destFolder = folder.toPath();
    if (Optional.ofNullable(pkg).isPresent()) {
      for (String p : pkg.split("\\.")) {
        destFolder = destFolder.resolve(p);
      }
    }
    destFolder.toFile().mkdirs();
    return destFolder.toFile();
  }
}

    try {
      createFolders(basePackage, basePath);
      for (GeneratorResult.ClassResult cr : this.classResults) {
        String pkg = cr.getPackageDeclaration()
            .map(NodeWithName::getNameAsString)
            .orElse(null);
        File path = createFolders(pkg, basePath);

        writeToFile(
            path.toPath().resolve(cr.getName() + ".java").toFile(),
            cr.getJavaSource());
      }
    } catch (Exception e) {
      throw new JavaGeneratorException(e);
    }
  
<no_super_class>