github.com/aldelo/common@v1.5.1/wrapper/gin/ginbindtype/ginbindtype_enumer.go (about) 1 // Code Generated By gen-enumer For "Enum Type: GinBindType" - DO NOT EDIT; 2 3 package ginbindtype 4 5 import ( 6 "fmt" 7 "strconv" 8 ) 9 10 // enum names constants 11 const ( 12 _GinBindTypeName_0 = "UNKNOWN" 13 _GinBindTypeName_1 = "BindHeader" 14 _GinBindTypeName_2 = "BindJson" 15 _GinBindTypeName_3 = "BindQuery" 16 _GinBindTypeName_4 = "BindUri" 17 _GinBindTypeName_5 = "BindXml" 18 _GinBindTypeName_6 = "BindYaml" 19 _GinBindTypeName_7 = "BindProtoBuf" 20 _GinBindTypeName_8 = "BindPostForm" 21 ) 22 23 // var declares of enum indexes 24 var ( 25 _GinBindTypeIndex_0 = [...]uint8{0, 7} 26 _GinBindTypeIndex_1 = [...]uint8{0, 10} 27 _GinBindTypeIndex_2 = [...]uint8{0, 8} 28 _GinBindTypeIndex_3 = [...]uint8{0, 9} 29 _GinBindTypeIndex_4 = [...]uint8{0, 7} 30 _GinBindTypeIndex_5 = [...]uint8{0, 7} 31 _GinBindTypeIndex_6 = [...]uint8{0, 8} 32 _GinBindTypeIndex_7 = [...]uint8{0, 12} 33 _GinBindTypeIndex_8 = [...]uint8{0, 12} 34 ) 35 36 func (i GinBindType) String() string { 37 switch { 38 case i == UNKNOWN: 39 return _GinBindTypeName_0 40 case i == BindHeader: 41 return _GinBindTypeName_1 42 case i == BindJson: 43 return _GinBindTypeName_2 44 case i == BindQuery: 45 return _GinBindTypeName_3 46 case i == BindUri: 47 return _GinBindTypeName_4 48 case i == BindXml: 49 return _GinBindTypeName_5 50 case i == BindYaml: 51 return _GinBindTypeName_6 52 case i == BindProtoBuf: 53 return _GinBindTypeName_7 54 case i == BindPostForm: 55 return _GinBindTypeName_8 56 default: 57 return "" 58 } 59 } 60 61 var _GinBindTypeValues = []GinBindType{ 62 0, // UNKNOWN 63 1, // BindHeader 64 2, // BindJson 65 3, // BindQuery 66 4, // BindUri 67 5, // BindXml 68 6, // BindYaml 69 7, // BindProtoBuf 70 8, // BindPostForm 71 } 72 73 var _GinBindTypeNameToValueMap = map[string]GinBindType{ 74 _GinBindTypeName_0[0:7]: 0, // UNKNOWN 75 _GinBindTypeName_1[0:10]: 1, // BindHeader 76 _GinBindTypeName_2[0:8]: 2, // BindJson 77 _GinBindTypeName_3[0:9]: 3, // BindQuery 78 _GinBindTypeName_4[0:7]: 4, // BindUri 79 _GinBindTypeName_5[0:7]: 5, // BindXml 80 _GinBindTypeName_6[0:8]: 6, // BindYaml 81 _GinBindTypeName_7[0:12]: 7, // BindProtoBuf 82 _GinBindTypeName_8[0:12]: 8, // BindPostForm 83 } 84 85 var _GinBindTypeValueToKeyMap = map[GinBindType]string{ 86 0: _GinBindTypeKey_0, // UNKNOWN 87 1: _GinBindTypeKey_1, // BindHeader 88 2: _GinBindTypeKey_2, // BindJson 89 3: _GinBindTypeKey_3, // BindQuery 90 4: _GinBindTypeKey_4, // BindUri 91 5: _GinBindTypeKey_5, // BindXml 92 6: _GinBindTypeKey_6, // BindYaml 93 7: _GinBindTypeKey_7, // BindProtoBuf 94 8: _GinBindTypeKey_8, // BindPostForm 95 } 96 97 var _GinBindTypeValueToCaptionMap = map[GinBindType]string{ 98 0: _GinBindTypeCaption_0, // UNKNOWN 99 1: _GinBindTypeCaption_1, // BindHeader 100 2: _GinBindTypeCaption_2, // BindJson 101 3: _GinBindTypeCaption_3, // BindQuery 102 4: _GinBindTypeCaption_4, // BindUri 103 5: _GinBindTypeCaption_5, // BindXml 104 6: _GinBindTypeCaption_6, // BindYaml 105 7: _GinBindTypeCaption_7, // BindProtoBuf 106 8: _GinBindTypeCaption_8, // BindPostForm 107 } 108 109 var _GinBindTypeValueToDescriptionMap = map[GinBindType]string{ 110 0: _GinBindTypeDescription_0, // UNKNOWN 111 1: _GinBindTypeDescription_1, // BindHeader 112 2: _GinBindTypeDescription_2, // BindJson 113 3: _GinBindTypeDescription_3, // BindQuery 114 4: _GinBindTypeDescription_4, // BindUri 115 5: _GinBindTypeDescription_5, // BindXml 116 6: _GinBindTypeDescription_6, // BindYaml 117 7: _GinBindTypeDescription_7, // BindProtoBuf 118 8: _GinBindTypeDescription_8, // BindPostForm 119 } 120 121 // Valid returns 'true' if the value is listed in the GinBindType enum map definition, 'false' otherwise 122 func (i GinBindType) Valid() bool { 123 for _, v := range _GinBindTypeValues { 124 if i == v { 125 return true 126 } 127 } 128 129 return false 130 } 131 132 // ParseByName retrieves a GinBindType enum value from the enum string name, 133 // throws an error if the param is not part of the enum 134 func (i GinBindType) ParseByName(s string) (GinBindType, error) { 135 if val, ok := _GinBindTypeNameToValueMap[s]; ok { 136 // parse ok 137 return val, nil 138 } 139 140 // error 141 return -1, fmt.Errorf("Enum Name of %s Not Expected In GinBindType Values List", s) 142 } 143 144 // ParseByKey retrieves a GinBindType enum value from the enum string key, 145 // throws an error if the param is not part of the enum 146 func (i GinBindType) ParseByKey(s string) (GinBindType, error) { 147 for k, v := range _GinBindTypeValueToKeyMap { 148 if v == s { 149 // parse ok 150 return k, nil 151 } 152 } 153 154 // error 155 return -1, fmt.Errorf("Enum Key of %s Not Expected In GinBindType Keys List", s) 156 } 157 158 // Key retrieves a GinBindType enum string key 159 func (i GinBindType) Key() string { 160 if val, ok := _GinBindTypeValueToKeyMap[i]; ok { 161 // found 162 return val 163 } else { 164 // not found 165 return "" 166 } 167 } 168 169 // Caption retrieves a GinBindType enum string caption 170 func (i GinBindType) Caption() string { 171 if val, ok := _GinBindTypeValueToCaptionMap[i]; ok { 172 // found 173 return val 174 } else { 175 // not found 176 return "" 177 } 178 } 179 180 // Description retrieves a GinBindType enum string description 181 func (i GinBindType) Description() string { 182 if val, ok := _GinBindTypeValueToDescriptionMap[i]; ok { 183 // found 184 return val 185 } else { 186 // not found 187 return "" 188 } 189 } 190 191 // IntValue gets the intrinsic enum integer value 192 func (i GinBindType) IntValue() int { 193 return int(i) 194 } 195 196 // IntString gets the intrinsic enum integer value represented in string format 197 func (i GinBindType) IntString() string { 198 return strconv.Itoa(int(i)) 199 } 200 201 // ValueSlice returns all values of the enum GinBindType in a slice 202 func (i GinBindType) ValueSlice() []GinBindType { 203 return _GinBindTypeValues 204 } 205 206 // NameMap returns all names of the enum GinBindType in a K:name,V:GinBindType map 207 func (i GinBindType) NameMap() map[string]GinBindType { 208 return _GinBindTypeNameToValueMap 209 } 210 211 // KeyMap returns all keys of the enum GinBindType in a K:GinBindType,V:key map 212 func (i GinBindType) KeyMap() map[GinBindType]string { 213 return _GinBindTypeValueToKeyMap 214 } 215 216 // CaptionMap returns all captions of the enum GinBindType in a K:GinBindType,V:caption map 217 func (i GinBindType) CaptionMap() map[GinBindType]string { 218 return _GinBindTypeValueToCaptionMap 219 } 220 221 // DescriptionMap returns all descriptions of the enum GinBindType in a K:GinBindType,V:description map 222 func (i GinBindType) DescriptionMap() map[GinBindType]string { 223 return _GinBindTypeValueToDescriptionMap 224 }