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 org.sonar.api.database.BaseIdentifiable; 023 024 import org.apache.commons.lang.builder.EqualsBuilder; 025 import org.apache.commons.lang.builder.HashCodeBuilder; 026 027 import javax.persistence.*; 028 029 /** 030 * @since 2.9 031 */ 032 @Entity 033 @Table(name = "active_rule_param_changes") 034 public class ActiveRuleParamChange extends BaseIdentifiable { 035 036 @ManyToOne(fetch = FetchType.LAZY) 037 @JoinColumn(name = "active_rule_change_id") 038 private ActiveRuleChange activeRuleChange; 039 040 @ManyToOne(fetch = FetchType.LAZY, optional = true) 041 @JoinColumn(name = "rules_parameter_id") 042 private RuleParam ruleParam; 043 044 @Column(name = "old_value", updatable = false, nullable = true, length = 4000) 045 private String oldValue; 046 047 @Column(name = "new_value", updatable = false, nullable = true, length = 4000) 048 private String newValue; 049 050 ActiveRuleParamChange(ActiveRuleChange activeRuleChange, RuleParam ruleParam, String oldValue, String newValue) { 051 this.activeRuleChange = activeRuleChange; 052 this.ruleParam = ruleParam; 053 this.oldValue = oldValue; 054 this.newValue = newValue; 055 } 056 057 public ActiveRuleChange getActiveRuleChange() { 058 return activeRuleChange; 059 } 060 061 public RuleParam getRuleParam() { 062 return ruleParam; 063 } 064 065 public String getOldValue() { 066 return oldValue; 067 } 068 069 public String getNewValue() { 070 return newValue; 071 } 072 073 public String getKey() { 074 return ruleParam.getKey(); 075 } 076 077 @Override 078 public boolean equals(Object obj) { 079 if (!(obj instanceof ActiveRuleParamChange)) { 080 return false; 081 } 082 if (this == obj) { 083 return true; 084 } 085 ActiveRuleParamChange other = (ActiveRuleParamChange) obj; 086 return new EqualsBuilder() 087 .append(getId(), other.getId()).isEquals(); 088 } 089 090 @Override 091 public int hashCode() { 092 return new HashCodeBuilder(17, 57) 093 .append(getId()) 094 .toHashCode(); 095 } 096 097 }