This repository has been archived by the owner on Oct 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrrm_inteface_opeartion_string.go
98 lines (79 loc) · 2.35 KB
/
rrm_inteface_opeartion_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
// Code generated by "enumer -type=RRMOperation -json -sql -transform=snake -output rrm_inteface_opeartion_string.go"; DO NOT EDIT.
//
package libwimark
import (
"database/sql/driver"
"encoding/json"
"fmt"
)
const _RRMOperationName = "create_rrm_operationupdate_rrm_operationdelete_rrm_operation"
var _RRMOperationIndex = [...]uint8{0, 20, 40, 60}
func (i RRMOperation) String() string {
if i >= RRMOperation(len(_RRMOperationIndex)-1) {
return fmt.Sprintf("RRMOperation(%d)", i)
}
return _RRMOperationName[_RRMOperationIndex[i]:_RRMOperationIndex[i+1]]
}
var _RRMOperationValues = []RRMOperation{0, 1, 2}
var _RRMOperationNameToValueMap = map[string]RRMOperation{
_RRMOperationName[0:20]: 0,
_RRMOperationName[20:40]: 1,
_RRMOperationName[40:60]: 2,
}
// RRMOperationString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func RRMOperationString(s string) (RRMOperation, error) {
if val, ok := _RRMOperationNameToValueMap[s]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to RRMOperation values", s)
}
// RRMOperationValues returns all values of the enum
func RRMOperationValues() []RRMOperation {
return _RRMOperationValues
}
// IsARRMOperation returns "true" if the value is listed in the enum definition. "false" otherwise
func (i RRMOperation) IsARRMOperation() bool {
for _, v := range _RRMOperationValues {
if i == v {
return true
}
}
return false
}
// MarshalJSON implements the json.Marshaler interface for RRMOperation
func (i RRMOperation) MarshalJSON() ([]byte, error) {
return json.Marshal(i.String())
}
// UnmarshalJSON implements the json.Unmarshaler interface for RRMOperation
func (i *RRMOperation) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return fmt.Errorf("RRMOperation should be a string, got %s", data)
}
var err error
*i, err = RRMOperationString(s)
return err
}
func (i RRMOperation) Value() (driver.Value, error) {
return i.String(), nil
}
func (i *RRMOperation) Scan(value interface{}) error {
if value == nil {
return nil
}
str, ok := value.(string)
if !ok {
bytes, ok := value.([]byte)
if !ok {
return fmt.Errorf("value is not a byte slice")
}
str = string(bytes[:])
}
val, err := RRMOperationString(str)
if err != nil {
return err
}
*i = val
return nil
}