Return early from composed Converter if initial conversion step returned null
See gh-23379
This commit is contained in:
parent
fec89af239
commit
2a34c0ea70
|
|
@ -57,8 +57,11 @@ public interface Converter<S, T> {
|
|||
* @since 5.3
|
||||
*/
|
||||
default <U> Converter<S, U> andThen(Converter<? super T, ? extends U> after) {
|
||||
Assert.notNull(after, "after must not be null");
|
||||
return (S s) -> after.convert(convert(s));
|
||||
Assert.notNull(after, "After Converter must not be null");
|
||||
return (S s) -> {
|
||||
T initialResult = convert(s);
|
||||
return (initialResult != null ? after.convert(initialResult) : null);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue