8228615: Optional.empty doc should suggest using isEmpty
Reviewed-by: lancea, bpb, naoto
This commit is contained in:
parent
805d05812c
commit
2b73f9929f
@ -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
|
||||
@ -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}
|
||||
|
@ -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
|
||||
@ -83,9 +83,9 @@ public final class 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}.
|
||||
*/
|
||||
|
@ -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
|
||||
@ -83,9 +83,9 @@ public final class 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}
|
||||
*/
|
||||
|
@ -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
|
||||
@ -83,9 +83,9 @@ public final class 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}.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user