Skip to content

Consider adding support for chaining converters #22381

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

Closed
jzheaux opened this issue Feb 7, 2019 · 2 comments
Closed

Consider adding support for chaining converters #22381

jzheaux opened this issue Feb 7, 2019 · 2 comments
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: superseded An issue that has been superseded by another type: enhancement A general enhancement

Comments

@jzheaux
Copy link
Contributor

jzheaux commented Feb 7, 2019

It would be nice to have some support for chaining converters:

public interface Converter<S, T> {
	// ...

	default <U> Converter<S, U> andThen(Converter<T, U> andThen) {
		return source -> andThen.convert(this.convert(source));
	}
}

Then, a user could more easily compose them:

Converter<A, B> aToB = ...;
Converter<B, C> bToC = ...;
Converter<A, C> aToC = aToB.andThen(bToC);

This is a modest improvement on:

Converter<A, C> aToC = source -> bToC.convert(aToB.convert(source));

in that code using andThen will read in the correct order, e.g. "do A then B" instead of "B.do(A.do)".

I'd be happy to submit a PR, if it's agreed that it's a reasonable improvement.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 7, 2019
jzheaux added a commit to jzheaux/spring-framework that referenced this issue Jul 29, 2019
@jzheaux
Copy link
Contributor Author

jzheaux commented Sep 28, 2020

@sbrannen, is this and its associated PR of interest?

@sbrannen
Copy link
Member

Oops. This one slipped through the cracks. We'll apply the PR to 5.3.


Superseded by #23379.

@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) status: superseded An issue that has been superseded by another type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Sep 29, 2020
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) status: superseded An issue that has been superseded by another type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants