/** * @since 4.0 */ public static Expression and(Collection<Expression> expressions) { return joinExp(Expression.AND, expressions); }
/** * @since 4.0 */ public static Expression or(Collection<Expression> expressions) { return joinExp(Expression.OR, expressions); }
@Override public Expression expressionForKey(Object key) { @SuppressWarnings("unchecked") Map<String, Object> keyMap = (Map<String, Object>) key; List<Expression> clauses = new ArrayList<>(pathMappers.size()); for (Entry<String, Mapper> e : pathMappers.entrySet()) { Object value = keyMap.get(e.getKey()); clauses.add(e.getValue().expressionForKey(value)); } return joinExp(Expression.AND, clauses); }
/** * Creates an expression that matches any of the objects contained in the * <code>objects</code> array */ public static Expression matchAnyExp(Persistent... objects) { if (objects == null || objects.length == 0) { return expFalse(); } List<Expression> pairs = new ArrayList<>(objects.length); for (Persistent object : objects) { pairs.add(matchExp(object)); } return joinExp(Expression.OR, pairs); }
SelectQuery<Persistent> createSelectQuery(ObjEntity entity, List<Expression> expressions) { SelectQuery<Persistent> query = new SelectQuery<>(entity, ExpressionFactory.joinExp(Expression.OR, expressions)); if (entity.equals(rootEntity)) { query.setPrefetchTree(internalQuery.getPrefetchTree()); } return query; }
@Override public Expression expressionForKey(Object key) { // can't match by NULL id if (key == null) { return null; } @SuppressWarnings("unchecked") Map<String, Object> idMap = (Map<String, Object>) key; // can't match by NULL id if (idMap.isEmpty()) { return null; } int len = keyPaths.length; if (len == 1) { return match(keyPaths[0], idMap); } List<Expression> exps = new ArrayList<>(len); for (ASTPath p : keyPaths) { exps.add(match(p, idMap)); } return joinExp(Expression.AND, exps); }
public SelectQuery getSelectQuery() { SelectQuery query = new SelectQuery(queryTarget.getObjEntity()); if (!conditions.isEmpty()) { Expression qualifier = ExpressionFactory.joinExp(Expression.AND, conditions); query.setQualifier(qualifier); } return query; } }
/** * Creates an expression that matches any of the key-values pairs in * <code>map</code>. * <p> * For each pair <code>pairType</code> operator is used to build a binary * expression. Key is considered to be a DB_PATH expression. OR is used to * join pair binary expressions. */ public static Expression matchAnyDbExp(Map<String, ?> map, int pairType) { List<Expression> pairs = new ArrayList<>(map.size()); for (Map.Entry<String, ?> entry : map.entrySet()) { Expression exp = expressionOfType(pairType); exp.setOperand(0, new ASTDbPath(entry.getKey())); exp.setOperand(1, wrapPathOperand(entry.getValue())); pairs.add(exp); } return joinExp(Expression.OR, pairs); }
/** * Creates an expression that matches any of the key-values pairs in the * <code>map</code>. * <p> * For each pair <code>pairType</code> operator is used to build a binary * expression. Key is considered to be a OBJ_PATH expression. OR is used to * join pair binary expressions. */ public static Expression matchAnyExp(Map<String, ?> map, int pairType) { List<Expression> pairs = new ArrayList<>(map.size()); for (Map.Entry<String, ?> entry : map.entrySet()) { Expression exp = expressionOfType(pairType); exp.setOperand(0, new ASTObjPath(entry.getKey())); exp.setOperand(1, wrapPathOperand(entry.getValue())); pairs.add(exp); } return joinExp(Expression.OR, pairs); }
/** * Creates an expression that matches any of the key-values pairs in <code>map</code>. * <p> * For each pair <code>pairType</code> operator is used to build a binary * expression. Key is considered to be a DB_PATH expression. Therefore all keys must * be java.lang.String objects, or ClassCastException is thrown. OR is used to join * pair binary expressions. */ public static Expression matchAnyDbExp(Map map, int pairType) { List pairs = new ArrayList(); Iterator it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); Expression exp = expressionOfType(pairType); exp.setOperand(0, new ASTDbPath(entry.getKey())); exp.setOperand(1, wrapPathOperand(entry.getValue())); pairs.add(exp); } return joinExp(Expression.OR, pairs); }
/** * Creates an expression that matches all key-values pairs in <code>map</code>. * <p> * For each pair <code>pairType</code> operator is used to build a binary * expression. Key is considered to be a DB_PATH expression. Therefore all keys must * be java.lang.String objects, or ClassCastException is thrown. AND is used to join * pair binary expressions. */ public static Expression matchAllDbExp(Map map, int pairType) { List pairs = new ArrayList(); Iterator it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); Expression exp = expressionOfType(pairType); exp.setOperand(0, new ASTDbPath(entry.getKey())); exp.setOperand(1, wrapPathOperand(entry.getValue())); pairs.add(exp); } return joinExp(Expression.AND, pairs); }
/** * Creates an expression that matches all key-values pairs in <code>map</code>. * <p> * For each pair <code>pairType</code> operator is used to build a binary * expression. Key is considered to be a OBJ_PATH expression. Therefore all keys must * be java.lang.String objects, or ClassCastException is thrown. AND is used to join * pair binary expressions. */ public static Expression matchAllExp(Map map, int pairType) { List pairs = new ArrayList(); Iterator it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); Expression exp = expressionOfType(pairType); exp.setOperand(0, new ASTObjPath(entry.getKey())); exp.setOperand(1, wrapPathOperand(entry.getValue())); pairs.add(exp); } return joinExp(Expression.AND, pairs); }
/** * Creates an expression that matches all key-values pairs in * <code>map</code>. * <p> * For each pair <code>pairType</code> operator is used to build a binary * expression. Key is considered to be a DB_PATH expression. AND is used to * join pair binary expressions. */ public static Expression matchAllDbExp(Map<String, ?> map, int pairType) { List<Expression> pairs = new ArrayList<>(map.size()); for (Map.Entry<String, ?> entry : map.entrySet()) { Expression exp = expressionOfType(pairType); exp.setOperand(0, new ASTDbPath(entry.getKey())); exp.setOperand(1, wrapPathOperand(entry.getValue())); pairs.add(exp); } return joinExp(Expression.AND, pairs); }
/** * Creates an expression that matches any of the key-values pairs in the * <code>map</code>. * <p> * For each pair <code>pairType</code> operator is used to build a binary * expression. Key is considered to be a OBJ_PATH expression. Therefore all keys must * be java.lang.String objects, or ClassCastException is thrown. OR is used to join * pair binary expressions. */ public static Expression matchAnyExp(Map map, int pairType) { List pairs = new ArrayList(); Iterator it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); Expression exp = expressionOfType(pairType); exp.setOperand(0, new ASTObjPath(entry.getKey())); exp.setOperand(1, wrapPathOperand(entry.getValue())); pairs.add(exp); } return joinExp(Expression.OR, pairs); }
/** * Creates an expression that matches all key-values pairs in * <code>map</code>. * <p> * For each pair <code>pairType</code> operator is used to build a binary * expression. Key is considered to be a OBJ_PATH expression. AND is used to * join pair binary expressions. */ public static Expression matchAllExp(Map<String, ?> map, int pairType) { List<Expression> pairs = new ArrayList<>(map.size()); for (Map.Entry<String, ?> entry : map.entrySet()) { Expression exp = expressionOfType(pairType); exp.setOperand(0, new ASTObjPath(entry.getKey())); exp.setOperand(1, wrapPathOperand(entry.getValue())); pairs.add(exp); } return joinExp(Expression.AND, pairs); }
return joinExp(Expression.AND, matches);
.joinExp(aggregateClass, childExpressions);
return ExpressionFactory.joinExp(aggregateClass, childExpressions);
query.setQualifier(ExpressionFactory.joinExp(Expression.OR, expressions));
SelectQuery<Object> createSelectQuery(List<Expression> expressions) { SelectQuery<Object> query = new SelectQuery<>(rootEntity, ExpressionFactory.joinExp(Expression.OR, expressions)); query.setFetchingDataRows(internalQuery.isFetchingDataRows()); if (!query.isFetchingDataRows()) { query.setPrefetchTree(internalQuery.getPrefetchTree()); } return query; }