forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reason_enumer.go
82 lines (67 loc) · 2.2 KB
/
reason_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
// Code generated by "enumer -type Reason -trimprefix Reason -transform=lower"; DO NOT EDIT.
package api
import (
"fmt"
"strings"
)
const _ReasonName = "unknownwaitingforauthorizationdisconnectrequired"
var _ReasonIndex = [...]uint8{0, 7, 30, 48}
const _ReasonLowerName = "unknownwaitingforauthorizationdisconnectrequired"
func (i Reason) String() string {
if i < 0 || i >= Reason(len(_ReasonIndex)-1) {
return fmt.Sprintf("Reason(%d)", i)
}
return _ReasonName[_ReasonIndex[i]:_ReasonIndex[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 _ReasonNoOp() {
var x [1]struct{}
_ = x[ReasonUnknown-(0)]
_ = x[ReasonWaitingForAuthorization-(1)]
_ = x[ReasonDisconnectRequired-(2)]
}
var _ReasonValues = []Reason{ReasonUnknown, ReasonWaitingForAuthorization, ReasonDisconnectRequired}
var _ReasonNameToValueMap = map[string]Reason{
_ReasonName[0:7]: ReasonUnknown,
_ReasonLowerName[0:7]: ReasonUnknown,
_ReasonName[7:30]: ReasonWaitingForAuthorization,
_ReasonLowerName[7:30]: ReasonWaitingForAuthorization,
_ReasonName[30:48]: ReasonDisconnectRequired,
_ReasonLowerName[30:48]: ReasonDisconnectRequired,
}
var _ReasonNames = []string{
_ReasonName[0:7],
_ReasonName[7:30],
_ReasonName[30:48],
}
// ReasonString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func ReasonString(s string) (Reason, error) {
if val, ok := _ReasonNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _ReasonNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Reason values", s)
}
// ReasonValues returns all values of the enum
func ReasonValues() []Reason {
return _ReasonValues
}
// ReasonStrings returns a slice of all String values of the enum
func ReasonStrings() []string {
strs := make([]string, len(_ReasonNames))
copy(strs, _ReasonNames)
return strs
}
// IsAReason returns "true" if the value is listed in the enum definition. "false" otherwise
func (i Reason) IsAReason() bool {
for _, v := range _ReasonValues {
if i == v {
return true
}
}
return false
}