github.com/yongjacky/phoenix-go-orm-builder@v0.3.5/cond.go (about)

     1  // Copyright 2016 The Xorm Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package builder
     6  
     7  // Cond defines an interface
     8  type Cond interface {
     9  	WriteTo(Writer) error
    10  	And(...Cond) Cond
    11  	Or(...Cond) Cond
    12  	IsValid() bool
    13  }
    14  
    15  type condEmpty struct{}
    16  
    17  var _ Cond = condEmpty{}
    18  
    19  // NewCond creates an empty condition
    20  func NewCond() Cond {
    21  	return condEmpty{}
    22  }
    23  
    24  func (condEmpty) WriteTo(w Writer) error {
    25  	return nil
    26  }
    27  
    28  func (condEmpty) And(conds ...Cond) Cond {
    29  	return And(conds...)
    30  }
    31  
    32  func (condEmpty) Or(conds ...Cond) Cond {
    33  	return Or(conds...)
    34  }
    35  
    36  func (condEmpty) IsValid() bool {
    37  	return false
    38  }