001 /* 002 * Sonar, open source software quality management tool. 003 * Copyright (C) 2008-2012 SonarSource 004 * mailto:contact AT sonarsource DOT com 005 * 006 * Sonar 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 * Sonar 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 017 * License along with Sonar; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 019 */ 020 package org.sonar.api.qualitymodel; 021 022 import javax.persistence.*; 023 024 /** 025 * @since 2.3 026 */ 027 @Entity 028 @Table(name = "characteristic_properties") 029 public final class CharacteristicProperty { 030 031 @Id 032 @Column(name = "id") 033 @GeneratedValue 034 private Integer id; 035 036 @Column(name = "kee", nullable = true, length = 100) 037 private String key; 038 039 @Column(name = "value", nullable = true) 040 private Double value; 041 042 @Column(name = "text_value", nullable = true, length = 4000) 043 private String textValue; 044 045 @ManyToOne(fetch = FetchType.EAGER) 046 @JoinColumn(name = "characteristic_id", updatable = true, nullable = false) 047 private Characteristic characteristic; 048 049 /** 050 * Use the factory method create() 051 */ 052 CharacteristicProperty() { 053 } 054 055 public static CharacteristicProperty create(String key) { 056 return new CharacteristicProperty().setKey(key); 057 } 058 059 public Integer getId() { 060 return id; 061 } 062 063 CharacteristicProperty setId(Integer i) { 064 this.id = i; 065 return this; 066 } 067 068 public String getKey() { 069 return key; 070 } 071 072 public CharacteristicProperty setKey(String s) { 073 this.key = s; 074 return this; 075 } 076 077 public String getTextValue() { 078 return textValue; 079 } 080 081 public Double getValue() { 082 return value; 083 } 084 085 public Long getValueAsLong() { 086 if (value!=null) { 087 return value.longValue(); 088 } 089 return null; 090 } 091 092 public CharacteristicProperty setTextValue(String s) { 093 this.textValue = s; 094 return this; 095 } 096 097 public CharacteristicProperty setValue(Double d) { 098 this.value = d; 099 return this; 100 } 101 102 Characteristic getCharacteristic() { 103 return characteristic; 104 } 105 106 CharacteristicProperty setCharacteristic(Characteristic c) { 107 this.characteristic = c; 108 return this; 109 } 110 }