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.sonar.api.database.BaseIdentifiable;
025
026 import javax.persistence.*;
027
028 @Entity
029 @Table(name = "active_rule_parameters")
030 public class ActiveRuleParam extends BaseIdentifiable implements Cloneable {
031
032
033 @ManyToOne(fetch = FetchType.LAZY)
034 @JoinColumn(name = "active_rule_id")
035 private ActiveRule activeRule;
036
037 @ManyToOne(fetch = FetchType.LAZY)
038 @JoinColumn(name = "rules_parameter_id")
039 private RuleParam ruleParam;
040
041 @Column(name = "value", updatable = false, nullable = true, length = 4000)
042 private String value;
043
044
045 public ActiveRuleParam() {
046 }
047
048 public ActiveRuleParam(ActiveRule activeRule, RuleParam ruleParam, String value) {
049 this.activeRule = activeRule;
050 this.ruleParam = ruleParam;
051 this.value = value;
052 }
053
054 public ActiveRule getActiveRule() {
055 return activeRule;
056 }
057
058 public void setActiveRule(ActiveRule activeRule) {
059 this.activeRule = activeRule;
060 }
061
062 public RuleParam getRuleParam() {
063 return ruleParam;
064 }
065
066 public void setRuleParam(RuleParam ruleParam) {
067 this.ruleParam = ruleParam;
068 }
069
070 public String getValue() {
071 return value;
072 }
073
074 public void setValue(String value) {
075 this.value = value;
076 }
077
078 @Override
079 public boolean equals(Object obj) {
080 if (!(obj instanceof RuleParam)) {
081 return false;
082 }
083 if (this == obj) {
084 return true;
085 }
086 RuleParam other = (RuleParam) obj;
087 return new EqualsBuilder()
088 .append(getId(), other.getKey()).isEquals();
089 }
090
091 @Override
092 public int hashCode() {
093 return new HashCodeBuilder(17, 37)
094 .append(getId())
095 .toHashCode();
096 }
097
098 @Override
099 public Object clone() {
100 return new ActiveRuleParam(getActiveRule(), getRuleParam(), getValue());
101 }
102
103 }