protected static Field findField(String fieldName, Class<?> declaringClass) { try { return declaringClass.getDeclaredField(fieldName); } catch (NoSuchFieldException e) { Class<?> superclass = declaringClass.getSuperclass(); if (superclass != null && superclass != declaringClass) { return findField(fieldName, superclass); } else { return null; } } } }
protected static Field findField(String fieldName, Class<?> declaringClass) { try { return declaringClass.getDeclaredField(fieldName); } catch (NoSuchFieldException e) { Class<?> superclass = declaringClass.getSuperclass(); if (superclass != null && superclass != declaringClass) { return findField(fieldName, superclass); } else { return null; } } } }
/** * Returns false if the getter method has a field of the same name which is transient * @return */ protected boolean isGetterMethodWithFieldVisible(Object method, String fieldName, Class<?> declaringClass) { Field field = findField(fieldName, declaringClass); if (field != null) { int fieldModifiers = field.getModifiers(); if (Modifier.isTransient(fieldModifiers)) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Ignoring getter " + method + " due to transient field called " + fieldName); } return false; } } return true; }
/** * Returns false if the getter method has a field of the same name which is transient * @return */ protected boolean isGetterMethodWithFieldVisible(Object method, String fieldName, Class<?> declaringClass) { Field field = findField(fieldName, declaringClass); if (field != null) { int fieldModifiers = field.getModifiers(); if (Modifier.isTransient(fieldModifiers)) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Ignoring getter " + method + " due to transient field called " + fieldName); } return false; } } return true; }