@VisibleForTesting
SearchArgument getSearchArgument(Expression expr) {
if (expr == null) {
return null;
}
Builder builder = SearchArgumentFactory.newBuilder();
boolean beginWithAnd = !(expr.getOpType().equals(OpType.OP_AND) || expr.getOpType().equals(OpType.OP_OR) || expr.getOpType().equals(OpType.OP_NOT));
if (beginWithAnd) {
builder.startAnd();
}
buildSearchArgument(expr, builder);
if (beginWithAnd) {
builder.end();
}
SearchArgument sArg = builder.build();
return sArg;
}