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

Method QualifyIfPresent

interpreter/interpretable.go:1567–1581  ·  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

1565
1566// QualifyIfPresent conditionally qualifies the variable and only records a value if one is present.
1567func (e *evalWatchConstQual) QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) {
1568 out, present, err := e.ConstantQualifier.QualifyIfPresent(vars, obj, presenceOnly)
1569 var val ref.Val
1570 if err != nil {
1571 val = types.LabelErrNode(e.ID(), types.WrapErr(err))
1572 } else if out != nil {
1573 val = e.adapter.NativeToValue(out)
1574 } else if presenceOnly {
1575 val = types.Bool(present)
1576 }
1577 if present || presenceOnly {
1578 e.observer(vars, e.ID(), e.ConstantQualifier, val)
1579 }
1580 return out, present, err
1581}
1582
1583// QualifierValueEquals tests whether the incoming value is equal to the qualifying constant.
1584func (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