evcc-io/api/feature_enumer.go
2025-08-19 19:48:50 +02:00

111 lines
3 KiB
Go

// Code generated by "enumer -type Feature -text"; DO NOT EDIT.
package api
import (
"fmt"
"strings"
)
const _FeatureName = "CoarseCurrentIntegratedDeviceHeatingCacheableOfflineRetryableWelcomeCharge"
var _FeatureIndex = [...]uint8{0, 13, 29, 36, 45, 52, 61, 74}
const _FeatureLowerName = "coarsecurrentintegrateddeviceheatingcacheableofflineretryablewelcomecharge"
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[Heating-(3)]
_ = x[Cacheable-(4)]
_ = x[Offline-(5)]
_ = x[Retryable-(6)]
_ = x[WelcomeCharge-(7)]
}
var _FeatureValues = []Feature{CoarseCurrent, IntegratedDevice, Heating, Cacheable, Offline, Retryable, WelcomeCharge}
var _FeatureNameToValueMap = map[string]Feature{
_FeatureName[0:13]: CoarseCurrent,
_FeatureLowerName[0:13]: CoarseCurrent,
_FeatureName[13:29]: IntegratedDevice,
_FeatureLowerName[13:29]: IntegratedDevice,
_FeatureName[29:36]: Heating,
_FeatureLowerName[29:36]: Heating,
_FeatureName[36:45]: Cacheable,
_FeatureLowerName[36:45]: Cacheable,
_FeatureName[45:52]: Offline,
_FeatureLowerName[45:52]: Offline,
_FeatureName[52:61]: Retryable,
_FeatureLowerName[52:61]: Retryable,
_FeatureName[61:74]: WelcomeCharge,
_FeatureLowerName[61:74]: WelcomeCharge,
}
var _FeatureNames = []string{
_FeatureName[0:13],
_FeatureName[13:29],
_FeatureName[29:36],
_FeatureName[36:45],
_FeatureName[45:52],
_FeatureName[52:61],
_FeatureName[61:74],
}
// 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
}