Search in sources :

Example 6 with ASTDbPath

use of org.apache.cayenne.exp.parser.ASTDbPath in project cayenne by apache.

the class ExpressionFactory method matchAnyDbExp.

/**
 * 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);
}
Also used : ASTDbPath(org.apache.cayenne.exp.parser.ASTDbPath) ArrayList(java.util.ArrayList) Map(java.util.Map)

Aggregations

ASTDbPath (org.apache.cayenne.exp.parser.ASTDbPath)6 CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)4 CayenneMapEntry (org.apache.cayenne.util.CayenneMapEntry)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Expression (org.apache.cayenne.exp.Expression)2 ExpressionException (org.apache.cayenne.exp.ExpressionException)2 DbAttribute (org.apache.cayenne.map.DbAttribute)2 DbEntity (org.apache.cayenne.map.DbEntity)2 DbJoin (org.apache.cayenne.map.DbJoin)2 DbRelationship (org.apache.cayenne.map.DbRelationship)2 ObjAttribute (org.apache.cayenne.map.ObjAttribute)2 ObjEntity (org.apache.cayenne.map.ObjEntity)2 ObjRelationship (org.apache.cayenne.map.ObjRelationship)2 AttributeProperty (org.apache.cayenne.reflect.AttributeProperty)2 ClassDescriptor (org.apache.cayenne.reflect.ClassDescriptor)2 PropertyVisitor (org.apache.cayenne.reflect.PropertyVisitor)2 ToManyProperty (org.apache.cayenne.reflect.ToManyProperty)2 ToOneProperty (org.apache.cayenne.reflect.ToOneProperty)2