if (node instanceof PredicateNode) {
final PredicateNode<AttributeId> predicateNode = (PredicateNode<AttributeId>) node;
Predicate.Callback predicateCallback = new Predicate.Callback() {
@Override
public void handleValue(MatcherEvalContext<?> ctx, boolean isMatching) {
FilterEvalContext filterEvalContext = ctx.getFilterEvalContext(filterSubscriptionImpl);
predicateNode.handleChildValue(null, isMatching, filterEvalContext);
}
};
predicateIndex.addSubscriptionForPredicate(predicateNode, predicateCallback);
}
}
return new ObjectFilter() {
@Override
public String getEntityTypeName() {
return filterSubscriptionImpl.getEntityTypeName();
}
@Override
public String[] getProjection() {
return filterSubscriptionImpl.getProjection();
}
@Override
public SortField[] getSortFields() {
return filterSubscriptionImpl.getSortFields();
}
@Override
public Comparator<Comparable[]> getComparator() {
return filterSubscriptionImpl.getComparator();
}
@Override
public FilterResult filter(Object instance) {
if (instance == null) {
throw new IllegalArgumentException("argument cannot be null");
}
MatcherEvalContext<AttributeId> matcherEvalContext = startContext(instance, knownTypes);
if (matcherEvalContext != null) {
FilterEvalContext filterEvalContext = matcherEvalContext.getFilterEvalContext(filterSubscriptionImpl);
matcherEvalContext.process(predicateIndex.getRoot());
if (filterEvalContext.getMatchResult()) {
return new FilterResultImpl(instance, filterEvalContext.getProjection(), filterEvalContext.getSortProjection());
}
}
return null;
}