/**
   * Creates a new {@link StringBasedGemfireRepositoryQuery} using the given query {@link String},
   * {@link GemfireQueryMethod} and {@link GemfireTemplate}.
   *
   * @param query will fall back to the query annotated to the given {@link GemfireQueryMethod} if
   *     {@literal null}.
   * @param method must not be {@literal null}.
   * @param template must not be {@literal null}.
   */
  public StringBasedGemfireRepositoryQuery(
      String query, GemfireQueryMethod method, GemfireTemplate template) {
    super(method);

    Assert.notNull(template);

    this.userDefinedQuery |= !StringUtils.hasText(query);
    this.query = new QueryString(StringUtils.hasText(query) ? query : method.getAnnotatedQuery());
    this.method = method;
    this.template = template;

    if (method.isPageQuery() || method.isModifyingQuery()) {
      throw new IllegalStateException(INVALID_QUERY);
    }
  }