001 /*
002 * SonarQube, open source software quality management tool.
003 * Copyright (C) 2008-2014 SonarSource
004 * mailto:contact AT sonarsource DOT com
005 *
006 * SonarQube 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 * SonarQube 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 License
017 * along with this program; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
019 */
020 package org.sonar.api.rules;
021
022 import javax.persistence.*;
023
024 @Entity
025 @Table(name = "active_rule_parameters")
026 public class ActiveRuleParam implements Cloneable {
027
028 @Id
029 @Column(name = "id")
030 @GeneratedValue
031 private Integer id;
032
033 @ManyToOne(fetch = FetchType.LAZY)
034 @JoinColumn(name = "active_rule_id")
035 private ActiveRule activeRule;
036
037 @ManyToOne(fetch = FetchType.LAZY, optional = true)
038 @JoinColumn(name = "rules_parameter_id")
039 private RuleParam ruleParam;
040
041 @Column(name = "rules_parameter_key", updatable = false, nullable = false, length = 128)
042 private String paramKey;
043
044 @Column(name = "value", updatable = false, nullable = true, length = 4000)
045 private String value;
046
047 public Integer getId() {
048 return id;
049 }
050
051 /**
052 * @deprecated visibility should be decreased to protected or package
053 */
054 @Deprecated
055 void setId(Integer id) {
056 this.id = id;
057 }
058
059 /**
060 * @deprecated visibility should be decreased to protected or package
061 */
062 @Deprecated
063 public ActiveRuleParam() {
064 }
065
066 /**
067 * @deprecated visibility should be decreased to protected or package
068 */
069 @Deprecated
070 public ActiveRuleParam(ActiveRule activeRule, RuleParam ruleParam, String value) {
071 this.activeRule = activeRule;
072 this.ruleParam = ruleParam;
073 this.value = value;
074 this.paramKey = ruleParam.getKey();
075 }
076
077 public ActiveRule getActiveRule() {
078 return activeRule;
079 }
080
081 /**
082 * @deprecated visibility should be decreased to protected or package
083 */
084 @Deprecated
085 public void setActiveRule(ActiveRule activeRule) {
086 this.activeRule = activeRule;
087 }
088
089 public RuleParam getRuleParam() {
090 return ruleParam;
091 }
092
093 /**
094 * @deprecated visibility should be decreased to protected or package
095 */
096 @Deprecated
097 public void setRuleParam(RuleParam ruleParam) {
098 this.ruleParam = ruleParam;
099 }
100
101 public String getValue() {
102 return value;
103 }
104
105 public void setValue(String value) {
106 this.value = value;
107 }
108
109 public String getParamKey() {
110 return paramKey;
111 }
112
113 public void setParamKey(String paramKey) {
114 this.paramKey = paramKey;
115 }
116
117
118 public String getKey() {
119 return ruleParam.getKey();
120 }
121
122 @Override
123 public boolean equals(Object obj) {
124 if (!(obj instanceof ActiveRuleParam)) {
125 return false;
126 }
127 if (this == obj) {
128 return true;
129 }
130 ActiveRuleParam other = (ActiveRuleParam) obj;
131 return other.getKey().equals(getKey());
132 }
133
134 @Override
135 public int hashCode() {
136 return getKey().hashCode();
137 }
138
139 @Override
140 public Object clone() {
141 return new ActiveRuleParam(getActiveRule(), getRuleParam(), getValue());
142 }
143
144 }