summaryrefslogtreecommitdiff
path: root/java/java-tests/testData/inspection/nullableProblems/GetterSetterProblems.java
blob: c8a5816ec7413928e9d655a25b6ca9d472f8140c (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import org.jetbrains.annotations.NotNull;

class B {
     @NotNull
     B b = new B();

    public B <warning descr="Getter for @NotNull field might be annotated @NotNull itself">getB</warning>() {
        return b;
    }

    public void setB(B <warning descr="Setter parameter for @NotNull field might be annotated @NotNull itself">b</warning>) {
        this.b = b;
    }

        @NotNull
        private String bug = "true";

        public boolean getBug() {
            return Boolean.valueOf(bug);
        }
}
class C {
  @NotNull C c;

  C(C <warning descr="Constructor parameter for @NotNull field might be annotated @NotNull itself">c</warning>) {
    this.c = c;
  }

  C(@<error descr="Cannot resolve symbol 'Nullable'">Nullable</error> C <warning descr="Constructor parameter for @NotNull field might be annotated @NotNull itself">c</warning>, int i) {
    this.c = c;
  }

  @<error descr="Cannot resolve symbol 'Nullable'">Nullable</error>
  public C <warning descr="Getter for @NotNull field might be annotated @NotNull itself">getC</warning>() {
    return c;
  }

  public void setC(@<error descr="Cannot resolve symbol 'Nullable'">Nullable</error> C <warning descr="Setter parameter for @NotNull field might be annotated @NotNull itself">c</warning>) {
    this.c = c;
  }

  @NotNull C c1 = new C(null);
  @org.jetbrains.annotations.Nullable
  public C getC1() {
    if (c1 != null) {
      return null;
    }
    return c1;
  }
}

class D {
    @<error descr="Cannot resolve symbol 'Nullable'">Nullable</error> Long myL;

    D(long l) {
      myL = l;
    }
}

class E {
  final @NotNull C c;

  E(C <warning descr="Constructor parameter for @NotNull field might be annotated @NotNull itself">c</warning>) {
    this.c = c;
  }

}