Summary:

This PR refactors the unwrapOptional() method in ObjectUtils to enhance code readability and slightly improve performance. The changes focus on simplifying the Optional handling logic.

Changes:

  • Replaced the combination of Optional.isEmpty() and Optional.get() with a single call to Optional.orElse(null), improving both readability and code clarity.
  • Removed unnecessary conditional checks and made the method more concise.
  • Maintained the existing functionality, ensuring that multi-level Optional usage is still not supported.

Impact:

This change will not affect the existing functionality of the system, but it simplifies the code and reduces the potential for errors when working with Optional objects. The performance improvement is marginal but contributes to better maintainability.

Please review and provide feedback!

Comment From: SungbinYang

@sdeleuze Could it be that my PR was reflected? Am I a contributor?

Comment From: sdeleuze

Not sure what you mean by "reflected", but yes your PR has been merged, thanks for your contribution.

Comment From: SungbinYang

@sdeleuze Thank you for doing the PR merge. I will try to contribute more. If I'm a little disappointed in this PR, it's that I wasn't able to add my name to the class comment @author! Thanks again!

Comment From: snicoll

@SungbinYang Your name can be added to a class if you add significant changes to it. I can see you've commented on the other PR asking if it was merged or not. It was. Please refrain from posting further comments like this as each triggers a notification to the thousands watching this repository.