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