You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RuleRepository.java 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2019 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonar.api.rules;
  21. import java.util.List;
  22. import org.apache.commons.lang.StringUtils;
  23. import org.apache.commons.lang.builder.ToStringBuilder;
  24. import org.apache.commons.lang.builder.ToStringStyle;
  25. import org.sonar.api.ExtensionPoint;
  26. import org.sonar.api.ce.ComputeEngineSide;
  27. import org.sonar.api.server.ServerSide;
  28. /**
  29. * @since 2.3
  30. * @deprecated in 4.2. Replaced by org.sonar.api.server.rule.RulesDefinition
  31. */
  32. @Deprecated
  33. @ServerSide
  34. @ComputeEngineSide
  35. @ExtensionPoint
  36. public abstract class RuleRepository {
  37. private String key;
  38. private String language;
  39. private String name;
  40. protected RuleRepository(String key, String language) {
  41. this.key = key;
  42. this.language = language;
  43. }
  44. public final String getKey() {
  45. return key;
  46. }
  47. public final String getLanguage() {
  48. return language;
  49. }
  50. public final String getName() {
  51. return name;
  52. }
  53. public final String getName(boolean useKeyIfEmpty) {
  54. if (useKeyIfEmpty) {
  55. return StringUtils.defaultIfEmpty(name, key);
  56. }
  57. return name;
  58. }
  59. public final RuleRepository setName(String s) {
  60. this.name = s;
  61. return this;
  62. }
  63. public abstract List<Rule> createRules();
  64. @Override
  65. public String toString() {
  66. return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
  67. .append("key", key)
  68. .append("language", language)
  69. .append("name", name)
  70. .toString();
  71. }
  72. }