public void setLike(String fieldName, Object fieldValue) { if (fieldName != null && fieldValue != null) { boolean haveField = false; for (Field field : entityField) { if (fieldName.equals(field.getFieldName()) && field.getWhereRule().equals(Field.RULE_LIKE)) { if (fieldValue.getClass().isAssignableFrom(String.class)) { String value = fieldValue.toString(); if (!StringUtils.isNull(value)) { field.setFieldValue("%" + fieldValue + "%"); haveField = true; break; } } } } if (!haveField) { extendField.add( new Field(fieldName, fieldValue, 1000, Field.WHERE_BY_AND, Field.RULE_LIKE, false)); } } }
private void setWhereFor( String fieldName, Object fieldValue, int fieldType, String whereBy, String whereRule, boolean isPrimaryKey) { boolean haveField = false; for (Field field : entityField) { if (fieldName.equals(field.getFieldName()) && field.getWhereRule().equals(Field.RULE_EQUAL) && fieldValue != null) { field.setFieldValue(fieldValue); field.setFieldType(fieldType); field.setWhereBy(whereBy); field.setWhereRule(whereRule); field.setPrimaryKey(isPrimaryKey); haveField = true; break; } } if (!haveField && fieldValue != null) { if (fieldValue.getClass().isAssignableFrom(String.class)) { String value = fieldValue.toString(); if (!StringUtils.isNull(value)) { entityField.add( new Field(fieldName, fieldValue, fieldType, whereBy, whereRule, isPrimaryKey)); } } else { entityField.add( new Field(fieldName, fieldValue, fieldType, whereBy, whereRule, isPrimaryKey)); } } }