Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

CharacteristicProperty.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. /**
  42. * Use the factory method create()
  43. */
  44. CharacteristicProperty() {
  45. }
  46. public static CharacteristicProperty create(String key) {
  47. return new CharacteristicProperty().setKey(key);
  48. }
  49. public Integer getId() {
  50. return id;
  51. }
  52. CharacteristicProperty setId(Integer i) {
  53. this.id = i;
  54. return this;
  55. }
  56. public String getKey() {
  57. return key;
  58. }
  59. public CharacteristicProperty setKey(String s) {
  60. this.key = s;
  61. return this;
  62. }
  63. public String getValue() {
  64. return textValue;
  65. }
  66. public Double getValueAsDouble() {
  67. return value;
  68. }
  69. public Long getValueAsLong() {
  70. if (value!=null) {
  71. return value.longValue();
  72. }
  73. return null;
  74. }
  75. public Boolean getValueAsBoolean() {
  76. if (textValue!=null) {
  77. return Boolean.parseBoolean(textValue);
  78. }
  79. return null;
  80. }
  81. public CharacteristicProperty setValue(String s) {
  82. this.textValue = s;
  83. return this;
  84. }
  85. public CharacteristicProperty setValue(Boolean b) {
  86. this.textValue = (b==null ? null : String.valueOf(b));
  87. return this;
  88. }
  89. public CharacteristicProperty setValue(Long l) {
  90. this.textValue = (l==null ? null : String.valueOf(l));
  91. return this;
  92. }
  93. public CharacteristicProperty setValue(Double d) {
  94. this.value = d;
  95. return this;
  96. }
  97. Characteristic getCharacteristic() {
  98. return characteristic;
  99. }
  100. CharacteristicProperty setCharacteristic(Characteristic c) {
  101. this.characteristic = c;
  102. return this;
  103. }
  104. }