Record Class CollectionFilterNode
java.lang.Object
java.lang.Record
cloud.opencode.base.expression.ast.CollectionFilterNode
- Record Components:
target- the target collection node | 目标集合节点predicate- the filter predicate | 过滤谓词mode- the filter mode (ALL, FIRST, LAST) | 过滤模式
- All Implemented Interfaces:
Node
public record CollectionFilterNode(Node target, Node predicate, CollectionFilterNode.FilterMode mode)
extends Record
implements Node
Collection Filter Node
集合过滤节点
Represents collection filtering: users.?[age > 18]
表示集合过滤:users.?[age > 18]
Features | 主要功能:
- Filter all matching elements (.?[]) - 过滤所有匹配元素
- Select first matching element (.^[]) - 选择第一个匹配元素
- Select last matching element (.$[]) - 选择最后一个匹配元素
- Child context with #this binding per element - 每个元素绑定#this的子上下文
Usage Examples | 使用示例:
// Filter users older than 18
Node filter = CollectionFilterNode.all(usersNode, predicateNode);
List<?> result = (List<?>) filter.evaluate(ctx);
// Get first match
Node first = CollectionFilterNode.first(usersNode, predicateNode);
Object firstMatch = first.evaluate(ctx);
Security | 安全性:
- Thread-safe: Yes, immutable record - 线程安全: 是,不可变记录
- Null-safe: Yes, null target returns empty list or null - 空值安全: 是,null目标返回空列表或null
- Since:
- JDK 25, opencode-base-expression V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumFilter mode enumeration 过滤模式枚举 -
Constructor Summary
ConstructorsConstructorDescriptionCollectionFilterNode(Node target, Node predicate, CollectionFilterNode.FilterMode mode) Creates an instance of aCollectionFilterNoderecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic CollectionFilterNodeCreate filter node for all matching elements 创建选择所有匹配元素的过滤节点final booleanIndicates whether some other object is "equal to" this one.evaluate(EvaluationContext context) Evaluate this node 求值此节点static CollectionFilterNodeCreate filter node for first matching element 创建选择第一个匹配元素的过滤节点final inthashCode()Returns a hash code value for this object.static CollectionFilterNodeCreate filter node for last matching element 创建选择最后一个匹配元素的过滤节点mode()Returns the value of themoderecord component.static CollectionFilterNodeCreate filter node (default: all matching elements) 创建过滤节点(默认:所有匹配元素)Returns the value of thepredicaterecord component.target()Returns the value of thetargetrecord component.Get string representation for debugging 获取用于调试的字符串表示final StringtoString()Returns a string representation of this record class.Methods inherited from interface Node
getTypeName
-
Constructor Details
-
Method Details
-
of
Create filter node (default: all matching elements) 创建过滤节点(默认:所有匹配元素)- Parameters:
target- the target node | 目标节点predicate- the predicate | 谓词- Returns:
- the filter node | 过滤节点
-
all
Create filter node for all matching elements 创建选择所有匹配元素的过滤节点- Parameters:
target- the target node | 目标节点predicate- the predicate | 谓词- Returns:
- the filter node | 过滤节点
-
first
Create filter node for first matching element 创建选择第一个匹配元素的过滤节点- Parameters:
target- the target node | 目标节点predicate- the predicate | 谓词- Returns:
- the filter node | 过滤节点
-
last
Create filter node for last matching element 创建选择最后一个匹配元素的过滤节点- Parameters:
target- the target node | 目标节点predicate- the predicate | 谓词- Returns:
- the filter node | 过滤节点
-
evaluate
Description copied from interface:NodeEvaluate this node 求值此节点 -
toExpressionString
Description copied from interface:NodeGet string representation for debugging 获取用于调试的字符串表示- Specified by:
toExpressionStringin interfaceNode- Returns:
- the string representation | 字符串表示
-
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). -
target
-
predicate
-
mode
-