KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > marshall > data > Person


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.cache.marshall.data;
8
9 import java.io.Serializable JavaDoc;
10
11
12 /**
13  */

14 public class Person implements Serializable JavaDoc
15 {
16    String JavaDoc name = null;
17    Address address;
18
19    public Person()
20    {
21    }
22
23    public String JavaDoc getName()
24    {
25       return name;
26    }
27
28    public void setName(String JavaDoc name)
29    {
30       this.name = name;
31    }
32
33    public void setName(Object JavaDoc obj)
34    {
35       this.name = (String JavaDoc) obj;
36    }
37
38    public Address getAddress()
39    {
40       return address;
41    }
42
43    public void setAddress(Address address)
44    {
45       this.address = address;
46    }
47
48    public String JavaDoc toString()
49    {
50       StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
51       sb.append("name=").append(getName()).append(" Address= ").append(address);
52       return sb.toString();
53    }
54
55    public boolean equals(Object JavaDoc o)
56    {
57       if (this == o) return true;
58       if (o == null || getClass() != o.getClass()) return false;
59
60       final Person person = (Person) o;
61
62       if (address != null ? !address.equals(person.address) : person.address != null) return false;
63       if (name != null ? !name.equals(person.name) : person.name != null) return false;
64
65       return true;
66    }
67
68    public int hashCode()
69    {
70       int result;
71       result = (name != null ? name.hashCode() : 0);
72       result = 29 * result + (address != null ? address.hashCode() : 0);
73       return result;
74    }
75
76 }
77
Popular Tags