* @return a new Criteria
*/
public static Criteria create(String left, String operator, String right) {
Object leftPrepared = left;
Object rightPrepared = right;
Path leftPath = null;
Path rightPath = null;
boolean existsCheck = true;
if(isPath(left)){
if(left.charAt(0) == '!'){
existsCheck = false;
left = left.substring(1);
}
leftPath = PathCompiler.compile(left);
if(!leftPath.isDefinite()){
throw new InvalidPathException("the predicate path: " + left + " is not definite");
}
leftPrepared = leftPath;
} else if(isString(left)) {
leftPrepared = left.substring(1, left.length() - 1);
} else if(isPattern(left)){
leftPrepared = compilePattern(left);
}
if(isPath(right)){
if(right.charAt(0) == '!'){
throw new InvalidPathException("Invalid negation! Can only be used for existence check e.g [?(!@.foo)]");
}
rightPath = PathCompiler.compile(right);
if(!rightPath.isDefinite()){
throw new InvalidPathException("the predicate path: " + right + " is not definite");
}
rightPrepared = rightPath;
} else if(isString(right)) {
rightPrepared = right.substring(1, right.length() - 1);