code: protected boolean isValidQuery(String query) {
          if (query == null) {
              return true;
          }
          
          return QUERY_PATTERN.matcher(query).matches();
      }
docs: Returns true if the query is null or it's a properly formatted query string.
  @param query Query value to validate.
  @return true if query is valid.