github.com/Axway/agent-sdk@v1.1.101/pkg/filter/expr_exists.go (about) 1 package filter 2 3 // ExistsExpr - Exists implementation. Checks the existance of the selector as key in filter data 4 type ExistsExpr struct { 5 FilterType string 6 Name string 7 } 8 9 func newExistsExpr(filterType, name string) CallExpr { 10 return &ExistsExpr{ 11 FilterType: filterType, 12 Name: name, 13 } 14 } 15 16 // GetType - Returns the CallType 17 func (e *ExistsExpr) GetType() CallType { 18 return EXISTS 19 } 20 21 // Execute - Returns true if the selector key is found in filter data 22 func (e *ExistsExpr) Execute(data Data) (interface{}, error) { 23 keysList := data.GetKeys(e.FilterType) 24 for _, keyEntry := range keysList { 25 if keyEntry == e.Name { 26 return true, nil 27 } 28 } 29 return false, nil 30 } 31 32 func (e *ExistsExpr) String() string { 33 return e.FilterType + "." + e.Name + ".Exists()" 34 }