@@ -60,11 +60,13 @@ public Optional<String> toSourceCode(boolean kt, MvcRoute route, int indent) {
6060 if (attributes .isEmpty ()) {
6161 return Optional .empty ();
6262 } else {
63- return Optional .of (toSourceCode (kt , annotationMap (route .getMethod ()), indent + 6 ));
63+ return Optional .of (
64+ toSourceCode (kt , annotationMap (route .getMethod ()), indent + 6 , new HashMap <>()));
6465 }
6566 }
6667
67- private String toSourceCode (boolean kt , Map <String , Object > attributes , int indent ) {
68+ private String toSourceCode (
69+ boolean kt , Map <String , Object > attributes , int indent , Map <String , Object > defaults ) {
6870 var buffer = new StringBuilder ();
6971 var separator = ",\n " ;
7072 var pairPrefix = "" ;
@@ -82,23 +84,24 @@ private String toSourceCode(boolean kt, Map<String, Object> attributes, int inde
8284 buffer .append (indent (indent + 4 ));
8385 buffer .append (pairPrefix );
8486 buffer .append (CodeBlock .string (e .getKey ())).append (", " );
85- buffer .append (valueToSourceCode (kt , e .getValue (), indent + 4 ));
87+ buffer .append (valueToSourceCode (kt , e .getValue (), indent + 4 , defaults ));
8688 buffer .append (pairSuffix ).append (separator );
8789 }
8890 buffer .setLength (buffer .length () - separator .length ());
8991 buffer .append (")" );
9092 return buffer .toString ();
9193 }
9294
93- private Object valueToSourceCode (boolean kt , Object value , int indent ) {
95+ private Object valueToSourceCode (
96+ boolean kt , Object value , int indent , Map <String , Object > defaults ) {
9497 if (value instanceof String ) {
9598 return CodeBlock .string ((String ) value );
9699 } else if (value instanceof Character ) {
97100 return "'" + value + "'" ;
98101 } else if (value instanceof Map attributeMap ) {
99- return "\n " + indent (indent ) + toSourceCode (kt , attributeMap , indent + 1 );
102+ return "\n " + indent (indent ) + toSourceCode (kt , attributeMap , indent + 1 , defaults );
100103 } else if (value instanceof List list ) {
101- return valueToSourceCode (kt , list , indent );
104+ return valueToSourceCode (kt , list , indent , defaults );
102105 } else if (value instanceof EnumValue enumValue ) {
103106 return enumValue .type + "." + enumValue .value ;
104107 } else if (value instanceof TypeMirror ) {
@@ -118,12 +121,13 @@ private Object valueToSourceCode(boolean kt, Object value, int indent) {
118121 }
119122 }
120123
121- private String valueToSourceCode (boolean kt , List values , int indent ) {
124+ private String valueToSourceCode (
125+ boolean kt , List values , int indent , Map <String , Object > defaults ) {
122126 var buffer = new StringBuilder ();
123127 buffer .append ("java.util.List.of(" );
124128 var separator = ", " ;
125129 for (Object value : values ) {
126- buffer .append (valueToSourceCode (kt , value , indent )).append (separator );
130+ buffer .append (valueToSourceCode (kt , value , indent , defaults )).append (separator );
127131 }
128132 buffer .setLength (buffer .length () - separator .length ());
129133 buffer .append (")" );
@@ -158,7 +162,8 @@ private Map<String, Object> annotationMap(List<? extends AnnotationMirror> annot
158162 String prefix = elem .getSimpleName ().toString ();
159163 // Set all values and then override with present values (fix for JDK 11+)
160164 result .putAll (toMap (annotation .getElementValues (), prefix ));
161- toMap (elements .getElementValuesWithDefaults (annotation ), prefix ).forEach (result ::putIfAbsent );
165+ // toMap(elements.getElementValuesWithDefaults(annotation),
166+ // prefix).forEach(result::putIfAbsent);
162167 }
163168 return result ;
164169 }
0 commit comments