forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
amperfied_decorators.go
58 lines (48 loc) · 1.24 KB
/
amperfied_decorators.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
52
53
54
55
56
57
58
package charger
// Code generated by github.com/evcc-io/evcc/cmd/tools/decorate.go. DO NOT EDIT.
import (
"github.com/evcc-io/evcc/api"
)
func decorateAmperfied(base *Amperfied, phaseSwitcher func(int) error, phaseGetter func() (int, error)) api.Charger {
switch {
case phaseSwitcher == nil:
return base
case phaseGetter == nil && phaseSwitcher != nil:
return &struct {
*Amperfied
api.PhaseSwitcher
}{
Amperfied: base,
PhaseSwitcher: &decorateAmperfiedPhaseSwitcherImpl{
phaseSwitcher: phaseSwitcher,
},
}
case phaseGetter != nil && phaseSwitcher != nil:
return &struct {
*Amperfied
api.PhaseGetter
api.PhaseSwitcher
}{
Amperfied: base,
PhaseGetter: &decorateAmperfiedPhaseGetterImpl{
phaseGetter: phaseGetter,
},
PhaseSwitcher: &decorateAmperfiedPhaseSwitcherImpl{
phaseSwitcher: phaseSwitcher,
},
}
}
return nil
}
type decorateAmperfiedPhaseGetterImpl struct {
phaseGetter func() (int, error)
}
func (impl *decorateAmperfiedPhaseGetterImpl) GetPhases() (int, error) {
return impl.phaseGetter()
}
type decorateAmperfiedPhaseSwitcherImpl struct {
phaseSwitcher func(int) error
}
func (impl *decorateAmperfiedPhaseSwitcherImpl) Phases1p3p(p0 int) error {
return impl.phaseSwitcher(p0)
}