You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CharacteristicProperty.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Sonar, open source software quality management tool.
  3. * Copyright (C) 2009 SonarSource SA
  4. * mailto:contact AT sonarsource DOT com
  5. *
  6. * Sonar is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * Sonar is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with Sonar; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
  19. */
  20. package org.sonar.api.qualitymodel;
  21. import javax.persistence.*;
  22. /**
  23. * @since 2.3
  24. */
  25. @Entity
  26. @Table(name = "characteristic_properties")
  27. public final class CharacteristicProperty {
  28. @Id
  29. @Column(name = "id")
  30. @GeneratedValue
  31. private Integer id;
  32. @Column(name = "kee", nullable = true, length = 100)
  33. private String key;
  34. @Column(name = "value", nullable = true)
  35. private Double value;
  36. @Column(name = "text_value", nullable = true, length = 4000)
  37. private String textValue;
  38. @ManyToOne(fetch = FetchType.EAGER)
  39. @JoinColumn(name = "characteristic_id", updatable = true, nullable = false)
  40. private Characteristic characteristic;
  41. CharacteristicProperty(Characteristic characteristic, String key) {
  42. this.characteristic = characteristic;
  43. this.key = key;
  44. }
  45. public Integer getId() {
  46. return id;
  47. }
  48. CharacteristicProperty setId(Integer i) {
  49. this.id = i;
  50. return this;
  51. }
  52. public String getKey() {
  53. return key;
  54. }
  55. public CharacteristicProperty setKey(String s) {
  56. this.key = s;
  57. return this;
  58. }
  59. public String getValue() {
  60. return textValue;
  61. }
  62. public Double getValueAsDouble() {
  63. return value;
  64. }
  65. public Long getValueAsLong() {
  66. if (value!=null) {
  67. return value.longValue();
  68. }
  69. return null;
  70. }
  71. public Boolean getValueAsBoolean() {
  72. if (textValue!=null) {
  73. return Boolean.parseBoolean(textValue);
  74. }
  75. return null;
  76. }
  77. public CharacteristicProperty setValue(String s) {
  78. this.textValue = s;
  79. return this;
  80. }
  81. public CharacteristicProperty setValue(Boolean b) {
  82. this.textValue = (b==null ? null : String.valueOf(b));
  83. return this;
  84. }
  85. public CharacteristicProperty setValue(Long l) {
  86. this.textValue = (l==null ? null : String.valueOf(l));
  87. return this;
  88. }
  89. public CharacteristicProperty setValue(Double d) {
  90. this.value = d;
  91. return this;
  92. }
  93. Characteristic getCharacteristic() {
  94. return characteristic;
  95. }
  96. CharacteristicProperty setCharacteristic(Characteristic c) {
  97. this.characteristic = c;
  98. return this;
  99. }
  100. }