KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > beans > SerializablePerson


1 /*
2  * Copyright 2002-2005 the original author or authors.
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
17 package org.springframework.beans;
18
19 import java.io.Serializable JavaDoc;
20
21 import org.springframework.util.ObjectUtils;
22
23 /**
24  * Serializable implementation of the Person interface.
25  *
26  * @author Rod Johnson
27  */

28 public class SerializablePerson implements Person, Serializable JavaDoc {
29
30     private String JavaDoc name;
31     private int age;
32
33     public int getAge() {
34         return age;
35     }
36     
37     public void setAge(int age) {
38         this.age = age;
39     }
40     
41     public String JavaDoc getName() {
42         return name;
43     }
44     
45     public void setName(String JavaDoc name) {
46         this.name = name;
47     }
48     
49     public Object JavaDoc echo(Object JavaDoc o) throws Throwable JavaDoc {
50         if (o instanceof Throwable JavaDoc) {
51             throw (Throwable JavaDoc) o;
52         }
53         return o;
54     }
55     
56     public boolean equals(Object JavaDoc other) {
57         if (!(other instanceof SerializablePerson)) {
58             return false;
59         }
60         SerializablePerson p = (SerializablePerson) other;
61         return p.age == age && ObjectUtils.nullSafeEquals(name, p.name);
62     }
63
64 }
65
Popular Tags