Package io.grpc
Class StatusOr<T>
- java.lang.Object
-
- io.grpc.StatusOr<T>
-
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/11563") public class StatusOr<T> extends Object
Either a Status or a value.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object other)
static <T> StatusOr<T>
fromStatus(Status status)
Construct from a non-Ok status.static <T> StatusOr<T>
fromValue(T value)
Construct from a value.Status
getStatus()
Returns the status.T
getValue()
Returns the value if set or throws exception if there is no value set.int
hashCode()
boolean
hasValue()
Returns whether there is a value.String
toString()
-
-
-
Method Detail
-
hasValue
public boolean hasValue()
Returns whether there is a value.
-
getValue
@Nullable public T getValue()
Returns the value if set or throws exception if there is no value set. This method is meant to be called after checking the return value of hasValue() first.
-
getStatus
public Status getStatus()
Returns the status. If there is a value (which can be null), returns OK.
-
-