Package dev.vortex.api.expressions
Class GetItem
java.lang.Object
dev.vortex.api.expressions.GetItem
- All Implemented Interfaces:
Expression
Represents a "get item" expression that extracts a field or property from a parent expression.
This expression is used to access nested fields in complex data structures such as structs,
lists, or other composite types by specifying a path to the desired field.
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.vortex.api.Expression
Expression.Visitor<T>
-
Method Summary
Modifier and TypeMethodDescription<T> T
accept
(Expression.Visitor<T> visitor) Accepts a visitor and dispatches to the appropriate visit method based on the expression type.children()
Returns the children of this expression.boolean
getChild()
Returns the child expression from which the field is being extracted.getPath()
Returns the path or name of the field being extracted from the child expression.int
hashCode()
id()
The globally unique identifier for this type of expression.Optional<byte[]>
metadata()
Returns the serialized metadata for this expression, or empty if serialization is not supported.static GetItem
of
(Expression child, String path) Creates a new GetItem expression that extracts the specified field from the given child expression.static GetItem
parse
(byte[] metadata, List<Expression> children) Parses a GetItem expression from serialized metadata and child expressions.
-
Method Details
-
of
Creates a new GetItem expression that extracts the specified field from the given child expression.- Parameters:
child
- the parent expression from which to extract the fieldpath
- the path or name of the field to extract- Returns:
- a new GetItem expression
-
parse
Parses a GetItem expression from serialized metadata and child expressions. This method is used during deserialization of Vortex expressions.- Parameters:
metadata
- the serialized metadata containing the field path informationchildren
- the child expressions, must contain exactly one element- Returns:
- a new GetItem expression parsed from the provided data
- Throws:
RuntimeException
- if the number of children is not exactly one, or if the metadata cannot be parsed
-
getChild
Returns the child expression from which the field is being extracted.- Returns:
- the child expression
-
getPath
Returns the path or name of the field being extracted from the child expression.- Returns:
- the field path
-
id
Description copied from interface:Expression
The globally unique identifier for this type of expression.- Specified by:
id
in interfaceExpression
-
children
Description copied from interface:Expression
Returns the children of this expression.- Specified by:
children
in interfaceExpression
-
metadata
Description copied from interface:Expression
Returns the serialized metadata for this expression, or empty if serialization is not supported.- Specified by:
metadata
in interfaceExpression
-
accept
Description copied from interface:Expression
Accepts a visitor and dispatches to the appropriate visit method based on the expression type. This method implements the visitor pattern, allowing different operations to be performed on expressions without modifying the expression classes themselves.- Specified by:
accept
in interfaceExpression
- Type Parameters:
T
- the return type of the visitor- Parameters:
visitor
- the visitor to accept- Returns:
- the result of the visitor's operation on this expression
-
equals
-
hashCode
public int hashCode()
-