public static List<Condition> extractConditions(Class<?> clazz, String prefix, String exclusiveAttrNames) {
    Object entity = null;
    try {
      if (clazz.isInterface()) {
        EntityType entityType = Model.getType(clazz.getName());
        clazz = entityType.getEntityClass();
      }
      entity = clazz.newInstance();
    } catch (Exception e) {
      throw new RuntimeException("[RequestUtil.extractConditions]: error in in initialize " + clazz);
    }
    List<Condition> conditions = CollectUtils.newArrayList();
    Map<String, Object> params = Params.sub(prefix, exclusiveAttrNames);
    for (Map.Entry<String, Object> entry : params.entrySet()) {
      String attr = entry.getKey();
      String strValue = entry.getValue().toString().trim();
      // 过滤空属性
      if (Strings.isNotEmpty(strValue)) {
        try {
          if (RESERVED_NULL && "null".equals(strValue)) {
            conditions.add(new Condition(prefix + "." + attr + " is null"));
          } else {
            Model.getPopulator().populateValue(entity, Model.getType(entity.getClass()), attr, strValue);
            Object setValue = PropertyUtils.getProperty(entity, attr);
            if (null == setValue) continue;
            if (setValue instanceof String) {
              conditions.add(new Condition(prefix + "." + attr + " like :" + attr.replace('.', '_'), "%"
                  + (String) setValue + "%"));
            } else {
              conditions.add(new Condition(prefix + "." + attr + "=:" + attr.replace('.', '_'), setValue));
            }
          }
        } catch (Exception e) {
          logger.error("Error populate entity " + prefix + "'s attribute " + attr, e);
        }
      }
    }
    return conditions;
  }
public static List < Condition > extractConditions ( Class < ? > clazz , String prefix , String exclusiveAttrNames ) { Object entity = null ; try { if ( clazz . isInterface ( ) ) { EntityType entityType = Model . getType ( clazz . getName ( ) ) ; clazz = entityType . getEntityClass ( ) ; } entity = clazz . newInstance ( ) ; } catch ( Exception e ) { throw new RuntimeException ( "[RequestUtil.extractConditions]: error in in initialize " + clazz ) ; } List < Condition > conditions = CollectUtils . newArrayList ( ) ; Map < String , Object > params = Params . sub ( prefix , exclusiveAttrNames ) ; for ( Map . Entry < String , Object > entry : params . entrySet ( ) ) { String attr = entry . getKey ( ) ; String strValue = entry . getValue ( ) . toString ( ) . trim ( ) ; if ( Strings . isNotEmpty ( strValue ) ) { try { if ( RESERVED_NULL && "null" . equals ( strValue ) ) { conditions . add ( new Condition ( prefix + "." + attr + " is null" ) ) ; } else { Model . getPopulator ( ) . populateValue ( entity , Model . getType ( entity . getClass ( ) ) , attr , strValue ) ; Object setValue = PropertyUtils . getProperty ( entity , attr ) ; if ( null == setValue ) continue ; if ( setValue instanceof String ) { conditions . add ( new Condition ( prefix + "." + attr + " like :" + attr . replace ( '.' , '_' ) , "%" + ( String ) setValue + "%" ) ) ; } else { conditions . add ( new Condition ( prefix + "." + attr + "=:" + attr . replace ( '.' , '_' ) , setValue ) ) ; } } } catch ( Exception e ) { logger . error ( "Error populate entity " + prefix + "'s attribute " + attr , e ) ; } } } return conditions ; }
提取中的条件

@param clazz
@param prefix
@param exclusiveAttrNames