Package cloud.opencode.base.functional.record
package cloud.opencode.base.functional.record
Record Utilities - Functional utilities for Java Records
Record 工具 - Java Record 的函数式工具
Provides utilities for working with Java Records in a functional style, including destructuring, field extraction, and tuple conversion.
提供以函数式风格处理 Java Record 的工具,包括解构、字段提取和元组转换。
Features | 主要功能:
RecordUtil- Record utilities
Usage Examples | 使用示例:
record Point(int x, int y) {}
record Person(String name, int age, String email) {}
// Destructure record
Point p = new Point(10, 20);
int sum = RecordUtil.destructure(p, (x, y) -> x + y);
// Convert to tuple
Pair<Integer, Integer> tuple = RecordUtil.toPair(p);
// Field extractor
Function<Person, String> getName = RecordUtil.field(Person.class, "name");
String name = getName.apply(person);
// Comparing by fields
Comparator<Person> comparator = RecordUtil.comparing(
Person.class, "name", "age");
Integration | 集成:
Uses Core module's Tuple types (Pair, Triple, Quadruple).
使用 Core 模块的元组类型(Pair、Triple、Quadruple)。
- Since:
- JDK 25, opencode-base-functional V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
ClassesClassDescriptionRecordUtil - Utilities for working with Java Records RecordUtil - 用于处理 Java Record 的工具