001 /* 002 * Sonar, open source software quality management tool. 003 * Copyright (C) 2009 SonarSource SA 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 package org.sonar.api.checks.templates; 021 022 import org.sonar.check.IsoCategory; 023 import org.sonar.check.Priority; 024 025 import java.util.ArrayList; 026 import java.util.Collections; 027 import java.util.List; 028 import java.util.Locale; 029 030 /** 031 * @since 2.1 (experimental) 032 * @deprecated since 2.3 033 */ 034 @Deprecated 035 public abstract class CheckTemplate { 036 037 protected String key; 038 protected String configKey; 039 protected Priority priority; 040 protected IsoCategory isoCategory; 041 protected List<CheckTemplateProperty> properties; 042 043 public CheckTemplate(String key) { 044 this.key = key; 045 } 046 047 public CheckTemplate() { 048 } 049 050 public String getKey() { 051 return key; 052 } 053 054 public void setKey(String s) { 055 this.key = s; 056 } 057 058 public Priority getPriority() { 059 return priority; 060 } 061 062 public void setPriority(Priority p) { 063 this.priority = p; 064 } 065 066 public IsoCategory getIsoCategory() { 067 return isoCategory; 068 } 069 070 public void setIsoCategory(IsoCategory c) { 071 this.isoCategory = c; 072 } 073 074 public String getConfigKey() { 075 return configKey; 076 } 077 078 public void setConfigKey(String configKey) { 079 this.configKey = configKey; 080 } 081 082 public abstract String getTitle(Locale locale); 083 084 public abstract String getDescription(Locale locale); 085 086 public abstract String getMessage(Locale locale, String key, Object... params); 087 088 public List<CheckTemplateProperty> getProperties() { 089 if (properties==null) { 090 return Collections.emptyList(); 091 } 092 return properties; 093 } 094 095 public void addProperty(CheckTemplateProperty p) { 096 if (properties==null) { 097 properties = new ArrayList<CheckTemplateProperty>(); 098 } 099 properties.add(p); 100 } 101 102 public CheckTemplateProperty getProperty(String key) { 103 if (properties!=null) { 104 for (CheckTemplateProperty property : properties) { 105 if (property.getKey().equals(key)) { 106 return property; 107 } 108 } 109 } 110 return null; 111 } 112 113 /** 114 * Checks are equal within the same plugin. Two plugins can have two different checks with the same key. 115 */ 116 @Override 117 public final boolean equals(Object o) { 118 if (this == o) { 119 return true; 120 } 121 if (!(o instanceof CheckTemplate)) { 122 return false; 123 } 124 125 CheckTemplate checkTemplate = (CheckTemplate) o; 126 return key.equals(checkTemplate.key); 127 } 128 129 @Override 130 public final int hashCode() { 131 return key.hashCode(); 132 } 133 134 }