001 /*
002 * SonarQube, open source software quality management tool.
003 * Copyright (C) 2008-2014 SonarSource
004 * mailto:contact AT sonarsource DOT com
005 *
006 * SonarQube is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * SonarQube is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public License
017 * along with this program; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
019 */
020 package org.sonar.api.batch.rule.internal;
021
022 import com.google.common.collect.ImmutableMap;
023 import org.sonar.api.batch.rule.ActiveRule;
024 import org.sonar.api.rule.RuleKey;
025
026 import javax.annotation.concurrent.Immutable;
027
028 import java.util.Map;
029
030 @Immutable
031 public class DefaultActiveRule implements ActiveRule {
032 private final RuleKey ruleKey;
033 private final String name;
034 private final String severity, internalKey, language;
035 private final Map<String, String> params;
036
037 DefaultActiveRule(NewActiveRule newActiveRule) {
038 this.severity = newActiveRule.severity;
039 this.name = newActiveRule.name;
040 this.internalKey = newActiveRule.internalKey;
041 this.ruleKey = newActiveRule.ruleKey;
042 this.params = ImmutableMap.copyOf(newActiveRule.params);
043 this.language = newActiveRule.language;
044 }
045
046 @Override
047 public RuleKey ruleKey() {
048 return ruleKey;
049 }
050
051 public String name() {
052 return name;
053 }
054
055 @Override
056 public String severity() {
057 return severity;
058 }
059
060 @Override
061 public String language() {
062 return language;
063 }
064
065 @Override
066 public String param(String key) {
067 return params.get(key);
068 }
069
070 @Override
071 public Map<String, String> params() {
072 // already immutable
073 return params;
074 }
075
076 @Override
077 public String internalKey() {
078 return internalKey;
079 }
080 }