KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > foxtrot > test > MutableHolder


1 /**
2  * Copyright (c) 2002-2005, Simone Bordet
3  * All rights reserved.
4  *
5  * This software is distributable under the BSD license.
6  * See the terms of the BSD license in the documentation provided with this software.
7  */

8
9 package foxtrot.test;
10
11 /**
12  * @version $Revision: 1.2 $
13  */

14 public class MutableHolder
15 {
16    private Object JavaDoc held;
17
18    public MutableHolder(Object JavaDoc held)
19    {
20       this.held = held;
21    }
22
23    public Object JavaDoc get()
24    {
25       return held;
26    }
27
28    public void set(Object JavaDoc held)
29    {
30       this.held = held;
31    }
32
33    public boolean equals(Object JavaDoc o)
34    {
35       if (this == o) return true;
36       if (!(o instanceof MutableHolder)) return false;
37
38       final MutableHolder holder = (MutableHolder)o;
39
40       if (held != null ? !held.equals(holder.held) : holder.held != null) return false;
41
42       return true;
43    }
44
45    public int hashCode()
46    {
47       return (held != null ? held.hashCode() : 0);
48    }
49 }
50
Popular Tags