1 package Analysis.OwnershipAnalysis;
9 // a change touple is a pair that indicates if the
10 // first TokenTupleSet is found in a ReachabilitySet,
11 // then the second TokenTupleSet should be added
13 // THIS CLASS IS IMMUTABLE!
15 public class ChangeTuple extends Canonical
17 private TokenTupleSet toMatch;
18 private TokenTupleSet toAdd;
20 public ChangeTuple(TokenTupleSet toMatch,
21 TokenTupleSet toAdd) {
22 this.toMatch = toMatch;
26 public ChangeTuple makeCanonical() {
27 return (ChangeTuple) Canonical.makeCanonical(this);
30 public TokenTupleSet getSetToMatch() {
33 public TokenTupleSet getSetToAdd() {
38 public boolean equals(Object o) {
43 if( !(o instanceof ChangeTuple) ) {
47 ChangeTuple ct = (ChangeTuple) o;
49 return toMatch.equals(ct.getSetToMatch() ) &&
50 toAdd.equals(ct.getSetToAdd() );
53 private boolean oldHashSet = false;
54 private int oldHash = 0;
55 public int hashCode() {
56 int currentHash = toMatch.hashCode() + toAdd.hashCode()*3;
58 if( oldHashSet == false ) {
59 oldHash = currentHash;
62 if( oldHash != currentHash ) {
63 System.out.println("IF YOU SEE THIS A CANONICAL ChangeTuple CHANGED");
73 public String toString() {
74 return new String("("+toMatch+" -> "+toAdd+")");