8228615: Optional.empty doc should suggest using isEmpty

Reviewed-by: lancea, bpb, naoto
This commit is contained in:
Stuart Marks 2020-12-03 19:32:53 +00:00
parent 805d05812c
commit 2b73f9929f
4 changed files with 12 additions and 12 deletions

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -74,9 +74,9 @@ public final class Optional<T> {
* *
* @apiNote * @apiNote
* Though it may be tempting to do so, avoid testing if an object is empty * 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. * {@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 * @param <T> The type of the non-existent value
* @return an empty {@code Optional} * @return an empty {@code Optional}

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -83,9 +83,9 @@ public final class OptionalDouble {
* *
* @apiNote * @apiNote
* Though it may be tempting to do so, avoid testing if an object is empty * 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. * {@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}. * @return an empty {@code OptionalDouble}.
*/ */

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -83,9 +83,9 @@ public final class OptionalInt {
* *
* @apiNote * @apiNote
* Though it may be tempting to do so, avoid testing if an object is empty * 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. * {@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} * @return an empty {@code OptionalInt}
*/ */

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -83,9 +83,9 @@ public final class OptionalLong {
* *
* @apiNote * @apiNote
* Though it may be tempting to do so, avoid testing if an object is empty * 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. * {@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}. * @return an empty {@code OptionalLong}.
*/ */