From bbd862de723d3707d0ae1b33676956c2e65c23a6 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Wed, 30 Oct 2013 07:41:55 +0100 Subject: [PATCH] [Minor] Added hashcode() and equals() to Locator --- src/main/java/li/strolch/model/Locator.java | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/main/java/li/strolch/model/Locator.java b/src/main/java/li/strolch/model/Locator.java index dc0d4e68a..3e9391e9f 100644 --- a/src/main/java/li/strolch/model/Locator.java +++ b/src/main/java/li/strolch/model/Locator.java @@ -220,6 +220,31 @@ public class Locator { return sb.toString(); } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((this.pathElements == null) ? 0 : this.pathElements.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; + Locator other = (Locator) obj; + if (this.pathElements == null) { + if (other.pathElements != null) + return false; + } else if (!this.pathElements.equals(other.pathElements)) + return false; + return true; + } + /** * {@link LocatorBuilder} is used to build {@link Locator}s where a deep hierarchy is to be created. The * {@link #append(String)} method returns itself for chain building