/** * recursively calls {@link RebindUtils#getGetter(JClassType, String)} to * handle "more-dots strings"<br /> * e.g.: address.street returns getAddress().getStreet * * @param beanType * @param fieldName * @return string - chain of getter methods * @throws NotFoundException */ public static String getGetterForMoreDotsInBeanTable(JClassType beanType, String fieldName) throws NotFoundException { JMethod method = null; int dotIndex = fieldName.indexOf("."); if (dotIndex == -1) { method = getGetter(beanType, fieldName); if (method == null) throw new NotFoundException(); return method.getName(); } else { method = getGetter(beanType, fieldName.substring(0, dotIndex)); return method.getName() + "()." + getGetterForMoreDotsInBeanTable(method.getReturnType().isClass(), fieldName .substring(dotIndex + 1)); } }
public static JMethod getGetter(JClassType beanType, String fieldName) throws NotFoundException { JMethod method = null; try { try { method = beanType.getMethod("get" + getterSetterDeterminator(fieldName), new JType[0]); } catch (NotFoundException e) { method = beanType.getMethod("is" + getterSetterDeterminator(fieldName), new JType[0]); } } catch (NotFoundException e) { JClassType superClass = beanType.getSuperclass(); if (superClass != null) { try { method = getGetter(superClass, fieldName); } catch (NotFoundException e1) { JClassType[] interfaces = beanType.getImplementedInterfaces(); if (interfaces != null && interfaces.length > 0) { for (JClassType intrface : interfaces) { method = getGetter(intrface, fieldName); if (method != null) { break; } } } } } } return method; }
JMethod setter = null; try { getter = RebindUtils.getGetter(beanType, field); setter = RebindUtils.getSetter(beanType, field, fieldType); } catch (NotFoundException e) {
fd.getterMethod = getGetter(beanType, fieldName); } catch (NotFoundException e) {
/** * Searches class and all its superclasses for a field. * * @param classType * @param fieldName * @return field or method containing representing the field * @throws NotFoundException */ public static Object getDeclaredDirectField(JClassType classType, String fieldName) throws NotFoundException { JField field = classType.getField(fieldName); JClassType superClass = classType.getSuperclass(); JMethod getter = null; if (field == null) { try { getter = getGetter(classType, fieldName); } catch (Exception e) {} } if (field == null && getter == null && superClass != null) { return getDeclaredDirectField(superClass, fieldName); } if (field != null) { return field; } else if (getter != null) { return getter; } throw new NotFoundException( "Unable to identify a property descriptor (field or method) for classType = " + classType + ", field = " + fieldName); }
JMethod getter = RebindUtils.getGetter(classType, fieldName); if (getter == null) {