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