KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > betwixt > derived > PersonBean


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.commons.betwixt.derived;
17
18 /** <p><code>PersonBean</code> is a sample bean for use with the test cases.</p>
19   *
20   * @author <a HREF="mailto:rdonkin@apache.org">Robert Burrell Donkin</a>
21   * @author <a HREF="mailto:Michael.Davey@coderage.org">Michael Davey</a>
22   * @version $Revision: 1.4 $
23   */

24 public class PersonBean {
25     
26     private int age;
27     
28     private String JavaDoc name;
29     
30     public PersonBean() {}
31     
32     public PersonBean(int age, String JavaDoc name)
33     {
34         setAge(age);
35         setName(name);
36     }
37     
38     public int getAge() {
39         return age;
40     }
41     
42     public void setAge(int age) {
43         this.age = age;
44     }
45     
46     public String JavaDoc getName() {
47         return name;
48     }
49     
50     public void setName(String JavaDoc name) {
51         this.name = name;
52     }
53     
54     public String JavaDoc toString() {
55         return "[" + this.getClass().getName() + ": age=" + age + " name=" + name + "]";
56     }
57     
58     public boolean equals( Object JavaDoc obj ) {
59         if ( obj == null ) return false;
60         return this.hashCode() == obj.hashCode();
61     }
62     
63     public int hashCode() {
64         return toString().hashCode();
65     }
66 }
67
Popular Tags