KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > lifecycle > InstanceTracker


1 /*****************************************************************************
2  * Copyright (C) Zephyr Business Solution. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  *****************************************************************************/

8
9 /*
10  * Created on Oct 13, 2005
11  *
12  * Author Michelle Lei
13  * ZBS
14  */

15 package jfun.yan.lifecycle;
16
17 import java.io.Serializable JavaDoc;
18 import java.util.Set JavaDoc;
19
20 import jfun.yan.Mutation;
21
22 final class InstanceTracker implements Mutation, Serializable JavaDoc{
23   private final Set JavaDoc history;
24   private final Life life;
25   
26   InstanceTracker(Life life, Set JavaDoc history) {
27     this.life = life;
28     this.history = history;
29   }
30   public void mutate(Object JavaDoc obj) {
31     history.add(life.bear(obj));
32   }
33   public boolean equals(Object JavaDoc obj) {
34     if(obj instanceof InstanceTracker){
35       final InstanceTracker other = (InstanceTracker)obj;
36       return history == other.history && life.equals(other.life);
37     }
38     return false;
39   }
40   public int hashCode() {
41     return life.hashCode()*31+System.identityHashCode(history);
42   }
43 }
44
Popular Tags