@Override
public JSONObject process(ExpressionFilterCriterion criterion) {
try {
JSONObject result = new JSONObject();
result.put(TYPE, CriterionType.EXPRESSION);
result.put(PROPERTY_LOCATOR_EXPRESSION, criterion.getPropertyLocator().getExpression());
JSONObject jsonParameters = new JSONObject();
Map<String, Object> parameters = criterion.getParameters();
for (String parameterName : parameters.keySet()) {
Object parameterValue = criterion.getParameters().get(parameterName);
JSONObject jsonParameterValue = new JSONObject();
ParameterType parameterType;
if (parameterValue instanceof Date) {
parameterType = ParameterType.DATE;
parameterValue = ((Date) parameterValue).getTime();
} else if (isNumberType(parameterValue.getClass())) {
parameterType = ParameterType.NUMBER;
} else if (isBooleanType(parameterValue.getClass())) {
parameterType = ParameterType.BOOLEAN;
} else {
parameterType = ParameterType.TEXT;
parameterValue = parameterValue.toString();
}
jsonParameterValue.put(PARAMETER_TYPE, parameterType);
jsonParameterValue.put(PARAMETER_VALUE, parameterValue);
jsonParameters.put(parameterName, jsonParameterValue);
}
result.put(PARAMETERS, jsonParameters);
result.put(FILTER_CONDITION_NAME, criterion.getCondition().getName());
result.put(INVERSE, criterion.isInverse());