Package dev.cel.common.ast
Class CelExpr
- java.lang.Object
-
- dev.cel.common.ast.CelExpr
-
- All Implemented Interfaces:
Expression
@Immutable public abstract class CelExpr extends java.lang.Object implements Expression
An abstract representation of a common expression. Refer toExpression
for details.This is the native type equivalent of Expr message in syntax.proto.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CelExpr.Builder
Builder for CelExpr.static class
CelExpr.CelCall
A call expression.static class
CelExpr.CelComprehension
A comprehension expression applied to a list or map.static class
CelExpr.CelIdent
An identifier expression.static class
CelExpr.CelList
A list creation expression.static class
CelExpr.CelMap
A map creation expression.static class
CelExpr.CelNotSet
An unset expression.static class
CelExpr.CelSelect
A field selection expression.static class
CelExpr.CelStruct
A message creation expression.static class
CelExpr.ExprKind
Denotes the kind of the expression.-
Nested classes/interfaces inherited from interface dev.cel.common.ast.Expression
Expression.Call<E extends Expression>, Expression.Comprehension<E extends Expression>, Expression.Ident, Expression.List<E extends Expression>, Expression.Map<E extends Expression.Map.Entry<?>>, Expression.Select<E extends Expression>, Expression.Struct<E extends Expression.Struct.Entry<?>>
-
-
Constructor Summary
Constructors Constructor Description CelExpr()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description CelExpr.CelCall
call()
Gets the underlying call expression.CelExpr.CelCall
callOrDefault()
Gets the underlying call expression or a default instance of one if expression is notCelExpr.ExprKind.Kind.CALL
.CelExpr.CelComprehension
comprehension()
Gets the underlying comprehension expression.CelExpr.CelComprehension
comprehensionOrDefault()
Gets the underlying comprehension expression or a default instance of one if expression is notCelExpr.ExprKind.Kind.COMPREHENSION
.CelConstant
constant()
Gets the underlying constant expression.CelConstant
constantOrDefault()
Gets the underlying constant expression or a default instance of one if expression is notCelExpr.ExprKind.Kind.CONSTANT
.abstract CelExpr.ExprKind
exprKind()
Represents the variant of the expression.CelExpr.ExprKind.Kind
getKind()
Represents the enumeration value for the underlying expression kind.abstract long
id()
Required.CelExpr.CelIdent
ident()
Gets the underlying identifier expression.CelExpr.CelIdent
identOrDefault()
Gets the underlying identifier expression or a default instance of one if expression is notCelExpr.ExprKind.Kind.IDENT
.CelExpr.CelList
list()
Gets the underlying identifier expression.CelExpr.CelList
listOrDefault()
Gets the underlying list expression or a default instance of one if expression is notCelExpr.ExprKind.Kind.LIST
.CelExpr.CelMap
map()
Gets the underlying map expression.CelExpr.CelMap
mapOrDefault()
Gets the underlying map expression or a default instance of one if expression is notCelExpr.ExprKind.Kind.MAP
.static CelExpr.Builder
newBuilder()
static CelExpr
ofCall(long id, java.util.Optional<CelExpr> targetExpr, java.lang.String function, com.google.common.collect.ImmutableList<CelExpr> arguments)
static CelExpr
ofComprehension(long id, java.lang.String iterVar, CelExpr iterRange, java.lang.String accuVar, CelExpr accuInit, CelExpr loopCondition, CelExpr loopStep, CelExpr result)
static CelExpr
ofConstant(long id, CelConstant celConstant)
static CelExpr
ofIdent(long id, java.lang.String identName)
static CelExpr
ofList(long id, com.google.common.collect.ImmutableList<CelExpr> elements, com.google.common.collect.ImmutableList<java.lang.Integer> optionalIndices)
static CelExpr
ofMap(long id, com.google.common.collect.ImmutableList<CelExpr.CelMap.Entry> entries)
static CelExpr.CelMap.Entry
ofMapEntry(long id, CelExpr mapKey, CelExpr value, boolean isOptionalEntry)
static CelExpr
ofNotSet(long id)
static CelExpr
ofSelect(long id, CelExpr operandExpr, java.lang.String field, boolean isTestOnly)
static CelExpr
ofStruct(long id, java.lang.String messageName, com.google.common.collect.ImmutableList<CelExpr.CelStruct.Entry> entries)
static CelExpr.CelStruct.Entry
ofStructEntry(long id, java.lang.String fieldKey, CelExpr value, boolean isOptionalEntry)
CelExpr.CelSelect
select()
Gets the underlying select expression.CelExpr.CelSelect
selectOrDefault()
Gets the underlying select expression or a default instance of one if expression is notCelExpr.ExprKind.Kind.SELECT
.CelExpr.CelStruct
struct()
Gets the underlying struct expression.CelExpr.CelStruct
structOrDefault()
Gets the underlying struct expression or a default instance of one if expression is notCelExpr.ExprKind.Kind.STRUCT
.abstract CelExpr.Builder
toBuilder()
java.lang.String
toString()
-
-
-
Method Detail
-
id
public abstract long id()
Description copied from interface:Expression
Required. An id assigned to this node by the parser which is unique in a given expression tree. This is used to associate type information and other attributes to a node in the parse tree.- Specified by:
id
in interfaceExpression
-
exprKind
public abstract CelExpr.ExprKind exprKind()
Represents the variant of the expression.
-
getKind
public CelExpr.ExprKind.Kind getKind()
Description copied from interface:Expression
Represents the enumeration value for the underlying expression kind.- Specified by:
getKind
in interfaceExpression
-
constant
public CelConstant constant()
Gets the underlying constant expression.- Specified by:
constant
in interfaceExpression
- Throws:
java.lang.UnsupportedOperationException
- if expression is notCelExpr.ExprKind.Kind.CONSTANT
.
-
ident
public CelExpr.CelIdent ident()
Gets the underlying identifier expression.- Specified by:
ident
in interfaceExpression
- Throws:
java.lang.UnsupportedOperationException
- if expression is notCelExpr.ExprKind.Kind.IDENT
.
-
select
public CelExpr.CelSelect select()
Gets the underlying select expression.- Specified by:
select
in interfaceExpression
- Throws:
java.lang.UnsupportedOperationException
- if expression is notCelExpr.ExprKind.Kind.SELECT
.
-
call
public CelExpr.CelCall call()
Gets the underlying call expression.- Specified by:
call
in interfaceExpression
- Throws:
java.lang.UnsupportedOperationException
- if expression is notCelExpr.ExprKind.Kind.CALL
.
-
list
public CelExpr.CelList list()
Gets the underlying identifier expression.- Specified by:
list
in interfaceExpression
- Throws:
java.lang.UnsupportedOperationException
- if expression is notCelExpr.ExprKind.Kind.LIST
.
-
struct
public CelExpr.CelStruct struct()
Gets the underlying struct expression.- Specified by:
struct
in interfaceExpression
- Throws:
java.lang.UnsupportedOperationException
- if expression is notCelExpr.ExprKind.Kind.STRUCT
.
-
map
public CelExpr.CelMap map()
Gets the underlying map expression.- Specified by:
map
in interfaceExpression
- Throws:
java.lang.UnsupportedOperationException
- if expression is notCelExpr.ExprKind.Kind.MAP
.
-
comprehension
public CelExpr.CelComprehension comprehension()
Gets the underlying comprehension expression.- Specified by:
comprehension
in interfaceExpression
- Throws:
java.lang.UnsupportedOperationException
- if expression is notCelExpr.ExprKind.Kind.COMPREHENSION
.
-
constantOrDefault
public CelConstant constantOrDefault()
Gets the underlying constant expression or a default instance of one if expression is notCelExpr.ExprKind.Kind.CONSTANT
.
-
identOrDefault
public CelExpr.CelIdent identOrDefault()
Gets the underlying identifier expression or a default instance of one if expression is notCelExpr.ExprKind.Kind.IDENT
.
-
selectOrDefault
public CelExpr.CelSelect selectOrDefault()
Gets the underlying select expression or a default instance of one if expression is notCelExpr.ExprKind.Kind.SELECT
.
-
callOrDefault
public CelExpr.CelCall callOrDefault()
Gets the underlying call expression or a default instance of one if expression is notCelExpr.ExprKind.Kind.CALL
.
-
listOrDefault
public CelExpr.CelList listOrDefault()
Gets the underlying list expression or a default instance of one if expression is notCelExpr.ExprKind.Kind.LIST
.
-
structOrDefault
public CelExpr.CelStruct structOrDefault()
Gets the underlying struct expression or a default instance of one if expression is notCelExpr.ExprKind.Kind.STRUCT
.
-
mapOrDefault
public CelExpr.CelMap mapOrDefault()
Gets the underlying map expression or a default instance of one if expression is notCelExpr.ExprKind.Kind.MAP
.
-
comprehensionOrDefault
public CelExpr.CelComprehension comprehensionOrDefault()
Gets the underlying comprehension expression or a default instance of one if expression is notCelExpr.ExprKind.Kind.COMPREHENSION
.
-
toBuilder
public abstract CelExpr.Builder toBuilder()
-
newBuilder
public static CelExpr.Builder newBuilder()
-
ofNotSet
public static CelExpr ofNotSet(long id)
-
ofConstant
public static CelExpr ofConstant(long id, CelConstant celConstant)
-
ofIdent
public static CelExpr ofIdent(long id, java.lang.String identName)
-
ofSelect
public static CelExpr ofSelect(long id, CelExpr operandExpr, java.lang.String field, boolean isTestOnly)
-
ofCall
public static CelExpr ofCall(long id, java.util.Optional<CelExpr> targetExpr, java.lang.String function, com.google.common.collect.ImmutableList<CelExpr> arguments)
-
ofList
public static CelExpr ofList(long id, com.google.common.collect.ImmutableList<CelExpr> elements, com.google.common.collect.ImmutableList<java.lang.Integer> optionalIndices)
-
ofStruct
public static CelExpr ofStruct(long id, java.lang.String messageName, com.google.common.collect.ImmutableList<CelExpr.CelStruct.Entry> entries)
-
ofMap
public static CelExpr ofMap(long id, com.google.common.collect.ImmutableList<CelExpr.CelMap.Entry> entries)
-
ofStructEntry
public static CelExpr.CelStruct.Entry ofStructEntry(long id, java.lang.String fieldKey, CelExpr value, boolean isOptionalEntry)
-
ofMapEntry
public static CelExpr.CelMap.Entry ofMapEntry(long id, CelExpr mapKey, CelExpr value, boolean isOptionalEntry)
-
ofComprehension
public static CelExpr ofComprehension(long id, java.lang.String iterVar, CelExpr iterRange, java.lang.String accuVar, CelExpr accuInit, CelExpr loopCondition, CelExpr loopStep, CelExpr result)
-
toString
public final java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-