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 */ 020package org.sonar.batch.protocol.input; 021 022import javax.annotation.CheckForNull; 023import javax.annotation.Nullable; 024 025import java.util.HashMap; 026import java.util.Map; 027 028public class ActiveRule { 029 private final String repositoryKey, ruleKey, templateRuleKey; 030 private final String name, severity, internalKey, language; 031 private final Map<String, String> params = new HashMap<String, String>(); 032 033 public ActiveRule(String repositoryKey, String ruleKey, @Nullable String templateRuleKey, String name, @Nullable String severity, 034 @Nullable String internalKey, @Nullable String language) { 035 this.repositoryKey = repositoryKey; 036 this.ruleKey = ruleKey; 037 this.templateRuleKey = templateRuleKey; 038 this.name = name; 039 this.severity = severity; 040 this.internalKey = internalKey; 041 this.language = language; 042 } 043 044 public String repositoryKey() { 045 return repositoryKey; 046 } 047 048 public String ruleKey() { 049 return ruleKey; 050 } 051 052 @CheckForNull 053 public String templateRuleKey() { 054 return templateRuleKey; 055 } 056 057 public String name() { 058 return name; 059 } 060 061 /** 062 * Is null on manual rules 063 */ 064 @CheckForNull 065 public String severity() { 066 return severity; 067 } 068 069 /** 070 * Is null on manual rules 071 */ 072 @CheckForNull 073 public String language() { 074 return language; 075 } 076 077 @CheckForNull 078 public String param(String key) { 079 return params.get(key); 080 } 081 082 public ActiveRule addParam(String key, String value) { 083 params.put(key, value); 084 return this; 085 } 086 087 public Map<String, String> params() { 088 return params; 089 } 090 091 @CheckForNull 092 public String internalKey() { 093 return internalKey; 094 } 095}