github.com/aldelo/common@v1.5.1/wrapper/redis/redisdatatype/redisdatatype_enumer.go (about) 1 // Code Generated By gen-enumer For "Enum Type: RedisDataType" - DO NOT EDIT; 2 3 /* 4 * Copyright 2020-2023 Aldelo, LP 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 package redisdatatype 20 21 import ( 22 "fmt" 23 "strconv" 24 ) 25 26 const ( 27 _RedisDataTypeKey_0 = "UNKNOWN" 28 _RedisDataTypeKey_1 = "String" 29 _RedisDataTypeKey_2 = "Bool" 30 _RedisDataTypeKey_3 = "Int" 31 _RedisDataTypeKey_4 = "Int64" 32 _RedisDataTypeKey_5 = "Float64" 33 _RedisDataTypeKey_6 = "Bytes" 34 _RedisDataTypeKey_7 = "Json" 35 _RedisDataTypeKey_8 = "Time" 36 ) 37 38 const ( 39 _RedisDataTypeCaption_0 = "UNKNOWN" 40 _RedisDataTypeCaption_1 = "String" 41 _RedisDataTypeCaption_2 = "Bool" 42 _RedisDataTypeCaption_3 = "Int" 43 _RedisDataTypeCaption_4 = "Int64" 44 _RedisDataTypeCaption_5 = "Float64" 45 _RedisDataTypeCaption_6 = "Bytes" 46 _RedisDataTypeCaption_7 = "Json" 47 _RedisDataTypeCaption_8 = "Time" 48 ) 49 50 const ( 51 _RedisDataTypeDescription_0 = "UNKNOWN" 52 _RedisDataTypeDescription_1 = "String" 53 _RedisDataTypeDescription_2 = "Bool" 54 _RedisDataTypeDescription_3 = "Int" 55 _RedisDataTypeDescription_4 = "Int64" 56 _RedisDataTypeDescription_5 = "Float64" 57 _RedisDataTypeDescription_6 = "Bytes" 58 _RedisDataTypeDescription_7 = "Json" 59 _RedisDataTypeDescription_8 = "Time" 60 ) 61 62 // enum names constants 63 const ( 64 _RedisDataTypeName_0 = "UNKNOWN" 65 _RedisDataTypeName_1 = "String" 66 _RedisDataTypeName_2 = "Bool" 67 _RedisDataTypeName_3 = "Int" 68 _RedisDataTypeName_4 = "Int64" 69 _RedisDataTypeName_5 = "Float64" 70 _RedisDataTypeName_6 = "Bytes" 71 _RedisDataTypeName_7 = "Json" 72 _RedisDataTypeName_8 = "Time" 73 ) 74 75 // var declares of enum indexes 76 var ( 77 _RedisDataTypeIndex_0 = [...]uint8{0, 7} 78 _RedisDataTypeIndex_1 = [...]uint8{0, 6} 79 _RedisDataTypeIndex_2 = [...]uint8{0, 4} 80 _RedisDataTypeIndex_3 = [...]uint8{0, 3} 81 _RedisDataTypeIndex_4 = [...]uint8{0, 5} 82 _RedisDataTypeIndex_5 = [...]uint8{0, 7} 83 _RedisDataTypeIndex_6 = [...]uint8{0, 5} 84 _RedisDataTypeIndex_7 = [...]uint8{0, 4} 85 _RedisDataTypeIndex_8 = [...]uint8{0, 4} 86 ) 87 88 func (i RedisDataType) String() string { 89 switch { 90 case i == UNKNOWN: 91 return _RedisDataTypeName_0 92 case i == String: 93 return _RedisDataTypeName_1 94 case i == Bool: 95 return _RedisDataTypeName_2 96 case i == Int: 97 return _RedisDataTypeName_3 98 case i == Int64: 99 return _RedisDataTypeName_4 100 case i == Float64: 101 return _RedisDataTypeName_5 102 case i == Bytes: 103 return _RedisDataTypeName_6 104 case i == Json: 105 return _RedisDataTypeName_7 106 case i == Time: 107 return _RedisDataTypeName_8 108 default: 109 return "" 110 } 111 } 112 113 var _RedisDataTypeValues = []RedisDataType{ 114 0, // UNKNOWN 115 1, // String 116 2, // Bool 117 3, // Int 118 4, // Int64 119 5, // Float64 120 6, // Bytes 121 7, // Json 122 8, // Time 123 } 124 125 var _RedisDataTypeNameToValueMap = map[string]RedisDataType{ 126 _RedisDataTypeName_0[0:7]: 0, // UNKNOWN 127 _RedisDataTypeName_1[0:6]: 1, // String 128 _RedisDataTypeName_2[0:4]: 2, // Bool 129 _RedisDataTypeName_3[0:3]: 3, // Int 130 _RedisDataTypeName_4[0:5]: 4, // Int64 131 _RedisDataTypeName_5[0:7]: 5, // Float64 132 _RedisDataTypeName_6[0:5]: 6, // Bytes 133 _RedisDataTypeName_7[0:4]: 7, // Json 134 _RedisDataTypeName_8[0:4]: 8, // Time 135 } 136 137 var _RedisDataTypeValueToKeyMap = map[RedisDataType]string{ 138 0: _RedisDataTypeKey_0, // UNKNOWN 139 1: _RedisDataTypeKey_1, // String 140 2: _RedisDataTypeKey_2, // Bool 141 3: _RedisDataTypeKey_3, // Int 142 4: _RedisDataTypeKey_4, // Int64 143 5: _RedisDataTypeKey_5, // Float64 144 6: _RedisDataTypeKey_6, // Bytes 145 7: _RedisDataTypeKey_7, // Json 146 8: _RedisDataTypeKey_8, // Time 147 } 148 149 var _RedisDataTypeValueToCaptionMap = map[RedisDataType]string{ 150 0: _RedisDataTypeCaption_0, // UNKNOWN 151 1: _RedisDataTypeCaption_1, // String 152 2: _RedisDataTypeCaption_2, // Bool 153 3: _RedisDataTypeCaption_3, // Int 154 4: _RedisDataTypeCaption_4, // Int64 155 5: _RedisDataTypeCaption_5, // Float64 156 6: _RedisDataTypeCaption_6, // Bytes 157 7: _RedisDataTypeCaption_7, // Json 158 8: _RedisDataTypeCaption_8, // Time 159 } 160 161 var _RedisDataTypeValueToDescriptionMap = map[RedisDataType]string{ 162 0: _RedisDataTypeDescription_0, // UNKNOWN 163 1: _RedisDataTypeDescription_1, // String 164 2: _RedisDataTypeDescription_2, // Bool 165 3: _RedisDataTypeDescription_3, // Int 166 4: _RedisDataTypeDescription_4, // Int64 167 5: _RedisDataTypeDescription_5, // Float64 168 6: _RedisDataTypeDescription_6, // Bytes 169 7: _RedisDataTypeDescription_7, // Json 170 8: _RedisDataTypeDescription_8, // Time 171 } 172 173 // Valid returns 'true' if the value is listed in the RedisDataType enum map definition, 'false' otherwise 174 func (i RedisDataType) Valid() bool { 175 for _, v := range _RedisDataTypeValues { 176 if i == v { 177 return true 178 } 179 } 180 181 return false 182 } 183 184 // ParseByName retrieves a RedisDataType enum value from the enum string name, 185 // throws an error if the param is not part of the enum 186 func (i RedisDataType) ParseByName(s string) (RedisDataType, error) { 187 if val, ok := _RedisDataTypeNameToValueMap[s]; ok { 188 // parse ok 189 return val, nil 190 } 191 192 // error 193 return -1, fmt.Errorf("Enum Name of %s Not Expected In RedisDataType Values List", s) 194 } 195 196 // ParseByKey retrieves a RedisDataType enum value from the enum string key, 197 // throws an error if the param is not part of the enum 198 func (i RedisDataType) ParseByKey(s string) (RedisDataType, error) { 199 for k, v := range _RedisDataTypeValueToKeyMap { 200 if v == s { 201 // parse ok 202 return k, nil 203 } 204 } 205 206 // error 207 return -1, fmt.Errorf("Enum Key of %s Not Expected In RedisDataType Keys List", s) 208 } 209 210 // Key retrieves a RedisDataType enum string key 211 func (i RedisDataType) Key() string { 212 if val, ok := _RedisDataTypeValueToKeyMap[i]; ok { 213 // found 214 return val 215 } else { 216 // not found 217 return "" 218 } 219 } 220 221 // Caption retrieves a RedisDataType enum string caption 222 func (i RedisDataType) Caption() string { 223 if val, ok := _RedisDataTypeValueToCaptionMap[i]; ok { 224 // found 225 return val 226 } else { 227 // not found 228 return "" 229 } 230 } 231 232 // Description retrieves a RedisDataType enum string description 233 func (i RedisDataType) Description() string { 234 if val, ok := _RedisDataTypeValueToDescriptionMap[i]; ok { 235 // found 236 return val 237 } else { 238 // not found 239 return "" 240 } 241 } 242 243 // IntValue gets the intrinsic enum integer value 244 func (i RedisDataType) IntValue() int { 245 return int(i) 246 } 247 248 // IntString gets the intrinsic enum integer value represented in string format 249 func (i RedisDataType) IntString() string { 250 return strconv.Itoa(int(i)) 251 } 252 253 // ValueSlice returns all values of the enum RedisDataType in a slice 254 func (i RedisDataType) ValueSlice() []RedisDataType { 255 return _RedisDataTypeValues 256 } 257 258 // NameMap returns all names of the enum RedisDataType in a K:name,V:RedisDataType map 259 func (i RedisDataType) NameMap() map[string]RedisDataType { 260 return _RedisDataTypeNameToValueMap 261 } 262 263 // KeyMap returns all keys of the enum RedisDataType in a K:RedisDataType,V:key map 264 func (i RedisDataType) KeyMap() map[RedisDataType]string { 265 return _RedisDataTypeValueToKeyMap 266 } 267 268 // CaptionMap returns all captions of the enum RedisDataType in a K:RedisDataType,V:caption map 269 func (i RedisDataType) CaptionMap() map[RedisDataType]string { 270 return _RedisDataTypeValueToCaptionMap 271 } 272 273 // DescriptionMap returns all descriptions of the enum RedisDataType in a K:RedisDataType,V:description map 274 func (i RedisDataType) DescriptionMap() map[RedisDataType]string { 275 return _RedisDataTypeValueToDescriptionMap 276 }