implement equals() and hashCode()

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@3204 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
msridhar1 2009-02-03 19:22:34 +00:00
parent 7b10fbfe5e
commit c66aa5c696
1 changed files with 31 additions and 1 deletions

View File

@ -27,7 +27,7 @@ public class MemoryAccess {
* index of the field access instruction in a shrikeBt or SSA instruction
* array
*/
final int instructionIndex;
final private int instructionIndex;
public MemoryAccess(int index, CGNode node) {
super();
@ -53,5 +53,35 @@ public class MemoryAccess {
public CGNode getNode() {
return node;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + instructionIndex;
result = prime * result + ((node == null) ? 0 : node.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
MemoryAccess other = (MemoryAccess) obj;
if (instructionIndex != other.instructionIndex)
return false;
if (node == null) {
if (other.node != null)
return false;
} else if (!node.equals(other.node))
return false;
return true;
}
}