public static LogicalOperator createOperator(String operator, int ctxPrecedence)
      throws InvalidQueryException {
    if ("&".equals(operator)) {
      return new AndOperator(ctxPrecedence);
    } else if ("|".equals(operator)) {
      return new OrOperator(ctxPrecedence);
    } else if ("!".equals(operator)) {
      return new NotOperator(ctxPrecedence);
    } else {
      throw new RuntimeException("Invalid Logical Operator Type: " + operator);
    }
  }
Creates a logical operator based on the operator token.

@param operator      string representation of operator
@param ctxPrecedence precedence value of current context

@return a logical operator instance
@throws InvalidQueryException if the operator string is invalid
ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/LogicalOperatorFactory.java