Interface Funnel<T>

Type Parameters:
T - the type of object this funnel can serialize | 此funnel可以序列化的对象类型

Security | 安全性:

  • Thread-safe: Implementation-dependent - 线程安全: 取决于实现
  • Null-safe: No - 空值安全: 否
All Superinterfaces:
Serializable
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Funnel<T> extends Serializable
Object serialization funnel for hashing 用于哈希的对象序列化通道

Defines how to serialize an object's data into a Hasher. This allows custom objects to be hashed by extracting their relevant fields into the hash computation.

定义如何将对象的数据序列化到Hasher中。 这允许通过将相关字段提取到哈希计算中来哈希自定义对象。

Features | 主要功能:

  • Custom object serialization - 自定义对象序列化
  • Built-in funnels for common types - 常见类型的内置funnel
  • Lambda-friendly functional interface - Lambda友好的函数式接口

Usage Examples | 使用示例:

// Define a funnel for User
Funnel<User> userFunnel = (user, into) -> {
    into.putUtf8(user.getName())
        .putInt(user.getAge())
        .putUtf8(user.getEmail());
};

// Hash a user object
HashCode hash = OpenHash.murmur3_128()
    .hashObject(user, userFunnel);
Since:
JDK 25, opencode-base-hash V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Field Details

    • STRING_FUNNEL

      static final Funnel<CharSequence> STRING_FUNNEL
      String funnel (UTF-8 encoding) 字符串Funnel(UTF-8编码)
    • BYTE_ARRAY_FUNNEL

      static final Funnel<byte[]> BYTE_ARRAY_FUNNEL
      Byte array funnel 字节数组Funnel
    • INTEGER_FUNNEL

      static final Funnel<Integer> INTEGER_FUNNEL
      Integer funnel Integer Funnel
    • LONG_FUNNEL

      static final Funnel<Long> LONG_FUNNEL
      Long funnel Long Funnel
    • DOUBLE_FUNNEL

      static final Funnel<Double> DOUBLE_FUNNEL
      Double funnel Double Funnel
    • BOOLEAN_FUNNEL

      static final Funnel<Boolean> BOOLEAN_FUNNEL
      Boolean funnel Boolean Funnel
    • CHARACTER_FUNNEL

      static final Funnel<Character> CHARACTER_FUNNEL
      Character funnel Character Funnel
  • Method Details

    • funnel

      void funnel(T from, Hasher into)
      Serializes object data into a Hasher 将对象数据序列化到Hasher中
      Parameters:
      from - source object | 源对象
      into - target hasher | 目标hasher