File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed
http-generator-core/src/main/java/io/avaje/http/generator/core Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -202,12 +202,35 @@ public Set<String> importTypes() {
202202 Set <String > set = new LinkedHashSet <>();
203203 for (String type : allTypes ) {
204204 if (!type .startsWith ("java.lang." ) && type .indexOf ('.' ) > -1 ) {
205- set .add (type .replace ("[]" , "" ));
205+ set .add (innerTypesImport ( type ) .replace ("[]" , "" ));
206206 }
207207 }
208208 return set ;
209209 }
210210
211+ public String innerTypesImport (String type ) {
212+
213+ final var parts = type .split ("\\ ." );
214+ var result = "" ;
215+ var foundUpper = false ;
216+
217+ for (var i = 0 ; i < parts .length ; i ++) {
218+ if (!Character .isUpperCase (parts [i ].charAt (0 ))) {
219+ result += parts [i ] + "." ;
220+ } else if (!foundUpper ) {
221+ foundUpper = true ;
222+ result += parts [i ] + (i == parts .length - 1 ? "" : "." );
223+ } else {
224+ break ;
225+ }
226+ }
227+
228+ if (result .endsWith ("." )) {
229+ result = result .substring (0 , result .length () - 1 );
230+ }
231+ return result ;
232+ }
233+
211234 @ Override
212235 public boolean isGeneric () {
213236 return true ;
Original file line number Diff line number Diff line change @@ -76,7 +76,15 @@ public static String shortName(String fullType) {
7676 if (p == -1 ) {
7777 return fullType ;
7878 } else {
79- return fullType .substring (p + 1 );
79+ var result = "" ;
80+ var foundClass = false ;
81+ for (final String part : fullType .split ("\\ ." )) {
82+ if (foundClass || Character .isUpperCase (part .charAt (0 ))) {
83+ foundClass = true ;
84+ result += (result .isEmpty () ? "" : "." ) + part ;
85+ }
86+ }
87+ return result ;
8088 }
8189 }
8290
You can’t perform that action at this time.
0 commit comments