mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-06 06:00:26 +00:00
8025610: Add explicit @throws NPE documentation to Optional constructor and Optional.of
Reviewed-by: briangoetz, chegar, alanb
This commit is contained in:
parent
512fbc2a59
commit
230478592d
@ -85,6 +85,7 @@ public final class Optional<T> {
|
||||
* Constructs an instance with the value present.
|
||||
*
|
||||
* @param value the non-null value to be present
|
||||
* @throws NullPointerException if value is null
|
||||
*/
|
||||
private Optional(T value) {
|
||||
this.value = Objects.requireNonNull(value);
|
||||
@ -96,6 +97,7 @@ public final class Optional<T> {
|
||||
* @param <T> the class of the value
|
||||
* @param value the value to be present, which must be non-null
|
||||
* @return an {@code Optional} with the value present
|
||||
* @throws NullPointerException if value is null
|
||||
*/
|
||||
public static <T> Optional<T> of(T value) {
|
||||
return new Optional<>(value);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user