Package com.google.api.expr.v1alpha1
Class Expr.Comprehension
java.lang.Object
com.google.protobuf.AbstractMessageLite<MessageType,BuilderType>
com.google.protobuf.GeneratedMessageLite<Expr.Comprehension,Expr.Comprehension.Builder>
com.google.api.expr.v1alpha1.Expr.Comprehension
- All Implemented Interfaces:
Expr.ComprehensionOrBuilder,com.google.protobuf.MessageLite,com.google.protobuf.MessageLiteOrBuilder
- Enclosing class:
- Expr
public static final class Expr.Comprehension
extends com.google.protobuf.GeneratedMessageLite<Expr.Comprehension,Expr.Comprehension.Builder>
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 type google.api.expr.v1alpha1.Expr.Comprehension-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA comprehension expression applied to a list or map.Nested classes/interfaces inherited from class com.google.protobuf.GeneratedMessageLite
com.google.protobuf.GeneratedMessageLite.DefaultInstanceBasedParser<T extends com.google.protobuf.GeneratedMessageLite<T,?>>, com.google.protobuf.GeneratedMessageLite.ExtendableBuilder<MessageType extends com.google.protobuf.GeneratedMessageLite.ExtendableMessage<MessageType, BuilderType>, BuilderType extends com.google.protobuf.GeneratedMessageLite.ExtendableBuilder<MessageType, BuilderType>>, com.google.protobuf.GeneratedMessageLite.ExtendableMessage<MessageType extends com.google.protobuf.GeneratedMessageLite.ExtendableMessage<MessageType, BuilderType>, BuilderType extends com.google.protobuf.GeneratedMessageLite.ExtendableBuilder<MessageType, BuilderType>>, com.google.protobuf.GeneratedMessageLite.ExtendableMessageOrBuilder<MessageType extends com.google.protobuf.GeneratedMessageLite.ExtendableMessage<MessageType, BuilderType>, BuilderType extends com.google.protobuf.GeneratedMessageLite.ExtendableBuilder<MessageType, BuilderType>>, com.google.protobuf.GeneratedMessageLite.GeneratedExtension<ContainingType extends com.google.protobuf.MessageLite, Type extends Object>, com.google.protobuf.GeneratedMessageLite.MethodToInvoke, com.google.protobuf.GeneratedMessageLite.SerializedForm Nested classes/interfaces inherited from class com.google.protobuf.AbstractMessageLite
com.google.protobuf.AbstractMessageLite.InternalOneOfEnum -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intFields inherited from class com.google.protobuf.GeneratedMessageLite
unknownFieldsFields inherited from class com.google.protobuf.AbstractMessageLite
memoizedHashCode -
Method Summary
Modifier and TypeMethodDescriptionprotected final ObjectdynamicMethod(com.google.protobuf.GeneratedMessageLite.MethodToInvoke method, Object arg0, Object arg1) The initial value of the accumulator.The name of the variable used for accumulation of the result.com.google.protobuf.ByteStringThe name of the variable used for accumulation of the result.static Expr.ComprehensionThe range over which the comprehension iterates.The name of the first iteration variable.The name of the second iteration variable, empty if not set.com.google.protobuf.ByteStringThe name of the second iteration variable, empty if not set.com.google.protobuf.ByteStringThe name of the first iteration variable.An expression which can contain iter_var, iter_var2, and accu_var.An expression which can contain iter_var, iter_var2, and accu_var.An expression which can contain accu_var.booleanThe initial value of the accumulator.booleanThe range over which the comprehension iterates.booleanAn expression which can contain iter_var, iter_var2, and accu_var.booleanAn expression which can contain iter_var, iter_var2, and accu_var.booleanAn expression which can contain accu_var.static Expr.Comprehension.Builderstatic Expr.Comprehension.BuildernewBuilder(Expr.Comprehension prototype) static Expr.ComprehensionparseDelimitedFrom(InputStream input) static Expr.ComprehensionparseDelimitedFrom(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(InputStream input) static Expr.ComprehensionparseFrom(InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) static Expr.ComprehensionparseFrom(ByteBuffer data) static Expr.ComprehensionparseFrom(ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) static com.google.protobuf.Parser<Expr.Comprehension>parser()Methods inherited from class com.google.protobuf.GeneratedMessageLite
createBuilder, createBuilder, dynamicMethod, dynamicMethod, emptyBooleanList, emptyDoubleList, emptyFloatList, emptyIntList, emptyLongList, emptyProtobufList, equals, getDefaultInstanceForType, getParserForType, getSerializedSize, hashCode, isInitialized, isInitialized, makeImmutable, mergeLengthDelimitedField, mergeUnknownFields, mergeVarintField, mutableCopy, mutableCopy, mutableCopy, mutableCopy, mutableCopy, mutableCopy, newBuilderForType, newMessageInfo, newRepeatedGeneratedExtension, newSingularGeneratedExtension, parseDelimitedFrom, parseDelimitedFrom, parseFrom, parseFrom, parseFrom, parseFrom, parseFrom, parseFrom, parseFrom, parseFrom, parseFrom, parseFrom, parsePartialFrom, parseUnknownField, registerDefaultInstance, toBuilder, toString, writeToMethods inherited from class com.google.protobuf.AbstractMessageLite
addAll, checkByteStringIsUtf8, toByteArray, toByteString, writeDelimitedTo, writeToMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.google.protobuf.MessageLiteOrBuilder
getDefaultInstanceForType, isInitialized
-
Field Details
-
ITER_VAR_FIELD_NUMBER
public static final int ITER_VAR_FIELD_NUMBER- See Also:
-
ITER_VAR2_FIELD_NUMBER
public static final int ITER_VAR2_FIELD_NUMBER- See Also:
-
ITER_RANGE_FIELD_NUMBER
public static final int ITER_RANGE_FIELD_NUMBER- See Also:
-
ACCU_VAR_FIELD_NUMBER
public static final int ACCU_VAR_FIELD_NUMBER- See Also:
-
ACCU_INIT_FIELD_NUMBER
public static final int ACCU_INIT_FIELD_NUMBER- See Also:
-
LOOP_CONDITION_FIELD_NUMBER
public static final int LOOP_CONDITION_FIELD_NUMBER- See Also:
-
LOOP_STEP_FIELD_NUMBER
public static final int LOOP_STEP_FIELD_NUMBER- See Also:
-
RESULT_FIELD_NUMBER
public static final int RESULT_FIELD_NUMBER- See Also:
-
-
Method Details
-
getIterVar
The name of the first iteration variable. When the iter_range is a list, this variable is the list element. When the iter_range is a map, this variable is the map entry key.
string iter_var = 1 [json_name = "iterVar"];- Specified by:
getIterVarin interfaceExpr.ComprehensionOrBuilder- Returns:
- The iterVar.
-
getIterVarBytes
public com.google.protobuf.ByteString getIterVarBytes()The name of the first iteration variable. When the iter_range is a list, this variable is the list element. When the iter_range is a map, this variable is the map entry key.
string iter_var = 1 [json_name = "iterVar"];- Specified by:
getIterVarBytesin interfaceExpr.ComprehensionOrBuilder- Returns:
- The bytes for iterVar.
-
getIterVar2
The name of the second iteration variable, empty if not set. When the iter_range is a list, this variable is the integer index. When the iter_range is a map, this variable is the map entry value. This field is only set for comprehension v2 macros.
string iter_var2 = 8 [json_name = "iterVar2"];- 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. When the iter_range is a list, this variable is the integer index. When the iter_range is a map, this variable is the map entry value. This field is only set for comprehension v2 macros.
string iter_var2 = 8 [json_name = "iterVar2"];- Specified by:
getIterVar2Bytesin interfaceExpr.ComprehensionOrBuilder- Returns:
- The bytes for iterVar2.
-
hasIterRange
public boolean hasIterRange()The range over which the comprehension iterates.
.google.api.expr.v1alpha1.Expr iter_range = 2 [json_name = "iterRange"];- Specified by:
hasIterRangein interfaceExpr.ComprehensionOrBuilder- Returns:
- Whether the iterRange field is set.
-
getIterRange
The range over which the comprehension iterates.
.google.api.expr.v1alpha1.Expr iter_range = 2 [json_name = "iterRange"];- Specified by:
getIterRangein interfaceExpr.ComprehensionOrBuilder- Returns:
- The iterRange.
-
getAccuVar
The name of the variable used for accumulation of the result.
string accu_var = 3 [json_name = "accuVar"];- 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 [json_name = "accuVar"];- Specified by:
getAccuVarBytesin interfaceExpr.ComprehensionOrBuilder- Returns:
- The bytes for accuVar.
-
hasAccuInit
public boolean hasAccuInit()The initial value of the accumulator.
.google.api.expr.v1alpha1.Expr accu_init = 4 [json_name = "accuInit"];- Specified by:
hasAccuInitin interfaceExpr.ComprehensionOrBuilder- Returns:
- Whether the accuInit field is set.
-
getAccuInit
The initial value of the accumulator.
.google.api.expr.v1alpha1.Expr accu_init = 4 [json_name = "accuInit"];- Specified by:
getAccuInitin interfaceExpr.ComprehensionOrBuilder- Returns:
- The accuInit.
-
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.
.google.api.expr.v1alpha1.Expr loop_condition = 5 [json_name = "loopCondition"];- Specified by:
hasLoopConditionin interfaceExpr.ComprehensionOrBuilder- Returns:
- Whether the loopCondition field is set.
-
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.
.google.api.expr.v1alpha1.Expr loop_condition = 5 [json_name = "loopCondition"];- Specified by:
getLoopConditionin interfaceExpr.ComprehensionOrBuilder- Returns:
- The loopCondition.
-
hasLoopStep
public boolean hasLoopStep()An expression which can contain iter_var, iter_var2, and accu_var. Computes the next value of accu_var.
.google.api.expr.v1alpha1.Expr loop_step = 6 [json_name = "loopStep"];- Specified by:
hasLoopStepin interfaceExpr.ComprehensionOrBuilder- Returns:
- Whether the loopStep field is set.
-
getLoopStep
An expression which can contain iter_var, iter_var2, and accu_var. Computes the next value of accu_var.
.google.api.expr.v1alpha1.Expr loop_step = 6 [json_name = "loopStep"];- Specified by:
getLoopStepin interfaceExpr.ComprehensionOrBuilder- Returns:
- The loopStep.
-
hasResult
public boolean hasResult()An expression which can contain accu_var. Computes the result.
.google.api.expr.v1alpha1.Expr result = 7 [json_name = "result"];- Specified by:
hasResultin interfaceExpr.ComprehensionOrBuilder- Returns:
- Whether the result field is set.
-
getResult
An expression which can contain accu_var. Computes the result.
.google.api.expr.v1alpha1.Expr result = 7 [json_name = "result"];- Specified by:
getResultin interfaceExpr.ComprehensionOrBuilder- Returns:
- The result.
-
parseFrom
public static Expr.Comprehension parseFrom(ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException - Throws:
com.google.protobuf.InvalidProtocolBufferException
-
parseFrom
public static Expr.Comprehension parseFrom(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
- Throws:
IOException
-
parseFrom
public static Expr.Comprehension parseFrom(InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws IOException - Throws:
IOException
-
parseDelimitedFrom
- Throws:
IOException
-
parseDelimitedFrom
public static Expr.Comprehension parseDelimitedFrom(InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws IOException - Throws:
IOException
-
parseFrom
public static Expr.Comprehension parseFrom(com.google.protobuf.CodedInputStream input) throws IOException - Throws:
IOException
-
parseFrom
public static Expr.Comprehension parseFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws IOException - Throws:
IOException
-
newBuilder
-
newBuilder
-
dynamicMethod
protected final Object dynamicMethod(com.google.protobuf.GeneratedMessageLite.MethodToInvoke method, Object arg0, Object arg1) - Specified by:
dynamicMethodin classcom.google.protobuf.GeneratedMessageLite<Expr.Comprehension,Expr.Comprehension.Builder>
-
getDefaultInstance
-
parser
-