3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00

Consistent #equals() implementation

Also dropped #hashCode(), as it just calls the parent class
implementation.
This commit is contained in:
George Karpenkov 2016-01-06 11:10:03 +01:00
parent 1dcaddbec7
commit 4d3675cb4e
2 changed files with 17 additions and 35 deletions

View file

@ -28,24 +28,17 @@ public class AST extends Z3Object implements Comparable<AST>
* Object comparison.
*
* @param o another AST
**/
**/
@Override
public boolean equals(Object o)
{
AST casted = null;
if (o == null) return false;
if (o == this) return true;
if (o.getClass() != this.getClass()) return false;
AST casted = (AST) o;
try
{
casted = AST.class.cast(o);
} catch (ClassCastException e)
{
return false;
}
return (this == casted) ||
(this != null) &&
(casted != null) &&
(getContext().nCtx() == casted.getContext().nCtx()) &&
return
(getContext().nCtx() == casted.getContext().nCtx()) &&
(Native.isEqAst(getContext().nCtx(), getNativeObject(), casted.getNativeObject()));
}

View file

@ -32,28 +32,17 @@ public class FuncDecl extends AST
@Override
public boolean equals(Object o)
{
FuncDecl casted = null;
if (o == null) return false;
if (o == this) return true;
if (o.getClass() != this.getClass()) return false;
FuncDecl other = (FuncDecl) o;
try {
casted = FuncDecl.class.cast(o);
} catch (ClassCastException e) {
return false;
}
return
(this == casted) ||
(this != null) &&
(casted != null) &&
(getContext().nCtx() == casted.getContext().nCtx()) &&
(Native.isEqFuncDecl(getContext().nCtx(), getNativeObject(), casted.getNativeObject()));
}
/**
* A hash code.
**/
public int hashCode()
{
return super.hashCode();
return
(getContext().nCtx() == other.getContext().nCtx()) &&
(Native.isEqFuncDecl(
getContext().nCtx(),
getNativeObject(),
other.getNativeObject()));
}
/**