001/* 002 * SonarQube 003 * Copyright (C) 2009-2018 SonarSource SA 004 * mailto:info 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 java.util.List; 023import org.apache.commons.lang.StringUtils; 024import org.apache.commons.lang.builder.ToStringBuilder; 025import org.apache.commons.lang.builder.ToStringStyle; 026import org.sonar.api.ExtensionPoint; 027import org.sonar.api.ce.ComputeEngineSide; 028import org.sonar.api.server.ServerSide; 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@ComputeEngineSide 037@ExtensionPoint 038public abstract class RuleRepository { 039 040 private String key; 041 private String language; 042 private String name; 043 044 protected RuleRepository(String key, String language) { 045 this.key = key; 046 this.language = language; 047 } 048 049 public final String getKey() { 050 return key; 051 } 052 053 public final String getLanguage() { 054 return language; 055 } 056 057 public final String getName() { 058 return name; 059 } 060 061 public final String getName(boolean useKeyIfEmpty) { 062 if (useKeyIfEmpty) { 063 return StringUtils.defaultIfEmpty(name, key); 064 } 065 return name; 066 } 067 068 public final RuleRepository setName(String s) { 069 this.name = s; 070 return this; 071 } 072 073 public abstract List<Rule> createRules(); 074 075 @Override 076 public String toString() { 077 return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) 078 .append("key", key) 079 .append("language", language) 080 .append("name", name) 081 .toString(); 082 } 083}