1 package org.hibernate.ce.auction.model; 2 3 import javax.persistence.*; 4 import java.io.Serializable ; 5 6 16 @Embeddable(access = AccessType.FIELD) 17 public class Address implements Serializable { 18 19 @Column(length = 255) 20 private String street; 21 22 @Column(length = 16) 23 private String zipcode; 24 25 @Column(length = 255) 26 private String city; 27 28 31 Address() {} 32 33 36 public Address(String street, String zipcode, String city) { 37 this.street = street; 38 this.zipcode = zipcode; 39 this.city = city; 40 } 41 42 44 public String getStreet() { return street; } 45 public void setStreet(String street) { this.street = street; } 46 47 public String getZipcode() { return zipcode; } 48 public void setZipcode(String zipcode) { this.zipcode = zipcode; } 49 50 public String getCity() { return city; } 51 public void setCity(String city) { this.city = city; } 52 53 55 public boolean equals(Object o) { 56 if (this == o) return true; 57 if (!(o instanceof Address)) return false; 58 59 final Address address = (Address) o; 60 61 if (!city.equals(address.city)) return false; 62 if (!street.equals(address.street)) return false; 63 if (!zipcode.equals(address.zipcode)) return false; 64 65 return true; 66 } 67 68 public int hashCode() { 69 int result; 70 result = street.hashCode(); 71 result = 29 * result + zipcode.hashCode(); 72 result = 29 * result + city.hashCode(); 73 return result; 74 } 75 76 public String toString() { 77 return "Street: '" + getStreet() + "', " + 78 "Zipcode: '" + getZipcode() + "', " + 79 "City: '" + getCity() + "'"; 80 } 81 82 84 } 85 | Popular Tags |