-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: supersededAn issue that has been superseded by anotherAn issue that has been superseded by anothertype: enhancementA general enhancementA general enhancement
Description
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.
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: supersededAn issue that has been superseded by anotherAn issue that has been superseded by anothertype: enhancementA general enhancementA general enhancement