Record Class InNode
java.lang.Object
java.lang.Record
cloud.opencode.base.expression.ast.InNode
- Record Components:
value- the value to test | 要测试的值collection- the collection to test against | 要测试的集合
- All Implemented Interfaces:
Node
Membership Test Node
成员测试节点
Represents the in operator which tests whether a value is contained
in a collection, array, or map key set.
表示 in 运算符,用于测试一个值是否包含在集合、数组或映射键集中。
Features | 主要功能:
- Collection membership test via
Collection.contains(Object)- 通过 Collection.contains 测试集合成员 - Array membership test via linear scan - 通过线性扫描测试数组成员
- Map key membership test via
Map.containsKey(Object)- 通过 Map.containsKey 测试映射键成员
Usage Examples | 使用示例:
// status in {'active', 'pending', 'approved'}
Node in = InNode.of(statusNode, collectionNode);
Object result = in.evaluate(ctx); // true or false
Security | 安全性:
- Thread-safe: Yes, immutable record - 线程安全: 是,不可变记录
- Null-safe: No, value and collection required non-null - 空值安全: 否,值和集合要求非空
- Since:
- JDK 25, opencode-base-expression V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecollectionrecord component.final booleanIndicates whether some other object is "equal to" this one.evaluate(EvaluationContext context) Evaluate this node 求值此节点final inthashCode()Returns a hash code value for this object.static InNodeCreate membership test node 创建成员测试节点Get string representation for debugging 获取用于调试的字符串表示final StringtoString()Returns a string representation of this record class.value()Returns the value of thevaluerecord component.Methods inherited from interface Node
getTypeName
-
Constructor Details
-
InNode
Creates an instance of aInNoderecord class.- Parameters:
value- the value for thevaluerecord componentcollection- the value for thecollectionrecord component
-
-
Method Details
-
of
-
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). -
value
-
collection
Returns the value of thecollectionrecord component.- Returns:
- the value of the
collectionrecord component
-