frostfs-api-go-pogpp/query/types.go

44 lines
810 B
Go
Raw Normal View History

2019-11-18 13:34:06 +00:00
package query
import (
"strings"
"github.com/gogo/protobuf/proto"
)
var (
_ proto.Message = (*Query)(nil)
_ proto.Message = (*Filter)(nil)
)
// String returns string representation of Filter.
func (m Filter) String() string {
b := new(strings.Builder)
b.WriteString("<Filter '$" + m.Name + "' ")
switch m.Type {
case Filter_Exact:
b.WriteString("==")
case Filter_Regex:
b.WriteString("~=")
default:
b.WriteString("??")
}
b.WriteString(" '" + m.Value + "'>")
return b.String()
}
// String returns string representation of Query.
func (m Query) String() string {
b := new(strings.Builder)
b.WriteString("<Query [")
ln := len(m.Filters)
for i := 0; i < ln; i++ {
b.WriteString(m.Filters[i].String())
if ln-1 != i {
b.WriteByte(',')
}
}
b.WriteByte(']')
return b.String()
}