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.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.hibernate.annotations.Cache;
026 import org.hibernate.annotations.CacheConcurrencyStrategy;
027 import org.hibernate.annotations.Immutable;
028 import org.sonar.api.database.BaseIdentifiable;
029
030 import javax.persistence.Column;
031 import javax.persistence.Entity;
032 import javax.persistence.Table;
033
034 @Immutable
035 @Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
036 @Entity
037 @Table(name = "rules_categories")
038 public class RulesCategory extends BaseIdentifiable {
039
040 @Column(name = "name", updatable = false, nullable = false)
041 private String name;
042
043 @Column(name = "description", updatable = false, nullable = true)
044 private String description;
045
046 public RulesCategory(String name) {
047 this.name = name;
048 }
049
050 public RulesCategory(String name, String description) {
051 this.name = name;
052 this.description = description;
053 }
054
055 public RulesCategory() {
056 }
057
058 public String getName() {
059 return name;
060 }
061
062 public void setName(String name) {
063 this.name = name;
064 }
065
066 public String getDescription() {
067 return description;
068 }
069
070 public void setDescription(String description) {
071 this.description = description;
072 }
073
074 @Override
075 public boolean equals(Object obj) {
076 if (!(obj instanceof RulesCategory)) {
077 return false;
078 }
079 if (this == obj) {
080 return true;
081 }
082 RulesCategory other = (RulesCategory) obj;
083 return new EqualsBuilder()
084 .append(name, other.getName()).isEquals();
085 }
086
087 @Override
088 public int hashCode() {
089 return new HashCodeBuilder(17, 37)
090 .append(name)
091 .toHashCode();
092 }
093
094 @Override
095 public String toString() {
096 return new ToStringBuilder(this)
097 .append("id", getId())
098 .append("name", name)
099 .append("desc", description)
100 .toString();
101 }
102
103 }