Record Class Quadruple<A,B,C,D>
java.lang.Object
java.lang.Record
cloud.opencode.base.core.tuple.Quadruple<A,B,C,D>
- Type Parameters:
A- first element type - 第一个元素类型B- second element type - 第二个元素类型C- third element type - 第三个元素类型D- fourth element type - 第四个元素类型- Record Components:
first- first element - 第一个元素second- second element - 第二个元素third- third element - 第三个元素fourth- fourth element - 第四个元素
- All Implemented Interfaces:
Serializable
public record Quadruple<A,B,C,D> (A first, B second, C third, D fourth)
extends Record
implements Serializable
Quadruple - Immutable four-element tuple (Record implementation)
四元组 - 不可变的四元素元组(Record 实现)
Immutable container for four related values.
不可变的四值容器,可用于返回四个相关值。
Features | 主要功能:
- Immutable storage for four values - 不可变的四值存储
- Element mapping and transformation - 元素映射和转换
- Extract to Pair or Triple - 提取为 Pair 或 Triple
- Null checks (hasNull, allNonNull) - 空值检查
Usage Examples | 使用示例:
Quadruple<String, Integer, Boolean, Double> quad =
Quadruple.of("name", 25, true, 3.14);
String first = quad.first();
Triple<String, Integer, Boolean> triple = quad.toFirstTriple();
Security | 安全性:
- Thread-safe: Yes (immutable record) - 线程安全: 是 (不可变 Record)
- Null-safe: Allows null values - 空值安全: 允许 null 值
- Since:
- JDK 25, opencode-base-core V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if all values are non-null 检查是否都非 null<R> RApplies a quad-function 应用四元函数static <A,B, C, D> Quadruple <A, B, C, D> empty()Creates an empty Quadruple 创建空四元组final booleanIndicates whether some other object is "equal to" this one.first()Returns the value of thefirstrecord component.fourth()Returns the value of thefourthrecord component.final inthashCode()Returns a hash code value for this object.booleanhasNull()Checks if it contains a null value 检查是否包含 null 值Maps the first element 映射第一个元素Maps the fourth element 映射第四个元素Maps the second element 映射第二个元素Maps the third element 映射第三个元素static <A,B, C, D> Quadruple <A, B, C, D> of(A first, B second, C third, D fourth) Creates a Quadruple 创建四元组second()Returns the value of thesecondrecord component.third()Returns the value of thethirdrecord component.Object[]toArray()Converts to an array 转换为数组Extracts the first two elements as a Pair 提取前两个元素为 PairExtracts the first three elements as a Triple 提取前三个元素为 TripleExtracts the last two elements as a Pair 提取后两个元素为 PairExtracts the last three elements as a Triple 提取后三个元素为 TripletoString()Returns a string representation of this record class.
-
Constructor Details
-
Method Details
-
of
Creates a Quadruple 创建四元组- Type Parameters:
A- first element type | 第一个元素类型B- second element type | 第二个元素类型C- third element type | 第三个元素类型D- fourth element type | 第四个元素类型- Parameters:
first- the first element | 第一个元素second- the second element | 第二个元素third- the third element | 第三个元素fourth- the fourth element | 第四个元素- Returns:
- the Quadruple | 四元组
-
empty
Creates an empty Quadruple 创建空四元组- Type Parameters:
A- first element type | 第一个元素类型B- second element type | 第二个元素类型C- third element type | 第三个元素类型D- fourth element type | 第四个元素类型- Returns:
- an empty Quadruple | 空四元组
-
mapFirst
-
mapSecond
-
mapThird
-
mapFourth
-
apply
Applies a quad-function 应用四元函数- Type Parameters:
R- result type | 结果类型- Parameters:
function- the quad-function | 四元函数- Returns:
- the function result | 函数结果
-
toFirstPair
-
toLastPair
-
toFirstTriple
-
toLastTriple
-
hasNull
public boolean hasNull()Checks if it contains a null value 检查是否包含 null 值- Returns:
- true if any value is null | 如果任一值为 null 返回 true
-
allNonNull
public boolean allNonNull()Checks if all values are non-null 检查是否都非 null- Returns:
- true if all values are non-null | 如果都非 null 返回 true
-
toArray
Converts to an array 转换为数组- Returns:
- an array containing four elements | 包含四个元素的数组
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
first
-
second
-
third
-
fourth
-