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 628d3d3 Add Eclipse IDE generated equals() and hashCode()
628d3d3 is described below
commit 628d3d37ace3af37ed5d2044c99e1d80321a463e
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Sep 29 10:25:29 2021 +0100
Add Eclipse IDE generated equals() and hashCode()
Required to pass the TCK (it compares two MethodInfo instances)
---
java/jakarta/el/MethodInfo.java | 44 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/java/jakarta/el/MethodInfo.java b/java/jakarta/el/MethodInfo.java
index 129a3e0..8b977a6 100644
--- a/java/jakarta/el/MethodInfo.java
+++ b/java/jakarta/el/MethodInfo.java
@@ -16,6 +16,8 @@
*/
package jakarta.el;
+import java.util.Arrays;
+
public class MethodInfo {
private final String name;
@@ -41,4 +43,46 @@ public class MethodInfo {
public Class<?>[] getParamTypes() {
return this.paramTypes;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + Arrays.hashCode(paramTypes);
+ result = prime * result + ((returnType == null) ? 0 :
returnType.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;
+ }
+ MethodInfo other = (MethodInfo) obj;
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+ if (!Arrays.equals(paramTypes, other.paramTypes)) {
+ return false;
+ }
+ if (returnType == null) {
+ if (other.returnType != null) {
+ return false;
+ }
+ } else if (!returnType.equals(other.returnType)) {
+ return false;
+ }
+ return true;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]