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

Add conversion support for Pattern/Regex #24311

Conversation

valfirst
Copy link
Contributor

@valfirst valfirst commented Jan 7, 2020

No description provided.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 7, 2020
@valfirst valfirst force-pushed the add-string-to-pattern-converter branch from de9d1f5 to cddaef7 Compare January 7, 2020 14:12
@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement labels Jan 7, 2020
@sbrannen
Copy link
Member

sbrannen commented Jan 7, 2020

@valfirst, can you please provide some background on the rationale for your proposal?

Do you have a particular use case that requires this support?

In addition, have you seen org.springframework.beans.propertyeditors.PatternEditor?

@sbrannen sbrannen added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 7, 2020
@valfirst
Copy link
Contributor Author

valfirst commented Jan 7, 2020

@sbrannen thank you for quick response!
We use conversion service to perform type conversion: https://github.com/vividus-framework/vividus/blob/master/vividus/src/main/resources/org/vividus/spring-configuration.xml#L51.
At some point we faced with necessity to convert String value from the property to Optional<Pattern> type. One of the proposed solutions was to re-use all property editors: vividus-framework/vividus@cbe84d8. For me this solution looks awkward.
I haven't found existing converter for Pattern type in Spring, so I've implemented own one and add it to our conversion service. It works as expected. I think the converter looks generic enough and could be useful for other users, so I've decided to create this PR.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 7, 2020
@sbrannen
Copy link
Member

sbrannen commented Jan 8, 2020

Thanks for providing the feedback on your use case.

We'll take that into consideration.

@rstoyanchev rstoyanchev added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 12, 2020
@valfirst
Copy link
Contributor Author

valfirst commented Jul 2, 2020

@sbrannen could you please review the changes when you have a chance? thanks

@sokomishalov
Copy link
Contributor

I think it makes sense to provide the same converter from String to kotlin.text.Regex if kotlin is present in the classpath due to closing the similar PR in the boot repository.
spring-projects/spring-boot#23706

@ikalinin1
Copy link

@sbrannen could you please take a look at this PR

@valfirst valfirst force-pushed the add-string-to-pattern-converter branch from cddaef7 to 44f3f6f Compare June 8, 2022 14:32
@snicoll snicoll self-assigned this Aug 23, 2023
@snicoll snicoll changed the title Add StringToPatternConverter Add conversion support for Pattern/Regex Aug 23, 2023
@snicoll snicoll added this to the 6.1.0-RC1 milestone Aug 23, 2023
@snicoll snicoll removed status: waiting-for-triage An issue we've not yet triaged or decided on status: feedback-provided Feedback has been provided labels Aug 23, 2023
snicoll pushed a commit that referenced this pull request Aug 23, 2023
snicoll added a commit that referenced this pull request Aug 23, 2023
@snicoll snicoll closed this in 471e4d2 Aug 23, 2023
@snicoll
Copy link
Member

snicoll commented Aug 23, 2023

Thanks @valfirst, I polished the proposal by adding support for Kotlin's Regex as well.

sdeleuze added a commit to sdeleuze/spring-framework that referenced this pull request Aug 23, 2023
This commit implements StringToRegexConverter in Java
in order to avoid circular dependencies between Java
and Kotlin codes that can break IDE support, and for
consistency with the rest of the codebase.

See spring-projectsgh-24311
sdeleuze added a commit to sdeleuze/spring-framework that referenced this pull request Aug 23, 2023
sdeleuze added a commit to sdeleuze/spring-framework that referenced this pull request Aug 23, 2023
@sdeleuze sdeleuze self-assigned this Aug 23, 2023
@valfirst valfirst deleted the add-string-to-pattern-converter branch August 23, 2023 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants