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

Replace UnaryOperator with Function in ListUtils methods #4720

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

knutwannheden
Copy link
Contributor

@knutwannheden knutwannheden commented Nov 26, 2024

The reason for this change is that the mapping functions should all expect a non-null input but are allowed to return null 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 input List is null). 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 returns null. 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 corresponding get-method this is not an issue, as both the get-method return type and the with-method parameter are annotated as @Nullable.

Important

This PR breaks binary compatibility and must therefore be part of a minor release.

The reason for this change is that the mapping functions should all expect a non-`null` input but are allowed to return `null` 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 input `List` is `null`). 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 returns `null`. 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 corresponding `get`-method this is not an issue, as both the `get`-method return type and the `with`-method parameter are annotated as `@Nullable`.
github-actions[bot]

This comment was marked as resolved.

@knutwannheden knutwannheden merged commit f4ca982 into main Nov 26, 2024
2 checks passed
@knutwannheden knutwannheden deleted the list-map-null branch November 26, 2024 15:54
timtebeek added a commit that referenced this pull request Nov 28, 2024
timtebeek added a commit that referenced this pull request Nov 28, 2024
* Restore ListUtils map methods that accept UnaryOperator

Following #4720

* Remove deprecated annotations as folks are not expected to cast their args
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants