This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 0967cd7  Add Eclipse IDE generated equals() and hashCode()
0967cd7 is described below

commit 0967cd752e32cff35acf3c61477602658f66b15a
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Sep 30 16:35:22 2021 +0100

    Add Eclipse IDE generated equals() and hashCode()
    
    For consistency with MethdInfo. Not required by the TCK but good to have
---
 java/jakarta/el/MethodReference.java | 49 ++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/java/jakarta/el/MethodReference.java 
b/java/jakarta/el/MethodReference.java
index b7855c6..c2ae338 100644
--- a/java/jakarta/el/MethodReference.java
+++ b/java/jakarta/el/MethodReference.java
@@ -17,6 +17,7 @@
 package jakarta.el;
 
 import java.lang.annotation.Annotation;
+import java.util.Arrays;
 
 /**
  * Provides information about the method to which a method expression resolves.
@@ -82,4 +83,52 @@ public class MethodReference {
     public Object[] getEvaluatedParameters() {
         return evaluatedParameters;
     }
+
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + Arrays.hashCode(annotations);
+        result = prime * result + ((base == null) ? 0 : base.hashCode());
+        result = prime * result + Arrays.deepHashCode(evaluatedParameters);
+        result = prime * result + ((methodInfo == null) ? 0 : 
methodInfo.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;
+        }
+        MethodReference other = (MethodReference) obj;
+        if (!Arrays.equals(annotations, other.annotations)) {
+            return false;
+        }
+        if (base == null) {
+            if (other.base != null) {
+                return false;
+            }
+        } else if (!base.equals(other.base)) {
+            return false;
+        }
+        if (!Arrays.deepEquals(evaluatedParameters, 
other.evaluatedParameters)) {
+            return false;
+        }
+        if (methodInfo == null) {
+            if (other.methodInfo != null) {
+                return false;
+            }
+        } else if (!methodInfo.equals(other.methodInfo)) {
+            return false;
+        }
+        return true;
+    }
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to