001/* 002 * SonarQube 003 * Copyright (C) 2009-2016 SonarSource SA 004 * mailto:contact AT sonarsource DOT com 005 * 006 * This program 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 * This program 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.api.rules; 021 022import org.apache.commons.lang.StringUtils; 023import org.apache.commons.lang.builder.ToStringBuilder; 024import org.apache.commons.lang.builder.ToStringStyle; 025import org.sonar.api.ExtensionPoint; 026import org.sonar.api.server.ServerSide; 027 028import java.util.List; 029 030/** 031 * @since 2.3 032 * @deprecated in 4.2. Replaced by org.sonar.api.server.rule.RulesDefinition 033 */ 034@Deprecated 035@ServerSide 036@ExtensionPoint 037public abstract class RuleRepository { 038 039 private String key; 040 private String language; 041 private String name; 042 043 protected RuleRepository(String key, String language) { 044 this.key = key; 045 this.language = language; 046 } 047 048 public final String getKey() { 049 return key; 050 } 051 052 public final String getLanguage() { 053 return language; 054 } 055 056 public final String getName() { 057 return name; 058 } 059 060 public final String getName(boolean useKeyIfEmpty) { 061 if (useKeyIfEmpty) { 062 return StringUtils.defaultIfEmpty(name, key); 063 } 064 return name; 065 } 066 067 public final RuleRepository setName(String s) { 068 this.name = s; 069 return this; 070 } 071 072 public abstract List<Rule> createRules(); 073 074 @Override 075 public String toString() { 076 return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) 077 .append("key", key) 078 .append("language", language) 079 .append("name", name) 080 .toString(); 081 } 082}