From 210db67ed9f65589fd3effaed0645805459ec684 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Thu, 12 Sep 2024 17:44:54 +0300 Subject: [PATCH] refactoring --- .../org/redisson/transaction/HashKey.java | 32 ++++++------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/redisson/src/main/java/org/redisson/transaction/HashKey.java b/redisson/src/main/java/org/redisson/transaction/HashKey.java index a4310fd22..cb8413707 100644 --- a/redisson/src/main/java/org/redisson/transaction/HashKey.java +++ b/redisson/src/main/java/org/redisson/transaction/HashKey.java @@ -17,12 +17,14 @@ package org.redisson.transaction; import org.redisson.client.codec.Codec; +import java.util.Objects; + /** * * @author Nikita Koksharov * */ -public class HashKey { +public final class HashKey { final Codec codec; final String name; @@ -41,29 +43,15 @@ public class HashKey { } @Override - @SuppressWarnings("AvoidInlineConditionals") - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + HashKey hashKey = (HashKey) o; + return Objects.equals(name, hashKey.name); } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - HashKey other = (HashKey) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; + public int hashCode() { + return Objects.hashCode(name); } - }