KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > webservice > samples > 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.test.webservice.samples;
8
9 // $Id: Person.java,v 1.1.2.1 2005/02/12 17:07:37 tdiesler Exp $
10

11 /**
12  * An example of a complex user type
13  *
14  * @author Thomas.Diesler@jboss.org
15  * @since 26-Apr-2004
16  */

17 public class Person
18 {
19    private String JavaDoc name;
20    private int age;
21
22    public Person()
23    {
24    }
25
26    public Person(String JavaDoc name, int age)
27    {
28       this.age = age;
29       this.name = name;
30    }
31
32    public int getAge()
33    {
34       return age;
35    }
36
37    public void setAge(int age)
38    {
39       this.age = age;
40    }
41
42    public String JavaDoc getName()
43    {
44       return name;
45    }
46
47    public void setName(String JavaDoc name)
48    {
49       this.name = name;
50    }
51
52    public boolean equals(Object JavaDoc o)
53    {
54       if (this == o) return true;
55       if (!(o instanceof Person)) return false;
56
57       final Person person = (Person)o;
58
59       if (age != person.age) return false;
60       if (!name.equals(person.name)) return false;
61
62       return true;
63    }
64
65    public int hashCode()
66    {
67       int result;
68       result = name.hashCode();
69       result = 29 * result + age;
70       return result;
71    }
72
73    public String JavaDoc toString()
74    {
75       return "[name=" + name + ",age=" + age + "]";
76    }
77 }
78
Popular Tags