Replace UnaryOperator
with Function
in ListUtils
methods
#4720
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The reason for this change is that the mapping functions should all expect a non-
null
input but are allowed to returnnull
to signal that the corresponding result is to be removed from the list.Additionally, the return type of the methods has been annotated with
@Nullable
where appropriate (typically when the inputList
isnull
). So that this doesn't result in new warnings getting reported, the methods have now additionally also been annotated with@Contract
, using which we capture the details of when the method returnsnull
. With powerful static analysis tools like IDEA, this should typically not result in any new unwanted warnings.For example when a
with
-method is called by mapping the result of the correspondingget
-method this is not an issue, as both theget
-method return type and thewith
-method parameter are annotated as@Nullable
.Important
This PR breaks binary compatibility and must therefore be part of a minor release.