@Override
 public File get() {
   final File file =
       new FileImpl(
           baseDirectoryName()
               + "/"
               + (isInImplPackage() ? "impl/" : "")
               + getFileName()
               + ".java");
   final J item = make(file);
   item.set(getJavaDoc());
   file.add(item);
   file.call(new AutoImports(getCodeGenerator().getDependencyMgr()));
   return file;
 }
예제 #2
0
  @Override
  public Optional<String> transform(Generator cg, File model) {
    final DependencyManager mgr = cg.getDependencyMgr();
    final Optional<String> className = fileToClassName(model.getName());
    Optional<String> packageName = packageName(className.orElse(EMPTY));
    mgr.clearDependencies();

    if (packageName.isPresent()) {
      if (mgr.isIgnored(packageName.get())) {
        packageName = Optional.empty();
      } else {
        mgr.ignorePackage(packageName.get());
      }
    }

    final Optional<String> view =
        Optional.of(
            renderJavadoc(cg, model)
                + renderPackage(model)
                + renderImports(cg, model)
                + renderClasses(cg, model));

    if (packageName.isPresent()) {
      mgr.acceptPackage(packageName.get());
    }

    return view;
  }
예제 #3
0
  private String renderPackage(File file) {
    final Optional<String> name = fileToClassName(file.getName());
    if (name.isPresent()) {
      final Optional<String> pack = packageName(name.get());
      if (pack.isPresent()) {
        return PACKAGE_STRING + pack.get() + scdnl();
      }
    }

    return EMPTY;
  }