Skip to content

Commit b33c17f

Browse files
authored
api: remove nullable from StatusOr value methods (#12338)
It someone wants it nullable, that should be defined via the type parameter, e.g. `StatusOr<@nullable Foo> foo`
1 parent 5c14596 commit b33c17f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

api/src/main/java/io/grpc/StatusOr.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private StatusOr(Status status, T value) {
3333
}
3434

3535
/** Construct from a value. */
36-
public static <T> StatusOr<T> fromValue(@Nullable T value) {
36+
public static <T> StatusOr<T> fromValue(T value) {
3737
StatusOr<T> result = new StatusOr<T>(null, value);
3838
return result;
3939
}
@@ -54,7 +54,7 @@ public boolean hasValue() {
5454
* Returns the value if set or throws exception if there is no value set. This method is meant
5555
* to be called after checking the return value of hasValue() first.
5656
*/
57-
public @Nullable T getValue() {
57+
public T getValue() {
5858
if (status != null) {
5959
throw new IllegalStateException("No value present.");
6060
}
@@ -105,6 +105,7 @@ public String toString() {
105105
return stringHelper.toString();
106106
}
107107

108+
@Nullable
108109
private final Status status;
109110
private final T value;
110111
}

0 commit comments

Comments
 (0)