1 package Analysis.Disjoint;
8 ///////////////////////////////////////////
10 // This class is an immutable Canonical, so
12 // 0) construct them with a factory pattern
13 // to ensure only canonical versions escape
15 // 1) any operation that modifies a Canonical
16 // is a static method in the Canonical class
18 // 2) operations that just read this object
19 // should be defined here
21 // 3) every Canonical subclass hashCode should
22 // throw an error if the hash ever changes
24 ///////////////////////////////////////////
26 public class ChangeSet extends Canonical {
28 protected HashSet<ChangeTuple> changeTuples;
30 public static ChangeSet factory() {
31 ChangeSet out = new ChangeSet();
32 out = (ChangeSet) Canonical.makeCanonical(out);
36 public static ChangeSet factory(ChangeTuple ct) {
38 assert ct.isCanonical();
39 ChangeSet out = new ChangeSet();
40 out.changeTuples.add(ct);
41 out = (ChangeSet) Canonical.makeCanonical(out);
45 protected ChangeSet() {
46 changeTuples = new HashSet<ChangeTuple>();
49 public Iterator<ChangeTuple> iterator() {
50 return changeTuples.iterator();
54 return changeTuples.size();
57 public boolean isEmpty() {
58 return changeTuples.isEmpty();
61 public boolean isSubset(ChangeSet ctsIn) {
63 return ctsIn.changeTuples.containsAll(this.changeTuples);
67 public boolean equalsSpecific(Object o) {
72 if( !(o instanceof ChangeSet) ) {
76 ChangeSet cts = (ChangeSet) o;
77 return changeTuples.equals(cts.changeTuples);
80 public int hashCodeSpecific() {
81 return changeTuples.hashCode();
85 public String toString() {
88 Iterator i = this.iterator();
89 while( i.hasNext() ) {