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: //
09: //
10:
11: package de.uka.ilkd.key.rule.inst;
12:
13: import java.io.Serializable;
14:
15: import de.uka.ilkd.key.java.JavaProgramElement;
16: import de.uka.ilkd.key.logic.op.SchemaVariable;
17:
18: /** this class encapsulates a SchemaVariable and its corresponding
19: * instantiation if it is a JavaProgramElement. The class MapFrom...cannot
20: * be used because of the different packages of the SchemaVariable and
21: * the JavaProgramElement.
22: */
23: public class ProgramSVEntry implements Serializable {
24:
25: /** the SchemaVariable */
26: private SchemaVariable key;
27: /** the JavaProgramElement */
28: private JavaProgramElement value;
29:
30: /** creates a new entry encapsulating the SchemaVariable key and its
31: * JavaProgramElement instantiation value
32: * @param key the SchemaVariable that is instantiated
33: * @param value the JavaProgramElement
34: */
35: public ProgramSVEntry(SchemaVariable key, JavaProgramElement value) {
36: this .key = key;
37: this .value = value;
38: }
39:
40: /** returns the SchemaVariable to be instantiated
41: * @return the SchemaVariable to be instantiated
42: */
43: public SchemaVariable key() {
44: return key;
45: }
46:
47: /** returns true iff the keys and the mapped values are equal
48: * @return true iff the keys and the mapped values are equal
49: */
50: public boolean equals(Object o) {
51: if (!(o instanceof ProgramSVEntry)) {
52: return false;
53: }
54: final ProgramSVEntry cmp = (ProgramSVEntry) o;
55: if (!(key().equals(cmp.key()))
56: || !(value().equals(cmp.value()))) {
57: return false;
58: }
59: return true;
60: }
61:
62: public int hashCode() {
63: int result = 17;
64: result = 37 * result + key().hashCode();
65: result = 37 * result + value().hashCode();
66: return result;
67: }
68:
69: /** returns the instantiation of the SchemaVariable
70: * @return the instantiation of the SchemaVariable
71: */
72: public JavaProgramElement value() {
73: return value;
74: }
75:
76: /** toString */
77: public String toString() {
78: return "{" + key + "<--" + value + "}";
79: }
80:
81: }
|