BrightSide Workbench Full Report + Source Code
contacts/src/main/java/org/turro/contacts/FieldValue.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.contacts;
19 
20 import javax.persistence.Column;
21 import javax.persistence.Entity;
22 import javax.persistence.GeneratedValue;
23 import javax.persistence.Id;
24 import javax.persistence.JoinColumn;
25 import javax.persistence.ManyToOne;
26 import org.turro.string.ObjectString;
27 
32 @Entity
33 @org.hibernate.annotations.GenericGenerator(name = "hibernate-uuid", strategy = "uuid")
34 public class FieldValue implements java.io.Serializable {
35 
36  @Id
37  @GeneratedValue(generator = "hibernate-uuid")
38  @Column(name="IDENTIFIER")
39  private String id;
40 
41  @Column(name="FIELD_VALUE")
42  private String value;
43 
44  @ManyToOne
45  private FieldDef fieldDef;
46 
47  @ManyToOne
48  @JoinColumn(name="CONTACT_FK")
49  private org.turro.contacts.Contact contact;
50 
51  public Contact getContact() {
52  return contact;
53  }
54 
55  public void setContact(Contact contact) {
56  this.contact = contact;
57  }
58 
59  public FieldDef getFieldDef() {
60  return fieldDef;
61  }
62 
63  public void setFieldDef(FieldDef fieldDef) {
64  this.fieldDef = fieldDef;
65  }
66 
67  public String getId() {
68  return id;
69  }
70 
71  public void setId(String id) {
72  this.id = id;
73  }
74 
75  public String getValue() {
76  return value;
77  }
78 
79  public void setValue(String value) {
80  this.value = value;
81  }
82 
83  /* Value Helper */
84 
85  public void setObjectValue(Object obj) {
86  value = ObjectString.formatNativeObject(obj, false);
87  }
88 
89  public Object getObjectValue() {
90  return ObjectString.parseNativeString(value, fieldDef.getJavaClass(), false);
91  }
92 }