@@ -279,6 +279,9 @@ private static List<Binding> getFields(Map<String, Type> lookup, Class clazz, bo
279279 if (Modifier .isTransient (field .getModifiers ())) {
280280 continue ;
281281 }
282+ if (!includingPrivate && !Modifier .isPublic (field .getType ().getModifiers ())) {
283+ continue ;
284+ }
282285 if (includingPrivate ) {
283286 field .setAccessible (true );
284287 }
@@ -316,16 +319,7 @@ private static List<Field> getAllFields(Class clazz, boolean includingPrivate) {
316319
317320 private static List <Binding > getSetters (Map <String , Type > lookup , Class clazz , boolean includingPrivate ) {
318321 ArrayList <Binding > setters = new ArrayList <Binding >();
319- List <Method > allMethods = Arrays .asList (clazz .getMethods ());
320- if (includingPrivate ) {
321- allMethods = new ArrayList <Method >();
322- Class current = clazz ;
323- while (current != null ) {
324- allMethods .addAll (Arrays .asList (current .getDeclaredMethods ()));
325- current = current .getSuperclass ();
326- }
327- }
328- for (Method method : allMethods ) {
322+ for (Method method : getAllMethods (clazz , includingPrivate )) {
329323 if (Modifier .isStatic (method .getModifiers ())) {
330324 continue ;
331325 }
@@ -340,6 +334,9 @@ private static List<Binding> getSetters(Map<String, Type> lookup, Class clazz, b
340334 if (paramTypes .length != 1 ) {
341335 continue ;
342336 }
337+ if (!includingPrivate && !Modifier .isPublic (method .getParameterTypes ()[0 ].getModifiers ())) {
338+ continue ;
339+ }
343340 if (includingPrivate ) {
344341 method .setAccessible (true );
345342 }
@@ -358,6 +355,19 @@ private static List<Binding> getSetters(Map<String, Type> lookup, Class clazz, b
358355 return setters ;
359356 }
360357
358+ private static List <Method > getAllMethods (Class clazz , boolean includingPrivate ) {
359+ List <Method > allMethods = Arrays .asList (clazz .getMethods ());
360+ if (includingPrivate ) {
361+ allMethods = new ArrayList <Method >();
362+ Class current = clazz ;
363+ while (current != null ) {
364+ allMethods .addAll (Arrays .asList (current .getDeclaredMethods ()));
365+ current = current .getSuperclass ();
366+ }
367+ }
368+ return allMethods ;
369+ }
370+
361371 private static String translateSetterName (String methodName ) {
362372 if (!methodName .startsWith ("set" )) {
363373 return null ;
@@ -371,7 +381,7 @@ private static String translateSetterName(String methodName) {
371381
372382 private static List <Binding > getGetters (Map <String , Type > lookup , Class clazz , boolean includingPrivate ) {
373383 ArrayList <Binding > getters = new ArrayList <Binding >();
374- for (Method method : clazz . getMethods ( )) {
384+ for (Method method : getAllMethods ( clazz , includingPrivate )) {
375385 if (Modifier .isStatic (method .getModifiers ())) {
376386 continue ;
377387 }
0 commit comments