Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.cassandra.repository.query;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.springframework.data.cassandra.repository.query.ExpressionEvaluatingParameterBinder.BindingContext;
import org.springframework.data.cassandra.repository.query.ExpressionEvaluatingParameterBinder.ParameterBinding;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
/**
* String-based Query abstracting a CQL query with parameter bindings.
*
* @author Mark Paluch
* @since 2.0
*/
class StringBasedQuery {
private final String query;
private final ExpressionEvaluatingParameterBinder parameterBinder;
private final List queryParameterBindings = new ArrayList<>();
/**
* Create a new {@link StringBasedQuery} given {@code query}, {@link ExpressionEvaluatingParameterBinder} and
* {@link CodecRegistry}.
*
* @param query must not be empty.
* @param parameterBinder must not be {@literal null}.
*/
StringBasedQuery(String query, ExpressionEvaluatingParameterBinder parameterBinder) {
Assert.hasText(query, "Query must not be empty");
Assert.notNull(parameterBinder, "ExpressionEvaluatingParameterBinder must not be null");
this.parameterBinder = parameterBinder;
this.query = ParameterBindingParser.INSTANCE.parseAndCollectParameterBindingsFromQueryIntoBindings(query,
this.queryParameterBindings);
}
private ExpressionEvaluatingParameterBinder getParameterBinder() {
return this.parameterBinder;
}
/* (non-Javadoc) */
protected String getQuery() {
return this.query;
}
/**
* Bind the query to actual parameters using {@link CassandraParameterAccessor},
*
* @param parameterAccessor must not be {@literal null}.
* @param queryMethod must not be {@literal null}.
* @return the bound String query containing formatted parameters.
*/
SimpleStatement bindQuery(CassandraParameterAccessor parameterAccessor, CassandraQueryMethod queryMethod) {
Assert.notNull(parameterAccessor, "CassandraParameterAccessor must not be null");
Assert.notNull(queryMethod, "CassandraQueryMethod must not be null");
List