1
2
3
4
5
6
7 package com.puppycrawl.tools.checkstyle.checks.coding.stringliteralequality;
8
9 public class InputStringLiteralEqualityConcatenatedString {
10
11 public void testMethod() {
12 String s = "abc";
13 String p = "asd";
14 if (s == "a" + "bc") {
15 }
16
17 if ("a" + "bc" == s) {
18 }
19
20 if ("a" + ("b" + "c") != s) {
21 }
22
23 if (s == "a" + "b" + "c") {
24 }
25 if ((s += "asd") != p) {
26 }
27
28 if ((s += "asd") == s + (p + "asd")) {
29 }
30
31 if ((s += "asd") != s + "p" + p) {
32 }
33
34 if (s != s + "p" + p) {
35 }
36
37 String a = (s + "asd") == null ? "asd" : s;
38
39 String b = s + "ab" + p != null ? s : p;
40
41 String c = ("ab" + s) != null ?
42 (p + "ab" == null ? p : s) : p;
43
44 }
45
46 }