specification-arg-resolver
specification-arg-resolver copied to clipboard
Work with char/Character for filtering
I tried to use this to filter based on char value but couldn't get it to do so. Am I implementing wrong or it doesn't support that?
For me adding the code below worked:
I was missing to pass the conversionService
to the new SpecificationArgumentResolver at first, which made it not work. Now it does work fine. MAybe this helps you too @abhishekshrivastava-proctur ?
@Configuration
@EnableScheduling
public class SpecificationConfig implements WebMvcConfigurer {
@Autowired
@Qualifier("mvcConversionService")
ConversionService conversionService;
@Override
public void addArgumentResolvers(final List<HandlerMethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(new SpecificationArgumentResolver(conversionService));
}
@Override
public void addFormatters(final FormatterRegistry registry) {
registry.addConverter(new StringToCharacterConverter());
}
public static class StringToCharacterConverter implements Converter<String, Character> {
@Override
public Character convert(final String charString) {
return charString.charAt(0);
}
}
}
direct support for chars/Characters added in v2.17.0 (released today)