Skip to content

Conversation

@Pankraz76
Copy link

@Pankraz76 Pankraz76 commented Mar 14, 2025

Thanks for your contribution to Apache Commons! Your help is appreciated!

Before you push a pull request, review this list:

  • Read the contribution guidelines for this project.
  • Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible but is a best-practice.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body. Note that commits might be squashed by a maintainer on merge.

@Pankraz76 Pankraz76 marked this pull request as ready for review March 14, 2025 07:33
@Pankraz76
Copy link
Author

Pankraz76 commented Mar 14, 2025

is this any good?

@Pankraz76 Pankraz76 force-pushed the fix-getIfNull branch 3 times, most recently from 15426f9 to 695e32a Compare March 14, 2025 07:46
@Pankraz76 Pankraz76 changed the title deprecated ObjectUtils defaultIfNull add getIfNull and getFirstNonNull deprecated ObjectUtils defaultIfNull in favor or getIfNull overload getFirstNonNull with collection support Mar 14, 2025
garydgregory added a commit that referenced this pull request May 28, 2025
defaultIfNull(Object, Object)

A adaptation of PR #1355 by Pankraz76
@garydgregory
Copy link
Member

Hello @Pankraz76

There are conflicts in the PR so I brought this in slightly differently in git master. You are credited in the commit comment and changes.xml

TY!

@Pankraz76
Copy link
Author

thx.

@brettkail-wk
Copy link

Out of curiosity, why is this rename/deprecation useful? Subjectively, defaultIfNull seems clearer than getIfNull, particularly when statically imported.

@Pankraz76
Copy link
Author

Pankraz76 commented Jul 15, 2025

The TODO directive given, it's considered deprecated to avoid breaking change.

I like both approaches, but the default context is somewhat implied. While having a verbose API is nice for beginners, for those used to it, this feels like overhead.

Since it's either/or, why do we need to explicitly mention the default? Asking this question could argue why not renaming to returnEtherValueOrDefaultValueIfNull this is a very verbose version giving good testament on naming.

considering:

big scope -> small name

small scope -> big name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants