From ca6b9ee2e5d4419187620454574a2624d49accc5 Mon Sep 17 00:00:00 2001 From: Erik Hatcher Date: Wed, 28 Dec 2005 14:25:34 +0000 Subject: [PATCH] add .equals/.hashCode git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@359537 13f79535-47bb-0310-9956-ffa450edef68 --- .../search/regex/JakartaRegexpCapabilities.java | 15 +++++++++++++++ .../search/regex/JavaUtilRegexCapabilities.java | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/contrib/regex/src/java/org/apache/lucene/search/regex/JakartaRegexpCapabilities.java b/contrib/regex/src/java/org/apache/lucene/search/regex/JakartaRegexpCapabilities.java index d32554825d3..0808b5db63e 100644 --- a/contrib/regex/src/java/org/apache/lucene/search/regex/JakartaRegexpCapabilities.java +++ b/contrib/regex/src/java/org/apache/lucene/search/regex/JakartaRegexpCapabilities.java @@ -18,4 +18,19 @@ public class JakartaRegexpCapabilities implements RegexCapabilities { char[] prefix = RegexpTunnel.getPrefix(regexp); return prefix == null ? null : new String(prefix); } + + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + final JakartaRegexpCapabilities that = (JakartaRegexpCapabilities) o; + + if (regexp != null ? !regexp.equals(that.regexp) : that.regexp != null) return false; + + return true; + } + + public int hashCode() { + return (regexp != null ? regexp.hashCode() : 0); + } } diff --git a/contrib/regex/src/java/org/apache/lucene/search/regex/JavaUtilRegexCapabilities.java b/contrib/regex/src/java/org/apache/lucene/search/regex/JavaUtilRegexCapabilities.java index 90720b55ab9..6245c1b488f 100644 --- a/contrib/regex/src/java/org/apache/lucene/search/regex/JavaUtilRegexCapabilities.java +++ b/contrib/regex/src/java/org/apache/lucene/search/regex/JavaUtilRegexCapabilities.java @@ -16,4 +16,19 @@ public class JavaUtilRegexCapabilities implements RegexCapabilities { public String prefix() { return null; } + + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + final JavaUtilRegexCapabilities that = (JavaUtilRegexCapabilities) o; + + if (pattern != null ? !pattern.equals(that.pattern) : that.pattern != null) return false; + + return true; + } + + public int hashCode() { + return (pattern != null ? pattern.hashCode() : 0); + } }