56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
package charger
|
|
|
|
// Code generated by github.com/evcc-io/evcc/cmd/tools/decorate.go. DO NOT EDIT.
|
|
|
|
import (
|
|
"reflect"
|
|
|
|
"github.com/evcc-io/evcc/api"
|
|
)
|
|
|
|
func decoratePeblar(base *Peblar, phaseSwitcher func(int) error, phaseGetter func() (int, error)) api.Charger {
|
|
caps := make(map[reflect.Type]any)
|
|
|
|
if phaseSwitcher != nil {
|
|
caps[reflect.TypeFor[api.PhaseSwitcher]()] = &decoratePeblarPhaseSwitcherImpl{phaseSwitcher: phaseSwitcher}
|
|
}
|
|
|
|
if phaseGetter != nil {
|
|
caps[reflect.TypeFor[api.PhaseGetter]()] = &decoratePeblarPhaseGetterImpl{phaseGetter: phaseGetter}
|
|
}
|
|
|
|
if len(caps) == 0 {
|
|
return base
|
|
}
|
|
|
|
return &decoratePeblarCapable{Peblar: base, caps: caps}
|
|
}
|
|
|
|
type decoratePeblarCapable struct {
|
|
*Peblar
|
|
caps map[reflect.Type]any
|
|
}
|
|
|
|
func (d *decoratePeblarCapable) Capability(typ reflect.Type) (any, bool) {
|
|
c, ok := d.caps[typ]
|
|
if !ok && reflect.TypeOf(d).Implements(typ) {
|
|
return d, true
|
|
}
|
|
return c, ok
|
|
}
|
|
|
|
type decoratePeblarPhaseGetterImpl struct {
|
|
phaseGetter func() (int, error)
|
|
}
|
|
|
|
func (impl *decoratePeblarPhaseGetterImpl) GetPhases() (int, error) {
|
|
return impl.phaseGetter()
|
|
}
|
|
|
|
type decoratePeblarPhaseSwitcherImpl struct {
|
|
phaseSwitcher func(int) error
|
|
}
|
|
|
|
func (impl *decoratePeblarPhaseSwitcherImpl) Phases1p3p(p0 int) error {
|
|
return impl.phaseSwitcher(p0)
|
|
}
|