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