View Javadoc
1   /*xml
2   <module name="Checker">
3     <module name="TreeWalker">
4       <module name="MultipleStringLiterals">
5         <property name="allowedDuplicates" value="2"/>
6       </module>
7     </module>
8   </module>
9   */
10  
11  package com.puppycrawl.tools.checkstyle.checks.coding.multiplestringliterals;
12  
13  // xdoc section -- start
14  public class Example2 {
15    String a = "StringContents"; // OK, two occurrences are allowed
16    String a1 = "unchecked";
17    @SuppressWarnings("unchecked") // OK, duplicate strings are ignored in annotations
18    public void myTest() {
19      String a2 = "StringContents";
20      String a3 = "DuoString" + "DuoString"; // OK, two occurrences are allowed
21      String a4 = "SingleString";
22      String a5 = ", " + ", " + ", "; // violation, three occurrences are NOT allowed
23    }
24  }
25  // xdoc section -- end