Skip to content
This repository has been archived by the owner on Aug 13, 2020. It is now read-only.

Commit

Permalink
Refactor for review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Rich committed May 5, 2016
1 parent c81bd91 commit c540b1b
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,8 @@ private List<String> writeToBasePackage(final List<TypeSpec> typeSpecs,
typeSpecs.stream()
.forEach(typeSpec -> {
try {
final String basePackageName = configuration.getBasePackageName();

if (!classExists(/*basePackageName*/configuration, typeSpec)) {
JavaFile.builder(basePackageName + packageName, typeSpec)
if (!classExists(configuration, typeSpec)) {
JavaFile.builder(configuration.getBasePackageName() + packageName, typeSpec)
.build()
.writeTo(configuration.getOutputDirectory());
}
Expand All @@ -127,8 +125,12 @@ private List<String> writeToBasePackage(final List<TypeSpec> typeSpecs,

private boolean classExists(final GeneratorConfig configuration, final TypeSpec typeSpec) {
final String relativeJavaSourcePath = configuration.getSourceDirectory().getParent().toString() + JAVA_SRC_PATH;
System.out.println(relativeJavaSourcePath);
final String pathname = relativeJavaSourcePath + configuration.getBasePackageName().replaceAll("\\.", "\\\\") + "\\" + Names.RESOURCE_PACKAGE_NAME + "\\" + typeSpec.name + Names.JAVA_FILENAME_SUFFIX;
final String basePackagePath = configuration.getBasePackageName().replaceAll("\\.", "\\\\");

final String pathname = relativeJavaSourcePath + basePackagePath + "\\"
+ Names.RESOURCE_PACKAGE_NAME + "\\"
+ typeSpec.name + Names.JAVA_FILENAME_SUFFIX;

return new File(pathname).exists();
}

Expand Down

0 comments on commit c540b1b

Please sign in to comment.