| | |
| | | public static Example generateExample(Class clzz, String params) { |
| | | Example example = new Example(clzz); |
| | | try { |
| | | if(StringUtils.isNullOrEmpty(params)){ return example;} |
| | | params = URLDecoder.decode(params, "UTF-8"); |
| | | if (!StringUtils.isNullOrEmpty(params) && params.startsWith("or|")) { |
| | | String[] criteria = params.trim().split(OR_SPLIT); |
| | |
| | | if (method != null && isPropertyOfClass(clzz, propertyName)) { |
| | | List values = new ArrayList<Object>(); |
| | | if (conditionItems.length > 2) { |
| | | //属性到类型 |
| | | Class<?> valutType = new PropertyDescriptor(propertyName, clzz).getPropertyType(); |
| | | for (int index = 2; index < conditionItems.length; index++) { |
| | | values.add(StringUtils.stringToObject4Type(valutType, conditionItems[index])); |
| | | values.add(conditionItems[index]); |
| | | } |
| | | } |
| | | invokeMethod(criteriaOfExample,method,propertyName,values); |