Package net.sourceforge.pmd.lang.rule
Class RuleSet.RuleSetBuilder
java.lang.Object
net.sourceforge.pmd.lang.rule.RuleSet.RuleSetBuilder
- Enclosing class:
RuleSet
A builder class to create a ruleset.
- Since:
- 7.14.0
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionAdd a new rule to this ruleset.addRuleByReference(String ruleSetFileName, Rule rule) Add a new rule by reference to this ruleset.addRuleIfNotExists(Rule ruleOrRef) Only adds a rule to the ruleset if no rule with the same name for the same language was added before, so that the existent rule configuration won't be overridden.addRuleReplaceIfExists(Rule rule) Adds a rule.addRuleSet(RuleSet ruleSet) Add all rules of a whole RuleSet to this RuleSetaddRuleSetByReference(RuleSet ruleSet, boolean allRules) Add all rules by reference from one RuleSet to this RuleSet.addRuleSetByReference(RuleSet ruleSet, boolean allRules, String... excludes) Add all rules by reference from one RuleSet to this RuleSet.build()voidfilterRulesByPriority(RulePriority minimumPriority) getName()booleanbooleanRemove all rules that matched the predicate.replaceFileExclusions(Collection<? extends Pattern> patterns) Replaces the existing exclusion patterns with the given patterns.replaceFileInclusions(Collection<? extends Pattern> patterns) Replaces the existing inclusion patterns with the given patterns.withDescription(String description) withFileExclusions(Collection<? extends Pattern> patterns) Adds some new file exclusion patterns.withFileExclusions(Pattern p1, Pattern... rest) Adds some new file exclusion patterns.withFileInclusions(Collection<? extends Pattern> patterns) Adds some new file inclusion patterns.withFileInclusions(Pattern p1, Pattern... rest) Adds some new file inclusion patterns.withFileName(String fileName)
-
Field Details
-
description
-
name
-
fileName
-
-
Method Details
-
addRule
Add a new rule to this ruleset. Note that this method does not check for duplicates.- Parameters:
newRule- the rule to be added- Returns:
- The same builder, for a fluid programming interface
-
removeIf
Remove all rules that matched the predicate. -
addRuleReplaceIfExists
Adds a rule. If a rule with the same name and language already existed before in the ruleset, then the new rule will replace it. This makes sure that the rule configured is overridden.- Parameters:
rule- the new rule to add- Returns:
- The same builder, for a fluid programming interface
-
addRuleIfNotExists
Only adds a rule to the ruleset if no rule with the same name for the same language was added before, so that the existent rule configuration won't be overridden.- Parameters:
ruleOrRef- the new rule to add- Returns:
- The same builder, for a fluid programming interface
-
addRuleByReference
Add a new rule by reference to this ruleset.- Parameters:
ruleSetFileName- the ruleset which contains the rulerule- the rule to be added- Returns:
- The same builder, for a fluid programming interface
-
addRuleSet
Add all rules of a whole RuleSet to this RuleSet- Parameters:
ruleSet- the RuleSet to add- Returns:
- The same builder, for a fluid programming interface
-
addRuleSetByReference
Add all rules by reference from one RuleSet to this RuleSet. The rules can be added as individual references, or collectively as an all rule reference.- Parameters:
ruleSet- the RuleSet to addallRules-trueif the ruleset should be added collectively orfalseto add individual references for each rule.- Returns:
- The same builder, for a fluid programming interface
-
addRuleSetByReference
public RuleSet.RuleSetBuilder addRuleSetByReference(RuleSet ruleSet, boolean allRules, String... excludes) Add all rules by reference from one RuleSet to this RuleSet. The rules can be added as individual references, or collectively as an all rule reference.- Parameters:
ruleSet- the RuleSet to addallRules-trueif the ruleset should be added collectively orfalseto add individual references for each rule.excludes- names of the rules that should be excluded.- Returns:
- The same builder, for a fluid programming interface
-
withFileExclusions
Adds some new file exclusion patterns.- Parameters:
p1- The first patternrest- Additional patterns- Returns:
- This builder
- Throws:
NullPointerException- If any of the specified patterns is null
-
withFileExclusions
Adds some new file exclusion patterns.- Parameters:
patterns- Exclusion patterns to add- Returns:
- This builder
- Throws:
NullPointerException- If any of the specified patterns is null
-
replaceFileExclusions
Replaces the existing exclusion patterns with the given patterns.- Parameters:
patterns- Exclusion patterns to set- Returns:
- This builder
- Throws:
NullPointerException- If any of the specified patterns is null
-
withFileInclusions
Adds some new file inclusion patterns.- Parameters:
p1- The first patternrest- Additional patterns- Returns:
- This builder
- Throws:
NullPointerException- If any of the specified patterns is null
-
withFileInclusions
Adds some new file inclusion patterns.- Parameters:
patterns- Inclusion patterns to add- Returns:
- This builder
- Throws:
NullPointerException- If any of the specified patterns is null
-
replaceFileInclusions
Replaces the existing inclusion patterns with the given patterns.- Parameters:
patterns- Inclusion patterns to set- Returns:
- This builder
- Throws:
NullPointerException- If any of the specified patterns is null
-
withFileName
-
withName
-
withDescription
-
hasDescription
public boolean hasDescription() -
getName
-
build
-
filterRulesByPriority
-