From ae7f01f64069421018c841cffce45bff0a3da339 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Wed, 21 Dec 2016 16:57:31 +0100 Subject: [PATCH] compareTo requires equals requires hashCode --- .../ant/taskdefs/optional/EchoProperties.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java b/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java index d8ef51a2f..30bcc759c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java @@ -440,6 +440,24 @@ public class EchoProperties extends Task { Tuple that = (Tuple) o; return key.compareTo(that.key); } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o == null || o.getClass() != getClass()) { + return false; + } + Tuple that = (Tuple) o; + return (key == null ? that.key == null : key.equals(that.key)) + && (value == null ? that.value == null : value.equals(that.value)); + } + + @Override + public int hashCode() { + return key != null ? key.hashCode() : 0; + } } private List sortProperties(Properties props) {