| 1 |
// Code generated by "enumer -linecomment -sql -json -text -yaml -gqlgen -type=ApplicationType,AccessTokenType"; DO NOT EDIT. |
| 2 |
|
| 3 |
package op |
| 4 |
|
| 5 |
import ( |
| 6 |
"database/sql/driver" |
| 7 |
"encoding/json" |
| 8 |
"fmt" |
| 9 |
"io" |
| 10 |
"strconv" |
| 11 |
"strings" |
| 12 |
) |
| 13 |
|
| 14 |
const _ApplicationTypeName = "webuser_agentnative" |
| 15 |
|
| 16 |
var _ApplicationTypeIndex = [...]uint8{0, 3, 13, 19} |
| 17 |
|
| 18 |
const _ApplicationTypeLowerName = "webuser_agentnative" |
| 19 |
|
| 20 |
func (i ApplicationType) String() string { |
| 21 |
if i < 0 || i >= ApplicationType(len(_ApplicationTypeIndex)-1) { |
| 22 |
return fmt.Sprintf("ApplicationType(%d)", i) |
| 23 |
} |
| 24 |
return _ApplicationTypeName[_ApplicationTypeIndex[i]:_ApplicationTypeIndex[i+1]] |
| 25 |
} |
| 26 |
|
| 27 |
// An "invalid array index" compiler error signifies that the constant values have changed. |
| 28 |
// Re-run the stringer command to generate them again. |
| 29 |
func _ApplicationTypeNoOp() { |
| 30 |
var x [1]struct{} |
| 31 |
_ = x[ApplicationTypeWeb-(0)] |
| 32 |
_ = x[ApplicationTypeUserAgent-(1)] |
| 33 |
_ = x[ApplicationTypeNative-(2)] |
| 34 |
} |
| 35 |
|
| 36 |
var _ApplicationTypeValues = []ApplicationType{ApplicationTypeWeb, ApplicationTypeUserAgent, ApplicationTypeNative} |
| 37 |
|
| 38 |
var _ApplicationTypeNameToValueMap = map[string]ApplicationType{ |
| 39 |
_ApplicationTypeName[0:3]: ApplicationTypeWeb, |
| 40 |
_ApplicationTypeLowerName[0:3]: ApplicationTypeWeb, |
| 41 |
_ApplicationTypeName[3:13]: ApplicationTypeUserAgent, |
| 42 |
_ApplicationTypeLowerName[3:13]: ApplicationTypeUserAgent, |
| 43 |
_ApplicationTypeName[13:19]: ApplicationTypeNative, |
| 44 |
_ApplicationTypeLowerName[13:19]: ApplicationTypeNative, |
| 45 |
} |
| 46 |
|
| 47 |
var _ApplicationTypeNames = []string{ |
| 48 |
_ApplicationTypeName[0:3], |
| 49 |
_ApplicationTypeName[3:13], |
| 50 |
_ApplicationTypeName[13:19], |
| 51 |
} |
| 52 |
|
| 53 |
// ApplicationTypeString retrieves an enum value from the enum constants string name. |
| 54 |
// Throws an error if the param is not part of the enum. |
| 55 |
func ApplicationTypeString(s string) (ApplicationType, error) { |
| 56 |
if val, ok := _ApplicationTypeNameToValueMap[s]; ok { |
| 57 |
return val, nil |
| 58 |
} |
| 59 |
|
| 60 |
if val, ok := _ApplicationTypeNameToValueMap[strings.ToLower(s)]; ok { |
| 61 |
return val, nil |
| 62 |
} |
| 63 |
return 0, fmt.Errorf("%s does not belong to ApplicationType values", s) |
| 64 |
} |
| 65 |
|
| 66 |
// ApplicationTypeValues returns all values of the enum |
| 67 |
func ApplicationTypeValues() []ApplicationType { |
| 68 |
return _ApplicationTypeValues |
| 69 |
} |
| 70 |
|
| 71 |
// ApplicationTypeStrings returns a slice of all String values of the enum |
| 72 |
func ApplicationTypeStrings() []string { |
| 73 |
strs := make([]string, len(_ApplicationTypeNames)) |
| 74 |
copy(strs, _ApplicationTypeNames) |
| 75 |
return strs |
| 76 |
} |
| 77 |
|
| 78 |
// IsAApplicationType returns "true" if the value is listed in the enum definition. "false" otherwise |
| 79 |
func (i ApplicationType) IsAApplicationType() bool { |
| 80 |
for _, v := range _ApplicationTypeValues { |
| 81 |
if i == v { |
| 82 |
return true |
| 83 |
} |
| 84 |
} |
| 85 |
return false |
| 86 |
} |
| 87 |
|
| 88 |
// MarshalJSON implements the json.Marshaler interface for ApplicationType |
| 89 |
func (i ApplicationType) MarshalJSON() ([]byte, error) { |
| 90 |
return json.Marshal(i.String()) |
| 91 |
} |
| 92 |
|
| 93 |
// UnmarshalJSON implements the json.Unmarshaler interface for ApplicationType |
| 94 |
func (i *ApplicationType) UnmarshalJSON(data []byte) error { |
| 95 |
var s string |
| 96 |
if err := json.Unmarshal(data, &s); err != nil { |
| 97 |
return fmt.Errorf("ApplicationType should be a string, got %s", data) |
| 98 |
} |
| 99 |
|
| 100 |
var err error |
| 101 |
*i, err = ApplicationTypeString(s) |
| 102 |
return err |
| 103 |
} |
| 104 |
|
| 105 |
// MarshalText implements the encoding.TextMarshaler interface for ApplicationType |
| 106 |
func (i ApplicationType) MarshalText() ([]byte, error) { |
| 107 |
return []byte(i.String()), nil |
| 108 |
} |
| 109 |
|
| 110 |
// UnmarshalText implements the encoding.TextUnmarshaler interface for ApplicationType |
| 111 |
func (i *ApplicationType) UnmarshalText(text []byte) error { |
| 112 |
var err error |
| 113 |
*i, err = ApplicationTypeString(string(text)) |
| 114 |
return err |
| 115 |
} |
| 116 |
|
| 117 |
// MarshalYAML implements a YAML Marshaler for ApplicationType |
| 118 |
func (i ApplicationType) MarshalYAML() (interface{}, error) { |
| 119 |
return i.String(), nil |
| 120 |
} |
| 121 |
|
| 122 |
// UnmarshalYAML implements a YAML Unmarshaler for ApplicationType |
| 123 |
func (i *ApplicationType) UnmarshalYAML(unmarshal func(interface{}) error) error { |
| 124 |
var s string |
| 125 |
if err := unmarshal(&s); err != nil { |
| 126 |
return err |
| 127 |
} |
| 128 |
|
| 129 |
var err error |
| 130 |
*i, err = ApplicationTypeString(s) |
| 131 |
return err |
| 132 |
} |
| 133 |
|
| 134 |
func (i ApplicationType) Value() (driver.Value, error) { |
| 135 |
return i.String(), nil |
| 136 |
} |
| 137 |
|
| 138 |
func (i *ApplicationType) Scan(value interface{}) error { |
| 139 |
if value == nil { |
| 140 |
return nil |
| 141 |
} |
| 142 |
|
| 143 |
var str string |
| 144 |
switch v := value.(type) { |
| 145 |
case []byte: |
| 146 |
str = string(v) |
| 147 |
case string: |
| 148 |
str = v |
| 149 |
case fmt.Stringer: |
| 150 |
str = v.String() |
| 151 |
default: |
| 152 |
return fmt.Errorf("invalid value of ApplicationType: %[1]T(%[1]v)", value) |
| 153 |
} |
| 154 |
|
| 155 |
val, err := ApplicationTypeString(str) |
| 156 |
if err != nil { |
| 157 |
return err |
| 158 |
} |
| 159 |
|
| 160 |
*i = val |
| 161 |
return nil |
| 162 |
} |
| 163 |
|
| 164 |
// MarshalGQL implements the graphql.Marshaler interface for ApplicationType |
| 165 |
func (i ApplicationType) MarshalGQL(w io.Writer) { |
| 166 |
fmt.Fprint(w, strconv.Quote(i.String())) |
| 167 |
} |
| 168 |
|
| 169 |
// UnmarshalGQL implements the graphql.Unmarshaler interface for ApplicationType |
| 170 |
func (i *ApplicationType) UnmarshalGQL(value interface{}) error { |
| 171 |
str, ok := value.(string) |
| 172 |
if !ok { |
| 173 |
return fmt.Errorf("ApplicationType should be a string, got %T", value) |
| 174 |
} |
| 175 |
|
| 176 |
var err error |
| 177 |
*i, err = ApplicationTypeString(str) |
| 178 |
return err |
| 179 |
} |
| 180 |
|
| 181 |
const _AccessTokenTypeName = "bearerJWT" |
| 182 |
|
| 183 |
var _AccessTokenTypeIndex = [...]uint8{0, 6, 9} |
| 184 |
|
| 185 |
const _AccessTokenTypeLowerName = "bearerjwt" |
| 186 |
|
| 187 |
func (i AccessTokenType) String() string { |
| 188 |
if i < 0 || i >= AccessTokenType(len(_AccessTokenTypeIndex)-1) { |
| 189 |
return fmt.Sprintf("AccessTokenType(%d)", i) |
| 190 |
} |
| 191 |
return _AccessTokenTypeName[_AccessTokenTypeIndex[i]:_AccessTokenTypeIndex[i+1]] |
| 192 |
} |
| 193 |
|
| 194 |
// An "invalid array index" compiler error signifies that the constant values have changed. |
| 195 |
// Re-run the stringer command to generate them again. |
| 196 |
func _AccessTokenTypeNoOp() { |
| 197 |
var x [1]struct{} |
| 198 |
_ = x[AccessTokenTypeBearer-(0)] |
| 199 |
_ = x[AccessTokenTypeJWT-(1)] |
| 200 |
} |
| 201 |
|
| 202 |
var _AccessTokenTypeValues = []AccessTokenType{AccessTokenTypeBearer, AccessTokenTypeJWT} |
| 203 |
|
| 204 |
var _AccessTokenTypeNameToValueMap = map[string]AccessTokenType{ |
| 205 |
_AccessTokenTypeName[0:6]: AccessTokenTypeBearer, |
| 206 |
_AccessTokenTypeLowerName[0:6]: AccessTokenTypeBearer, |
| 207 |
_AccessTokenTypeName[6:9]: AccessTokenTypeJWT, |
| 208 |
_AccessTokenTypeLowerName[6:9]: AccessTokenTypeJWT, |
| 209 |
} |
| 210 |
|
| 211 |
var _AccessTokenTypeNames = []string{ |
| 212 |
_AccessTokenTypeName[0:6], |
| 213 |
_AccessTokenTypeName[6:9], |
| 214 |
} |
| 215 |
|
| 216 |
// AccessTokenTypeString retrieves an enum value from the enum constants string name. |
| 217 |
// Throws an error if the param is not part of the enum. |
| 218 |
func AccessTokenTypeString(s string) (AccessTokenType, error) { |
| 219 |
if val, ok := _AccessTokenTypeNameToValueMap[s]; ok { |
| 220 |
return val, nil |
| 221 |
} |
| 222 |
|
| 223 |
if val, ok := _AccessTokenTypeNameToValueMap[strings.ToLower(s)]; ok { |
| 224 |
return val, nil |
| 225 |
} |
| 226 |
return 0, fmt.Errorf("%s does not belong to AccessTokenType values", s) |
| 227 |
} |
| 228 |
|
| 229 |
// AccessTokenTypeValues returns all values of the enum |
| 230 |
func AccessTokenTypeValues() []AccessTokenType { |
| 231 |
return _AccessTokenTypeValues |
| 232 |
} |
| 233 |
|
| 234 |
// AccessTokenTypeStrings returns a slice of all String values of the enum |
| 235 |
func AccessTokenTypeStrings() []string { |
| 236 |
strs := make([]string, len(_AccessTokenTypeNames)) |
| 237 |
copy(strs, _AccessTokenTypeNames) |
| 238 |
return strs |
| 239 |
} |
| 240 |
|
| 241 |
// IsAAccessTokenType returns "true" if the value is listed in the enum definition. "false" otherwise |
| 242 |
func (i AccessTokenType) IsAAccessTokenType() bool { |
| 243 |
for _, v := range _AccessTokenTypeValues { |
| 244 |
if i == v { |
| 245 |
return true |
| 246 |
} |
| 247 |
} |
| 248 |
return false |
| 249 |
} |
| 250 |
|
| 251 |
// MarshalJSON implements the json.Marshaler interface for AccessTokenType |
| 252 |
func (i AccessTokenType) MarshalJSON() ([]byte, error) { |
| 253 |
return json.Marshal(i.String()) |
| 254 |
} |
| 255 |
|
| 256 |
// UnmarshalJSON implements the json.Unmarshaler interface for AccessTokenType |
| 257 |
func (i *AccessTokenType) UnmarshalJSON(data []byte) error { |
| 258 |
var s string |
| 259 |
if err := json.Unmarshal(data, &s); err != nil { |
| 260 |
return fmt.Errorf("AccessTokenType should be a string, got %s", data) |
| 261 |
} |
| 262 |
|
| 263 |
var err error |
| 264 |
*i, err = AccessTokenTypeString(s) |
| 265 |
return err |
| 266 |
} |
| 267 |
|
| 268 |
// MarshalText implements the encoding.TextMarshaler interface for AccessTokenType |
| 269 |
func (i AccessTokenType) MarshalText() ([]byte, error) { |
| 270 |
return []byte(i.String()), nil |
| 271 |
} |
| 272 |
|
| 273 |
// UnmarshalText implements the encoding.TextUnmarshaler interface for AccessTokenType |
| 274 |
func (i *AccessTokenType) UnmarshalText(text []byte) error { |
| 275 |
var err error |
| 276 |
*i, err = AccessTokenTypeString(string(text)) |
| 277 |
return err |
| 278 |
} |
| 279 |
|
| 280 |
// MarshalYAML implements a YAML Marshaler for AccessTokenType |
| 281 |
func (i AccessTokenType) MarshalYAML() (interface{}, error) { |
| 282 |
return i.String(), nil |
| 283 |
} |
| 284 |
|
| 285 |
// UnmarshalYAML implements a YAML Unmarshaler for AccessTokenType |
| 286 |
func (i *AccessTokenType) UnmarshalYAML(unmarshal func(interface{}) error) error { |
| 287 |
var s string |
| 288 |
if err := unmarshal(&s); err != nil { |
| 289 |
return err |
| 290 |
} |
| 291 |
|
| 292 |
var err error |
| 293 |
*i, err = AccessTokenTypeString(s) |
| 294 |
return err |
| 295 |
} |
| 296 |
|
| 297 |
func (i AccessTokenType) Value() (driver.Value, error) { |
| 298 |
return i.String(), nil |
| 299 |
} |
| 300 |
|
| 301 |
func (i *AccessTokenType) Scan(value interface{}) error { |
| 302 |
if value == nil { |
| 303 |
return nil |
| 304 |
} |
| 305 |
|
| 306 |
var str string |
| 307 |
switch v := value.(type) { |
| 308 |
case []byte: |
| 309 |
str = string(v) |
| 310 |
case string: |
| 311 |
str = v |
| 312 |
case fmt.Stringer: |
| 313 |
str = v.String() |
| 314 |
default: |
| 315 |
return fmt.Errorf("invalid value of AccessTokenType: %[1]T(%[1]v)", value) |
| 316 |
} |
| 317 |
|
| 318 |
val, err := AccessTokenTypeString(str) |
| 319 |
if err != nil { |
| 320 |
return err |
| 321 |
} |
| 322 |
|
| 323 |
*i = val |
| 324 |
return nil |
| 325 |
} |
| 326 |
|
| 327 |
// MarshalGQL implements the graphql.Marshaler interface for AccessTokenType |
| 328 |
func (i AccessTokenType) MarshalGQL(w io.Writer) { |
| 329 |
fmt.Fprint(w, strconv.Quote(i.String())) |
| 330 |
} |
| 331 |
|
| 332 |
// UnmarshalGQL implements the graphql.Unmarshaler interface for AccessTokenType |
| 333 |
func (i *AccessTokenType) UnmarshalGQL(value interface{}) error { |
| 334 |
str, ok := value.(string) |
| 335 |
if !ok { |
| 336 |
return fmt.Errorf("AccessTokenType should be a string, got %T", value) |
| 337 |
} |
| 338 |
|
| 339 |
var err error |
| 340 |
*i, err = AccessTokenTypeString(str) |
| 341 |
return err |
| 342 |
} |