Skip to content

Commit

Permalink
Issue #493: Refactored nested annotation logic
Browse files Browse the repository at this point in the history
Signed-off-by: Ernesto Posse <eposse.gmail.com>
  • Loading branch information
Ernesto Posse committed Feb 21, 2024
1 parent e72ea24 commit 744c622
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,13 @@ private Map<String, String> getEntityInfo(Object model) {
@Override
public Object caseStructType(StructType object) {

String commentString = "//@top-level false";
boolean nested = true;

EAnnotation annotation = object.getEAnnotation(AnnotationUtil.ZCX_ANNOTATION);
if( annotation != null ) {
String topLevel = annotation.getDetails().get("toplevel");
if( topLevel != null && topLevel.matches("true")) {
commentString = "//@top-level true";
nested = false;
}
}

Expand All @@ -307,6 +307,12 @@ public Object caseStructType(StructType object) {
}
}

String nestedAnnotation = "@nested(FALSE)";
if (nested) {
nestedAnnotation = "@nested(TRUE)";
}
buf.append(String.format("%s%s%n", indentString, nestedAnnotation));

buf.append(String.format("%sstruct %s {%n",
indentString,
object.getName()));
Expand All @@ -315,8 +321,8 @@ public Object caseStructType(StructType object) {
doSwitch(m);
}
popScope();
buf.append(String.format("%s}; %s%n",
indentString, commentString));
buf.append(String.format("%s};%n",
indentString));
conditionalNewLine();
return buf.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,13 @@ public Object caseUnionType(UnionType object) {
@Override
public Object caseStructType(StructType object) {

boolean nested = false;
boolean nested = true;

EAnnotation annotation = object.getEAnnotation(AnnotationUtil.ZCX_ANNOTATION);
if (annotation != null) {
String topLevel = annotation.getDetails().get("toplevel");
if (topLevel != null && topLevel.matches("true")) {
nested = true;
nested = false;
}
}

Expand All @@ -368,7 +368,7 @@ public Object caseStructType(StructType object) {
}
buf.append(String.format("%s%s%n", indentString, extensibility));
String nestedAnnotation = "@nested(FALSE)";
if (!nested) {
if (nested) {
nestedAnnotation = "@nested(TRUE)";
}
buf.append(String.format("%s%s%n", indentString, nestedAnnotation));
Expand Down

0 comments on commit 744c622

Please sign in to comment.