github.com/aldelo/common@v1.5.1/wrapper/redis/rediskeytype/rediskeytype_enumer.go (about) 1 // Code Generated By gen-enumer For "Enum Type: RedisKeyType" - 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 rediskeytype 20 21 import ( 22 "fmt" 23 "strconv" 24 ) 25 26 const ( 27 _RedisKeyTypeKey_0 = "UNKNOWN" 28 _RedisKeyTypeKey_1 = "String" 29 _RedisKeyTypeKey_2 = "List" 30 _RedisKeyTypeKey_3 = "Set" 31 _RedisKeyTypeKey_4 = "ZSet" 32 _RedisKeyTypeKey_5 = "Hash" 33 _RedisKeyTypeKey_6 = "Stream" 34 ) 35 36 const ( 37 _RedisKeyTypeCaption_0 = "UNKNOWN" 38 _RedisKeyTypeCaption_1 = "String" 39 _RedisKeyTypeCaption_2 = "List" 40 _RedisKeyTypeCaption_3 = "Set" 41 _RedisKeyTypeCaption_4 = "ZSet" 42 _RedisKeyTypeCaption_5 = "Hash" 43 _RedisKeyTypeCaption_6 = "Stream" 44 ) 45 46 const ( 47 _RedisKeyTypeDescription_0 = "UNKNOWN" 48 _RedisKeyTypeDescription_1 = "String" 49 _RedisKeyTypeDescription_2 = "List" 50 _RedisKeyTypeDescription_3 = "Set" 51 _RedisKeyTypeDescription_4 = "ZSet" 52 _RedisKeyTypeDescription_5 = "Hash" 53 _RedisKeyTypeDescription_6 = "Stream" 54 ) 55 56 // enum names constants 57 const ( 58 _RedisKeyTypeName_0 = "UNKNOWN" 59 _RedisKeyTypeName_1 = "String" 60 _RedisKeyTypeName_2 = "List" 61 _RedisKeyTypeName_3 = "Set" 62 _RedisKeyTypeName_4 = "ZSet" 63 _RedisKeyTypeName_5 = "Hash" 64 _RedisKeyTypeName_6 = "Stream" 65 ) 66 67 // var declares of enum indexes 68 var ( 69 _RedisKeyTypeIndex_0 = [...]uint8{0, 7} 70 _RedisKeyTypeIndex_1 = [...]uint8{0, 6} 71 _RedisKeyTypeIndex_2 = [...]uint8{0, 4} 72 _RedisKeyTypeIndex_3 = [...]uint8{0, 3} 73 _RedisKeyTypeIndex_4 = [...]uint8{0, 4} 74 _RedisKeyTypeIndex_5 = [...]uint8{0, 4} 75 _RedisKeyTypeIndex_6 = [...]uint8{0, 6} 76 ) 77 78 func (i RedisKeyType) String() string { 79 switch { 80 case i == UNKNOWN: 81 return _RedisKeyTypeName_0 82 case i == String: 83 return _RedisKeyTypeName_1 84 case i == List: 85 return _RedisKeyTypeName_2 86 case i == Set: 87 return _RedisKeyTypeName_3 88 case i == ZSet: 89 return _RedisKeyTypeName_4 90 case i == Hash: 91 return _RedisKeyTypeName_5 92 case i == Stream: 93 return _RedisKeyTypeName_6 94 default: 95 return "" 96 } 97 } 98 99 var _RedisKeyTypeValues = []RedisKeyType{ 100 0, // UNKNOWN 101 1, // String 102 2, // List 103 3, // Set 104 4, // ZSet 105 5, // Hash 106 6, // Stream 107 } 108 109 var _RedisKeyTypeNameToValueMap = map[string]RedisKeyType{ 110 _RedisKeyTypeName_0[0:7]: 0, // UNKNOWN 111 _RedisKeyTypeName_1[0:6]: 1, // String 112 _RedisKeyTypeName_2[0:4]: 2, // List 113 _RedisKeyTypeName_3[0:3]: 3, // Set 114 _RedisKeyTypeName_4[0:4]: 4, // ZSet 115 _RedisKeyTypeName_5[0:4]: 5, // Hash 116 _RedisKeyTypeName_6[0:6]: 6, // Stream 117 } 118 119 var _RedisKeyTypeValueToKeyMap = map[RedisKeyType]string{ 120 0: _RedisKeyTypeKey_0, // UNKNOWN 121 1: _RedisKeyTypeKey_1, // String 122 2: _RedisKeyTypeKey_2, // List 123 3: _RedisKeyTypeKey_3, // Set 124 4: _RedisKeyTypeKey_4, // ZSet 125 5: _RedisKeyTypeKey_5, // Hash 126 6: _RedisKeyTypeKey_6, // Stream 127 } 128 129 var _RedisKeyTypeValueToCaptionMap = map[RedisKeyType]string{ 130 0: _RedisKeyTypeCaption_0, // UNKNOWN 131 1: _RedisKeyTypeCaption_1, // String 132 2: _RedisKeyTypeCaption_2, // List 133 3: _RedisKeyTypeCaption_3, // Set 134 4: _RedisKeyTypeCaption_4, // ZSet 135 5: _RedisKeyTypeCaption_5, // Hash 136 6: _RedisKeyTypeCaption_6, // Stream 137 } 138 139 var _RedisKeyTypeValueToDescriptionMap = map[RedisKeyType]string{ 140 0: _RedisKeyTypeDescription_0, // UNKNOWN 141 1: _RedisKeyTypeDescription_1, // String 142 2: _RedisKeyTypeDescription_2, // List 143 3: _RedisKeyTypeDescription_3, // Set 144 4: _RedisKeyTypeDescription_4, // ZSet 145 5: _RedisKeyTypeDescription_5, // Hash 146 6: _RedisKeyTypeDescription_6, // Stream 147 } 148 149 // Valid returns 'true' if the value is listed in the RedisKeyType enum map definition, 'false' otherwise 150 func (i RedisKeyType) Valid() bool { 151 for _, v := range _RedisKeyTypeValues { 152 if i == v { 153 return true 154 } 155 } 156 157 return false 158 } 159 160 // ParseByName retrieves a RedisKeyType enum value from the enum string name, 161 // throws an error if the param is not part of the enum 162 func (i RedisKeyType) ParseByName(s string) (RedisKeyType, error) { 163 if val, ok := _RedisKeyTypeNameToValueMap[s]; ok { 164 // parse ok 165 return val, nil 166 } 167 168 // error 169 return -1, fmt.Errorf("Enum Name of %s Not Expected In RedisKeyType Values List", s) 170 } 171 172 // ParseByKey retrieves a RedisKeyType enum value from the enum string key, 173 // throws an error if the param is not part of the enum 174 func (i RedisKeyType) ParseByKey(s string) (RedisKeyType, error) { 175 for k, v := range _RedisKeyTypeValueToKeyMap { 176 if v == s { 177 // parse ok 178 return k, nil 179 } 180 } 181 182 // error 183 return -1, fmt.Errorf("Enum Key of %s Not Expected In RedisKeyType Keys List", s) 184 } 185 186 // Key retrieves a RedisKeyType enum string key 187 func (i RedisKeyType) Key() string { 188 if val, ok := _RedisKeyTypeValueToKeyMap[i]; ok { 189 // found 190 return val 191 } else { 192 // not found 193 return "" 194 } 195 } 196 197 // Caption retrieves a RedisKeyType enum string caption 198 func (i RedisKeyType) Caption() string { 199 if val, ok := _RedisKeyTypeValueToCaptionMap[i]; ok { 200 // found 201 return val 202 } else { 203 // not found 204 return "" 205 } 206 } 207 208 // Description retrieves a RedisKeyType enum string description 209 func (i RedisKeyType) Description() string { 210 if val, ok := _RedisKeyTypeValueToDescriptionMap[i]; ok { 211 // found 212 return val 213 } else { 214 // not found 215 return "" 216 } 217 } 218 219 // IntValue gets the intrinsic enum integer value 220 func (i RedisKeyType) IntValue() int { 221 return int(i) 222 } 223 224 // IntString gets the intrinsic enum integer value represented in string format 225 func (i RedisKeyType) IntString() string { 226 return strconv.Itoa(int(i)) 227 } 228 229 // ValueSlice returns all values of the enum RedisKeyType in a slice 230 func (i RedisKeyType) ValueSlice() []RedisKeyType { 231 return _RedisKeyTypeValues 232 } 233 234 // NameMap returns all names of the enum RedisKeyType in a K:name,V:RedisKeyType map 235 func (i RedisKeyType) NameMap() map[string]RedisKeyType { 236 return _RedisKeyTypeNameToValueMap 237 } 238 239 // KeyMap returns all keys of the enum RedisKeyType in a K:RedisKeyType,V:key map 240 func (i RedisKeyType) KeyMap() map[RedisKeyType]string { 241 return _RedisKeyTypeValueToKeyMap 242 } 243 244 // CaptionMap returns all captions of the enum RedisKeyType in a K:RedisKeyType,V:caption map 245 func (i RedisKeyType) CaptionMap() map[RedisKeyType]string { 246 return _RedisKeyTypeValueToCaptionMap 247 } 248 249 // DescriptionMap returns all descriptions of the enum RedisKeyType in a K:RedisKeyType,V:description map 250 func (i RedisKeyType) DescriptionMap() map[RedisKeyType]string { 251 return _RedisKeyTypeValueToDescriptionMap 252 }