All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.codenarc.ruleset.CompositeRuleSet.groovy Maven / Gradle / Ivy

There is a newer version: 3.5.0-groovy-4.0
Show newest version
/*
 * Copyright 2009 the original author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.codenarc.ruleset

import org.codenarc.rule.Rule

/**
 * A RuleSet implementation that aggregates a set of RuleSets and Rules.
 *
 * @author Chris Mair
  */
class CompositeRuleSet implements RuleSet {

    private final rules = []

    /**
     * Add a single Rule to this RuleSet
     * @param rule - the Rule to add
     */
    void addRule(Rule rule) {
        assert rule != null
        rules << rule
    }

    /**
     * Add all of the Rules within the specified RuleSet to this RuleSet
     * @param ruleSet - the RuleSet whose Rules are to be included
     */
    void addRuleSet(RuleSet ruleSet) {
        assert ruleSet != null
        rules.addAll(ruleSet.getRules())
    }

    /**
     * @return a List of Rule objects. The returned List is immutable.
     */
    List getRules() {
        rules.asImmutable()
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy