TimeZone timeZone = (TimeZone) expressionFilterCriterion.getParameters().get("timeZone");
Date dayStart = ParametersInterpreter.dayStart((Date) parameter, timeZone);
Predicate preficateForBefore = new ComparePredicate(dayStart, FilterCondition.GREATER_OR_EQUAL, comparator);
Date dayEnd = ParametersInterpreter.dayEnd((Date) parameter, timeZone);
Predicate preficateForAfter = new ComparePredicate(dayEnd, FilterCondition.LESS_OR_EQUAL, comparator);
return new AllPredicate(new Predicate[]{preficateForBefore, preficateForAfter});
} else if (parameter instanceof String) {
boolean caseSensitive = expressionFilterCriterion.isCaseSensitive();
return new AbstractStringPredicate(parameter.toString(), caseSensitive) {
public boolean evaluate(String parameter, String value) {
return value.equals(parameter);
}
};
} else {
return new ComparePredicate(parameter, condition, comparator);
}
}
public Predicate processContains() {
boolean caseSensitive = expressionFilterCriterion.isCaseSensitive();
return new AbstractStringPredicate(parameter.toString(), caseSensitive) {
public boolean evaluate(String parameter, String value) {
return value.contains(parameter);
}
};
}
public Predicate processBegins() {
boolean caseSensitive = expressionFilterCriterion.isCaseSensitive();
return new AbstractStringPredicate(parameter.toString(), caseSensitive) {
public boolean evaluate(String parameter, String value) {
return value.startsWith(parameter);
}
};
}
public Predicate processEnds() {
boolean caseSensitive = expressionFilterCriterion.isCaseSensitive();
return new AbstractStringPredicate(parameter.toString(), caseSensitive) {
public boolean evaluate(String parameter, String value) {
return value.endsWith(parameter);
}
};
}
public Predicate processLess() {
Comparator comparator = getComparatorForParameter(parameter);
Object correctedParameter = parameter;
if (parameter instanceof Date) {
TimeZone timeZone = (TimeZone) expressionFilterCriterion.getParameters().get("timeZone");
correctedParameter = ParametersInterpreter.dayStart((Date) parameter, timeZone);
}
return new ComparePredicate(correctedParameter, condition, comparator);
}
public Predicate processGreater() {
Comparator comparator = getComparatorForParameter(parameter);
Object correctedParameter = parameter;
if (parameter instanceof Date) {
TimeZone timeZone = (TimeZone) expressionFilterCriterion.getParameters().get("timeZone");
correctedParameter = ParametersInterpreter.dayEnd((Date) parameter, timeZone);
}
return new ComparePredicate(correctedParameter, condition, comparator);
}
public Predicate processLessOrEqual() {
Comparator comparator = getComparatorForParameter(parameter);
Object correctedParameter = parameter;
if (parameter instanceof Date) {
TimeZone timeZone = (TimeZone) expressionFilterCriterion.getParameters().get("timeZone");
correctedParameter = ParametersInterpreter.dayEnd((Date) parameter, timeZone);
}
return new ComparePredicate(correctedParameter, condition, comparator);
}
public Predicate processGreaterOrEqual() {
Comparator comparator = getComparatorForParameter(parameter);
Object correctedParameter = parameter;
if (parameter instanceof Date) {
TimeZone timeZone = (TimeZone) expressionFilterCriterion.getParameters().get("timeZone");
correctedParameter = ParametersInterpreter.dayStart((Date) parameter, timeZone);
}
return new ComparePredicate(correctedParameter, condition, comparator);
}
public Predicate processBetween() {
Comparator comparator = getComparatorForParameter(parameter);
Object parameter1 = parameter;
Object parameter2 = expressionFilterCriterion.getArg2();
if (parameter2 == null)
return TruePredicate.getInstance();
if (parameter1 instanceof Date && parameter2 instanceof Date) {
TimeZone timeZone = (TimeZone) expressionFilterCriterion.getParameters().get("timeZone");
parameter1 = ParametersInterpreter.dayStart((Date) parameter1, timeZone);
parameter2 = ParametersInterpreter.dayEnd((Date) parameter1, timeZone);
}
Predicate preficateForBefore = new ComparePredicate(parameter1, FilterCondition.GREATER_OR_EQUAL, comparator);
Predicate preficateForAfter = new ComparePredicate(parameter2, FilterCondition.LESS_OR_EQUAL, comparator);
return new AllPredicate(new Predicate[]{preficateForBefore, preficateForAfter});
}
});
final PropertyLocator propertyLocator = expressionFilterCriterion.getPropertyLocator();
Predicate predicate = new Predicate() {