-
Notifications
You must be signed in to change notification settings - Fork 0
/
collectible_approval.go
132 lines (108 loc) · 4.09 KB
/
collectible_approval.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// Code generated by "enumer --values --type=CollectibleApprovalAction --transform=snake --trimprefix=ActionCollectibleApproval --output collectible_approval.go --json --sql"; DO NOT EDIT.
package metadata
import (
"database/sql/driver"
"encoding/json"
"fmt"
"strings"
)
const _CollectibleApprovalActionName = "approverevoke"
var _CollectibleApprovalActionIndex = [...]uint8{0, 7, 13}
const _CollectibleApprovalActionLowerName = "approverevoke"
func (i CollectibleApprovalAction) String() string {
i -= 1
if i >= CollectibleApprovalAction(len(_CollectibleApprovalActionIndex)-1) {
return fmt.Sprintf("CollectibleApprovalAction(%d)", i+1)
}
return _CollectibleApprovalActionName[_CollectibleApprovalActionIndex[i]:_CollectibleApprovalActionIndex[i+1]]
}
func (CollectibleApprovalAction) Values() []string {
return CollectibleApprovalActionStrings()
}
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _CollectibleApprovalActionNoOp() {
var x [1]struct{}
_ = x[ActionCollectibleApprovalApprove-(1)]
_ = x[ActionCollectibleApprovalRevoke-(2)]
}
var _CollectibleApprovalActionValues = []CollectibleApprovalAction{ActionCollectibleApprovalApprove, ActionCollectibleApprovalRevoke}
var _CollectibleApprovalActionNameToValueMap = map[string]CollectibleApprovalAction{
_CollectibleApprovalActionName[0:7]: ActionCollectibleApprovalApprove,
_CollectibleApprovalActionLowerName[0:7]: ActionCollectibleApprovalApprove,
_CollectibleApprovalActionName[7:13]: ActionCollectibleApprovalRevoke,
_CollectibleApprovalActionLowerName[7:13]: ActionCollectibleApprovalRevoke,
}
var _CollectibleApprovalActionNames = []string{
_CollectibleApprovalActionName[0:7],
_CollectibleApprovalActionName[7:13],
}
// CollectibleApprovalActionString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func CollectibleApprovalActionString(s string) (CollectibleApprovalAction, error) {
if val, ok := _CollectibleApprovalActionNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _CollectibleApprovalActionNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to CollectibleApprovalAction values", s)
}
// CollectibleApprovalActionValues returns all values of the enum
func CollectibleApprovalActionValues() []CollectibleApprovalAction {
return _CollectibleApprovalActionValues
}
// CollectibleApprovalActionStrings returns a slice of all String values of the enum
func CollectibleApprovalActionStrings() []string {
strs := make([]string, len(_CollectibleApprovalActionNames))
copy(strs, _CollectibleApprovalActionNames)
return strs
}
// IsACollectibleApprovalAction returns "true" if the value is listed in the enum definition. "false" otherwise
func (i CollectibleApprovalAction) IsACollectibleApprovalAction() bool {
for _, v := range _CollectibleApprovalActionValues {
if i == v {
return true
}
}
return false
}
// MarshalJSON implements the json.Marshaler interface for CollectibleApprovalAction
func (i CollectibleApprovalAction) MarshalJSON() ([]byte, error) {
return json.Marshal(i.String())
}
// UnmarshalJSON implements the json.Unmarshaler interface for CollectibleApprovalAction
func (i *CollectibleApprovalAction) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return fmt.Errorf("CollectibleApprovalAction should be a string, got %s", data)
}
var err error
*i, err = CollectibleApprovalActionString(s)
return err
}
func (i CollectibleApprovalAction) Value() (driver.Value, error) {
return i.String(), nil
}
func (i *CollectibleApprovalAction) Scan(value interface{}) error {
if value == nil {
return nil
}
var str string
switch v := value.(type) {
case []byte:
str = string(v)
case string:
str = v
case fmt.Stringer:
str = v.String()
default:
return fmt.Errorf("invalid value of CollectibleApprovalAction: %[1]T(%[1]v)", value)
}
val, err := CollectibleApprovalActionString(str)
if err != nil {
return err
}
*i = val
return nil
}