@Immutable @ThreadSafe public final class Optional<T> extends Object implements Serializable
Modifier and Type | Method and Description |
---|---|
static <T> Optional<T> |
empty() |
boolean |
equals(Object obj) |
T |
get() |
int |
hashCode() |
boolean |
isPresent() |
static <T> Optional<T> |
of(T value) |
static <T> Optional<T> |
ofNullable(T value) |
T |
orElse(T other) |
String |
toString() |
public static <T> Optional<T> of(T value) throws IllegalArgumentException
IllegalArgumentException
- if the value is nullpublic static <T> Optional<T> ofNullable(T value)
public T orElse(T other)
other
- public boolean isPresent()
Copyright © 2016 The Apache Software Foundation. All rights reserved.