5050
5151import java .io .File ;
5252import java .io .IOException ;
53- import java .util .ArrayList ;
54- import java .util .Arrays ;
55- import java .util .HashMap ;
56- import java .util .HashSet ;
57- import java .util .List ;
58- import java .util .Map ;
59- import java .util .Objects ;
60- import java .util .Set ;
53+ import java .util .*;
6154import java .util .concurrent .CopyOnWriteArraySet ;
6255import java .util .stream .Collectors ;
6356
@@ -635,7 +628,7 @@ public static KV getPojoJson(Project project, PsiType psiType) throws JSONExcept
635628 String childPackage = types [1 ].split (">" )[0 ];
636629 if (NormalTypes .noramlTypesPackages .keySet ().contains (childPackage )) {
637630 String [] childTypes = childPackage .split ("\\ ." );
638- listKv .set ("type" , childTypes [childTypes .length - 1 ]);
631+ listKv .set ("type" , Optional . ofNullable ( NormalTypes . java2JsonTypes . get ( childTypes [childTypes .length - 1 ])). orElse ( childTypes [ childTypes . length - 1 ]) );
639632 } else if (NormalTypes .collectTypesPackages .containsKey (childPackage )) {
640633 String [] childTypes = childPackage .split ("\\ ." );
641634 listKv .set ("type" , childTypes [childTypes .length - 1 ]);
@@ -665,7 +658,7 @@ public static KV getPojoJson(Project project, PsiType psiType) throws JSONExcept
665658 String childPackage = types [1 ].split (">" )[0 ];
666659 if (NormalTypes .noramlTypesPackages .keySet ().contains (childPackage )) {
667660 String [] childTypes = childPackage .split ("\\ ." );
668- listKv .set ("type" , childTypes [childTypes .length - 1 ]);
661+ listKv .set ("type" , Optional . ofNullable ( NormalTypes . java2JsonTypes . get ( childTypes [childTypes .length - 1 ])). orElse ( childTypes [ childTypes . length - 1 ]) );
669662 } else if (NormalTypes .collectTypesPackages .containsKey (childPackage )) {
670663 String [] childTypes = childPackage .split ("\\ ." );
671664 listKv .set ("type" , childTypes [childTypes .length - 1 ]);
@@ -835,7 +828,7 @@ public static void getField(PsiField field, Project project, KV kv, String[] chi
835828 // 如果是基本类型
836829 if (type instanceof PsiPrimitiveType ) {
837830 JsonObject jsonObject = new JsonObject ();
838- jsonObject .addProperty ("type" , type .getPresentableText ());
831+ jsonObject .addProperty ("type" , Optional . ofNullable ( NormalTypes . java2JsonTypes . get ( type .getPresentableText ())). orElse ( type . getPresentableText () ));
839832 if (!Strings .isNullOrEmpty (remark )) {
840833 jsonObject .addProperty ("description" , remark );
841834 }
@@ -848,7 +841,7 @@ public static void getField(PsiField field, Project project, KV kv, String[] chi
848841 //normal Type
849842 if (NormalTypes .isNormalType (fieldTypeName )) {
850843 JsonObject jsonObject = new JsonObject ();
851- jsonObject .addProperty ("type" , fieldTypeName );
844+ jsonObject .addProperty ("type" , Optional . ofNullable ( NormalTypes . java2JsonTypes . get ( fieldTypeName )). orElse ( fieldTypeName ) );
852845 if (!Strings .isNullOrEmpty (remark )) {
853846 jsonObject .addProperty ("description" , remark );
854847 }
@@ -882,7 +875,7 @@ public static void getField(PsiField field, Project project, KV kv, String[] chi
882875 } else if (NormalTypes .isNormalType (child ) || NormalTypes .noramlTypesPackages .containsKey (child )) {
883876 KV kv1 = new KV ();
884877 PsiClass psiClassChild = JavaPsiFacade .getInstance (project ).findClass (child , GlobalSearchScope .allScope (project ));
885- kv1 .set (KV .by ("type" , psiClassChild .getName ()));
878+ kv1 .set (KV .by ("type" , Optional . ofNullable ( NormalTypes . java2JsonTypes . get ( psiClassChild .getName ())). orElse ( psiClassChild . getName () )));
886879 kv .set (name , kv1 );
887880 kv1 .set (KV .by ("description" , (Strings .isNullOrEmpty (remark ) ? name : remark )));
888881 kv1 .set (KV .by ("mock" , NormalTypes .formatMockType (child
@@ -917,7 +910,7 @@ public static void getField(PsiField field, Project project, KV kv, String[] chi
917910 kvlist .set ("description" , remark );
918911 }
919912 } else if (NormalTypes .isNormalType (deepTypeName )) {
920- kvlist .set ("type" , deepTypeName );
913+ kvlist .set ("type" , Optional . ofNullable ( NormalTypes . java2JsonTypes . get ( deepTypeName )). orElse ( deepTypeName ) );
921914 if (!Strings .isNullOrEmpty (remark )) {
922915 kvlist .set ("description" , remark );
923916 }
@@ -1001,7 +994,7 @@ public static void getField(PsiField field, Project project, KV kv, String[] chi
1001994 public static void getCollect (KV kv , String classTypeName , String remark , PsiClass psiClass , Project project , String name , Set <String > pNames , String [] childType , Integer index ) {
1002995 KV kvlist = new KV ();
1003996 if (NormalTypes .isNormalType (classTypeName ) || NormalTypes .collectTypes .containsKey (classTypeName )) {
1004- kvlist .set ("type" , classTypeName );
997+ kvlist .set ("type" , Optional . ofNullable ( NormalTypes . java2JsonTypes . get ( classTypeName )). orElse ( classTypeName ) );
1005998 if (!Strings .isNullOrEmpty (remark )) {
1006999 kvlist .set ("description" , remark );
10071000 }
0 commit comments