Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8228615: Optional.empty doc should suggest using isEmpty
Reviewed-by: lancea, bpb, naoto
  • Loading branch information
Stuart Marks committed Dec 3, 2020
1 parent 805d058 commit 2b73f99
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/java.base/share/classes/java/util/Optional.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -74,9 +74,9 @@ public final class Optional<T> {
*
* @apiNote
* Though it may be tempting to do so, avoid testing if an object is empty
* by comparing with {@code ==} against instances returned by
* by comparing with {@code ==} or {@code !=} against instances returned by
* {@code Optional.empty()}. There is no guarantee that it is a singleton.
* Instead, use {@link #isPresent()}.
* Instead, use {@link #isEmpty()} or {@link #isPresent()}.
*
* @param <T> The type of the non-existent value
* @return an empty {@code Optional}
Expand Down
6 changes: 3 additions & 3 deletions src/java.base/share/classes/java/util/OptionalDouble.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -83,9 +83,9 @@ private OptionalDouble() {
*
* @apiNote
* Though it may be tempting to do so, avoid testing if an object is empty
* by comparing with {@code ==} against instances returned by
* by comparing with {@code ==} or {@code !=} against instances returned by
* {@code OptionalDouble.empty()}. There is no guarantee that it is a singleton.
* Instead, use {@link #isPresent()}.
* Instead, use {@link #isEmpty()} or {@link #isPresent()}.
*
* @return an empty {@code OptionalDouble}.
*/
Expand Down
6 changes: 3 additions & 3 deletions src/java.base/share/classes/java/util/OptionalInt.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -83,9 +83,9 @@ private OptionalInt() {
*
* @apiNote
* Though it may be tempting to do so, avoid testing if an object is empty
* by comparing with {@code ==} against instances returned by
* by comparing with {@code ==} or {@code !=} against instances returned by
* {@code OptionalInt.empty()}. There is no guarantee that it is a singleton.
* Instead, use {@link #isPresent()}.
* Instead, use {@link #isEmpty()} or {@link #isPresent()}.
*
* @return an empty {@code OptionalInt}
*/
Expand Down
6 changes: 3 additions & 3 deletions src/java.base/share/classes/java/util/OptionalLong.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -83,9 +83,9 @@ private OptionalLong() {
*
* @apiNote
* Though it may be tempting to do so, avoid testing if an object is empty
* by comparing with {@code ==} against instances returned by
* by comparing with {@code ==} or {@code !=} against instances returned by
* {@code OptionalLong.empty()}. There is no guarantee that it is a singleton.
* Instead, use {@link #isPresent()}.
* Instead, use {@link #isEmpty()} or {@link #isPresent()}.
*
* @return an empty {@code OptionalLong}.
*/
Expand Down

1 comment on commit 2b73f99

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.