AndCondition.go 497 B

1234567891011121314151617181920212223242526
  1. package core
  2. type AndCondition struct {
  3. Conditions []Condition
  4. }
  5. func And(conditions ...Condition) Condition {
  6. return AndCondition{Conditions: conditions}
  7. }
  8. func (c AndCondition) Fields() []string {
  9. var fields []string
  10. for _, cond := range c.Conditions {
  11. fields = append(fields, cond.Fields()...)
  12. }
  13. return fields
  14. }
  15. func (c AndCondition) Match(row []byte, table *Table) bool {
  16. for _, cond := range c.Conditions {
  17. if !cond.Match(row, table) {
  18. return false
  19. }
  20. }
  21. return true
  22. }