1 8 9 15 package jfun.yan.lifecycle; 16 17 import java.io.Serializable ; 18 import java.util.Set ; 19 20 import jfun.yan.Mutation; 21 22 final class InstanceTracker implements Mutation, Serializable { 23 private final Set history; 24 private final Life life; 25 26 InstanceTracker(Life life, Set history) { 27 this.life = life; 28 this.history = history; 29 } 30 public void mutate(Object obj) { 31 history.add(life.bear(obj)); 32 } 33 public boolean equals(Object 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 |