blob: 2d68b280fb040efd9204397c659d891de2ff514e (
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
|
package test.pkg;
import android.annotation.SuppressLint;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.PorterDuff;
@SuppressWarnings("incomplete-switch")
public class TestEnum {
public static void test1(final CompressFormat format) {
switch (format) {
case JPEG: {
System.out.println("jpeg");
break;
}
default: {
System.out.println("Default");
}
}
}
public static void test2(final PorterDuff.Mode mode) {
switch (mode) {
case CLEAR: {
System.out.println("clear");
}
case OVERLAY: {
System.out.println("add");
break;
}
}
// Second usage: should also complain here
switch (mode) {
case CLEAR: {
System.out.println("clear");
}
case OVERLAY: {
System.out.println("add");
break;
}
}
}
@SuppressLint("NewApi")
public static void test3(PorterDuff.Mode mode) {
// Third usage: no complaint because it's suppressed
switch (mode) {
case CLEAR: {
System.out.println("clear");
}
case OVERLAY: {
System.out.println("add");
break;
}
}
}
public static void test4(final android.renderscript.Element.DataType type) {
// Switch usage where the whole underlying enum requires a higher API level:
// test customized error message
switch (type) {
case RS_FONT: {
System.out.println("font");
}
}
}
}
|