Search in sources :

Example 1 with CastUtils

use of org.springframework.data.util.CastUtils in project spring-data-commons by spring-projects.

the class QuerydslPredicateArgumentResolverSupport method getPredicate.

Predicate getPredicate(MethodParameter parameter, MultiValueMap<String, String> queryParameters) {
    MergedAnnotations annotations = MergedAnnotations.from(parameter.getParameter());
    MergedAnnotation<QuerydslPredicate> predicateAnnotation = annotations.get(QuerydslPredicate.class);
    TypeInformation<?> domainType = extractTypeInfo(parameter, predicateAnnotation).getRequiredActualType();
    Optional<Class<? extends QuerydslBinderCustomizer<?>>> bindingsAnnotation = // 
    predicateAnnotation.getValue("bindings").map(CastUtils::cast);
    QuerydslBindings bindings = // 
    bindingsAnnotation.map(// 
    it -> bindingsFactory.createBindingsFor(domainType, it)).orElseGet(() -> bindingsFactory.createBindingsFor(domainType));
    return predicateBuilder.getPredicate(domainType, queryParameters, bindings);
}
Also used : HandlerMethodArgumentResolver(org.springframework.web.method.support.HandlerMethodArgumentResolver) QuerydslBinderCustomizer(org.springframework.data.querydsl.binding.QuerydslBinderCustomizer) MultiValueMap(org.springframework.util.MultiValueMap) TypeInformation(org.springframework.data.util.TypeInformation) MergedAnnotation(org.springframework.core.annotation.MergedAnnotation) QuerydslPredicateBuilder(org.springframework.data.querydsl.binding.QuerydslPredicateBuilder) ClassTypeInformation(org.springframework.data.util.ClassTypeInformation) MergedAnnotations(org.springframework.core.annotation.MergedAnnotations) MethodParameter(org.springframework.core.MethodParameter) Optional(java.util.Optional) Nullable(org.springframework.lang.Nullable) ResolvableType(org.springframework.core.ResolvableType) QuerydslBindingsFactory(org.springframework.data.querydsl.binding.QuerydslBindingsFactory) Predicate(com.querydsl.core.types.Predicate) Method(java.lang.reflect.Method) ConversionService(org.springframework.core.convert.ConversionService) QuerydslPredicate(org.springframework.data.querydsl.binding.QuerydslPredicate) QuerydslBindings(org.springframework.data.querydsl.binding.QuerydslBindings) CastUtils(org.springframework.data.util.CastUtils) Assert(org.springframework.util.Assert) QuerydslBinderCustomizer(org.springframework.data.querydsl.binding.QuerydslBinderCustomizer) QuerydslPredicate(org.springframework.data.querydsl.binding.QuerydslPredicate) QuerydslBindings(org.springframework.data.querydsl.binding.QuerydslBindings) MergedAnnotations(org.springframework.core.annotation.MergedAnnotations) CastUtils(org.springframework.data.util.CastUtils)

Aggregations

Predicate (com.querydsl.core.types.Predicate)1 Method (java.lang.reflect.Method)1 Optional (java.util.Optional)1 MethodParameter (org.springframework.core.MethodParameter)1 ResolvableType (org.springframework.core.ResolvableType)1 MergedAnnotation (org.springframework.core.annotation.MergedAnnotation)1 MergedAnnotations (org.springframework.core.annotation.MergedAnnotations)1 ConversionService (org.springframework.core.convert.ConversionService)1 QuerydslBinderCustomizer (org.springframework.data.querydsl.binding.QuerydslBinderCustomizer)1 QuerydslBindings (org.springframework.data.querydsl.binding.QuerydslBindings)1 QuerydslBindingsFactory (org.springframework.data.querydsl.binding.QuerydslBindingsFactory)1 QuerydslPredicate (org.springframework.data.querydsl.binding.QuerydslPredicate)1 QuerydslPredicateBuilder (org.springframework.data.querydsl.binding.QuerydslPredicateBuilder)1 CastUtils (org.springframework.data.util.CastUtils)1 ClassTypeInformation (org.springframework.data.util.ClassTypeInformation)1 TypeInformation (org.springframework.data.util.TypeInformation)1 Nullable (org.springframework.lang.Nullable)1 Assert (org.springframework.util.Assert)1 MultiValueMap (org.springframework.util.MultiValueMap)1 HandlerMethodArgumentResolver (org.springframework.web.method.support.HandlerMethodArgumentResolver)1