int dotIndex = property.indexOf("."); if (dotIndex == -1) { return getDeclaredDirectField(classType, property); } else { Object propertyRepresentation = getDeclaredDirectField(classType, property.substring(0, dotIndex)); JClassType propertyType; if (propertyRepresentation instanceof JField) {
/** * 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); }