private void generateMethodParamToHeaderCodeForComplexType( SourcePrinter srcWriter, String builder, String headerName, JType parameterType, String parameterExpression, String parameterCheckExpression) { PropertyInfo[] propertiesInfo = JClassUtils.extractBeanPropertiesInfo(parameterType.isClassOrInterface()); for (PropertyInfo propertyInfo : propertiesInfo) { if (JClassUtils.isSimpleType(propertyInfo.getType())) { generateMethodParamToHeaderCodeForSimpleType( srcWriter, builder, headerName + "." + propertyInfo.getName(), propertyInfo.getType(), parameterExpression + "." + propertyInfo.getReadMethod().getName() + "()", (propertyInfo.getType().isPrimitive() != null ? parameterCheckExpression : parameterCheckExpression + " && " + parameterExpression + "." + propertyInfo.getReadMethod().getName() + "()!=null")); } else { generateMethodParamToHeaderCodeForComplexType( srcWriter, builder, headerName + "." + propertyInfo.getName(), propertyInfo.getType(), parameterExpression + "." + propertyInfo.getReadMethod().getName() + "()", parameterCheckExpression + " && " + parameterExpression + "." + propertyInfo.getReadMethod().getName() + "()!=null"); } } }
private void buildFormStringForComplexType(StringBuilder str, JType parameterType, String value) throws UnsupportedEncodingException { PropertyInfo[] propertiesInfo = JClassUtils.extractBeanPropertiesInfo(parameterType.isClassOrInterface()); boolean first = true; for (PropertyInfo propertyInfo : propertiesInfo) { if (!first) { str.append("&"); } first = false; String parameterName = (StringUtils.isEmpty(value) ? propertyInfo.getName() : value + "." + propertyInfo.getName()); if (JClassUtils.isSimpleType(propertyInfo.getType())) { buildFormStringForSimpleType(str, parameterName); } else { buildFormStringForComplexType(str, propertyInfo.getType(), parameterName); } } }