-
Notifications
You must be signed in to change notification settings - Fork 3
/
platform_string.go
236 lines (209 loc) · 7.28 KB
/
platform_string.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
// Code generated by "enumer --values --type=Platform --linecomment --output platform_string.go --json --yaml --sql"; DO NOT EDIT.
package worker
import (
"database/sql/driver"
"encoding/json"
"fmt"
"strings"
)
const _PlatformName = "Unknown1inchAAVEAavegotchiCrossbellCurveENSFarcasterHighlightIQWikiKiwiStandLensLidoLooksRareMattersMirrorOpenSeaOptimismParagraphRSS3SAVMStargateUniswapVSL"
var _PlatformIndex = [...]uint8{0, 7, 12, 16, 26, 35, 40, 43, 52, 61, 67, 76, 80, 84, 93, 100, 106, 113, 121, 130, 134, 138, 146, 153, 156}
const _PlatformLowerName = "unknown1inchaaveaavegotchicrossbellcurveensfarcasterhighlightiqwikikiwistandlenslidolooksraremattersmirroropenseaoptimismparagraphrss3savmstargateuniswapvsl"
func (i Platform) String() string {
if i >= Platform(len(_PlatformIndex)-1) {
return fmt.Sprintf("Platform(%d)", i)
}
return _PlatformName[_PlatformIndex[i]:_PlatformIndex[i+1]]
}
func (Platform) Values() []string {
return PlatformStrings()
}
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _PlatformNoOp() {
var x [1]struct{}
_ = x[PlatformUnknown-(0)]
_ = x[Platform1Inch-(1)]
_ = x[PlatformAAVE-(2)]
_ = x[PlatformAavegotchi-(3)]
_ = x[PlatformCrossbell-(4)]
_ = x[PlatformCurve-(5)]
_ = x[PlatformENS-(6)]
_ = x[PlatformFarcaster-(7)]
_ = x[PlatformHighlight-(8)]
_ = x[PlatformIQWiki-(9)]
_ = x[PlatformKiwiStand-(10)]
_ = x[PlatformLens-(11)]
_ = x[PlatformLido-(12)]
_ = x[PlatformLooksRare-(13)]
_ = x[PlatformMatters-(14)]
_ = x[PlatformMirror-(15)]
_ = x[PlatformOpenSea-(16)]
_ = x[PlatformOptimism-(17)]
_ = x[PlatformParagraph-(18)]
_ = x[PlatformRSS3-(19)]
_ = x[PlatformSAVM-(20)]
_ = x[PlatformStargate-(21)]
_ = x[PlatformUniswap-(22)]
_ = x[PlatformVSL-(23)]
}
var _PlatformValues = []Platform{PlatformUnknown, Platform1Inch, PlatformAAVE, PlatformAavegotchi, PlatformCrossbell, PlatformCurve, PlatformENS, PlatformFarcaster, PlatformHighlight, PlatformIQWiki, PlatformKiwiStand, PlatformLens, PlatformLido, PlatformLooksRare, PlatformMatters, PlatformMirror, PlatformOpenSea, PlatformOptimism, PlatformParagraph, PlatformRSS3, PlatformSAVM, PlatformStargate, PlatformUniswap, PlatformVSL}
var _PlatformNameToValueMap = map[string]Platform{
_PlatformName[0:7]: PlatformUnknown,
_PlatformLowerName[0:7]: PlatformUnknown,
_PlatformName[7:12]: Platform1Inch,
_PlatformLowerName[7:12]: Platform1Inch,
_PlatformName[12:16]: PlatformAAVE,
_PlatformLowerName[12:16]: PlatformAAVE,
_PlatformName[16:26]: PlatformAavegotchi,
_PlatformLowerName[16:26]: PlatformAavegotchi,
_PlatformName[26:35]: PlatformCrossbell,
_PlatformLowerName[26:35]: PlatformCrossbell,
_PlatformName[35:40]: PlatformCurve,
_PlatformLowerName[35:40]: PlatformCurve,
_PlatformName[40:43]: PlatformENS,
_PlatformLowerName[40:43]: PlatformENS,
_PlatformName[43:52]: PlatformFarcaster,
_PlatformLowerName[43:52]: PlatformFarcaster,
_PlatformName[52:61]: PlatformHighlight,
_PlatformLowerName[52:61]: PlatformHighlight,
_PlatformName[61:67]: PlatformIQWiki,
_PlatformLowerName[61:67]: PlatformIQWiki,
_PlatformName[67:76]: PlatformKiwiStand,
_PlatformLowerName[67:76]: PlatformKiwiStand,
_PlatformName[76:80]: PlatformLens,
_PlatformLowerName[76:80]: PlatformLens,
_PlatformName[80:84]: PlatformLido,
_PlatformLowerName[80:84]: PlatformLido,
_PlatformName[84:93]: PlatformLooksRare,
_PlatformLowerName[84:93]: PlatformLooksRare,
_PlatformName[93:100]: PlatformMatters,
_PlatformLowerName[93:100]: PlatformMatters,
_PlatformName[100:106]: PlatformMirror,
_PlatformLowerName[100:106]: PlatformMirror,
_PlatformName[106:113]: PlatformOpenSea,
_PlatformLowerName[106:113]: PlatformOpenSea,
_PlatformName[113:121]: PlatformOptimism,
_PlatformLowerName[113:121]: PlatformOptimism,
_PlatformName[121:130]: PlatformParagraph,
_PlatformLowerName[121:130]: PlatformParagraph,
_PlatformName[130:134]: PlatformRSS3,
_PlatformLowerName[130:134]: PlatformRSS3,
_PlatformName[134:138]: PlatformSAVM,
_PlatformLowerName[134:138]: PlatformSAVM,
_PlatformName[138:146]: PlatformStargate,
_PlatformLowerName[138:146]: PlatformStargate,
_PlatformName[146:153]: PlatformUniswap,
_PlatformLowerName[146:153]: PlatformUniswap,
_PlatformName[153:156]: PlatformVSL,
_PlatformLowerName[153:156]: PlatformVSL,
}
var _PlatformNames = []string{
_PlatformName[0:7],
_PlatformName[7:12],
_PlatformName[12:16],
_PlatformName[16:26],
_PlatformName[26:35],
_PlatformName[35:40],
_PlatformName[40:43],
_PlatformName[43:52],
_PlatformName[52:61],
_PlatformName[61:67],
_PlatformName[67:76],
_PlatformName[76:80],
_PlatformName[80:84],
_PlatformName[84:93],
_PlatformName[93:100],
_PlatformName[100:106],
_PlatformName[106:113],
_PlatformName[113:121],
_PlatformName[121:130],
_PlatformName[130:134],
_PlatformName[134:138],
_PlatformName[138:146],
_PlatformName[146:153],
_PlatformName[153:156],
}
// PlatformString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func PlatformString(s string) (Platform, error) {
if val, ok := _PlatformNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _PlatformNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Platform values", s)
}
// PlatformValues returns all values of the enum
func PlatformValues() []Platform {
return _PlatformValues
}
// PlatformStrings returns a slice of all String values of the enum
func PlatformStrings() []string {
strs := make([]string, len(_PlatformNames))
copy(strs, _PlatformNames)
return strs
}
// IsAPlatform returns "true" if the value is listed in the enum definition. "false" otherwise
func (i Platform) IsAPlatform() bool {
for _, v := range _PlatformValues {
if i == v {
return true
}
}
return false
}
// MarshalJSON implements the json.Marshaler interface for Platform
func (i Platform) MarshalJSON() ([]byte, error) {
return json.Marshal(i.String())
}
// UnmarshalJSON implements the json.Unmarshaler interface for Platform
func (i *Platform) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return fmt.Errorf("Platform should be a string, got %s", data)
}
var err error
*i, err = PlatformString(s)
return err
}
// MarshalYAML implements a YAML Marshaler for Platform
func (i Platform) MarshalYAML() (interface{}, error) {
return i.String(), nil
}
// UnmarshalYAML implements a YAML Unmarshaler for Platform
func (i *Platform) UnmarshalYAML(unmarshal func(interface{}) error) error {
var s string
if err := unmarshal(&s); err != nil {
return err
}
var err error
*i, err = PlatformString(s)
return err
}
func (i Platform) Value() (driver.Value, error) {
return i.String(), nil
}
func (i *Platform) 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 Platform: %[1]T(%[1]v)", value)
}
val, err := PlatformString(str)
if err != nil {
return err
}
*i = val
return nil
}