MCPcopy Create free account
hub / github.com/cel-expr/cel-go / QualifyIfPresent

Method QualifyIfPresent

interpreter/interpretable.go:1155–1169  ·  view source on GitHub ↗

QualifyIfPresent conditionally qualifies the variable and only records a value if one is present.

(vars Activation, obj any, presenceOnly bool)

Source from the content-addressed store, hash-verified

1153
1154// QualifyIfPresent conditionally qualifies the variable and only records a value if one is present.
1155func (e *evalWatchConstQual) QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) {
1156 out, present, err := e.ConstantQualifier.QualifyIfPresent(vars, obj, presenceOnly)
1157 var val ref.Val
1158 if err != nil {
1159 val = types.LabelErrNode(e.ID(), types.WrapErr(err))
1160 } else if out != nil {
1161 val = e.adapter.NativeToValue(out)
1162 } else if presenceOnly {
1163 val = types.Bool(present)
1164 }
1165 if present || presenceOnly {
1166 e.observer(vars, e.ID(), e.ConstantQualifier, val)
1167 }
1168 return out, present, err
1169}
1170
1171// QualifierValueEquals tests whether the incoming value is equal to the qualifying constant.
1172func (e *evalWatchConstQual) QualifierValueEquals(value any) bool {

Callers

nothing calls this directly

Calls 6

LabelErrNodeFunction · 0.92
WrapErrFunction · 0.92
BoolTypeAlias · 0.92
QualifyIfPresentMethod · 0.65
IDMethod · 0.65
NativeToValueMethod · 0.65

Tested by

no test coverage detected