Package co.permify.sdk.model
Class Comprehension
java.lang.Object
co.permify.sdk.model.Comprehension
@Generated("org.openapitools.codegen.languages.JavaClientCodegen")
public class Comprehension
extends Object
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` ```
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturn true if this Comprehension object is equal to o.Get accuInitThe name of the variable used for accumulation of the result.Get iterRangeThe name of the first iteration variable.The name of the second iteration variable, empty if not set.Get loopConditionGet loopStepGet resultinthashCode()loopCondition(Expr loopCondition) voidsetAccuInit(Expr accuInit) voidsetAccuVar(String accuVar) voidsetIterRange(Expr iterRange) voidsetIterVar(String iterVar) voidsetIterVar2(String iterVar2) voidsetLoopCondition(Expr loopCondition) voidsetLoopStep(Expr loopStep) voidtoString()Convert the instance into URL query string.toUrlQueryString(String prefix) Convert the instance into URL query string.
-
Field Details
-
JSON_PROPERTY_ITER_VAR
- See Also:
-
JSON_PROPERTY_ITER_VAR2
- See Also:
-
JSON_PROPERTY_ITER_RANGE
- See Also:
-
JSON_PROPERTY_ACCU_VAR
- See Also:
-
JSON_PROPERTY_ACCU_INIT
- See Also:
-
JSON_PROPERTY_LOOP_CONDITION
- See Also:
-
JSON_PROPERTY_LOOP_STEP
- See Also:
-
JSON_PROPERTY_RESULT
- See Also:
-
-
Constructor Details
-
Comprehension
public Comprehension()
-
-
Method Details
-
iterVar
-
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.- Returns:
- iterVar
-
setIterVar
-
iterVar2
-
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.- Returns:
- iterVar2
-
setIterVar2
-
iterRange
-
getIterRange
Get iterRange- Returns:
- iterRange
-
setIterRange
-
accuVar
-
getAccuVar
The name of the variable used for accumulation of the result.- Returns:
- accuVar
-
setAccuVar
-
accuInit
-
getAccuInit
Get accuInit- Returns:
- accuInit
-
setAccuInit
-
loopCondition
-
getLoopCondition
Get loopCondition- Returns:
- loopCondition
-
setLoopCondition
-
loopStep
-
getLoopStep
Get loopStep- Returns:
- loopStep
-
setLoopStep
-
result
-
getResult
Get result- Returns:
- result
-
setResult
-
equals
Return true if this Comprehension object is equal to o. -
hashCode
public int hashCode() -
toString
-
toUrlQueryString
Convert the instance into URL query string.- Returns:
- URL query string
-
toUrlQueryString
Convert the instance into URL query string.- Parameters:
prefix- prefix of the query string- Returns:
- URL query string
-