From 78298bb382e4ed7d79781b206954218df1de36ba Mon Sep 17 00:00:00 2001 From: Terence Parr Date: Sat, 31 Aug 2013 16:56:07 -0700 Subject: [PATCH] defined compareTo but not equals/hash (Coverity) --- tool/src/org/antlr/v4/misc/MutableInt.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tool/src/org/antlr/v4/misc/MutableInt.java b/tool/src/org/antlr/v4/misc/MutableInt.java index 8f2ae6ad1..816a4ba33 100644 --- a/tool/src/org/antlr/v4/misc/MutableInt.java +++ b/tool/src/org/antlr/v4/misc/MutableInt.java @@ -34,6 +34,15 @@ public class MutableInt extends Number implements Comparable { public int v; public MutableInt(int v) { this.v = v; } + + @Override + public boolean equals(Object o) { + if ( o instanceof Number ) return v == ((Number)o).intValue(); + return false; + } + + @Override public int hashCode() { return v; } + @Override public int compareTo(Number o) { return v-o.intValue(); } @Override public int intValue() { return v; } @Override public long longValue() { return v; }