001    /*
002     * Sonar, open source software quality management tool.
003     * Copyright (C) 2008-2012 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    package org.sonar.api.rules;
021    
022    import org.apache.commons.lang.builder.EqualsBuilder;
023    import org.apache.commons.lang.builder.HashCodeBuilder;
024    import org.apache.commons.lang.builder.ToStringBuilder;
025    import org.sonar.api.database.BaseIdentifiable;
026    
027    /**
028     * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
029     */
030    @Deprecated
031    public class RulesCategory extends BaseIdentifiable {
032    
033      private String name;
034      private String description;
035    
036      /**
037       * Creates a RuleCategory based on the category name
038       *
039       * @param name the category name
040       */
041      public RulesCategory(String name) {
042        this.name = name;
043      }
044    
045      /**
046       * Creates a category based on the category name and description
047       *
048       * @param name        the category name
049       * @param description the category description
050       */
051      public RulesCategory(String name, String description) {
052        this.name = name;
053        this.description = description;
054      }
055    
056      /**
057       * Creates an empty category
058       */
059      public RulesCategory() {
060      }
061    
062      /**
063       * @return the category name
064       */
065      public String getName() {
066        return name;
067      }
068    
069      /**
070       * Sets the category name
071       *
072       * @param name the name
073       */
074      public void setName(String name) {
075        this.name = name;
076      }
077    
078      /**
079       * @return the category description
080       */
081      public String getDescription() {
082        return description;
083      }
084    
085      /**
086       * Sets the cay description
087       *
088       * @param description the description
089       */
090      public void setDescription(String description) {
091        this.description = description;
092      }
093    
094      @Override
095      public boolean equals(Object obj) {
096        if (!(obj instanceof RulesCategory)) {
097          return false;
098        }
099        if (this == obj) {
100          return true;
101        }
102        RulesCategory other = (RulesCategory) obj;
103        return new EqualsBuilder()
104          .append(name, other.getName()).isEquals();
105      }
106    
107      @Override
108      public int hashCode() {
109        return new HashCodeBuilder(17, 37)
110          .append(name)
111          .toHashCode();
112      }
113    
114      @Override
115      public String toString() {
116        return new ToStringBuilder(this)
117          .append("id", getId())
118          .append("name", name)
119          .append("desc", description)
120          .toString();
121      }
122    }