Skip to content

Commit 2b73f99

Browse files
author
Stuart Marks
committed
8228615: Optional.empty doc should suggest using isEmpty
Reviewed-by: lancea, bpb, naoto
1 parent 805d058 commit 2b73f99

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

src/java.base/share/classes/java/util/Optional.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -74,9 +74,9 @@ public final class Optional<T> {
7474
*
7575
* @apiNote
7676
* Though it may be tempting to do so, avoid testing if an object is empty
77-
* by comparing with {@code ==} against instances returned by
77+
* by comparing with {@code ==} or {@code !=} against instances returned by
7878
* {@code Optional.empty()}. There is no guarantee that it is a singleton.
79-
* Instead, use {@link #isPresent()}.
79+
* Instead, use {@link #isEmpty()} or {@link #isPresent()}.
8080
*
8181
* @param <T> The type of the non-existent value
8282
* @return an empty {@code Optional}

src/java.base/share/classes/java/util/OptionalDouble.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -83,9 +83,9 @@ private OptionalDouble() {
8383
*
8484
* @apiNote
8585
* Though it may be tempting to do so, avoid testing if an object is empty
86-
* by comparing with {@code ==} against instances returned by
86+
* by comparing with {@code ==} or {@code !=} against instances returned by
8787
* {@code OptionalDouble.empty()}. There is no guarantee that it is a singleton.
88-
* Instead, use {@link #isPresent()}.
88+
* Instead, use {@link #isEmpty()} or {@link #isPresent()}.
8989
*
9090
* @return an empty {@code OptionalDouble}.
9191
*/

src/java.base/share/classes/java/util/OptionalInt.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -83,9 +83,9 @@ private OptionalInt() {
8383
*
8484
* @apiNote
8585
* Though it may be tempting to do so, avoid testing if an object is empty
86-
* by comparing with {@code ==} against instances returned by
86+
* by comparing with {@code ==} or {@code !=} against instances returned by
8787
* {@code OptionalInt.empty()}. There is no guarantee that it is a singleton.
88-
* Instead, use {@link #isPresent()}.
88+
* Instead, use {@link #isEmpty()} or {@link #isPresent()}.
8989
*
9090
* @return an empty {@code OptionalInt}
9191
*/

src/java.base/share/classes/java/util/OptionalLong.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -83,9 +83,9 @@ private OptionalLong() {
8383
*
8484
* @apiNote
8585
* Though it may be tempting to do so, avoid testing if an object is empty
86-
* by comparing with {@code ==} against instances returned by
86+
* by comparing with {@code ==} or {@code !=} against instances returned by
8787
* {@code OptionalLong.empty()}. There is no guarantee that it is a singleton.
88-
* Instead, use {@link #isPresent()}.
88+
* Instead, use {@link #isEmpty()} or {@link #isPresent()}.
8989
*
9090
* @return an empty {@code OptionalLong}.
9191
*/

0 commit comments

Comments
 (0)