use of org.apache.camel.util.ExpressionToPredicateAdapter in project camel by apache.
the class ExpressionDefinition method createPredicate.
public Predicate createPredicate(CamelContext camelContext) {
if (predicate == null) {
if (getExpressionType() != null) {
predicate = getExpressionType().createPredicate(camelContext);
} else if (getExpressionValue() != null) {
predicate = new ExpressionToPredicateAdapter(getExpressionValue());
} else if (getExpression() != null) {
ObjectHelper.notNull("language", getLanguage());
Language language = camelContext.resolveLanguage(getLanguage());
if (language == null) {
throw new NoSuchLanguageException(getLanguage());
}
String exp = getExpression();
// should be true by default
boolean isTrim = getTrim() == null || getTrim();
// trim if configured to trim
if (exp != null && isTrim) {
exp = exp.trim();
}
// resolve the expression as it may be an external script from the classpath/file etc
exp = ResourceHelper.resolveOptionalExternalScript(camelContext, exp);
predicate = language.createPredicate(exp);
configurePredicate(camelContext, predicate);
}
}
return predicate;
}
Aggregations