github.com/aldelo/common@v1.5.1/wrapper/gin/gingzipcompression/gingzipcompression_enumer.go (about) 1 // Code Generated By gen-enumer For "Enum Type: GinGZipCompression" - 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 gingzipcompression 20 21 import ( 22 "fmt" 23 "strconv" 24 ) 25 26 // enum names constants 27 const ( 28 _GinGZipCompressionName_0 = "UNKNOWN" 29 _GinGZipCompressionName_1 = "Default" 30 _GinGZipCompressionName_2 = "BestSpeed" 31 _GinGZipCompressionName_3 = "BestCompression" 32 ) 33 34 // var declares of enum indexes 35 var ( 36 _GinGZipCompressionIndex_0 = [...]uint8{0, 7} 37 _GinGZipCompressionIndex_1 = [...]uint8{0, 7} 38 _GinGZipCompressionIndex_2 = [...]uint8{0, 9} 39 _GinGZipCompressionIndex_3 = [...]uint8{0, 15} 40 ) 41 42 func (i GinGZipCompression) String() string { 43 switch { 44 case i == UNKNOWN: 45 return _GinGZipCompressionName_0 46 case i == Default: 47 return _GinGZipCompressionName_1 48 case i == BestSpeed: 49 return _GinGZipCompressionName_2 50 case i == BestCompression: 51 return _GinGZipCompressionName_3 52 default: 53 return "" 54 } 55 } 56 57 var _GinGZipCompressionValues = []GinGZipCompression{ 58 0, // UNKNOWN 59 1, // Default 60 2, // BestSpeed 61 3, // BestCompression 62 } 63 64 var _GinGZipCompressionNameToValueMap = map[string]GinGZipCompression{ 65 _GinGZipCompressionName_0[0:7]: 0, // UNKNOWN 66 _GinGZipCompressionName_1[0:7]: 1, // Default 67 _GinGZipCompressionName_2[0:9]: 2, // BestSpeed 68 _GinGZipCompressionName_3[0:15]: 3, // BestCompression 69 } 70 71 var _GinGZipCompressionValueToKeyMap = map[GinGZipCompression]string{ 72 0: _GinGZipCompressionKey_0, // UNKNOWN 73 1: _GinGZipCompressionKey_1, // Default 74 2: _GinGZipCompressionKey_2, // BestSpeed 75 3: _GinGZipCompressionKey_3, // BestCompression 76 } 77 78 var _GinGZipCompressionValueToCaptionMap = map[GinGZipCompression]string{ 79 0: _GinGZipCompressionCaption_0, // UNKNOWN 80 1: _GinGZipCompressionCaption_1, // Default 81 2: _GinGZipCompressionCaption_2, // BestSpeed 82 3: _GinGZipCompressionCaption_3, // BestCompression 83 } 84 85 var _GinGZipCompressionValueToDescriptionMap = map[GinGZipCompression]string{ 86 0: _GinGZipCompressionDescription_0, // UNKNOWN 87 1: _GinGZipCompressionDescription_1, // Default 88 2: _GinGZipCompressionDescription_2, // BestSpeed 89 3: _GinGZipCompressionDescription_3, // BestCompression 90 } 91 92 // Valid returns 'true' if the value is listed in the GinGZipCompression enum map definition, 'false' otherwise 93 func (i GinGZipCompression) Valid() bool { 94 for _, v := range _GinGZipCompressionValues { 95 if i == v { 96 return true 97 } 98 } 99 100 return false 101 } 102 103 // ParseByName retrieves a GinGZipCompression enum value from the enum string name, 104 // throws an error if the param is not part of the enum 105 func (i GinGZipCompression) ParseByName(s string) (GinGZipCompression, error) { 106 if val, ok := _GinGZipCompressionNameToValueMap[s]; ok { 107 // parse ok 108 return val, nil 109 } 110 111 // error 112 return -1, fmt.Errorf("Enum Name of %s Not Expected In GinGZipCompression Values List", s) 113 } 114 115 // ParseByKey retrieves a GinGZipCompression enum value from the enum string key, 116 // throws an error if the param is not part of the enum 117 func (i GinGZipCompression) ParseByKey(s string) (GinGZipCompression, error) { 118 for k, v := range _GinGZipCompressionValueToKeyMap { 119 if v == s { 120 // parse ok 121 return k, nil 122 } 123 } 124 125 // error 126 return -1, fmt.Errorf("Enum Key of %s Not Expected In GinGZipCompression Keys List", s) 127 } 128 129 // Key retrieves a GinGZipCompression enum string key 130 func (i GinGZipCompression) Key() string { 131 if val, ok := _GinGZipCompressionValueToKeyMap[i]; ok { 132 // found 133 return val 134 } else { 135 // not found 136 return "" 137 } 138 } 139 140 // Caption retrieves a GinGZipCompression enum string caption 141 func (i GinGZipCompression) Caption() string { 142 if val, ok := _GinGZipCompressionValueToCaptionMap[i]; ok { 143 // found 144 return val 145 } else { 146 // not found 147 return "" 148 } 149 } 150 151 // Description retrieves a GinGZipCompression enum string description 152 func (i GinGZipCompression) Description() string { 153 if val, ok := _GinGZipCompressionValueToDescriptionMap[i]; ok { 154 // found 155 return val 156 } else { 157 // not found 158 return "" 159 } 160 } 161 162 // IntValue gets the intrinsic enum integer value 163 func (i GinGZipCompression) IntValue() int { 164 return int(i) 165 } 166 167 // IntString gets the intrinsic enum integer value represented in string format 168 func (i GinGZipCompression) IntString() string { 169 return strconv.Itoa(int(i)) 170 } 171 172 // ValueSlice returns all values of the enum GinGZipCompression in a slice 173 func (i GinGZipCompression) ValueSlice() []GinGZipCompression { 174 return _GinGZipCompressionValues 175 } 176 177 // NameMap returns all names of the enum GinGZipCompression in a K:name,V:GinGZipCompression map 178 func (i GinGZipCompression) NameMap() map[string]GinGZipCompression { 179 return _GinGZipCompressionNameToValueMap 180 } 181 182 // KeyMap returns all keys of the enum GinGZipCompression in a K:GinGZipCompression,V:key map 183 func (i GinGZipCompression) KeyMap() map[GinGZipCompression]string { 184 return _GinGZipCompressionValueToKeyMap 185 } 186 187 // CaptionMap returns all captions of the enum GinGZipCompression in a K:GinGZipCompression,V:caption map 188 func (i GinGZipCompression) CaptionMap() map[GinGZipCompression]string { 189 return _GinGZipCompressionValueToCaptionMap 190 } 191 192 // DescriptionMap returns all descriptions of the enum GinGZipCompression in a K:GinGZipCompression,V:description map 193 func (i GinGZipCompression) DescriptionMap() map[GinGZipCompression]string { 194 return _GinGZipCompressionValueToDescriptionMap 195 }