2 * SonarQube, open source software quality management tool.
3 * Copyright (C) 2008-2013 SonarSource
4 * mailto:contact AT sonarsource DOT com
6 * SonarQube is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * SonarQube is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 package org.sonar.api.technicaldebt.server.internal;
23 import org.apache.commons.lang.builder.ToStringBuilder;
24 import org.apache.commons.lang.builder.ToStringStyle;
25 import org.sonar.api.rule.RuleKey;
26 import org.sonar.api.technicaldebt.server.Characteristic;
27 import org.sonar.api.utils.WorkUnit;
29 import javax.annotation.CheckForNull;
30 import javax.annotation.Nullable;
35 public class DefaultCharacteristic implements Characteristic {
40 private Integer order;
41 private Integer parentId;
42 private Integer rootId;
43 private RuleKey ruleKey;
44 private String function;
45 private WorkUnit factor;
46 private WorkUnit offset;
52 public DefaultCharacteristic setId(Integer id) {
62 public DefaultCharacteristic setKey(@Nullable String key) {
68 public String name() {
72 public DefaultCharacteristic setName(@Nullable String name) {
78 public Integer order() {
82 public DefaultCharacteristic setOrder(@Nullable Integer order) {
88 public Integer parentId() {
92 public DefaultCharacteristic setParentId(@Nullable Integer parentId) {
93 this.parentId = parentId;
98 public Integer rootId() {
102 public DefaultCharacteristic setRootId(@Nullable Integer rootId) {
103 this.rootId = rootId;
108 public RuleKey ruleKey() {
112 public DefaultCharacteristic setRuleKey(@Nullable RuleKey ruleKey) {
113 this.ruleKey = ruleKey;
118 public String function() {
122 public DefaultCharacteristic setFunction(@Nullable String function) {
123 this.function = function;
128 public WorkUnit factor() {
132 public DefaultCharacteristic setFactor(@Nullable WorkUnit factor) {
133 this.factor = factor;
138 public WorkUnit offset() {
142 public DefaultCharacteristic setOffset(@Nullable WorkUnit offset) {
143 this.offset = offset;
147 public boolean isRoot() {
148 return parentId == null;
151 public boolean isRequirement() {
152 return ruleKey != null;
156 public boolean equals(Object o) {
160 if (o == null || getClass() != o.getClass()) {
164 DefaultCharacteristic that = (DefaultCharacteristic) o;
166 if (key != null ? !key.equals(that.key) : that.key != null) {
169 if (ruleKey != null ? !ruleKey.equals(that.ruleKey) : that.ruleKey != null) {
177 public int hashCode() {
178 int result = key != null ? key.hashCode() : 0;
179 result = 31 * result + (ruleKey != null ? ruleKey.hashCode() : 0);
184 public String toString() {
185 return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);