File tree Expand file tree Collapse file tree
src/main/java/it/aboutbits/springboot/testing/validation/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212
1313import java .lang .reflect .Field ;
1414import java .lang .reflect .InvocationTargetException ;
15+ import java .lang .reflect .Modifier ;
1516import java .util .ArrayList ;
1617import java .util .Arrays ;
1718import java .util .HashSet ;
@@ -367,6 +368,10 @@ private static <T> Set<String> getAllPropertiesOf(T object) {
367368
368369 var properties = new HashSet <String >();
369370 for (var field : clazz .getDeclaredFields ()) {
371+ if (Modifier .isStatic (field .getModifiers ())) {
372+ continue ;
373+ }
374+
370375 properties .add (field .getName ());
371376 }
372377
@@ -410,7 +415,11 @@ private static Field[] getAllFields(Class<?> initialClazz) {
410415
411416 var fields = new ArrayList <Field >();
412417 while (clazz != null ) {
413- fields .addAll (Arrays .asList (clazz .getDeclaredFields ()));
418+ var newFields = Arrays .stream (clazz .getDeclaredFields ())
419+ .filter (field -> !Modifier .isStatic (field .getModifiers ()))
420+ .toList ();
421+
422+ fields .addAll (newFields );
414423 clazz = clazz .getSuperclass ();
415424 }
416425 return fields .toArray (new Field [0 ]);
You can’t perform that action at this time.
0 commit comments