Skip to content

Commit

Permalink
Add NotQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
tenntenn committed Feb 26, 2017
1 parent 01133fc commit f67f237
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ package typequery

import "go/types"

var (
_ Query = andQuery(nil)
_ Query = orQuery(nil)
_ Query = (*notQuery)(nil)
)

type Query interface {
Exec(o types.Object) bool
}
Expand Down Expand Up @@ -35,3 +41,17 @@ func (qs orQuery) Exec(o types.Object) bool {
}
return false
}

func Not(q Query) Query {
return &notQuery{
Query: q,
}
}

type notQuery struct {
Query
}

func (q *notQuery) Exec(o types.Object) bool {
return !q.Query.Exec(o)
}

0 comments on commit f67f237

Please sign in to comment.