It looks like we have the key types as nullable but the value type not? I would have guessed that they'd both be nullable.
|
public static <T extends @Nullable Object, K extends @Nullable Object, U> |
|
public static <T extends @Nullable Object, K extends @Nullable Object, U> |
|
public static <T extends @Nullable Object, K extends @Nullable Object, U, M extends Map<K, U>> |
I wonder if part of the story here is that the ones that declare a mergeFunction would want a non-null type argument there? But, if so:
- We could accomplish that with
@NonNull.
- It's not clear to me that a nullable type argument there would be wrong, just potentially inconvenient in some cases (and convenient in others).
I'm belatedly realizing that a Guava user had raised a related question before in google/guava#6824. So part of the story might be that a more flexible signature has been difficult for some tools in the past. But I know that the Checker Framework improved its type inference a while back, so we should get some real-world data on this once we're able to import those changes to Google's monorepo.
(I noticed this as I was putting together #146.)
It looks like we have the key types as nullable but the value type not? I would have guessed that they'd both be nullable.
jdk/src/java.base/share/classes/java/util/stream/Collectors.java
Line 1446 in cba7f90
jdk/src/java.base/share/classes/java/util/stream/Collectors.java
Line 1550 in cba7f90
jdk/src/java.base/share/classes/java/util/stream/Collectors.java
Line 1642 in cba7f90
I wonder if part of the story here is that the ones that declare a
mergeFunctionwould want a non-null type argument there? But, if so:@NonNull.I'm belatedly realizing that a Guava user had raised a related question before in google/guava#6824. So part of the story might be that a more flexible signature has been difficult for some tools in the past. But I know that the Checker Framework improved its type inference a while back, so we should get some real-world data on this once we're able to import those changes to Google's monorepo.
(I noticed this as I was putting together #146.)