RuleSet implements ChecksumAware { public Rule getRuleByName(String ruleName) { for (Rule r : rules) { if (r.getName().equals(ruleName)) { return r; } } return null; } private  RuleSet(final RuleSetBuilder builder);  RuleSet(final RuleSet rs); @Deprecated List<String> getExcludePatterns(); int size(); Collection<Rule> getRules(); Rule getRuleByName(String ruleName); boolean applies(File file); void start(RuleContext ctx); void apply(List<? extends Node> acuList, RuleContext ctx); static boolean applies(Rule rule, LanguageVersion languageVersion); void end(RuleContext ctx); @Override boolean equals(Object o); @Override int hashCode(); String getFileName(); String getName(); String getDescription(); @Deprecated List<String> getIncludePatterns(); List<Pattern> getFileExclusions(); List<Pattern> getFileInclusions(); @Deprecated boolean usesDFA(Language language); @Deprecated boolean usesTypeResolution(Language language); @Deprecated boolean usesMultifile(Language language); void removeDysfunctionalRules(Collection<Rule> collector); @Override long getChecksum();  }
@Test public void testGetRuleByName() { MockRule mock = new MockRule("name", "desc", "msg", "rulesetname"); RuleSet rs = RulesetsFactoryUtils.defaultFactory().createSingleRuleRuleSet(mock); assertEquals("unable to fetch rule by name", mock, rs.getRuleByName("name")); }
@Test public void testGetRuleByName2() { MockRule mock = new MockRule("name", "desc", "msg", "rulesetname"); RuleSet rs = RulesetsFactoryUtils.defaultFactory().createSingleRuleRuleSet(mock); assertNull("the rule FooRule must not be found!", rs.getRuleByName("FooRule")); }
@Test public void copyConstructorDeepCopies() { Rule rule = new FooRule(); rule.setName("FooRule1"); rule.setLanguage(LanguageRegistry.getLanguage(DummyLanguageModule.NAME)); rule.addRuleChainVisit("dummyNode"); RuleSet ruleSet1 = createRuleSetBuilder("RuleSet1") .addRule(rule) .build(); RuleSet ruleSet2 = new RuleSet(ruleSet1); assertEquals(ruleSet1, ruleSet2); assertNotSame(ruleSet1, ruleSet2); assertEquals(rule, ruleSet2.getRuleByName("FooRule1")); assertNotSame(rule, ruleSet2.getRuleByName("FooRule1")); }