From 9aa7fee0ec535a616cfaf2f90933b9cb3f7fbfe4 Mon Sep 17 00:00:00 2001 From: Glavo Date: Tue, 31 Dec 2024 01:16:05 +0800 Subject: [PATCH] Update Hasher --- kala-base/src/main/java/kala/function/Hasher.java | 1 - kala-base/src/main/java/kala/function/Hashers.java | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/kala-base/src/main/java/kala/function/Hasher.java b/kala-base/src/main/java/kala/function/Hasher.java index 73c03a45..ee756b57 100644 --- a/kala-base/src/main/java/kala/function/Hasher.java +++ b/kala-base/src/main/java/kala/function/Hasher.java @@ -17,7 +17,6 @@ import kala.annotations.ReplaceWith; -import java.io.Serializable; import java.util.Objects; import java.util.function.BiPredicate; diff --git a/kala-base/src/main/java/kala/function/Hashers.java b/kala-base/src/main/java/kala/function/Hashers.java index ce971493..34226653 100644 --- a/kala-base/src/main/java/kala/function/Hashers.java +++ b/kala-base/src/main/java/kala/function/Hashers.java @@ -15,6 +15,7 @@ */ package kala.function; +import java.io.Serial; import java.io.Serializable; import java.util.Objects; @@ -24,6 +25,7 @@ final class Hashers { static final Hasher IDENTITY = new Identity<>(); private static final class Default implements Hasher, Serializable { + @Serial private static final long serialVersionUID = 0L; @Override @@ -36,12 +38,14 @@ public String toString() { return "Hashers.Default"; } + @Serial private Object readResolve() { return DEFAULT; } } private static final class Optimized implements Hasher, Serializable { + @Serial private static final long serialVersionUID = 0L; @Override @@ -51,7 +55,6 @@ public int hash(T obj) { } int originalHash = obj.hashCode(); - return originalHash ^ (originalHash >>> 16); } @@ -60,12 +63,14 @@ public String toString() { return "Hashers.Optimized"; } + @Serial private Object readResolve() { return OPTIMIZED; } } private static final class Identity implements Hasher, Serializable { + @Serial private static final long serialVersionUID = 0L; @Override @@ -83,6 +88,7 @@ public String toString() { return "Hashers.Optimized"; } + @Serial private Object readResolve() { return IDENTITY; }