forked from ravendb/ravendb-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfacet_value.go
51 lines (43 loc) · 898 Bytes
/
facet_value.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package ravendb
import (
"fmt"
"strconv"
"strings"
)
type FacetValue struct {
Range string
Count int
Sum *float64
Max *float64
Min *float64
Average *float64
}
func (v *FacetValue) SetSum(sum float64) {
v.Sum = &sum
}
func (v *FacetValue) SetMax(max float64) {
v.Max = &max
}
func (v *FacetValue) SetMin(min float64) {
v.Min = &min
}
func (v *FacetValue) SetAverage(average float64) {
v.Average = &average
}
func (v *FacetValue) String() string {
msg := v.Range + " - Count: " + strconv.Itoa(v.Count) + ", "
if v.Sum != nil {
msg += fmt.Sprintf("Sum: %f,", *v.Sum)
}
if v.Max != nil {
msg += fmt.Sprintf("Max: %f,", *v.Max)
}
if v.Min != nil {
msg += fmt.Sprintf("Min: %f,", *v.Min)
}
if v.Average != nil {
msg += fmt.Sprintf("Average: %f,", *v.Average)
}
// TODO: this makes no sense but is in Java code
return strings.TrimSuffix(msg, ";")
}