You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/12/08 16:15:46 UTC

[commons-compress] 15/38: Use Java Objects class

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

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 9752f9d1d89f361ebf539c1cba736f7dc5faa0b6
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:06:41 2022 -0500

    Use Java Objects class
---
 .../compress/harmony/unpack200/bytecode/CPConstant.java       | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/CPConstant.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/CPConstant.java
index e94df933..5b6d39f2 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/CPConstant.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/CPConstant.java
@@ -50,11 +50,7 @@ public abstract class CPConstant extends ConstantPoolEntry {
             return false;
         }
         final CPConstant other = (CPConstant) obj;
-        if (value == null) {
-            if (other.value != null) {
-                return false;
-            }
-        } else if (!value.equals(other.value)) {
+        if (!Objects.equals(value, other.value)) {
             return false;
         }
         return true;
@@ -62,10 +58,7 @@ public abstract class CPConstant extends ConstantPoolEntry {
 
     @Override
     public int hashCode() {
-        final int PRIME = 31;
-        int result = 1;
-        result = PRIME * result + ((value == null) ? 0 : value.hashCode());
-        return result;
+        return Objects.hash(value);
     }
 
     protected Object getValue() {