KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > rentacar > persistance > bo > Partner


1 package org.objectweb.rentacar.persistance.bo;
2
3 import javax.persistence.CascadeType;
4 import javax.persistence.Entity;
5 import javax.persistence.GeneratedValue;
6 import javax.persistence.Id;
7 import javax.persistence.OneToOne;
8
9 import org.apache.commons.lang.builder.EqualsBuilder;
10 import org.apache.commons.lang.builder.HashCodeBuilder;
11 import org.apache.commons.lang.builder.ToStringBuilder;
12 import org.hibernate.annotations.GenericGenerator;
13
14 /**
15  *
16  * @author ofabre
17  *
18  */

19 @Entity
20 public class Partner {
21     
22     private String JavaDoc partnerId;
23     
24     private Contact contact;
25
26     public Partner() {
27         super();
28         // TODO Auto-generated constructor stub
29
}
30     
31     public Partner(Contact contact) {
32         super();
33         this.contact = contact;
34     }
35
36     public Partner(String JavaDoc partnerId, Contact contact) {
37         super();
38         // TODO Auto-generated constructor stub
39
this.partnerId = partnerId;
40         this.contact = contact;
41     }
42     
43     public Partner(PartnerVO partnerVO) {
44         super();
45         // TODO Auto-generated constructor stub
46
this.partnerId = partnerVO.getPartnerId();
47         this.contact = new Contact(partnerVO.getContact());
48     }
49
50     @OneToOne(cascade={CascadeType.ALL})
51     public Contact getContact() {
52         return contact;
53     }
54
55     public void setContact(Contact contact) {
56         this.contact = contact;
57     }
58
59     @Id @GeneratedValue(generator = "system-uuid")
60     @GenericGenerator(name="system-uuid", strategy = "uuid")
61     public String JavaDoc getPartnerId() {
62         return partnerId;
63     }
64
65     public void setPartnerId(String JavaDoc partnerId) {
66         this.partnerId = partnerId;
67     }
68
69     /**
70      * @see java.lang.Object#equals(Object)
71      */

72     public boolean equals(Object JavaDoc object) {
73         if (!(object instanceof Partner)) {
74             return false;
75         }
76         Partner rhs = (Partner) object;
77         return new EqualsBuilder().append(this.contact, rhs.contact).append(
78                 this.partnerId, rhs.partnerId).isEquals();
79     }
80
81     /**
82      * @see java.lang.Object#hashCode()
83      */

84     public int hashCode() {
85         return new HashCodeBuilder(-1604205539, -524900141)
86                 .append(this.contact).append(this.partnerId).toHashCode();
87     }
88
89     /**
90      * @see java.lang.Object#toString()
91      */

92     public String JavaDoc toString() {
93         return new ToStringBuilder(this).append("partnerId", this.partnerId)
94                 .append("contact", this.contact).toString();
95     }
96     
97     
98
99 }
100
Popular Tags