@@ -279,6 +279,9 @@ private static List<Binding> getFields(Map<String, Type> lookup, Class clazz, bo
279
279
if (Modifier .isTransient (field .getModifiers ())) {
280
280
continue ;
281
281
}
282
+ if (!includingPrivate && !Modifier .isPublic (field .getType ().getModifiers ())) {
283
+ continue ;
284
+ }
282
285
if (includingPrivate ) {
283
286
field .setAccessible (true );
284
287
}
@@ -316,16 +319,7 @@ private static List<Field> getAllFields(Class clazz, boolean includingPrivate) {
316
319
317
320
private static List <Binding > getSetters (Map <String , Type > lookup , Class clazz , boolean includingPrivate ) {
318
321
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 )) {
329
323
if (Modifier .isStatic (method .getModifiers ())) {
330
324
continue ;
331
325
}
@@ -340,6 +334,9 @@ private static List<Binding> getSetters(Map<String, Type> lookup, Class clazz, b
340
334
if (paramTypes .length != 1 ) {
341
335
continue ;
342
336
}
337
+ if (!includingPrivate && !Modifier .isPublic (method .getParameterTypes ()[0 ].getModifiers ())) {
338
+ continue ;
339
+ }
343
340
if (includingPrivate ) {
344
341
method .setAccessible (true );
345
342
}
@@ -358,6 +355,19 @@ private static List<Binding> getSetters(Map<String, Type> lookup, Class clazz, b
358
355
return setters ;
359
356
}
360
357
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
+
361
371
private static String translateSetterName (String methodName ) {
362
372
if (!methodName .startsWith ("set" )) {
363
373
return null ;
@@ -371,7 +381,7 @@ private static String translateSetterName(String methodName) {
371
381
372
382
private static List <Binding > getGetters (Map <String , Type > lookup , Class clazz , boolean includingPrivate ) {
373
383
ArrayList <Binding > getters = new ArrayList <Binding >();
374
- for (Method method : clazz . getMethods ( )) {
384
+ for (Method method : getAllMethods ( clazz , includingPrivate )) {
375
385
if (Modifier .isStatic (method .getModifiers ())) {
376
386
continue ;
377
387
}
0 commit comments