View Javadoc
1   package org.myorg.jpatickets.bo;
2   
3   import java.io.Serializable;
4   
5   import javax.persistence.Column;
6   import javax.persistence.Embeddable;
7   
8   @Embeddable
9   public class Address implements Serializable {
10      private static final long serialVersionUID = 5678018330323499890L;
11      @Column(name="STREET", length=20)
12      private String street;
13      @Column(name="CITY", length=20)
14      private String city;
15      @Column(name="STATE", length=2)
16      private String state;
17      @Column(name="POSTAL_CODE")
18      private int zipCode;
19      
20      public String getStreet() { return street; }
21      public void setStreet(String street) {
22          this.street = street;
23      }
24      public Address withStreet(String street) {
25          setStreet(street);
26          return this;
27      }
28      
29      public String getCity() { return city; }
30      public void setCity(String city) {
31          this.city = city;
32      }
33      public Address withCity(String city) {
34          setCity(city);
35          return this;
36      }
37      
38      public String getState() { return state; }
39      public void setState(String state) {
40          this.state = state;
41      }
42      public Address withState(String state) {
43          setState(state);
44          return this;
45      }
46  
47      public int getZipCode() { return zipCode; }
48      public void setZipCode(int zipCode) {
49          this.zipCode = zipCode;
50      }
51      public Address withZipCode(int zipCode) {
52          setZipCode(zipCode);
53          return this;
54      }
55      
56      
57      @Override
58      public int hashCode() {
59          final int prime = 31;
60          int result = 1;
61          result = prime * result + ((city == null) ? 0 : city.hashCode());
62          result = prime * result + ((state == null) ? 0 : state.hashCode());
63          result = prime * result + ((street == null) ? 0 : street.hashCode());
64          result = prime * result + zipCode;
65          return result;
66      }
67      
68      
69      @Override
70      public boolean equals(Object obj) {
71          if (this == obj) { return true; }
72          if (obj == null) { return false; }
73          if (getClass() != obj.getClass()) { return false; }
74          Address other = (Address) obj;
75          
76          return (city == null ? other.city == null : city.equals(other.city)) &&
77              (state == null ? other.state == null : state.equals(other.state)) &&
78              (street == null ? other.street == null : street.equals(other.street)) &&
79              (zipCode == other.zipCode);
80      }
81      
82      
83  }