forked from tidepool-org/platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
normalizer.go
47 lines (38 loc) · 1010 Bytes
/
normalizer.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
package normalizer
import (
"github.com/tidepool-org/platform/structure"
structureBase "github.com/tidepool-org/platform/structure/base"
)
type Normalizer struct {
base *structureBase.Base
}
func New() *Normalizer {
return NewNormalizer(structureBase.New().WithSource(structure.NewPointerSource()))
}
func NewNormalizer(base *structureBase.Base) *Normalizer {
return &Normalizer{
base: base,
}
}
func (n *Normalizer) Error() error {
return n.base.Error()
}
func (n *Normalizer) Normalize(normalizable structure.Normalizable) error {
normalizable.Normalize(n)
return n.Error()
}
func (n *Normalizer) WithSource(source structure.Source) structure.Normalizer {
return &Normalizer{
base: n.base.WithSource(source),
}
}
func (n *Normalizer) WithMeta(meta interface{}) structure.Normalizer {
return &Normalizer{
base: n.base.WithMeta(meta),
}
}
func (n *Normalizer) WithReference(reference string) structure.Normalizer {
return &Normalizer{
base: n.base.WithReference(reference),
}
}