Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Better double brace ?
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbelang committed Jul 15, 2018
1 parent afcea5f commit b095203
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ public boolean apply(@Nullable TypeDeclaration property) {

if ( properties.size() == 0) {

return CodeBlock.builder().addStatement("new $T()", newSpec);
return CodeBlock.of("new $T()", newSpec).toBuilder();
}

CodeBlock.Builder cb = CodeBlock.builder().beginControlFlow("new $T(){", newSpec);
CodeBlock.Builder cb = CodeBlock.builder().beginControlFlow("new $T()", newSpec).beginControlFlow("");
for (TypeDeclaration typeDeclaration : object.properties()) {

cb.addStatement("addAcceptedPattern($T.compile($S))", Pattern.class, EcmaPattern.fromString(typeDeclaration.name()).asJavaPattern());
}
return cb.endControlFlow("}");
return cb.endControlFlow().endControlFlow();
}

protected TypeSpec.Builder buildSpecialMap() {
Expand Down

0 comments on commit b095203

Please sign in to comment.