コード例 #1
0
 private String generateFileContents(GenerateDirective generateDirective) {
   String typeName = generateDirective.getTypeName();
   int lastDot = typeName.lastIndexOf('.');
   String packageName = (lastDot < 0) ? null : typeName.substring(0, lastDot);
   String simpleTypeName = (lastDot < 0) ? typeName : typeName.substring(lastDot + 1);
   StringBuilder result = new StringBuilder();
   if (packageName != null && packageName.length() > 0)
     result.append("package " + packageName + "; ");
   if (simpleTypeName.length() > 0) result.append("public class " + simpleTypeName + " {}");
   return result.toString();
 }
コード例 #2
0
 private String generateFileName(GenerateDirective generateDirective) {
   return generateDirective.getTypeName().replace('.', '/') + ".java";
 }