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 2017-2021 original 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 io.micronaut.data.runtime.operations.internal.query;
import io.micronaut.aop.InvocationContext;
import io.micronaut.core.annotation.AnnotationMetadata;
import io.micronaut.core.annotation.AnnotationValue;
import io.micronaut.core.annotation.Internal;
import io.micronaut.core.annotation.Nullable;
import io.micronaut.core.beans.BeanWrapper;
import io.micronaut.core.type.Argument;
import io.micronaut.core.util.CollectionUtils;
import io.micronaut.data.model.DataType;
import io.micronaut.data.model.JsonDataType;
import io.micronaut.data.model.PersistentPropertyPath;
import io.micronaut.data.model.runtime.DelegatingQueryParameterBinding;
import io.micronaut.data.model.runtime.QueryParameterBinding;
import io.micronaut.data.model.runtime.RuntimePersistentEntity;
import io.micronaut.data.model.runtime.RuntimePersistentProperty;
import io.micronaut.data.model.runtime.StoredQuery;
import io.micronaut.data.runtime.query.internal.DelegateStoredQuery;
import io.micronaut.inject.annotation.EvaluatedAnnotationValue;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Objects;
/**
* Implementation of {@link BindableParametersStoredQuery}.
*
* @param The entity type
* @param The result type
* @author Denis Stepanov
* @since 3.8.0
*/
@Internal
public class DefaultBindableParametersStoredQuery implements BindableParametersStoredQuery, DelegateStoredQuery {
private final StoredQuery storedQuery;
private final RuntimePersistentEntity runtimePersistentEntity;
/**
* @param storedQuery The stored query
* @param runtimePersistentEntity The persistent entity
*/
public DefaultBindableParametersStoredQuery(StoredQuery storedQuery, RuntimePersistentEntity runtimePersistentEntity) {
this.storedQuery = storedQuery;
this.runtimePersistentEntity = runtimePersistentEntity;
Objects.requireNonNull(storedQuery, "Query cannot be null");
}
@Override
public RuntimePersistentEntity getPersistentEntity() {
return runtimePersistentEntity;
}
@Override
public StoredQuery getStoredQueryDelegate() {
return storedQuery;
}
@Override
public void bindParameters(Binder binder,
@Nullable
InvocationContext, ?> invocationContext,
@Nullable
E entity,
@Nullable
Map previousValues) {
for (QueryParameterBinding queryParameterBinding : storedQuery.getQueryBindings()) {
bindParameter(binder, invocationContext, entity, previousValues, queryParameterBinding);
}
}
protected final void bindParameter(Binder binder,
@Nullable InvocationContext, ?> invocationContext,
@Nullable E entity,
@Nullable Map previousValues,
QueryParameterBinding binding) {
RuntimePersistentEntity persistentEntity = getPersistentEntity();
Class> parameterConverter = binding.getParameterConverterClass();
Object value = binding.getValue();
RuntimePersistentProperty