1
2
3
4
5
6
7
8
9
10
11
12
13
14 package com.puppycrawl.tools.checkstyle.checks.coding.unnecessaryparentheses;
15
16 import static org.junit.Assert.assertEquals;
17 import static java.lang.Math.abs;
18 import java.util.Arrays;
19 import java.util.HashSet;
20 import java.util.function.ToIntFunction;
21
22 public class InputUnnecessaryParenthesesCasts2 {
23 public void fooConditionals(T element) {
24 int x = 23;
25 int y = 44;
26 float k = 12f;
27 boolean finished = true;
28 boolean result = false;
29
30 String filevalue = "FILEVALUE";
31 if (!finished || !((boolean) filevalue.contains("O"))) {
32
33 filevalue += "F";
34 }
35 else if (finished || !(boolean) filevalue.contains("O")) {
36 filevalue += "G";
37 }
38
39 if (result && finished || ((int) 23.1 + 21) == 32) {
40 y--;
41 }
42
43
44 if (!((boolean) filevalue.contains("G")) || finished) {
45 x++;
46 }
47 else if (!(boolean) filevalue.contains("P") || finished) {
48 filevalue += "p";
49 }
50
51 String[] a = {"s", "a", "1", "2", "3"};
52 String[] abr = {"18", "z", "w", "30", "u", "vel"};
53 Arrays.stream(a)
54 .filter(s -> !((boolean) s.isEmpty()))
55
56 .toArray(String[]::new);
57
58 Arrays.stream(abr).filter(s -> !(boolean) s.isEmpty())
59 .toArray(String[]::new);
60
61 Arrays.stream(a)
62 .filter(s -> ((boolean) s.isEmpty()))
63 .toArray(String[]::new);
64 Arrays.stream(abr)
65 .filter(s -> (boolean) s.isEmpty())
66 .toArray(String[]::new);
67
68 new HashSet<Integer>().stream()
69 .filter(f -> f > ((int) 1.1 + 200));
70
71
72 if (((double) abs(10 - 2)) / 2 <= 0.01) {
73 y += 10;
74 }
75 else if ((double) abs(10 - 2) / 2 >= 0.02) {
76 x += 2;
77 }
78
79 final ToIntFunction<T> comparison1 = ((Comparable<T>) element)::compareTo;
80
81 Bean bean = new Bean();
82 assertEquals(1, ((int[]) bean.array)[0]);
83
84
85 float rest = ((float) (50 - System.currentTimeMillis())) / 1000;
86 float stop = (float) (50 - System.currentTimeMillis()) / 1000;
87
88
89
90 float pin = false ? ((float) 21) : ((float) 31);
91
92 Object obj = "hello";
93 String result1 = (obj instanceof String) ? ((String) obj) : "Default";
94
95
96 String op1 = ((String) obj) + ((Boolean) finished).toString();
97 String op2 = (String) obj + ((Boolean) finished).toString();
98
99 filevalue = "'" + ((char) 32) + "'";
100
101 filevalue = "'" + (char) 31 + "'";
102
103
104 ck("name", (long) k, (long) ((byte) 0x22));
105 ck("check", (long) k, (long) (byte) 0x24);
106 }
107
108 public void ck(String byt, long a, long c) {}
109 static class T {}
110 public class Bean {
111 public Object array;
112 public Bean() {
113 array = new int[]{1, 2, 3};
114 }
115 }
116 }