Guest User

Untitled

a guest
Jun 23rd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. @Embeddable
  2. public class Address implements Serializable {
  3.  
  4. @Column(length = 255, nullable = false)
  5. private String street;
  6.  
  7. @Column(length = 16, nullable = false)
  8. private String zipcode;
  9.  
  10. @Column(length = 255, nullable = false)
  11. private String city;
  12.  
  13. /**
  14. * No-arg constructor for JavaBean tools
  15. */
  16. public Address() {}
  17.  
  18. /**
  19. * Full constructor
  20. */
  21. public Address(String street, String zipcode, String city) {
  22. this.street = street;
  23. this.zipcode = zipcode;
  24. this.city = city;
  25. }
  26.  
  27. // ********************** Accessor Methods ********************** //
  28.  
  29. public String getStreet() { return street; }
  30. public void setStreet(String street) { this.street = street; }
  31.  
  32. public String getZipcode() { return zipcode; }
  33. public void setZipcode(String zipcode) { this.zipcode = zipcode; }
  34.  
  35. public String getCity() { return city; }
  36. public void setCity(String city) { this.city = city; }
  37.  
  38. // ********************** Common Methods ********************** //
  39.  
  40. public boolean equals(Object o) {
  41. if (this == o) return true;
  42. if (!(o instanceof Address)) return false;
  43.  
  44. final Address address = (Address) o;
  45.  
  46. if (!city.equals(address.city)) return false;
  47. if (!street.equals(address.street)) return false;
  48. if (!zipcode.equals(address.zipcode)) return false;
  49.  
  50. return true;
  51. }
  52.  
  53. public int hashCode() {
  54. int result;
  55. result = street.hashCode();
  56. result = 29 * result + zipcode.hashCode();
  57. result = 29 * result + city.hashCode();
  58. return result;
  59. }
  60.  
  61. public String toString() {
  62. return "Street: '" + getStreet() + "', " +
  63. "Zipcode: '" + getZipcode() + "', " +
  64. "City: '" + getCity() + "'";
  65. }
  66.  
  67. // ********************** Business Methods ********************** //
  68.  
  69. }
Add Comment
Please, Sign In to add comment