Class AbstractHashFunction.AbstractHasher

java.lang.Object
cloud.opencode.base.hash.function.AbstractHashFunction.AbstractHasher
All Implemented Interfaces:
Hasher
Direct Known Subclasses:
AbstractHashFunction.BufferedHasher
Enclosing class:
AbstractHashFunction

protected abstract static class AbstractHashFunction.AbstractHasher extends Object implements Hasher
Abstract base class for Hasher implementations Hasher实现的抽象基类
Since:
JDK 25, opencode-base-hash V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Checks if this hasher has been used 检查此hasher是否已被使用
    protected abstract HashCode
    Performs the actual hash computation 执行实际的哈希计算
    final HashCode
    Computes the hash value 计算哈希值
    putBoolean(boolean b)
    Adds a boolean value to the hash computation 向哈希计算添加boolean值
    putBytes(byte[] bytes)
    Adds a byte array to the hash computation 向哈希计算添加字节数组
    Adds a ByteBuffer to the hash computation 向哈希计算添加ByteBuffer
    putChar(char c)
    Adds a char value to the hash computation 向哈希计算添加char值
    putDouble(double d)
    Adds a double value to the hash computation 向哈希计算添加double值
    putFloat(float f)
    Adds a float value to the hash computation 向哈希计算添加float值
    putInt(int i)
    Adds an int value to the hash computation 向哈希计算添加int值
    putLong(long l)
    Adds a long value to the hash computation 向哈希计算添加long值
    <T> Hasher
    putObject(T instance, Funnel<? super T> funnel)
    Adds an object using a Funnel to the hash computation 使用Funnel向哈希计算添加对象
    putShort(short s)
    Adds a short value to the hash computation 向哈希计算添加short值
    putString(CharSequence charSequence, Charset charset)
    Adds a string with specified charset to the hash computation 向哈希计算添加指定字符集的字符串

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface Hasher

    putByte, putBytes, putUtf8
  • Constructor Details

    • AbstractHasher

      protected AbstractHasher()
  • Method Details

    • putBytes

      public Hasher putBytes(byte[] bytes)
      Description copied from interface: Hasher
      Adds a byte array to the hash computation 向哈希计算添加字节数组
      Specified by:
      putBytes in interface Hasher
      Parameters:
      bytes - byte array | 字节数组
      Returns:
      this hasher | 此hasher
    • putBytes

      public Hasher putBytes(ByteBuffer buffer)
      Description copied from interface: Hasher
      Adds a ByteBuffer to the hash computation 向哈希计算添加ByteBuffer
      Specified by:
      putBytes in interface Hasher
      Parameters:
      buffer - byte buffer | 字节缓冲区
      Returns:
      this hasher | 此hasher
    • putShort

      public Hasher putShort(short s)
      Description copied from interface: Hasher
      Adds a short value to the hash computation 向哈希计算添加short值
      Specified by:
      putShort in interface Hasher
      Parameters:
      s - short value | short值
      Returns:
      this hasher | 此hasher
    • putInt

      public Hasher putInt(int i)
      Description copied from interface: Hasher
      Adds an int value to the hash computation 向哈希计算添加int值
      Specified by:
      putInt in interface Hasher
      Parameters:
      i - int value | int值
      Returns:
      this hasher | 此hasher
    • putLong

      public Hasher putLong(long l)
      Description copied from interface: Hasher
      Adds a long value to the hash computation 向哈希计算添加long值
      Specified by:
      putLong in interface Hasher
      Parameters:
      l - long value | long值
      Returns:
      this hasher | 此hasher
    • putFloat

      public Hasher putFloat(float f)
      Description copied from interface: Hasher
      Adds a float value to the hash computation 向哈希计算添加float值
      Specified by:
      putFloat in interface Hasher
      Parameters:
      f - float value | float值
      Returns:
      this hasher | 此hasher
    • putDouble

      public Hasher putDouble(double d)
      Description copied from interface: Hasher
      Adds a double value to the hash computation 向哈希计算添加double值
      Specified by:
      putDouble in interface Hasher
      Parameters:
      d - double value | double值
      Returns:
      this hasher | 此hasher
    • putBoolean

      public Hasher putBoolean(boolean b)
      Description copied from interface: Hasher
      Adds a boolean value to the hash computation 向哈希计算添加boolean值
      Specified by:
      putBoolean in interface Hasher
      Parameters:
      b - boolean value | boolean值
      Returns:
      this hasher | 此hasher
    • putChar

      public Hasher putChar(char c)
      Description copied from interface: Hasher
      Adds a char value to the hash computation 向哈希计算添加char值
      Specified by:
      putChar in interface Hasher
      Parameters:
      c - char value | char值
      Returns:
      this hasher | 此hasher
    • putString

      public Hasher putString(CharSequence charSequence, Charset charset)
      Description copied from interface: Hasher
      Adds a string with specified charset to the hash computation 向哈希计算添加指定字符集的字符串
      Specified by:
      putString in interface Hasher
      Parameters:
      charSequence - string | 字符串
      charset - character set | 字符集
      Returns:
      this hasher | 此hasher
    • putObject

      public <T> Hasher putObject(T instance, Funnel<? super T> funnel)
      Description copied from interface: Hasher
      Adds an object using a Funnel to the hash computation 使用Funnel向哈希计算添加对象
      Specified by:
      putObject in interface Hasher
      Type Parameters:
      T - object type | 对象类型
      Parameters:
      instance - object instance | 对象实例
      funnel - serialization funnel | 序列化通道
      Returns:
      this hasher | 此hasher
    • hash

      public final HashCode hash()
      Description copied from interface: Hasher
      Computes the hash value 计算哈希值

      This method can only be called once. After calling hash(), this Hasher should not be used again.

      此方法只能调用一次。调用hash()后,此Hasher不应再使用。

      Specified by:
      hash in interface Hasher
      Returns:
      computed hash code | 计算的哈希码
    • doHash

      protected abstract HashCode doHash()
      Performs the actual hash computation 执行实际的哈希计算
      Returns:
      computed hash code | 计算的哈希码
    • checkNotUsed

      protected void checkNotUsed()
      Checks if this hasher has been used 检查此hasher是否已被使用