View Javadoc
1   /*
2   MultipleStringLiterals
3   allowedDuplicates = 2
4   ignoreStringsRegexp =
5   ignoreOccurrenceContext = (default)ANNOTATION
6   
7   
8   */
9   
10  package com.puppycrawl.tools.checkstyle.checks.coding.multiplestringliterals;
11  
12  public class InputMultipleStringLiterals
13  {   /*string literals*/
14      String m = "StringContents"; // violation
15      String m1 = "SingleString";
16      String m2 = "DoubleString" + "DoubleString";
17      String m3 = "" + ""; // violation
18      String m4 = "" + "";
19      String debugStr = ", " + ", " + ", "; // violation
20  
21      void method1() {
22          String a1 = "StringContents";
23          System.identityHashCode("StringContents");
24          // The following is not reported, since it is two string literals.
25          String a2 = "String" + "Contents";
26      }
27  
28      @SuppressWarnings("unchecked")
29      void method2(){}
30  
31      @SuppressWarnings("unchecked")
32      void method3(){}
33  
34      @SuppressWarnings("unchecked")
35      void method4(){}
36  
37      @SuppressWarnings("unchecked")
38      void method5(){}
39  }