@Override
 public String calculateName(JavaResource resource) {
   String fullPath = Packages.fromFileSyntax(resource.getFullyQualifiedName());
   String pkg = calculatePackage(resource);
   String name = fullPath.substring(fullPath.lastIndexOf(pkg) + pkg.length() + 1);
   name = name.substring(0, name.lastIndexOf(".java"));
   return name;
 }
  private JavaResource getJavaResource(
      final DirectoryResource sourceDir, final String relativePath) {
    String path =
        relativePath.trim().endsWith(".java")
            ? relativePath.substring(0, relativePath.lastIndexOf(".java"))
            : relativePath;

    path = Packages.toFileSyntax(path) + ".java";
    JavaResource target = sourceDir.getChildOfType(JavaResource.class, path);
    return target;
  }
  @Override
  public String calculatePackage(JavaResource resource) {
    String pkg = resource.getParent().getFullyQualifiedName();
    pkg = Packages.fromFileSyntax(pkg);

    String result = pkg;
    if (result.contains(getBasePackage())) {
      result = pkg.substring(pkg.lastIndexOf(getBasePackage()));
    }

    return result;
  }
 @Override
 public DirectoryResource getBasePackageResource() {
   return getSourceFolder().getChildDirectory(Packages.toFileSyntax(getBasePackage()));
 }