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 javax.persistence.Column;
023 import javax.persistence.Entity;
024 import javax.persistence.FetchType;
025 import javax.persistence.GeneratedValue;
026 import javax.persistence.Id;
027 import javax.persistence.JoinColumn;
028 import javax.persistence.ManyToOne;
029 import javax.persistence.Table;
030
031 @Entity
032 @Table(name = "active_rule_parameters")
033 public class ActiveRuleParam implements Cloneable {
034
035 @Id
036 @Column(name = "id")
037 @GeneratedValue
038 private Integer id;
039
040 @ManyToOne(fetch = FetchType.LAZY)
041 @JoinColumn(name = "active_rule_id")
042 private ActiveRule activeRule;
043
044 @ManyToOne(fetch = FetchType.LAZY, optional = true)
045 @JoinColumn(name = "rules_parameter_id")
046 private RuleParam ruleParam;
047
048 @Column(name = "value", updatable = false, nullable = true, length = 4000)
049 private String value;
050
051 public Integer getId() {
052 return id;
053 }
054
055 /**
056 * @deprecated visibility should be decreased to protected or package
057 */
058 @Deprecated
059 void setId(Integer id) {
060 this.id = id;
061 }
062
063 /**
064 * @deprecated visibility should be decreased to protected or package
065 */
066 @Deprecated
067 public ActiveRuleParam() {
068 }
069
070 /**
071 * @deprecated visibility should be decreased to protected or package
072 */
073 @Deprecated
074 public ActiveRuleParam(ActiveRule activeRule, RuleParam ruleParam, String value) {
075 this.activeRule = activeRule;
076 this.ruleParam = ruleParam;
077 this.value = value;
078 }
079
080 public ActiveRule getActiveRule() {
081 return activeRule;
082 }
083
084 /**
085 * @deprecated visibility should be decreased to protected or package
086 */
087 @Deprecated
088 public void setActiveRule(ActiveRule activeRule) {
089 this.activeRule = activeRule;
090 }
091
092 public RuleParam getRuleParam() {
093 return ruleParam;
094 }
095
096 /**
097 * @deprecated visibility should be decreased to protected or package
098 */
099 @Deprecated
100 public void setRuleParam(RuleParam ruleParam) {
101 this.ruleParam = ruleParam;
102 }
103
104 public String getValue() {
105 return value;
106 }
107
108 public void setValue(String value) {
109 this.value = value;
110 }
111
112 public String getKey() {
113 return ruleParam.getKey();
114 }
115
116 @Override
117 public boolean equals(Object obj) {
118 if (!(obj instanceof ActiveRuleParam)) {
119 return false;
120 }
121 if (this == obj) {
122 return true;
123 }
124 ActiveRuleParam other = (ActiveRuleParam) obj;
125 return other.getKey().equals(getKey());
126 }
127
128 @Override
129 public int hashCode() {
130 return getKey().hashCode();
131 }
132
133 @Override
134 public Object clone() {
135 return new ActiveRuleParam(getActiveRule(), getRuleParam(), getValue());
136 }
137
138 }