Package dev.cel.expr
Class Expr.Comprehension
- java.lang.Object
-
- com.google.protobuf.AbstractMessageLite
-
- com.google.protobuf.AbstractMessage
-
- com.google.protobuf.GeneratedMessageV3
-
- dev.cel.expr.Expr.Comprehension
-
- All Implemented Interfaces:
Message,MessageLite,MessageLiteOrBuilder,MessageOrBuilder,Expr.ComprehensionOrBuilder,java.io.Serializable
- Enclosing class:
- Expr
public static final class Expr.Comprehension extends GeneratedMessageV3 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`. Comprehension 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` ```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.GeneratedMessageV3
GeneratedMessageV3.BuilderParent, GeneratedMessageV3.ExtendableBuilder<MessageType extends GeneratedMessageV3.ExtendableMessage,BuilderType extends GeneratedMessageV3.ExtendableBuilder<MessageType,BuilderType>>, GeneratedMessageV3.ExtendableMessage<MessageType extends GeneratedMessageV3.ExtendableMessage>, GeneratedMessageV3.ExtendableMessageOrBuilder<MessageType extends GeneratedMessageV3.ExtendableMessage>, GeneratedMessageV3.FieldAccessorTable, GeneratedMessageV3.UnusedPrivateParameter
-
Nested classes/interfaces inherited from class com.google.protobuf.AbstractMessageLite
AbstractMessageLite.InternalOneOfEnum
-
-
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 intLOOP_CONDITION_FIELD_NUMBERstatic intLOOP_STEP_FIELD_NUMBERstatic intRESULT_FIELD_NUMBER-
Fields inherited from class com.google.protobuf.GeneratedMessageV3
alwaysUseFieldBuilders, unknownFields
-
Fields inherited from class com.google.protobuf.AbstractMessage
memoizedSize
-
Fields inherited from class com.google.protobuf.AbstractMessageLite
memoizedHashCode
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)Compares the specified object with this message for equality.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.ByteStringgetAccuVarBytes()The name of the variable used for accumulation of the result.static Expr.ComprehensiongetDefaultInstance()Expr.ComprehensiongetDefaultInstanceForType()Get an instance of the type with no fields set.static Descriptors.DescriptorgetDescriptor()ExprgetIterRange()The range over which var iterates.ExprOrBuildergetIterRangeOrBuilder()The range over which var iterates.java.lang.StringgetIterVar()The name of the iteration variable.ByteStringgetIterVarBytes()The name of the iteration variable.ExprgetLoopCondition()An expression which can contain iter_var and accu_var.ExprOrBuildergetLoopConditionOrBuilder()An expression which can contain iter_var and accu_var.ExprgetLoopStep()An expression which can contain iter_var and accu_var.ExprOrBuildergetLoopStepOrBuilder()An expression which can contain iter_var and accu_var.Parser<Expr.Comprehension>getParserForType()Gets the parser for a message of the same type as this message.ExprgetResult()An expression which can contain accu_var.ExprOrBuildergetResultOrBuilder()An expression which can contain accu_var.intgetSerializedSize()Get the number of bytes required to encode this message.UnknownFieldSetgetUnknownFields()Get theUnknownFieldSetfor this message.booleanhasAccuInit()The initial value of the accumulator.inthashCode()Returns the hash code value for this message.booleanhasIterRange()The range over which var iterates.booleanhasLoopCondition()An expression which can contain iter_var and accu_var.booleanhasLoopStep()An expression which can contain iter_var and accu_var.booleanhasResult()An expression which can contain accu_var.protected GeneratedMessageV3.FieldAccessorTableinternalGetFieldAccessorTable()Get the FieldAccessorTable for this type.booleanisInitialized()Returns true if all required fields in the message and all embedded messages are set, false otherwise.static Expr.Comprehension.BuildernewBuilder()static Expr.Comprehension.BuildernewBuilder(Expr.Comprehension prototype)Expr.Comprehension.BuildernewBuilderForType()Constructs a new builder for a message of the same type as this message.protected Expr.Comprehension.BuildernewBuilderForType(GeneratedMessageV3.BuilderParent parent)TODO(xiaofeng): remove this together with GeneratedMessageV3.BuilderParent.protected java.lang.ObjectnewInstance(GeneratedMessageV3.UnusedPrivateParameter unused)Creates a new instance of this message type.static Expr.ComprehensionparseDelimitedFrom(java.io.InputStream input)static Expr.ComprehensionparseDelimitedFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry)static Expr.ComprehensionparseFrom(byte[] data)static Expr.ComprehensionparseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)static Expr.ComprehensionparseFrom(ByteString data)static Expr.ComprehensionparseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)static Expr.ComprehensionparseFrom(CodedInputStream input)static Expr.ComprehensionparseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)static Expr.ComprehensionparseFrom(java.io.InputStream input)static Expr.ComprehensionparseFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry)static Expr.ComprehensionparseFrom(java.nio.ByteBuffer data)static Expr.ComprehensionparseFrom(java.nio.ByteBuffer data, ExtensionRegistryLite extensionRegistry)static Parser<Expr.Comprehension>parser()Expr.Comprehension.BuildertoBuilder()Constructs a builder initialized with the current message.voidwriteTo(CodedOutputStream output)Serializes the message and writes it tooutput.-
Methods inherited from class com.google.protobuf.GeneratedMessageV3
canUseUnsafe, computeStringSize, computeStringSizeNoTag, emptyBooleanList, emptyDoubleList, emptyFloatList, emptyIntList, emptyLongList, getAllFields, getDescriptorForType, getField, getOneofFieldDescriptor, getRepeatedField, getRepeatedFieldCount, hasField, hasOneof, internalGetMapField, isStringEmpty, makeExtensionsImmutable, mergeFromAndMakeImmutableInternal, mutableCopy, mutableCopy, mutableCopy, mutableCopy, mutableCopy, newBooleanList, newBuilderForType, newDoubleList, newFloatList, newIntList, newLongList, 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, hashBoolean, hashEnum, hashEnumList, hashFields, hashLong, toString
-
Methods inherited from class com.google.protobuf.AbstractMessageLite
addAll, addAll, checkByteStringIsUtf8, toByteArray, toByteString, writeDelimitedTo, writeTo
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.google.protobuf.MessageLite
toByteArray, toByteString, writeDelimitedTo, writeTo
-
Methods inherited from interface com.google.protobuf.MessageOrBuilder
findInitializationErrors, getAllFields, getDescriptorForType, getField, getInitializationErrorString, getOneofFieldDescriptor, getRepeatedField, getRepeatedFieldCount, hasField, hasOneof
-
-
-
-
Field Detail
-
ITER_VAR_FIELD_NUMBER
public static final int ITER_VAR_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
-
newInstance
protected java.lang.Object newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)
Description copied from class:GeneratedMessageV3Creates a new instance of this message type. Overridden in the generated code.- Overrides:
newInstancein classGeneratedMessageV3
-
getUnknownFields
public final UnknownFieldSet getUnknownFields()
Description copied from interface:MessageOrBuilderGet theUnknownFieldSetfor this message.- Specified by:
getUnknownFieldsin interfaceMessageOrBuilder- Overrides:
getUnknownFieldsin classGeneratedMessageV3
-
getDescriptor
public static final Descriptors.Descriptor getDescriptor()
-
internalGetFieldAccessorTable
protected GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
Description copied from class:GeneratedMessageV3Get the FieldAccessorTable for this type. We can't have the message class pass this in to the constructor because of bootstrapping trouble with DescriptorProtos.- Specified by:
internalGetFieldAccessorTablein classGeneratedMessageV3
-
getIterVar
public java.lang.String getIterVar()
The name of the iteration variable.
string iter_var = 1;- Specified by:
getIterVarin interfaceExpr.ComprehensionOrBuilder- Returns:
- The iterVar.
-
getIterVarBytes
public ByteString getIterVarBytes()
The name of the iteration variable.
string iter_var = 1;- Specified by:
getIterVarBytesin interfaceExpr.ComprehensionOrBuilder- Returns:
- The bytes for iterVar.
-
hasIterRange
public boolean hasIterRange()
The range over which var 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 var iterates.
.cel.expr.Expr iter_range = 2;- Specified by:
getIterRangein interfaceExpr.ComprehensionOrBuilder- Returns:
- The iterRange.
-
getIterRangeOrBuilder
public ExprOrBuilder getIterRangeOrBuilder()
The range over which var 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 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 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 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 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 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 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 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()
Description copied from interface:MessageLiteOrBuilderReturns true if all required fields in the message and all embedded messages are set, false otherwise.- Specified by:
isInitializedin interfaceMessageLiteOrBuilder- Overrides:
isInitializedin classGeneratedMessageV3
-
writeTo
public void writeTo(CodedOutputStream output) throws java.io.IOException
Description copied from interface:MessageLiteSerializes the message and writes it tooutput. This does not flush or close the stream.- Specified by:
writeToin interfaceMessageLite- Overrides:
writeToin classGeneratedMessageV3- Throws:
java.io.IOException
-
getSerializedSize
public int getSerializedSize()
Description copied from interface:MessageLiteGet the number of bytes required to encode this message. The result is only computed on the first call and memoized after that. If this message requires more than Integer.MAX_VALUE bytes to encode, the return value will be smaller than the actual number of bytes required and might be negative.- Specified by:
getSerializedSizein interfaceMessageLite- Overrides:
getSerializedSizein classGeneratedMessageV3
-
equals
public boolean equals(java.lang.Object obj)
Description copied from interface:MessageCompares the specified object with this message for equality. Returnstrueif the given object is a message of the same type (as defined bygetDescriptorForType()) and has identical values for all of its fields. Subclasses must implement this; inheritingObject.equals()is incorrect.- Specified by:
equalsin interfaceMessage- Overrides:
equalsin classAbstractMessage- Parameters:
obj- object to be compared for equality with this message- Returns:
trueif the specified object is equal to this message
-
hashCode
public int hashCode()
Description copied from interface:MessageReturns the hash code value for this message. The hash code of a message should mix the message's type (object identity of the descriptor) with its contents (known and unknown field values). Subclasses must implement this; inheritingObject.hashCode()is incorrect.- Specified by:
hashCodein interfaceMessage- Overrides:
hashCodein classAbstractMessage- Returns:
- the hash code value for this message
- See Also:
Map.hashCode()
-
parseFrom
public static Expr.Comprehension parseFrom(java.nio.ByteBuffer data) throws InvalidProtocolBufferException
- Throws:
InvalidProtocolBufferException
-
parseFrom
public static Expr.Comprehension parseFrom(java.nio.ByteBuffer data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
- Throws:
InvalidProtocolBufferException
-
parseFrom
public static Expr.Comprehension parseFrom(ByteString data) throws InvalidProtocolBufferException
- Throws:
InvalidProtocolBufferException
-
parseFrom
public static Expr.Comprehension parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
- Throws:
InvalidProtocolBufferException
-
parseFrom
public static Expr.Comprehension parseFrom(byte[] data) throws InvalidProtocolBufferException
- Throws:
InvalidProtocolBufferException
-
parseFrom
public static Expr.Comprehension parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
- Throws:
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, 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, ExtensionRegistryLite extensionRegistry) throws java.io.IOException
- Throws:
java.io.IOException
-
parseFrom
public static Expr.Comprehension parseFrom(CodedInputStream input) throws java.io.IOException
- Throws:
java.io.IOException
-
parseFrom
public static Expr.Comprehension parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws java.io.IOException
- Throws:
java.io.IOException
-
newBuilderForType
public Expr.Comprehension.Builder newBuilderForType()
Description copied from interface:MessageLiteConstructs a new builder for a message of the same type as this message.- Specified by:
newBuilderForTypein interfaceMessage- Specified by:
newBuilderForTypein interfaceMessageLite
-
newBuilder
public static Expr.Comprehension.Builder newBuilder()
-
newBuilder
public static Expr.Comprehension.Builder newBuilder(Expr.Comprehension prototype)
-
toBuilder
public Expr.Comprehension.Builder toBuilder()
Description copied from interface:MessageLiteConstructs a builder initialized with the current message. Use this to derive a new message from the current one.- Specified by:
toBuilderin interfaceMessage- Specified by:
toBuilderin interfaceMessageLite
-
newBuilderForType
protected Expr.Comprehension.Builder newBuilderForType(GeneratedMessageV3.BuilderParent parent)
Description copied from class:GeneratedMessageV3TODO(xiaofeng): remove this together with GeneratedMessageV3.BuilderParent.- Specified by:
newBuilderForTypein classGeneratedMessageV3
-
getDefaultInstance
public static Expr.Comprehension getDefaultInstance()
-
parser
public static Parser<Expr.Comprehension> parser()
-
getParserForType
public Parser<Expr.Comprehension> getParserForType()
Description copied from interface:MessageLiteGets the parser for a message of the same type as this message.- Specified by:
getParserForTypein interfaceMessage- Specified by:
getParserForTypein interfaceMessageLite- Overrides:
getParserForTypein classGeneratedMessageV3
-
getDefaultInstanceForType
public Expr.Comprehension getDefaultInstanceForType()
Description copied from interface:MessageLiteOrBuilderGet an instance of the type with no fields set. Because no fields are set, all getters for singular fields will return default values and repeated fields will appear empty. This may or may not be a singleton. This differs from thegetDefaultInstance()method of generated message classes in that this method is an abstract method of theMessageLiteinterface whereasgetDefaultInstance()is a static method of a specific class. They return the same thing.- Specified by:
getDefaultInstanceForTypein interfaceMessageLiteOrBuilder- Specified by:
getDefaultInstanceForTypein interfaceMessageOrBuilder
-
-