File: Issue402.java

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,104 kB
  • sloc: java: 145,916; xml: 839; sh: 518; makefile: 404; perl: 26
file content (35 lines) | stat: -rw-r--r-- 1,141 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Test case that was submitted in Issue 402, but was combined with Issue 979
// https://github.com/typetools/checker-framework/issues/979

import java.util.Comparator;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;

// Type argument inference does not infer the correct types.
// Once Issue 979 is fixed, this suppression should be removed.
@SuppressWarnings({"nullness", "keyfor"}) // Issue 979
public final class Issue402 {
    static final Comparator<Issue402> COMPARATOR =
            Comparator.comparing(
                            Issue402::getStr1, Comparator.nullsFirst(Comparator.naturalOrder()))
                    .thenComparing(
                            Issue402::getStr2, Comparator.nullsFirst(Comparator.naturalOrder()));

    @CheckForNull private final String str1;
    @CheckForNull private final String str2;

    Issue402(@Nullable final String str1, @Nullable final String str2) {
        this.str1 = str1;
        this.str2 = str2;
    }

    @CheckForNull
    String getStr1() {
        return this.str1;
    }

    @CheckForNull
    String getStr2() {
        return this.str2;
    }
}