@Override
    public QueryCriteria visit(NotQueryCriteria criteria, List<AttributeReference.Key> arg) {
      QueryCriteria subQuery = criteria.getSubQueryCriteria().accept(this, arg);

      if (subQuery.equals(criteria.getSubQueryCriteria())) {
        return criteria;
      }
      return new NotQueryCriteria(subQuery);
    }
    @Override
    public QueryCriteria visit(NotQueryCriteria criteria, Void arg) {
      QueryCriteria subQuery = criteria.getSubQueryCriteria().accept(this, null);

      if (subQuery.equals(criteria.getSubQueryCriteria())) {
        return criteria;
      }

      return new NotQueryCriteria(subQuery);
    }
Beispiel #3
0
  public static List<ProcessedQueryCriteria> process(
      NotQueryCriteria criteria, QueryCriteriaVisitor<List<ProcessedQueryCriteria>, Void> visitor) {

    List<ProcessedQueryCriteria> childResults =
        criteria.getSubQueryCriteria().accept(visitor, null);

    List<ProcessedQueryCriteria> result = Lists.newArrayListWithCapacity(childResults.size() * 2);

    for (ProcessedQueryCriteria cr : childResults) {
      // if the structure query is not a tautology (=always true)
      // then we add the negation of the given expression with no data query
      if (cr.getStructureQuery() != null
          && !TrueQueryCriteria.getInstance().equals(cr.getStructureQuery())) {
        result.add(new ProcessedQueryCriteria(new NotQueryCriteria(cr.getStructureQuery()), null));
      }
      if (cr.getDataQuery() != null && !TrueQueryCriteria.getInstance().equals(cr.getDataQuery())) {
        result.add(
            new ProcessedQueryCriteria(
                cr.getStructureQuery(), new NotQueryCriteria(cr.getDataQuery())));
      }
    }
    return result;
  }