01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: package de.uka.ilkd.key.unittest;
09:
10: import java.util.HashSet;
11:
12: import de.uka.ilkd.key.java.Expression;
13:
14: public abstract class ValueContainer {
15:
16: protected HashSet values;
17:
18: public ValueContainer(Object v) {
19: values = new HashSet();
20: add(v);
21: }
22:
23: public ValueContainer(Object o1, Object o2) {
24: values = new HashSet();
25: add(o1);
26: add(o2);
27: }
28:
29: public abstract Expression[] getValuesAsExpressions();
30:
31: public abstract ValueContainer union(ValueContainer v);
32:
33: public boolean equals(Object o) {
34: if (!(o instanceof ValueContainer)) {
35: return false;
36: }
37: ValueContainer vc = (ValueContainer) o;
38: return values.equals(vc.values);
39: }
40:
41: public boolean contains(Object o) {
42: if (o instanceof ValueContainer) {
43: return values.containsAll(((ValueContainer) o).values);
44: }
45: return values.contains(o);
46: }
47:
48: public int hashCode() {
49: return 7 + 13 * values.hashCode();
50: }
51:
52: private void add(Object o) {
53: if (o instanceof ValueContainer) {
54: values.addAll(((ValueContainer) o).values);
55: } else {
56: values.add(o);
57: }
58: }
59:
60: public String toString() {
61: return "values: " + values;
62: }
63:
64: }
|