Package dev.cel.expr
Class Expr.Comprehension
- java.lang.Object
-
- com.google.protobuf.AbstractMessageLite
-
- com.google.protobuf.AbstractMessage
-
- com.google.protobuf.GeneratedMessage
-
- dev.cel.expr.Expr.Comprehension
-
- All Implemented Interfaces:
com.google.protobuf.Message,com.google.protobuf.MessageLite,com.google.protobuf.MessageLiteOrBuilder,com.google.protobuf.MessageOrBuilder,Expr.ComprehensionOrBuilder,java.io.Serializable
- Enclosing class:
- Expr
public static final class Expr.Comprehension extends com.google.protobuf.GeneratedMessage implements Expr.ComprehensionOrBuilder
A comprehension expression applied to a list or map. Comprehensions are not part of the core syntax, but enabled with macros. A macro matches a specific call signature within a parsed AST and replaces the call with an alternate AST block. Macro expansion happens at parse time. The following macros are supported within CEL: Aggregate type macros may be applied to all elements in a list or all keys in a map: * `all`, `exists`, `exists_one` - test a predicate expression against the inputs and return `true` if the predicate is satisfied for all, any, or only one value `list.all(x, x < 10)`. * `filter` - test a predicate expression against the inputs and return the subset of elements which satisfy the predicate: `payments.filter(p, p > 1000)`. * `map` - apply an expression to all elements in the input and return the output aggregate type: `[1, 2, 3].map(i, i * i)`. The `has(m.x)` macro tests whether the property `x` is present in struct `m`. The semantics of this macro depend on the type of `m`. For proto2 messages `has(m.x)` is defined as 'defined, but not set`. For proto3, the macro tests whether the property is set to its default. For map and struct types, the macro tests whether the property `x` is defined on `m`. Comprehensions for the standard environment macros evaluation can be best visualized as the following pseudocode: ``` let `accu_var` = `accu_init` for (let `iter_var` in `iter_range`) { if (!`loop_condition`) { break } `accu_var` = `loop_step` } return `result` ``` Comprehensions for the optional V2 macros which support map-to-map translation differ slightly from the standard environment macros in that they expose both the key or index in addition to the value for each list or map entry: ``` let `accu_var` = `accu_init` for (let `iter_var`, `iter_var2` in `iter_range`) { if (!`loop_condition`) { break } `accu_var` = `loop_step` } return `result` ```Protobuf typecel.expr.Expr.Comprehension- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classExpr.Comprehension.BuilderA comprehension expression applied to a list or map.-
Nested classes/interfaces inherited from class com.google.protobuf.GeneratedMessage
com.google.protobuf.GeneratedMessage.ExtendableBuilder<MessageT extends com.google.protobuf.GeneratedMessage.ExtendableMessage<MessageT>,BuilderT extends com.google.protobuf.GeneratedMessage.ExtendableBuilder<MessageT,BuilderT>>, com.google.protobuf.GeneratedMessage.ExtendableMessage<MessageT extends com.google.protobuf.GeneratedMessage.ExtendableMessage<MessageT>>, com.google.protobuf.GeneratedMessage.ExtendableMessageOrBuilder<MessageT extends com.google.protobuf.GeneratedMessage.ExtendableMessage<MessageT>>, com.google.protobuf.GeneratedMessage.FieldAccessorTable, com.google.protobuf.GeneratedMessage.GeneratedExtension<ContainingT extends com.google.protobuf.Message,T extends java.lang.Object>, com.google.protobuf.GeneratedMessage.UnusedPrivateParameter
-
-
Field Summary
Fields Modifier and Type Field Description static intACCU_INIT_FIELD_NUMBERstatic intACCU_VAR_FIELD_NUMBERstatic intITER_RANGE_FIELD_NUMBERstatic intITER_VAR_FIELD_NUMBERstatic intITER_VAR2_FIELD_NUMBERstatic intLOOP_CONDITION_FIELD_NUMBERstatic intLOOP_STEP_FIELD_NUMBERstatic intRESULT_FIELD_NUMBER
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)ExprgetAccuInit()The initial value of the accumulator.ExprOrBuildergetAccuInitOrBuilder()The initial value of the accumulator.java.lang.StringgetAccuVar()The name of the variable used for accumulation of the result.com.google.protobuf.ByteStringgetAccuVarBytes()The name of the variable used for accumulation of the result.static Expr.ComprehensiongetDefaultInstance()Expr.ComprehensiongetDefaultInstanceForType()static com.google.protobuf.Descriptors.DescriptorgetDescriptor()ExprgetIterRange()The range over which the comprehension iterates.ExprOrBuildergetIterRangeOrBuilder()The range over which the comprehension iterates.java.lang.StringgetIterVar()The name of the first iteration variable.java.lang.StringgetIterVar2()The name of the second iteration variable, empty if not set.com.google.protobuf.ByteStringgetIterVar2Bytes()The name of the second iteration variable, empty if not set.com.google.protobuf.ByteStringgetIterVarBytes()The name of the first iteration variable.ExprgetLoopCondition()An expression which can contain iter_var, iter_var2, and accu_var.ExprOrBuildergetLoopConditionOrBuilder()An expression which can contain iter_var, iter_var2, and accu_var.ExprgetLoopStep()An expression which can contain iter_var, iter_var2, and accu_var.ExprOrBuildergetLoopStepOrBuilder()An expression which can contain iter_var, iter_var2, and accu_var.com.google.protobuf.Parser<Expr.Comprehension>getParserForType()ExprgetResult()An expression which can contain accu_var.ExprOrBuildergetResultOrBuilder()An expression which can contain accu_var.intgetSerializedSize()booleanhasAccuInit()The initial value of the accumulator.inthashCode()booleanhasIterRange()The range over which the comprehension iterates.booleanhasLoopCondition()An expression which can contain iter_var, iter_var2, and accu_var.booleanhasLoopStep()An expression which can contain iter_var, iter_var2, and accu_var.booleanhasResult()An expression which can contain accu_var.protected com.google.protobuf.GeneratedMessage.FieldAccessorTableinternalGetFieldAccessorTable()booleanisInitialized()static Expr.Comprehension.BuildernewBuilder()static Expr.Comprehension.BuildernewBuilder(Expr.Comprehension prototype)Expr.Comprehension.BuildernewBuilderForType()protected Expr.Comprehension.BuildernewBuilderForType(com.google.protobuf.AbstractMessage.BuilderParent parent)static Expr.ComprehensionparseDelimitedFrom(java.io.InputStream input)static Expr.ComprehensionparseDelimitedFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)static Expr.ComprehensionparseFrom(byte[] data)static Expr.ComprehensionparseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)static Expr.ComprehensionparseFrom(com.google.protobuf.ByteString data)static Expr.ComprehensionparseFrom(com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)static Expr.ComprehensionparseFrom(com.google.protobuf.CodedInputStream input)static Expr.ComprehensionparseFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)static Expr.ComprehensionparseFrom(java.io.InputStream input)static Expr.ComprehensionparseFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)static Expr.ComprehensionparseFrom(java.nio.ByteBuffer data)static Expr.ComprehensionparseFrom(java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)static com.google.protobuf.Parser<Expr.Comprehension>parser()Expr.Comprehension.BuildertoBuilder()voidwriteTo(com.google.protobuf.CodedOutputStream output)-
Methods inherited from class com.google.protobuf.GeneratedMessage
canUseUnsafe, computeStringSize, computeStringSizeNoTag, emptyBooleanList, emptyDoubleList, emptyFloatList, emptyIntList, emptyList, emptyLongList, getAllFields, getDescriptorForType, getField, getOneofFieldDescriptor, getRepeatedField, getRepeatedFieldCount, getUnknownFields, hasField, hasOneof, internalGetMapField, internalGetMapFieldReflection, isStringEmpty, makeMutableCopy, makeMutableCopy, mergeFromAndMakeImmutableInternal, newFileScopedGeneratedExtension, newInstance, newMessageScopedGeneratedExtension, parseDelimitedWithIOException, parseDelimitedWithIOException, parseUnknownField, parseUnknownFieldProto3, parseWithIOException, parseWithIOException, parseWithIOException, parseWithIOException, serializeBooleanMapTo, serializeIntegerMapTo, serializeLongMapTo, serializeStringMapTo, writeReplace, writeString, writeStringNoTag
-
Methods inherited from class com.google.protobuf.AbstractMessage
findInitializationErrors, getInitializationErrorString, hashFields, toString
-
Methods inherited from class com.google.protobuf.AbstractMessageLite
addAll, checkByteStringIsUtf8, toByteArray, toByteString, writeDelimitedTo, writeTo
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
ITER_VAR_FIELD_NUMBER
public static final int ITER_VAR_FIELD_NUMBER
- See Also:
- Constant Field Values
-
ITER_VAR2_FIELD_NUMBER
public static final int ITER_VAR2_FIELD_NUMBER
- See Also:
- Constant Field Values
-
ITER_RANGE_FIELD_NUMBER
public static final int ITER_RANGE_FIELD_NUMBER
- See Also:
- Constant Field Values
-
ACCU_VAR_FIELD_NUMBER
public static final int ACCU_VAR_FIELD_NUMBER
- See Also:
- Constant Field Values
-
ACCU_INIT_FIELD_NUMBER
public static final int ACCU_INIT_FIELD_NUMBER
- See Also:
- Constant Field Values
-
LOOP_CONDITION_FIELD_NUMBER
public static final int LOOP_CONDITION_FIELD_NUMBER
- See Also:
- Constant Field Values
-
LOOP_STEP_FIELD_NUMBER
public static final int LOOP_STEP_FIELD_NUMBER
- See Also:
- Constant Field Values
-
RESULT_FIELD_NUMBER
public static final int RESULT_FIELD_NUMBER
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDescriptor
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor()
-
internalGetFieldAccessorTable
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable()
- Specified by:
internalGetFieldAccessorTablein classcom.google.protobuf.GeneratedMessage
-
getIterVar
public java.lang.String getIterVar()
The name of the first iteration variable. For the single iteration variable macros, when iter_range is a list, this variable is the list element and when the iter_range is a map, this variable is the map key.
string iter_var = 1;- Specified by:
getIterVarin interfaceExpr.ComprehensionOrBuilder- Returns:
- The iterVar.
-
getIterVarBytes
public com.google.protobuf.ByteString getIterVarBytes()
The name of the first iteration variable. For the single iteration variable macros, when iter_range is a list, this variable is the list element and when the iter_range is a map, this variable is the map key.
string iter_var = 1;- Specified by:
getIterVarBytesin interfaceExpr.ComprehensionOrBuilder- Returns:
- The bytes for iterVar.
-
getIterVar2
public java.lang.String getIterVar2()
The name of the second iteration variable, empty if not set. This field is only set for comprehension v2 macros.
string iter_var2 = 8;- Specified by:
getIterVar2in interfaceExpr.ComprehensionOrBuilder- Returns:
- The iterVar2.
-
getIterVar2Bytes
public com.google.protobuf.ByteString getIterVar2Bytes()
The name of the second iteration variable, empty if not set. This field is only set for comprehension v2 macros.
string iter_var2 = 8;- Specified by:
getIterVar2Bytesin interfaceExpr.ComprehensionOrBuilder- Returns:
- The bytes for iterVar2.
-
hasIterRange
public boolean hasIterRange()
The range over which the comprehension iterates.
.cel.expr.Expr iter_range = 2;- Specified by:
hasIterRangein interfaceExpr.ComprehensionOrBuilder- Returns:
- Whether the iterRange field is set.
-
getIterRange
public Expr getIterRange()
The range over which the comprehension iterates.
.cel.expr.Expr iter_range = 2;- Specified by:
getIterRangein interfaceExpr.ComprehensionOrBuilder- Returns:
- The iterRange.
-
getIterRangeOrBuilder
public ExprOrBuilder getIterRangeOrBuilder()
The range over which the comprehension iterates.
.cel.expr.Expr iter_range = 2;- Specified by:
getIterRangeOrBuilderin interfaceExpr.ComprehensionOrBuilder
-
getAccuVar
public java.lang.String getAccuVar()
The name of the variable used for accumulation of the result.
string accu_var = 3;- Specified by:
getAccuVarin interfaceExpr.ComprehensionOrBuilder- Returns:
- The accuVar.
-
getAccuVarBytes
public com.google.protobuf.ByteString getAccuVarBytes()
The name of the variable used for accumulation of the result.
string accu_var = 3;- Specified by:
getAccuVarBytesin interfaceExpr.ComprehensionOrBuilder- Returns:
- The bytes for accuVar.
-
hasAccuInit
public boolean hasAccuInit()
The initial value of the accumulator.
.cel.expr.Expr accu_init = 4;- Specified by:
hasAccuInitin interfaceExpr.ComprehensionOrBuilder- Returns:
- Whether the accuInit field is set.
-
getAccuInit
public Expr getAccuInit()
The initial value of the accumulator.
.cel.expr.Expr accu_init = 4;- Specified by:
getAccuInitin interfaceExpr.ComprehensionOrBuilder- Returns:
- The accuInit.
-
getAccuInitOrBuilder
public ExprOrBuilder getAccuInitOrBuilder()
The initial value of the accumulator.
.cel.expr.Expr accu_init = 4;- Specified by:
getAccuInitOrBuilderin interfaceExpr.ComprehensionOrBuilder
-
hasLoopCondition
public boolean hasLoopCondition()
An expression which can contain iter_var, iter_var2, and accu_var. Returns false when the result has been computed and may be used as a hint to short-circuit the remainder of the comprehension.
.cel.expr.Expr loop_condition = 5;- Specified by:
hasLoopConditionin interfaceExpr.ComprehensionOrBuilder- Returns:
- Whether the loopCondition field is set.
-
getLoopCondition
public Expr getLoopCondition()
An expression which can contain iter_var, iter_var2, and accu_var. Returns false when the result has been computed and may be used as a hint to short-circuit the remainder of the comprehension.
.cel.expr.Expr loop_condition = 5;- Specified by:
getLoopConditionin interfaceExpr.ComprehensionOrBuilder- Returns:
- The loopCondition.
-
getLoopConditionOrBuilder
public ExprOrBuilder getLoopConditionOrBuilder()
An expression which can contain iter_var, iter_var2, and accu_var. Returns false when the result has been computed and may be used as a hint to short-circuit the remainder of the comprehension.
.cel.expr.Expr loop_condition = 5;- Specified by:
getLoopConditionOrBuilderin interfaceExpr.ComprehensionOrBuilder
-
hasLoopStep
public boolean hasLoopStep()
An expression which can contain iter_var, iter_var2, and accu_var. Computes the next value of accu_var.
.cel.expr.Expr loop_step = 6;- Specified by:
hasLoopStepin interfaceExpr.ComprehensionOrBuilder- Returns:
- Whether the loopStep field is set.
-
getLoopStep
public Expr getLoopStep()
An expression which can contain iter_var, iter_var2, and accu_var. Computes the next value of accu_var.
.cel.expr.Expr loop_step = 6;- Specified by:
getLoopStepin interfaceExpr.ComprehensionOrBuilder- Returns:
- The loopStep.
-
getLoopStepOrBuilder
public ExprOrBuilder getLoopStepOrBuilder()
An expression which can contain iter_var, iter_var2, and accu_var. Computes the next value of accu_var.
.cel.expr.Expr loop_step = 6;- Specified by:
getLoopStepOrBuilderin interfaceExpr.ComprehensionOrBuilder
-
hasResult
public boolean hasResult()
An expression which can contain accu_var. Computes the result.
.cel.expr.Expr result = 7;- Specified by:
hasResultin interfaceExpr.ComprehensionOrBuilder- Returns:
- Whether the result field is set.
-
getResult
public Expr getResult()
An expression which can contain accu_var. Computes the result.
.cel.expr.Expr result = 7;- Specified by:
getResultin interfaceExpr.ComprehensionOrBuilder- Returns:
- The result.
-
getResultOrBuilder
public ExprOrBuilder getResultOrBuilder()
An expression which can contain accu_var. Computes the result.
.cel.expr.Expr result = 7;- Specified by:
getResultOrBuilderin interfaceExpr.ComprehensionOrBuilder
-
isInitialized
public final boolean isInitialized()
- Specified by:
isInitializedin interfacecom.google.protobuf.MessageLiteOrBuilder- Overrides:
isInitializedin classcom.google.protobuf.GeneratedMessage
-
writeTo
public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException- Specified by:
writeToin interfacecom.google.protobuf.MessageLite- Overrides:
writeToin classcom.google.protobuf.GeneratedMessage- Throws:
java.io.IOException
-
getSerializedSize
public int getSerializedSize()
- Specified by:
getSerializedSizein interfacecom.google.protobuf.MessageLite- Overrides:
getSerializedSizein classcom.google.protobuf.GeneratedMessage
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin interfacecom.google.protobuf.Message- Overrides:
equalsin classcom.google.protobuf.AbstractMessage
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacecom.google.protobuf.Message- Overrides:
hashCodein classcom.google.protobuf.AbstractMessage
-
parseFrom
public static Expr.Comprehension parseFrom(java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException
- Throws:
com.google.protobuf.InvalidProtocolBufferException
-
parseFrom
public static Expr.Comprehension parseFrom(java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException
- Throws:
com.google.protobuf.InvalidProtocolBufferException
-
parseFrom
public static Expr.Comprehension parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException
- Throws:
com.google.protobuf.InvalidProtocolBufferException
-
parseFrom
public static Expr.Comprehension parseFrom(com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException
- Throws:
com.google.protobuf.InvalidProtocolBufferException
-
parseFrom
public static Expr.Comprehension parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException
- Throws:
com.google.protobuf.InvalidProtocolBufferException
-
parseFrom
public static Expr.Comprehension parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException
- Throws:
com.google.protobuf.InvalidProtocolBufferException
-
parseFrom
public static Expr.Comprehension parseFrom(java.io.InputStream input) throws java.io.IOException
- Throws:
java.io.IOException
-
parseFrom
public static Expr.Comprehension parseFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException
- Throws:
java.io.IOException
-
parseDelimitedFrom
public static Expr.Comprehension parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException
- Throws:
java.io.IOException
-
parseDelimitedFrom
public static Expr.Comprehension parseDelimitedFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException
- Throws:
java.io.IOException
-
parseFrom
public static Expr.Comprehension parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException
- Throws:
java.io.IOException
-
parseFrom
public static Expr.Comprehension parseFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException
- Throws:
java.io.IOException
-
newBuilderForType
public Expr.Comprehension.Builder newBuilderForType()
- Specified by:
newBuilderForTypein interfacecom.google.protobuf.Message- Specified by:
newBuilderForTypein interfacecom.google.protobuf.MessageLite
-
newBuilder
public static Expr.Comprehension.Builder newBuilder()
-
newBuilder
public static Expr.Comprehension.Builder newBuilder(Expr.Comprehension prototype)
-
toBuilder
public Expr.Comprehension.Builder toBuilder()
- Specified by:
toBuilderin interfacecom.google.protobuf.Message- Specified by:
toBuilderin interfacecom.google.protobuf.MessageLite
-
newBuilderForType
protected Expr.Comprehension.Builder newBuilderForType(com.google.protobuf.AbstractMessage.BuilderParent parent)
- Overrides:
newBuilderForTypein classcom.google.protobuf.AbstractMessage
-
getDefaultInstance
public static Expr.Comprehension getDefaultInstance()
-
parser
public static com.google.protobuf.Parser<Expr.Comprehension> parser()
-
getParserForType
public com.google.protobuf.Parser<Expr.Comprehension> getParserForType()
- Specified by:
getParserForTypein interfacecom.google.protobuf.Message- Specified by:
getParserForTypein interfacecom.google.protobuf.MessageLite- Overrides:
getParserForTypein classcom.google.protobuf.GeneratedMessage
-
getDefaultInstanceForType
public Expr.Comprehension getDefaultInstanceForType()
- Specified by:
getDefaultInstanceForTypein interfacecom.google.protobuf.MessageLiteOrBuilder- Specified by:
getDefaultInstanceForTypein interfacecom.google.protobuf.MessageOrBuilder
-
-