use of io.micronaut.data.processor.model.criteria.impl.SourceParameterExpressionImpl in project micronaut-data by micronaut-projects.
the class RepositoryTypeElementVisitor method bindAdditionalParameters.
private void bindAdditionalParameters(MatchContext matchContext, SourcePersistentEntity entity, List<QueryParameterBinding> parameterBinding, ParameterElement[] parameters, Map<String, String> params) {
if (CollectionUtils.isNotEmpty(params)) {
Map<String, DataType> configuredDataTypes = Utils.getConfiguredDataTypes(matchContext.getRepositoryClass());
for (Map.Entry<String, String> param : params.entrySet()) {
ParameterElement parameter = Arrays.stream(parameters).filter(p -> p.stringValue(Parameter.class).orElse(p.getName()).equals(param.getValue())).findFirst().orElse(null);
if (parameter == null) {
throw new MatchFailedException("A @Where(..) definition requires a parameter called [" + param.getValue() + "] which is not present in the method signature.");
}
PersistentPropertyPath propertyPath = entity.getPropertyPath(parameter.getName());
BindingParameter.BindingContext bindingContext = BindingParameter.BindingContext.create().name(param.getKey()).incomingMethodParameterProperty(propertyPath).outgoingQueryParameterProperty(propertyPath);
QueryParameterBinding binding = new SourceParameterExpressionImpl(configuredDataTypes, matchContext.parameters, parameter, false).bind(bindingContext);
parameterBinding.add(binding);
}
}
}
Aggregations