public static boolean isPublicField ( Object obj , String name ) { Class < ? > clazz = obj . getClass ( ) ; try { Field f = clazz . getDeclaredField ( name ) ; return Modifier . isPublic ( f . getModifiers ( ) ) ; } catch ( NoSuchFieldException e ) { return false ; } }
Work out if the specified object has a public field with the name supplied .