86 lines
2.4 KiB
Go
86 lines
2.4 KiB
Go
// Code generated by "enumer -type BatteryMode"; DO NOT EDIT.
|
|
|
|
package api
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
const _BatteryModeName = "BatteryUnknownBatteryNormalBatteryLockedBatteryCharge"
|
|
|
|
var _BatteryModeIndex = [...]uint8{0, 14, 27, 40, 53}
|
|
|
|
const _BatteryModeLowerName = "batteryunknownbatterynormalbatterylockedbatterycharge"
|
|
|
|
func (i BatteryMode) String() string {
|
|
if i < 0 || i >= BatteryMode(len(_BatteryModeIndex)-1) {
|
|
return fmt.Sprintf("BatteryMode(%d)", i)
|
|
}
|
|
return _BatteryModeName[_BatteryModeIndex[i]:_BatteryModeIndex[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 _BatteryModeNoOp() {
|
|
var x [1]struct{}
|
|
_ = x[BatteryUnknown-(0)]
|
|
_ = x[BatteryNormal-(1)]
|
|
_ = x[BatteryLocked-(2)]
|
|
_ = x[BatteryCharge-(3)]
|
|
}
|
|
|
|
var _BatteryModeValues = []BatteryMode{BatteryUnknown, BatteryNormal, BatteryLocked, BatteryCharge}
|
|
|
|
var _BatteryModeNameToValueMap = map[string]BatteryMode{
|
|
_BatteryModeName[0:14]: BatteryUnknown,
|
|
_BatteryModeLowerName[0:14]: BatteryUnknown,
|
|
_BatteryModeName[14:27]: BatteryNormal,
|
|
_BatteryModeLowerName[14:27]: BatteryNormal,
|
|
_BatteryModeName[27:40]: BatteryLocked,
|
|
_BatteryModeLowerName[27:40]: BatteryLocked,
|
|
_BatteryModeName[40:53]: BatteryCharge,
|
|
_BatteryModeLowerName[40:53]: BatteryCharge,
|
|
}
|
|
|
|
var _BatteryModeNames = []string{
|
|
_BatteryModeName[0:14],
|
|
_BatteryModeName[14:27],
|
|
_BatteryModeName[27:40],
|
|
_BatteryModeName[40:53],
|
|
}
|
|
|
|
// BatteryModeString retrieves an enum value from the enum constants string name.
|
|
// Throws an error if the param is not part of the enum.
|
|
func BatteryModeString(s string) (BatteryMode, error) {
|
|
if val, ok := _BatteryModeNameToValueMap[s]; ok {
|
|
return val, nil
|
|
}
|
|
|
|
if val, ok := _BatteryModeNameToValueMap[strings.ToLower(s)]; ok {
|
|
return val, nil
|
|
}
|
|
return 0, fmt.Errorf("%s does not belong to BatteryMode values", s)
|
|
}
|
|
|
|
// BatteryModeValues returns all values of the enum
|
|
func BatteryModeValues() []BatteryMode {
|
|
return _BatteryModeValues
|
|
}
|
|
|
|
// BatteryModeStrings returns a slice of all String values of the enum
|
|
func BatteryModeStrings() []string {
|
|
strs := make([]string, len(_BatteryModeNames))
|
|
copy(strs, _BatteryModeNames)
|
|
return strs
|
|
}
|
|
|
|
// IsABatteryMode returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
func (i BatteryMode) IsABatteryMode() bool {
|
|
for _, v := range _BatteryModeValues {
|
|
if i == v {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|