evcc-io/api/feature_enumer.go
2026-06-17 21:45:09 +02:00

135 lines
4.1 KiB
Go

// Code generated by "enumer -type Feature -text"; DO NOT EDIT.
package api
import (
"fmt"
"strings"
)
const _FeatureName = "CoarseCurrentIntegratedDeviceSwitchDeviceHeatingContinuousAverageCacheableOfflineRetryableStreamingWelcomeChargeClimaterDisabledAutodetectDisabled"
var _FeatureIndex = [...]uint8{0, 13, 29, 41, 48, 58, 65, 74, 81, 90, 99, 112, 128, 146}
const _FeatureLowerName = "coarsecurrentintegrateddeviceswitchdeviceheatingcontinuousaveragecacheableofflineretryablestreamingwelcomechargeclimaterdisabledautodetectdisabled"
func (i Feature) String() string {
i -= 1
if i < 0 || i >= Feature(len(_FeatureIndex)-1) {
return fmt.Sprintf("Feature(%d)", i+1)
}
return _FeatureName[_FeatureIndex[i]:_FeatureIndex[i+1]]
}
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _FeatureNoOp() {
var x [1]struct{}
_ = x[CoarseCurrent-(1)]
_ = x[IntegratedDevice-(2)]
_ = x[SwitchDevice-(3)]
_ = x[Heating-(4)]
_ = x[Continuous-(5)]
_ = x[Average-(6)]
_ = x[Cacheable-(7)]
_ = x[Offline-(8)]
_ = x[Retryable-(9)]
_ = x[Streaming-(10)]
_ = x[WelcomeCharge-(11)]
_ = x[ClimaterDisabled-(12)]
_ = x[AutodetectDisabled-(13)]
}
var _FeatureValues = []Feature{CoarseCurrent, IntegratedDevice, SwitchDevice, Heating, Continuous, Average, Cacheable, Offline, Retryable, Streaming, WelcomeCharge, ClimaterDisabled, AutodetectDisabled}
var _FeatureNameToValueMap = map[string]Feature{
_FeatureName[0:13]: CoarseCurrent,
_FeatureLowerName[0:13]: CoarseCurrent,
_FeatureName[13:29]: IntegratedDevice,
_FeatureLowerName[13:29]: IntegratedDevice,
_FeatureName[29:41]: SwitchDevice,
_FeatureLowerName[29:41]: SwitchDevice,
_FeatureName[41:48]: Heating,
_FeatureLowerName[41:48]: Heating,
_FeatureName[48:58]: Continuous,
_FeatureLowerName[48:58]: Continuous,
_FeatureName[58:65]: Average,
_FeatureLowerName[58:65]: Average,
_FeatureName[65:74]: Cacheable,
_FeatureLowerName[65:74]: Cacheable,
_FeatureName[74:81]: Offline,
_FeatureLowerName[74:81]: Offline,
_FeatureName[81:90]: Retryable,
_FeatureLowerName[81:90]: Retryable,
_FeatureName[90:99]: Streaming,
_FeatureLowerName[90:99]: Streaming,
_FeatureName[99:112]: WelcomeCharge,
_FeatureLowerName[99:112]: WelcomeCharge,
_FeatureName[112:128]: ClimaterDisabled,
_FeatureLowerName[112:128]: ClimaterDisabled,
_FeatureName[128:146]: AutodetectDisabled,
_FeatureLowerName[128:146]: AutodetectDisabled,
}
var _FeatureNames = []string{
_FeatureName[0:13],
_FeatureName[13:29],
_FeatureName[29:41],
_FeatureName[41:48],
_FeatureName[48:58],
_FeatureName[58:65],
_FeatureName[65:74],
_FeatureName[74:81],
_FeatureName[81:90],
_FeatureName[90:99],
_FeatureName[99:112],
_FeatureName[112:128],
_FeatureName[128:146],
}
// FeatureString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func FeatureString(s string) (Feature, error) {
if val, ok := _FeatureNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _FeatureNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Feature values", s)
}
// FeatureValues returns all values of the enum
func FeatureValues() []Feature {
return _FeatureValues
}
// FeatureStrings returns a slice of all String values of the enum
func FeatureStrings() []string {
strs := make([]string, len(_FeatureNames))
copy(strs, _FeatureNames)
return strs
}
// IsAFeature returns "true" if the value is listed in the enum definition. "false" otherwise
func (i Feature) IsAFeature() bool {
for _, v := range _FeatureValues {
if i == v {
return true
}
}
return false
}
// MarshalText implements the encoding.TextMarshaler interface for Feature
func (i Feature) MarshalText() ([]byte, error) {
return []byte(i.String()), nil
}
// UnmarshalText implements the encoding.TextUnmarshaler interface for Feature
func (i *Feature) UnmarshalText(text []byte) error {
var err error
*i, err = FeatureString(string(text))
return err
}