Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make StringToEnumIgnoringCaseConverterFactory public #3021

Closed
ghillert opened this issue May 20, 2015 · 6 comments
Closed

Make StringToEnumIgnoringCaseConverterFactory public #3021

ghillert opened this issue May 20, 2015 · 6 comments
Labels
status: declined A suggestion or change that we don't feel we should currently apply

Comments

@ghillert
Copy link

For Spring XD we ran into the need to have a more lenient enum converter. The functionality provided by StringToEnumIgnoringCaseConverterFactory is pretty much what we need, but unfortunately it is private, and hence we had to copy the code.

See also: https://jira.spring.io/browse/XD-3066

@snicoll
Copy link
Member

snicoll commented May 21, 2015

How about using the RelaxedConversionService then? That one is public.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 17, 2016
@wilkinsona
Copy link
Member

Given the lack of response to @snicoll's suggestion, I'm going to assume that this is no longer needed. We can reopen this if that turns out to not be the case.

@wilkinsona wilkinsona added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 2, 2016
@michaldo
Copy link
Contributor

I would like to use enum binding ignoring case in Spring MVC binding. I think simplest way is write WebMvcConfigurer with

@Override
 public void addFormatters(FormatterRegistry registry) {
    registry.addConverterFactory(new StringToEnumIgnoringCaseConverterFactory());
}

But StringToEnumIgnoringCaseConverterFactory is package private and RelaxedConversionService has gone.
Please give next suggestion

@wilkinsona
Copy link
Member

wilkinsona commented Oct 30, 2018

I believe that'll work without configuring Spring MVC in Spring Boot 2.1 as the ApplicationConversionService, with which StringToEnumIgnoringCaseConverterFactory is registered, is now registered by default with the application context.

@michaldo
Copy link
Contributor

Unfortunately, not. Spring Boot MVC 2.10 use WebConversionService, which is different than ApplicationConversionService

Fortunately, I found solution https://stackoverflow.com/a/52978020 which works in my case. But I feel a bit uncomfortable when I have to add bunch of converters (ApplicationConversionService.addApplicationConverters()) when I need only one

@wilkinsona
Copy link
Member

Ah, yes. I'd forgotten about the different WebConversionService. Thanks for the reminder. I've opened #15019 to review the differences between the two and consider aligning them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

5 participants