forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tarifftype_enumer.go
87 lines (72 loc) · 2.53 KB
/
tarifftype_enumer.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Code generated by "enumer -type TariffType -trimprefix TariffType -transform=lower"; DO NOT EDIT.
package api
import (
"fmt"
"strings"
)
const _TariffTypeName = "pricestaticpricedynamicpriceforecastco2"
var _TariffTypeIndex = [...]uint8{0, 11, 23, 36, 39}
const _TariffTypeLowerName = "pricestaticpricedynamicpriceforecastco2"
func (i TariffType) String() string {
i -= 1
if i < 0 || i >= TariffType(len(_TariffTypeIndex)-1) {
return fmt.Sprintf("TariffType(%d)", i+1)
}
return _TariffTypeName[_TariffTypeIndex[i]:_TariffTypeIndex[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 _TariffTypeNoOp() {
var x [1]struct{}
_ = x[TariffTypePriceStatic-(1)]
_ = x[TariffTypePriceDynamic-(2)]
_ = x[TariffTypePriceForecast-(3)]
_ = x[TariffTypeCo2-(4)]
}
var _TariffTypeValues = []TariffType{TariffTypePriceStatic, TariffTypePriceDynamic, TariffTypePriceForecast, TariffTypeCo2}
var _TariffTypeNameToValueMap = map[string]TariffType{
_TariffTypeName[0:11]: TariffTypePriceStatic,
_TariffTypeLowerName[0:11]: TariffTypePriceStatic,
_TariffTypeName[11:23]: TariffTypePriceDynamic,
_TariffTypeLowerName[11:23]: TariffTypePriceDynamic,
_TariffTypeName[23:36]: TariffTypePriceForecast,
_TariffTypeLowerName[23:36]: TariffTypePriceForecast,
_TariffTypeName[36:39]: TariffTypeCo2,
_TariffTypeLowerName[36:39]: TariffTypeCo2,
}
var _TariffTypeNames = []string{
_TariffTypeName[0:11],
_TariffTypeName[11:23],
_TariffTypeName[23:36],
_TariffTypeName[36:39],
}
// TariffTypeString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func TariffTypeString(s string) (TariffType, error) {
if val, ok := _TariffTypeNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _TariffTypeNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to TariffType values", s)
}
// TariffTypeValues returns all values of the enum
func TariffTypeValues() []TariffType {
return _TariffTypeValues
}
// TariffTypeStrings returns a slice of all String values of the enum
func TariffTypeStrings() []string {
strs := make([]string, len(_TariffTypeNames))
copy(strs, _TariffTypeNames)
return strs
}
// IsATariffType returns "true" if the value is listed in the enum definition. "false" otherwise
func (i TariffType) IsATariffType() bool {
for _, v := range _TariffTypeValues {
if i == v {
return true
}
}
return false
}