elharo commented on a change in pull request #8:
URL: https://github.com/apache/maven-gpg-plugin/pull/8#discussion_r414097910



##########
File path: src/main/java/org/apache/maven/plugins/gpg/GpgVersion.java
##########
@@ -140,4 +140,26 @@ public String toString()
         return rawVersion;
     }
 
+    @Override
+    public boolean equals( Object o )
+    {
+        if ( this == o )
+        {
+            return true;
+        }
+
+        if ( o == null || getClass() != o.getClass() )
+        {
+            return false;
+        }
+
+        GpgVersion that = (GpgVersion) o;
+        return compareTo( that ) == 0;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return 1;

Review comment:
       Unequal objects need unequal hashcodes with high probability. 

##########
File path: src/main/java/org/apache/maven/plugins/gpg/GpgVersion.java
##########
@@ -140,4 +140,26 @@ public String toString()
         return rawVersion;
     }
 
+    @Override
+    public boolean equals( Object o )
+    {
+        if ( this == o )
+        {
+            return true;
+        }
+
+        if ( o == null || getClass() != o.getClass() )
+        {
+            return false;
+        }
+
+        GpgVersion that = (GpgVersion) o;
+        return compareTo( that ) == 0;

Review comment:
       as written compareTo can throw an IllegalArgumentException which 
violates the contract of equals. I'm not sure if you can just compare the raw 
strings here or if you need to parse the string in the constructor first. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to