@@ -1066,18 +1066,41 @@ public static List<ApiDocDict> buildDictionary(ApiConfig config, JavaProjectBuil
10661066 */
10671067 public static String formatFieldTypeGicName (Map <String , String > genericMap , String [] globGicName , String fieldGicName ) {
10681068 String gicName = "" ;
1069+ String fieldGicNameCopy = fieldGicName ;
10691070 String [] gNameArr = DocClassUtil .getSimpleGicName (fieldGicName );
10701071 for (String g : gNameArr ) {
10711072 if (g .length () == 1 ) {
10721073 if (Objects .nonNull (genericMap .get (g ))) {
10731074 gicName = genericMap .get (g );
10741075 }
10751076 if (StringUtil .isNotEmpty (gicName )) {
1076- fieldGicName = fieldGicName . replace ( g , gicName );
1077+ fieldGicNameCopy = replaceGenericParameter ( fieldGicName , g , gicName );
10771078 }
10781079 }
10791080 }
1080- return fieldGicName ;
1081+ return fieldGicNameCopy ;
1082+ }
1083+
1084+ /**
1085+ * Replaces the specified generic parameter in a string with a given type,
1086+ * supporting multi-level generics.
1087+ *
1088+ * @param baseString The base string
1089+ * @param originalGenericParameter The generic parameter to be replaced, like "T"
1090+ * @param replacementType The type to replace the original parameter with, like "User"
1091+ * @return The modified string
1092+ */
1093+ public static String replaceGenericParameter (String baseString , String originalGenericParameter , String replacementType ) {
1094+ StringBuilder result = new StringBuilder (baseString );
1095+ String searchPattern = "<" + originalGenericParameter + ">" ;
1096+ int index = 0 ;
1097+ while ((index = result .indexOf (searchPattern , index )) != -1 ) {
1098+ // Replace the specified generic parameter with the replacement type
1099+ result .replace (index , index + searchPattern .length (), "<" + replacementType + ">" );
1100+ // Update the index to continue searching for the next occurrence
1101+ index += replacementType .length () + 2 ; // +2 for '<' and '>' characters
1102+ }
1103+ return result .toString ();
10811104 }
10821105
10831106 public static String handleConstants (Map <String , String > constantsMap , String value ) {
0 commit comments