Documentation
¶
Index ¶
- Constants
- type AndOp
- type BetweenOp
- func (op *BetweenOp) IsEqualTo(x Condition) bool
- func (op *BetweenOp) IsValid() (bool, error)
- func (op *BetweenOp) Lhs() string
- func (op *BetweenOp) Lower() interface{}
- func (op *BetweenOp) Negate() Condition
- func (op *BetweenOp) Simplify() Condition
- func (op *BetweenOp) String() string
- func (op *BetweenOp) Upper() interface{}
- type Bool
- type Condition
- func And(cond ...Condition) Condition
- func Between(lhs string, lower interface{}, upper interface{}) Condition
- func Equal(lhs string, rhs interface{}) Condition
- func FromRecord(r record.Record) Condition
- func GreaterThan(lhs string, rhs interface{}) Condition
- func GreaterThanOrEqualTo(lhs string, rhs interface{}) Condition
- func In(lhs string, value ...interface{}) Condition
- func Is(lhs string, value bool) Condition
- func IsFalse(lhs string) Condition
- func IsTrue(lhs string) Condition
- func LessThan(lhs string, rhs interface{}) Condition
- func LessThanOrEqualTo(lhs string, rhs interface{}) Condition
- func NotBetween(lhs string, lower interface{}, upper interface{}) Condition
- func NotEqual(lhs string, rhs interface{}) Condition
- func NotIn(lhs string, value ...interface{}) Condition
- func Or(cond ...Condition) Condition
- type InOp
- type IsOp
- type LeafOp
- type NotBetweenOp
- func (op *NotBetweenOp) IsEqualTo(x Condition) bool
- func (op *NotBetweenOp) IsValid() (bool, error)
- func (op *NotBetweenOp) Lhs() string
- func (op *NotBetweenOp) Lower() interface{}
- func (op *NotBetweenOp) Negate() Condition
- func (op *NotBetweenOp) Simplify() Condition
- func (op *NotBetweenOp) String() string
- func (op *NotBetweenOp) Upper() interface{}
- type NotInOp
- type OpCode
- type OrOp
Constants ¶
const ( True = Bool(true) False = Bool(false) )
The possible truth valuations.
const ( Eq = OpCode(iota) // Equal to (=) Ne // Not equal to (!=) Gt // Greater than (>) Lt // Less than (<) Ge // Greater than or equal to (>=) Le // Less than or equal to (<=) )
The valid OpCodes.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AndOp ¶
type AndOp struct {
// contains filtered or unexported fields
}
AndOp describes an AND operator.
func (*AndOp) Conditions ¶
Conditions returns the conditions that form the AND operator.
func (*AndOp) IsEqualTo ¶
IsEqualTo returns true iff the conditions are equal (note that this does not check for equivalence).
func (*AndOp) IsValid ¶
IsValid returns true iff the condition validates. If false, also returns an error describing why validation failed.
type BetweenOp ¶
type BetweenOp struct {
// contains filtered or unexported fields
}
BetweenOp describes a BETWEEN operator.
func (*BetweenOp) IsEqualTo ¶
IsEqualTo returns true iff the conditions are equal (note that this does not check for equivalence).
func (*BetweenOp) IsValid ¶
IsValid returns true iff the condition validates. If false, also returns an error describing why validation failed.
func (*BetweenOp) Lower ¶
func (op *BetweenOp) Lower() interface{}
Lower returns the lower value for of the operator.
func (*BetweenOp) Simplify ¶
Simplify re-expresses the operator in terms of Bool, *LeafOp, *AndOp, and *OrOp conditions only.
type Bool ¶
type Bool bool
Bool defines a truth valuation.
func (Bool) IsEqualTo ¶
IsEqualTo returns true iff the conditions are equal (note that this does not check for equivalence).
type Condition ¶
type Condition interface { // IsValid returns true iff the condition validates. If false, also // returns an error describing why validation failed. IsValid() (bool, error) // Negate returns the negation of the given operation. Negate() Condition // Simplify re-expresses the operator in terms of Bool, *LeafOp, *AndOp, // and *OrOp conditions only. Simplify() Condition // IsEqualTo returns true iff the conditions are equal (note that this does not check for equivalence). IsEqualTo(Condition) bool }
Condition is the interface satisfied by a logical condition. Conditions produced by this package will be of one of the following types:
Bool *LeafOp *IsOp *InOp *NotInOp *BetweenOp *NotBetweenOp *AndOp *OrOp
func And ¶
And returns a new AND operator as an *AndOp or equivalent Condition. That is, it is equivalent to:
cond1 AND cond2 AND ... AND condN.
If no conditions are provided then this equivalent to the True valuation.
func Between ¶
Between returns a new BETWEEN operator as a *BetweenOp or equivalent Condition. The BETWEEN operator can be used to match against a range of values and is equivalent to:
lhs >= lower AND lhs <= upper.
func FromRecord ¶
FromRecord converts a record to a condition.
func GreaterThan ¶
GreaterThan returns the operator "lhs > rhs" (or its equivalent) as a *LeafOp.
func GreaterThanOrEqualTo ¶
GreaterThanOrEqualTo returns the operator "lhs >= rhs" (or its equivalent) as a *LeafOp.
func In ¶
In returns a new IN operator as an *InOp or equivalent Condition. The IN operator can be used to match a value against a list of values and is equivalent to successive OR operators:
lhs = value1 OR lhs = value2 OR ... OR lhs = valueN
If no values are provided then this equivalent to the False valuation.
func Is ¶
Is returns a new IS operator as an *IsOp. The IS operator can be used to match a value against a boolean value only.
func LessThanOrEqualTo ¶
LessThanOrEqualTo returns the operator "lhs <= rhs" (or its equivalent) as a *LeafOp.
func NotBetween ¶
NotBetween returns a new NOT BETWEEN operator as a *NotBetweenOp or equivalent Condition. The NOT BETWEEN operator can be used to match against a range of values and is equivalent to:
lhs < lower OR lhs > upper.
func NotIn ¶
NotIn returns a new NOT IN operator as a *NotInOp or equivalent Condition. The NOT IN operator can be used to match a value against a list of values and is equivalent to successive AND operators:
lhs != value1 AND lhs != value2 AND ... AND lhs != valueN
If no values are provided then this equivalent to the True valuation.
type InOp ¶
type InOp struct {
// contains filtered or unexported fields
}
InOp describes an IN operator.
func (*InOp) IsEqualTo ¶
IsEqualTo returns true iff the conditions are equal (note that this does not check for equivalence).
func (*InOp) IsValid ¶
IsValid returns true iff the condition validates. If false, also returns an error describing why validation failed.
func (*InOp) Simplify ¶
Simplify re-expresses the operator in terms of Bool, *LeafOp, *AndOp, and *OrOp conditions only.
type IsOp ¶
type IsOp struct {
// contains filtered or unexported fields
}
IsOp describes an IS operator.
func (*IsOp) IsEqualTo ¶
IsEqualTo returns true iff the conditions are equal (note that this does not check for equivalence).
func (*IsOp) IsValid ¶
IsValid returns true iff the condition validates. If false, also returns an error describing why validation failed.
func (*IsOp) Simplify ¶
Simplify re-expresses the operator in terms of Bool, *LeafOp, *AndOp, and *OrOp conditions only.
type LeafOp ¶
type LeafOp struct {
// contains filtered or unexported fields
}
LeafOp describes an operator of the form "lhs op rhs" where "lhs" is given by a key, "op" is a valid OpCode, and "rhs" is a value.
func (*LeafOp) IsEqualTo ¶
IsEqualTo returns true iff the conditions are equal (note that this does not check for equivalence).
func (*LeafOp) IsValid ¶
IsValid returns true iff the operator validates. If false, also returns an error describing why validation failed.
type NotBetweenOp ¶
type NotBetweenOp struct {
// contains filtered or unexported fields
}
NotBetweenOp describes a NOT BETWEEN operator.
func (*NotBetweenOp) IsEqualTo ¶
func (op *NotBetweenOp) IsEqualTo(x Condition) bool
IsEqualTo returns true iff the conditions are equal (note that this does not check for equivalence).
func (*NotBetweenOp) IsValid ¶
func (op *NotBetweenOp) IsValid() (bool, error)
IsValid returns true iff the condition validates. If false, also returns an error describing why validation failed.
func (*NotBetweenOp) Lhs ¶
func (op *NotBetweenOp) Lhs() string
Lhs returns the lhs of the operator.
func (*NotBetweenOp) Lower ¶
func (op *NotBetweenOp) Lower() interface{}
Lower returns the lower value for of the operator.
func (*NotBetweenOp) Negate ¶
func (op *NotBetweenOp) Negate() Condition
Negate returns the negation of the given operation.
func (*NotBetweenOp) Simplify ¶
func (op *NotBetweenOp) Simplify() Condition
Simplify re-expresses the operator in terms of Bool, *LeafOp, *AndOp, and *OrOp conditions only.
func (*NotBetweenOp) String ¶
func (op *NotBetweenOp) String() string
String returns a string description of the operator.
func (*NotBetweenOp) Upper ¶
func (op *NotBetweenOp) Upper() interface{}
Upper returns the upper value for of the operator.
type NotInOp ¶
type NotInOp struct {
// contains filtered or unexported fields
}
NotInOp describes a NOT IN operator.
func (*NotInOp) IsEqualTo ¶
IsEqualTo returns true iff the conditions are equal (note that this does not check for equivalence).
func (*NotInOp) IsValid ¶
IsValid returns true iff the condition validates. If false, also returns an error describing why validation failed.
func (*NotInOp) Simplify ¶
Simplify re-expresses the operator in terms of Bool, *LeafOp, *AndOp, and *OrOp conditions only.
type OpCode ¶
type OpCode int
OpCode describes a binary operator.
type OrOp ¶
type OrOp struct {
// contains filtered or unexported fields
}
OrOp describes an OR operator.
func (*OrOp) Conditions ¶
Conditions returns the conditions that form the OR operator.
func (*OrOp) IsEqualTo ¶
IsEqualTo returns true iff the conditions are equal (note that this does not check for equivalence).
func (*OrOp) IsValid ¶
IsValid returns true iff the condition validates. If false, also returns an error describing why validation failed.