Pull #3189: aligned setters with String collection fields
This commit is contained in:
parent
a6ab6053e6
commit
48d32f40d2
|
|
@ -43,7 +43,7 @@
|
|||
<!-- we can not change it as, Check property is part of API (used in configurations) -->
|
||||
<suppress checks="AbbreviationAsWordInName"
|
||||
files="JavadocMethodCheck.java"
|
||||
lines="145,258"/>
|
||||
lines="146,252"/>
|
||||
<!-- we can not change it as, Check property is part of API (used in configurations) -->
|
||||
<suppress checks="AbbreviationAsWordInName"
|
||||
files="SuppressWithNearbyCommentFilter.java"
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
|
@ -173,7 +172,7 @@ public class TranslationCheck extends AbstractFileSetCheck {
|
|||
/**
|
||||
* Language codes of required translations for the check (de, pt, ja, etc).
|
||||
*/
|
||||
private SortedSet<String> requiredTranslations = Sets.newTreeSet();
|
||||
private Set<String> requiredTranslations = Sets.newHashSet();
|
||||
|
||||
/**
|
||||
* Creates a new {@code TranslationCheck} instance.
|
||||
|
|
@ -195,9 +194,8 @@ public class TranslationCheck extends AbstractFileSetCheck {
|
|||
* Sets language codes of required translations for the check.
|
||||
* @param translationCodes a comma separated list of language codes.
|
||||
*/
|
||||
public void setRequiredTranslations(String translationCodes) {
|
||||
requiredTranslations = Sets.newTreeSet(Splitter.on(',')
|
||||
.trimResults().omitEmptyStrings().split(translationCodes));
|
||||
public void setRequiredTranslations(String... translationCodes) {
|
||||
requiredTranslations = Sets.newHashSet(translationCodes);
|
||||
validateUserSpecifiedLanguageCodes(requiredTranslations);
|
||||
}
|
||||
|
||||
|
|
@ -205,7 +203,7 @@ public class TranslationCheck extends AbstractFileSetCheck {
|
|||
* Validates the correctness of user specififed language codes for the check.
|
||||
* @param languageCodes user specified language codes for the check.
|
||||
*/
|
||||
private void validateUserSpecifiedLanguageCodes(SortedSet<String> languageCodes) {
|
||||
private void validateUserSpecifiedLanguageCodes(Set<String> languageCodes) {
|
||||
for (String code : languageCodes) {
|
||||
if (!isValidLanguageCode(code)) {
|
||||
final LocalizedMessage msg = new LocalizedMessage(0, TRANSLATION_BUNDLE,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import antlr.collections.AST;
|
||||
|
||||
|
|
@ -73,9 +72,6 @@ public class IllegalInstantiationCheck
|
|||
/** {@link java.lang} package as string */
|
||||
private static final String JAVA_LANG = "java.lang.";
|
||||
|
||||
/** Set of fully qualified class names. E.g. "java.lang.Boolean" */
|
||||
private final Set<String> illegalClasses = Sets.newHashSet();
|
||||
|
||||
/** The imports for the file. */
|
||||
private final Set<FullIdent> imports = Sets.newHashSet();
|
||||
|
||||
|
|
@ -85,6 +81,9 @@ public class IllegalInstantiationCheck
|
|||
/** The instantiations in the file. */
|
||||
private final Set<DetailAST> instantiations = Sets.newHashSet();
|
||||
|
||||
/** Set of fully qualified class names. E.g. "java.lang.Boolean" */
|
||||
private Set<String> illegalClasses = Sets.newHashSet();
|
||||
|
||||
/** Name of the package. */
|
||||
private String pkgName;
|
||||
|
||||
|
|
@ -355,11 +354,7 @@ public class IllegalInstantiationCheck
|
|||
* Sets the classes that are illegal to instantiate.
|
||||
* @param names a comma separate list of class names
|
||||
*/
|
||||
public void setClasses(String names) {
|
||||
illegalClasses.clear();
|
||||
final StringTokenizer tok = new StringTokenizer(names, ",");
|
||||
while (tok.hasMoreTokens()) {
|
||||
illegalClasses.add(tok.nextToken());
|
||||
}
|
||||
public void setClasses(String... names) {
|
||||
illegalClasses = Sets.newHashSet(names);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
package com.puppycrawl.tools.checkstyle.checks.javadoc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
|
@ -220,15 +221,8 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck {
|
|||
* Sets list of annotations.
|
||||
* @param userAnnotations user's value.
|
||||
*/
|
||||
public void setAllowedAnnotations(String userAnnotations) {
|
||||
final List<String> annotations = new ArrayList<>();
|
||||
final String[] sAnnotations = userAnnotations.split(",");
|
||||
for (int i = 0; i < sAnnotations.length; i++) {
|
||||
sAnnotations[i] = sAnnotations[i].trim();
|
||||
}
|
||||
|
||||
Collections.addAll(annotations, sAnnotations);
|
||||
allowedAnnotations = annotations;
|
||||
public void setAllowedAnnotations(String... userAnnotations) {
|
||||
allowedAnnotations = Arrays.asList(userAnnotations);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@
|
|||
|
||||
package com.puppycrawl.tools.checkstyle.checks.naming;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.puppycrawl.tools.checkstyle.api.AbstractCheck;
|
||||
import com.puppycrawl.tools.checkstyle.api.DetailAST;
|
||||
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
|
||||
|
|
@ -156,10 +156,9 @@ public class AbbreviationAsWordInNameCheck extends AbstractCheck {
|
|||
* an string of abbreviations that must be skipped from checking,
|
||||
* each abbreviation separated by comma.
|
||||
*/
|
||||
public void setAllowedAbbreviations(String allowedAbbreviations) {
|
||||
public void setAllowedAbbreviations(String... allowedAbbreviations) {
|
||||
if (allowedAbbreviations != null) {
|
||||
this.allowedAbbreviations = new HashSet<>(
|
||||
Arrays.asList(allowedAbbreviations.split(",")));
|
||||
this.allowedAbbreviations = Sets.newHashSet(allowedAbbreviations);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ public int checkReturnTag(final int aTagIndex,
|
|||
<tr>
|
||||
<td>allowedAnnotations</td>
|
||||
<td>List of annotations that could allow missed documentation.</td>
|
||||
<td><a href="property_types.html#stringSet">list of strings</a></td>
|
||||
<td><a href="property_types.html#stringSet">String Set</a></td>
|
||||
<td><code>Override</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@
|
|||
<td>allowedAbbreviations</td>
|
||||
<td>list of abbreviations that must be skipped for checking.
|
||||
Abbreviations should be separated by comma, no spaces are allowed.</td>
|
||||
<td><a href="property_types.html#stringSet">stringSet</a></td>
|
||||
<td><a href="property_types.html#stringSet">String Set</a></td>
|
||||
<td>null</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
|||
Loading…
Reference in New Issue