Exemple #1
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;
  }
Exemple #2
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;
  }