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
021package org.sonar.api.server.debt.internal;
022
023import org.apache.commons.lang.builder.ToStringBuilder;
024import org.apache.commons.lang.builder.ToStringStyle;
025import org.sonar.api.server.debt.DebtCharacteristic;
026
027import javax.annotation.CheckForNull;
028import javax.annotation.Nullable;
029
030import java.util.Date;
031
032/**
033 * @since 4.3
034 */
035public class DefaultDebtCharacteristic implements DebtCharacteristic {
036
037  private Integer id;
038  private String key;
039  private String name;
040  private Integer order;
041  private Integer parentId;
042  private Date createdAt;
043  private Date updatedAt;
044
045  public Integer id() {
046    return id;
047  }
048
049  public DefaultDebtCharacteristic setId(Integer id) {
050    this.id = id;
051    return this;
052  }
053
054  @Override
055  public String key() {
056    return key;
057  }
058
059  public DefaultDebtCharacteristic setKey(String key) {
060    this.key = key;
061    return this;
062  }
063
064  @Override
065  public String name() {
066    return name;
067  }
068
069  public DefaultDebtCharacteristic setName(String name) {
070    this.name = name;
071    return this;
072  }
073
074  @Override
075  @CheckForNull
076  public Integer order() {
077    return order;
078  }
079
080  public DefaultDebtCharacteristic setOrder(@Nullable Integer order) {
081    this.order = order;
082    return this;
083  }
084
085  @CheckForNull
086  public Integer parentId() {
087    return parentId;
088  }
089
090  public DefaultDebtCharacteristic setParentId(@Nullable Integer parentId) {
091    this.parentId = parentId;
092    return this;
093  }
094
095  public Date createdAt() {
096    return createdAt;
097  }
098
099  public DefaultDebtCharacteristic setCreatedAt(Date createdAt) {
100    this.createdAt = createdAt;
101    return this;
102  }
103
104  @CheckForNull
105  public Date updatedAt() {
106    return updatedAt;
107  }
108
109  public DefaultDebtCharacteristic setUpdatedAt(@Nullable Date updatedAt) {
110    this.updatedAt = updatedAt;
111    return this;
112  }
113
114  @Override
115  public boolean isSub(){
116    return parentId != null;
117  }
118
119  @Override
120  public String toString() {
121    return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
122  }
123
124}