KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > betwixt > dotbetwixt > ExampleImpl


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.dotbetwixt;
17
18 /**
19   * Implementation for example interface
20   *
21   * @author Robert Burrell Donkin
22   */

23 public class ExampleImpl implements IExample {
24     
25     private int id;
26     private String JavaDoc name;
27     
28     public ExampleImpl() {}
29     public ExampleImpl(int id, String JavaDoc name) {
30         setId(id);
31         setName(name);
32     }
33     
34     public int getId() {
35         return id;
36     }
37     public void setId(int id) {
38         this.id = id;
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 String JavaDoc toString() {
50         return "[" + this.getClass().getName() + ": id=" + id + ", name=" + name + "]";
51     }
52     
53     public boolean equals( Object JavaDoc obj ) {
54         if ( obj == null ) return false;
55         return this.hashCode() == obj.hashCode();
56     }
57     
58     public int hashCode() {
59         return toString().hashCode();
60     }
61 }
62
63
Popular Tags