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 19 @Entity 20 public class Partner { 21 22 private String partnerId; 23 24 private Contact contact; 25 26 public Partner() { 27 super(); 28 } 30 31 public Partner(Contact contact) { 32 super(); 33 this.contact = contact; 34 } 35 36 public Partner(String partnerId, Contact contact) { 37 super(); 38 this.partnerId = partnerId; 40 this.contact = contact; 41 } 42 43 public Partner(PartnerVO partnerVO) { 44 super(); 45 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 getPartnerId() { 62 return partnerId; 63 } 64 65 public void setPartnerId(String partnerId) { 66 this.partnerId = partnerId; 67 } 68 69 72 public boolean equals(Object 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 84 public int hashCode() { 85 return new HashCodeBuilder(-1604205539, -524900141) 86 .append(this.contact).append(this.partnerId).toHashCode(); 87 } 88 89 92 public String toString() { 93 return new ToStringBuilder(this).append("partnerId", this.partnerId) 94 .append("contact", this.contact).toString(); 95 } 96 97 98 99 } 100 | Popular Tags |