JField field = beanType.getField(fieldName);
WidgetMapper mf = currField.getAnnotation(WidgetMapper.class); JField widgetField = targetClass.getField(mf.value()); String varName = widgetField.getName() + "Mapper"; EntityFields ef = currField.getAnnotation(EntityFields.class); for (String fieldName : ef.value()) { JField fld = jEntityTarget.getField(fieldName); if (fld == null) { RuntimeException e = new RuntimeException("no such field in entity class '" + jEntityTarget.getName() + "': " + fieldName); fieldsToMap.add(jEntityTarget.getField(fieldName)); String fieldName = fld.getName(); JField targetField = jEntityTarget.getField(fieldName); if (targetField == null) { throw new RuntimeException("The field '" + fieldName + "' does not correspond with a field in the class: " JField targetField = entityType.getField(fieldName); if (targetField == null) { throw new RuntimeException("The field '" + fieldName + "' does not correspond with a field in the class: "
/** * 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); }
protected String toStringExpression(JParameter arg) throws UnableToCompleteException { Attribute attribute = getAnnotation(arg, Attribute.class); if (attribute != null) { if (arg.getType().isClass().getField(attribute.value()) != null && arg.getType().isClass().getField(attribute.value()).isPublic()) { return "(" + arg.getName() + "." + attribute.value() + "+ \"\")"; } String publicGetter = "get" + attribute.value().substring(0, 1).toUpperCase() + attribute.value().substring(1); for (JMethod jMethod : arg.getType().isClass().getMethods()) { if (jMethod.getName().equals(publicGetter)) { return "(" + arg.getName() + "." + publicGetter + "()" + "+ \"\")"; } } getLogger().log(ERROR, "Neither public argument " + attribute.value() + " nor public getter " + publicGetter + " found!"); throw new UnableToCompleteException(); } return toStringExpression(arg.getType(), arg.getName()); }
protected String toStringExpression(JParameter arg) throws UnableToCompleteException { Attribute attribute = getAnnotation(arg, Attribute.class); if (attribute != null) { if (arg.getType().isClass().getField(attribute.value()) != null && arg.getType().isClass().getField(attribute.value()).isPublic()) { return "(" + arg.getName() + "." + attribute.value() + "+ \"\")"; } String publicGetter = "get" + attribute.value().substring(0, 1).toUpperCase() + attribute.value().substring(1); for (JMethod jMethod : arg.getType().isClass().getMethods()) { if (jMethod.getName().equals(publicGetter)) { return "(" + arg.getName() + "." + publicGetter + "()" + "+ \"\")"; } } getLogger().log(ERROR, "Neither public argument " + attribute.value() + " nor public getter " + publicGetter + " found!"); throw new UnableToCompleteException(); } return toStringExpression(arg.getType(), arg.getName()); }
private void generateValidators(SourceWriter w, String propertyName) { JField field = this.beanType.getField(propertyName); if (field != null) { appendTrueValidator(w, field); appendFalseValidator(w, field); appendFutureValidator(w, field); appendMaxValidator(w, field); appendMinValidator(w, field); appendNotNullValidator(w, field); appendNullValidator(w, field); appendPastValidator(w, field); appendPatternValidator(w, field); appendSizeValidator(w, field); } }
private void generateValidators(SourceWriter w, String propertyName) { JField field = this.beanType.getField(propertyName); if (field != null) { appendTrueValidator(w, field); appendFalseValidator(w, field); appendFutureValidator(w, field); appendMaxValidator(w, field); appendMinValidator(w, field); appendNotNullValidator(w, field); appendNullValidator(w, field); appendPastValidator(w, field); appendPatternValidator(w, field); appendSizeValidator(w, field); } }
} else { sw.print("object, "); final JField field = beanType.getField(propertyName); if (field.isPublic()) { sw.print("object.");
} else { sw.print("object, "); JField field = beanType.getField(propertyName); if (field.isPublic()) { sw.print("object.");
} else { sw.print("object, "); JField field = beanType.getField(propertyName); if (field.isPublic()) { sw.print("object.");