3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-28 08:58:44 +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

@ -32,19 +32,12 @@ public class AST extends Z3Object implements Comparable<AST>
@Override @Override
public boolean equals(Object o) 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 return
{
casted = AST.class.cast(o);
} catch (ClassCastException e)
{
return false;
}
return (this == casted) ||
(this != null) &&
(casted != null) &&
(getContext().nCtx() == casted.getContext().nCtx()) && (getContext().nCtx() == casted.getContext().nCtx()) &&
(Native.isEqAst(getContext().nCtx(), getNativeObject(), casted.getNativeObject())); (Native.isEqAst(getContext().nCtx(), getNativeObject(), casted.getNativeObject()));
} }

View file

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