@@ -74,12 +74,12 @@ private String convertEnum(Class<?> clazz) {
7474 }
7575
7676 private String convertClass (Class <?> clazz ) {
77- var output = new StringBuilder ("interface " ).append (convertName (clazz )).append (" {" );
78- var methodAnnotations = new LinkedHashMap <String , List <String >>();
77+ var out = new StringBuilder ("interface " ).append (convertName (clazz )).append (" {" );
78+ var nonRuntimeAnnotations = new LinkedHashMap <String , List <String >>();
7979
8080 try {
8181 var in = clazz .getClassLoader ().getResourceAsStream (clazz .getName ().replace ("." , "/" ) + ".class" );
82- new ClassReader (in ).accept (new ClassAnnotationExtractor (methodAnnotations ), ClassReader .SKIP_CODE );
82+ new ClassReader (in ).accept (new ClassAnnotationExtractor (nonRuntimeAnnotations ), ClassReader .SKIP_CODE );
8383
8484 var getters = clazz .isRecord () ?
8585 stream (clazz .getMethods ())
@@ -89,7 +89,7 @@ private String convertClass(Class<?> clazz) {
8989 .filter (m -> !isStatic (m .getModifiers ()) && m .getParameterCount () == 0 && isLikeGetter (m .getName ()))
9090 .collect (toMap (m -> toPropertyName (m .getName ()), m -> m , (m1 , m2 ) -> m1 .getReturnType ().isAssignableFrom (m2 .getReturnType ()) ? m2 : m1 ));
9191
92- var methodNamesInOrder = new ArrayList <>(methodAnnotations .keySet ());
92+ var methodNamesInOrder = new ArrayList <>(nonRuntimeAnnotations .keySet ());
9393 methodNamesInOrder .retainAll (getters .keySet ());
9494
9595 var superClassGetters = new ArrayList <>(getters .keySet ());
@@ -98,23 +98,23 @@ private String convertClass(Class<?> clazz) {
9898 methodNamesInOrder .addAll (superClassGetters );
9999
100100 for (String name : methodNamesInOrder ) {
101- processProperty (name , getters .get (name ), output , methodAnnotations );
101+ processProperty (out , name , getters .get (name ), nonRuntimeAnnotations );
102102 }
103103 } catch (Exception e ) {
104104 logger .log (SEVERE , "Failed to convert " + clazz , e );
105105 }
106106
107- if (output .charAt (output .length () - 1 ) == ' ' ) output .setLength (output .length () - 1 );
108- output .append ("}" );
109- var result = output .toString ();
107+ if (out .charAt (out .length () - 1 ) == ' ' ) out .setLength (out .length () - 1 );
108+ out .append ("}" );
109+ var result = out .toString ();
110110 return result .endsWith ("{}" ) ? null : result ;
111111 }
112112
113113 static boolean isLikeGetter (String methodName ) {
114114 return (methodName .startsWith ("get" ) || methodName .startsWith ("is" )) && !methodName .equals ("getClass" );
115115 }
116116
117- private void processProperty (String propertyName , Method method , StringBuilder out , Map <String , List <String >> methodAnnotations ) throws IllegalAccessException , InvocationTargetException , NoSuchMethodException {
117+ private void processProperty (StringBuilder out , String propertyName , Method method , Map <String , List <String >> nonRuntimeAnnotations ) throws IllegalAccessException , InvocationTargetException , NoSuchMethodException {
118118 var fieldBuffer = new StringBuilder ();
119119
120120 if (propertyName == null ) return ;
@@ -139,10 +139,10 @@ else if (annotationName.equals("JsonProperty")) {
139139
140140 fieldBuffer .append (propertyName );
141141
142- if (!methodAnnotations .isEmpty ())
143- for (var annotation : methodAnnotations .getOrDefault (method .getName (), emptyList ()))
144- if (annotation .contains ("Nullable;" ))
145- fieldBuffer . append ( "?" );
142+ if (!nonRuntimeAnnotations .isEmpty ()) {
143+ for (var annotation : nonRuntimeAnnotations .getOrDefault (method .getName (), emptyList ()))
144+ if (annotation .contains ("Nullable;" )) fieldBuffer . append ( "?" );
145+ }
146146
147147 var type = method .getReturnType ();
148148 var genericType = method .getGenericReturnType ();
0 commit comments