org.springframework.data.cassandra.repository.query.BindingContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-data-cassandra Show documentation
Show all versions of spring-data-cassandra Show documentation
Cassandra support for Spring Data
/*
* Copyright 2020-2023 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.Collections;
import java.util.List;
import org.springframework.data.mapping.model.SpELExpressionEvaluator;
import org.springframework.data.repository.query.Parameter;
import org.springframework.data.repository.query.ParameterAccessor;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
* Value object capturing the binding context to provide {@link #getBindingValues() binding values} for queries.
*
* @author Mark Paluch
* @since 1.5
*/
class BindingContext {
private final CassandraParameters parameters;
private final ParameterAccessor parameterAccessor;
private final List bindings;
private final SpELExpressionEvaluator evaluator;
/**
* Create new {@link BindingContext}.
*/
public BindingContext(CassandraParameters parameters, ParameterAccessor parameterAccessor,
List bindings, SpELExpressionEvaluator evaluator) {
this.parameters = parameters;
this.parameterAccessor = parameterAccessor;
this.bindings = bindings;
this.evaluator = evaluator;
}
/**
* @return {@literal true} when list of bindings is not empty.
*/
private boolean hasBindings() {
return !bindings.isEmpty();
}
/**
* Bind values provided by {@link CassandraParameterAccessor} to placeholders in {@link BindingContext} while
* considering potential conversions and parameter types.
*
* @return {@literal null} if given {@code raw} value is empty.
*/
public List