Debian Codegraph @

checker/tests/nullness/java8inference/Issue402.java

raw
1 // Test case that was submitted in Issue 402, but was combined with Issue 979
2 // https://github.com/typetools/checker-framework/issues/979
3
4 import java.util.Comparator;
5 import javax.annotation.CheckForNull;
6 import javax.annotation.Nullable;
7
8 // Type argument inference does not infer the correct types.
9 // Once Issue 979 is fixed, this suppression should be removed.
10 @SuppressWarnings({"nullness", "keyfor"}) // Issue 979
11 public final class Issue402 {
12 static final Comparator<Issue402> COMPARATOR =
13 Comparator.comparing(
14 Issue402::getStr1, Comparator.nullsFirst(Comparator.naturalOrder()))
15 .thenComparing(
16 Issue402::getStr2, Comparator.nullsFirst(Comparator.naturalOrder()));
17
18 @CheckForNull private final String str1;
19 @CheckForNull private final String str2;
20
21 Issue402(@Nullable final String str1, @Nullable final String str2) {
22 this.str1 = str1;
23 this.str2 = str2;
24 }
25
26 @CheckForNull
27 String getStr1() {
28 return this.str1;
29 }
30
31 @CheckForNull
32 String getStr2() {
33 return this.str2;
34 }
35 }