001 /* 002 * Sonar, open source software quality management tool. 003 * Copyright (C) 2008-2011 SonarSource 004 * mailto:contact AT sonarsource DOT com 005 * 006 * Sonar 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 * Sonar 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 017 * License along with Sonar; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 019 */ 020 021 package org.sonar.wsclient.services; 022 023 import java.util.*; 024 025 /** 026 * @since 2.7 027 */ 028 public class Profile extends Model { 029 030 private String language; 031 private String name; 032 private boolean defaultProfile; 033 private boolean provided; 034 private String parentName; 035 private List<Rule> rules = new ArrayList<Rule>(); 036 037 public String getLanguage() { 038 return language; 039 } 040 041 public Profile setLanguage(String s) { 042 this.language = s; 043 return this; 044 } 045 046 public String getName() { 047 return name; 048 } 049 050 public Profile setName(String name) { 051 this.name = name; 052 return this; 053 } 054 055 public boolean isDefaultProfile() { 056 return defaultProfile; 057 } 058 059 public Profile setDefaultProfile(boolean b) { 060 this.defaultProfile = b; 061 return this; 062 } 063 064 public boolean isProvided() { 065 return provided; 066 } 067 068 public Profile setProvided(boolean b) { 069 this.provided = b; 070 return this; 071 } 072 073 public String getParentName() { 074 return parentName; 075 } 076 077 public Profile setParentName(String s) { 078 this.parentName = s; 079 return this; 080 } 081 082 public List<Rule> getRules() { 083 return rules; 084 } 085 086 public Rule getRule(String repositoryKey, String ruleKey) { 087 for (Rule rule : rules) { 088 if (repositoryKey.equals(rule.getRepository()) && ruleKey.equals(rule.getKey())) { 089 return rule; 090 } 091 } 092 return null; 093 } 094 095 public Profile addRule(Rule rule) { 096 rules.add(rule); 097 return this; 098 } 099 100 public static final class Rule { 101 private String key; 102 private String repository; 103 private String severity; 104 private String inheritance; 105 private Map<String,String> parameters; 106 107 public String getKey() { 108 return key; 109 } 110 111 public Rule setKey(String key) { 112 this.key = key; 113 return this; 114 } 115 116 public String getRepository() { 117 return repository; 118 } 119 120 public Rule setRepository(String repository) { 121 this.repository = repository; 122 return this; 123 } 124 125 public String getSeverity() { 126 return severity; 127 } 128 129 public Rule setSeverity(String severity) { 130 this.severity = severity; 131 return this; 132 } 133 134 public String getInheritance() { 135 return inheritance; 136 } 137 138 public Rule setInheritance(String inheritance) { 139 this.inheritance = inheritance; 140 return this; 141 } 142 143 public Map<String, String> getParameters() { 144 if (parameters==null) { 145 return Collections.emptyMap(); 146 } 147 return parameters; 148 } 149 150 public String getParameter(String key) { 151 return getParameters().get(key); 152 } 153 154 public Rule addParameter(String key, String value) { 155 if (parameters==null) { 156 parameters = new HashMap<String,String>(); 157 } 158 parameters.put(key, value); 159 return this; 160 } 161 } 162 }