RFR: 8291954: Use Optional.isEmpty instead of !Optional.isPresent in java.base

Alan Bateman alanb at openjdk.org
Fri Aug 5 07:49:52 UTC 2022


On Mon, 1 Aug 2022 06:51:44 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:

> I propose to replace usages of !Optional.isPresent() with Optional.isEmpty method.
> It's makes code a bit easier to read.
> Noticing negation before long chain of method calls is hard.

Looks good. The isEmpty was added in Java 11 so I think most (if not all) of these pre-date this method.

-------------

Marked as reviewed by alanb (Reviewer).

PR: https://git.openjdk.org/jdk/pull/9697


More information about the core-libs-dev mailing list