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 */
020package org.sonar.api.rules;
021
022public class ActiveRuleParam implements Cloneable {
023
024  private Integer id;
025  private ActiveRule activeRule;
026  private RuleParam ruleParam;
027  private String paramKey;
028  private String value;
029
030  public Integer getId() {
031    return id;
032  }
033
034  /**
035   * @deprecated visibility should be decreased to protected or package
036   */
037  @Deprecated
038  void setId(Integer id) {
039    this.id = id;
040  }
041
042  /**
043   * @deprecated visibility should be decreased to protected or package
044   */
045  @Deprecated
046  public ActiveRuleParam() {
047  }
048
049  /**
050   * @deprecated visibility should be decreased to protected or package
051   */
052  @Deprecated
053  public ActiveRuleParam(ActiveRule activeRule, RuleParam ruleParam, String value) {
054    this.activeRule = activeRule;
055    this.ruleParam = ruleParam;
056    this.value = value;
057    this.paramKey = ruleParam.getKey();
058  }
059
060  public ActiveRule getActiveRule() {
061    return activeRule;
062  }
063
064  /**
065   * @deprecated visibility should be decreased to protected or package
066   */
067  @Deprecated
068  public void setActiveRule(ActiveRule activeRule) {
069    this.activeRule = activeRule;
070  }
071
072  public RuleParam getRuleParam() {
073    return ruleParam;
074  }
075
076  /**
077   * @deprecated visibility should be decreased to protected or package
078   */
079  @Deprecated
080  public void setRuleParam(RuleParam ruleParam) {
081    this.ruleParam = ruleParam;
082  }
083
084  public String getValue() {
085    return value;
086  }
087
088  public void setValue(String value) {
089    this.value = value;
090  }
091
092  public String getParamKey() {
093    return paramKey;
094  }
095
096  public void setParamKey(String paramKey) {
097    this.paramKey = paramKey;
098  }
099
100
101  public String getKey() {
102    return ruleParam.getKey();
103  }
104
105  @Override
106  public boolean equals(Object obj) {
107    if (!(obj instanceof ActiveRuleParam)) {
108      return false;
109    }
110    if (this == obj) {
111      return true;
112    }
113    ActiveRuleParam other = (ActiveRuleParam) obj;
114    return other.getKey().equals(getKey());
115  }
116
117  @Override
118  public int hashCode() {
119    return getKey().hashCode();
120  }
121
122  @Override
123  public Object clone() {
124    return new ActiveRuleParam(getActiveRule(), getRuleParam(), getValue());
125  }
126
127}