Ejemplo n.º 1
0
 /**
  * Returns true if and only if all child queries matches the given object, otherwise returns
  * false.
  *
  * @return True if and only if all child queries matches the given object, otherwise returns false
  */
 @Override
 public boolean matches(O object) {
   for (Query<O> query : super.getSimpleQueries()) {
     if (!query.matches(object)) {
       return false;
     }
   }
   for (Query<O> query : super.getLogicalQueries()) {
     if (!query.matches(object)) {
       return false;
     }
   }
   // No queries evaluated false therefore all evaluated true...
   return true;
 }
Ejemplo n.º 2
0
 /**
  * Creates a new {@link LogicalQuery} initialized to logically connect the supplied set of child
  * queries.
  *
  * @param childQueries The child queries which this {@code LogicalQuery} is to logically connect
  */
 public LogicalQuery(Collection<Query<O>> childQueries) {
   for (Query<O> query : childQueries) {
     if (query instanceof LogicalQuery) {
       logicalQueries.add((LogicalQuery<O>) query);
     } else if (query instanceof SimpleQuery) {
       simpleQueries.add((SimpleQuery<O, ?>) query);
     } else {
       throw new IllegalStateException(
           "Unexpected type of query: "
               + (query == null ? null : query + ", " + query.getClass()));
     }
   }
   this.hasLogicalQueries = !logicalQueries.isEmpty();
   this.hasSimpleQueries = !simpleQueries.isEmpty();
   this.size = childQueries.size();
 }