github.com/aldelo/common@v1.5.1/wrapper/gin/ginhttpmethod/ginhttpmethod_enumer.go (about)

     1  // Code Generated By gen-enumer For "Enum Type: GinHttpMethod" - 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 ginhttpmethod
    20  
    21  import (
    22  	"fmt"
    23  	"strconv"
    24  )
    25  
    26  // enum names constants
    27  const (
    28  	_GinHttpMethodName_0 = "UNKNOWN"
    29  	_GinHttpMethodName_1 = "GET"
    30  	_GinHttpMethodName_2 = "POST"
    31  	_GinHttpMethodName_3 = "PUT"
    32  	_GinHttpMethodName_4 = "DELETE"
    33  )
    34  
    35  // var declares of enum indexes
    36  var (
    37  	_GinHttpMethodIndex_0 = [...]uint8{0, 7}
    38  	_GinHttpMethodIndex_1 = [...]uint8{0, 3}
    39  	_GinHttpMethodIndex_2 = [...]uint8{0, 4}
    40  	_GinHttpMethodIndex_3 = [...]uint8{0, 3}
    41  	_GinHttpMethodIndex_4 = [...]uint8{0, 6}
    42  )
    43  
    44  func (i GinHttpMethod) String() string {
    45  	switch {
    46  	case i == UNKNOWN:
    47  		return _GinHttpMethodName_0
    48  	case i == GET:
    49  		return _GinHttpMethodName_1
    50  	case i == POST:
    51  		return _GinHttpMethodName_2
    52  	case i == PUT:
    53  		return _GinHttpMethodName_3
    54  	case i == DELETE:
    55  		return _GinHttpMethodName_4
    56  	default:
    57  		return ""
    58  	}
    59  }
    60  
    61  var _GinHttpMethodValues = []GinHttpMethod{
    62  	0, // UNKNOWN
    63  	1, // GET
    64  	2, // POST
    65  	3, // PUT
    66  	4, // DELETE
    67  }
    68  
    69  var _GinHttpMethodNameToValueMap = map[string]GinHttpMethod{
    70  	_GinHttpMethodName_0[0:7]: 0, // UNKNOWN
    71  	_GinHttpMethodName_1[0:3]: 1, // GET
    72  	_GinHttpMethodName_2[0:4]: 2, // POST
    73  	_GinHttpMethodName_3[0:3]: 3, // PUT
    74  	_GinHttpMethodName_4[0:6]: 4, // DELETE
    75  }
    76  
    77  var _GinHttpMethodValueToKeyMap = map[GinHttpMethod]string{
    78  	0: _GinHttpMethodKey_0, // UNKNOWN
    79  	1: _GinHttpMethodKey_1, // GET
    80  	2: _GinHttpMethodKey_2, // POST
    81  	3: _GinHttpMethodKey_3, // PUT
    82  	4: _GinHttpMethodKey_4, // DELETE
    83  }
    84  
    85  var _GinHttpMethodValueToCaptionMap = map[GinHttpMethod]string{
    86  	0: _GinHttpMethodCaption_0, // UNKNOWN
    87  	1: _GinHttpMethodCaption_1, // GET
    88  	2: _GinHttpMethodCaption_2, // POST
    89  	3: _GinHttpMethodCaption_3, // PUT
    90  	4: _GinHttpMethodCaption_4, // DELETE
    91  }
    92  
    93  var _GinHttpMethodValueToDescriptionMap = map[GinHttpMethod]string{
    94  	0: _GinHttpMethodDescription_0, // UNKNOWN
    95  	1: _GinHttpMethodDescription_1, // GET
    96  	2: _GinHttpMethodDescription_2, // POST
    97  	3: _GinHttpMethodDescription_3, // PUT
    98  	4: _GinHttpMethodDescription_4, // DELETE
    99  }
   100  
   101  // Valid returns 'true' if the value is listed in the GinHttpMethod enum map definition, 'false' otherwise
   102  func (i GinHttpMethod) Valid() bool {
   103  	for _, v := range _GinHttpMethodValues {
   104  		if i == v {
   105  			return true
   106  		}
   107  	}
   108  
   109  	return false
   110  }
   111  
   112  // ParseByName retrieves a GinHttpMethod enum value from the enum string name,
   113  // throws an error if the param is not part of the enum
   114  func (i GinHttpMethod) ParseByName(s string) (GinHttpMethod, error) {
   115  	if val, ok := _GinHttpMethodNameToValueMap[s]; ok {
   116  		// parse ok
   117  		return val, nil
   118  	}
   119  
   120  	// error
   121  	return -1, fmt.Errorf("Enum Name of %s Not Expected In GinHttpMethod Values List", s)
   122  }
   123  
   124  // ParseByKey retrieves a GinHttpMethod enum value from the enum string key,
   125  // throws an error if the param is not part of the enum
   126  func (i GinHttpMethod) ParseByKey(s string) (GinHttpMethod, error) {
   127  	for k, v := range _GinHttpMethodValueToKeyMap {
   128  		if v == s {
   129  			// parse ok
   130  			return k, nil
   131  		}
   132  	}
   133  
   134  	// error
   135  	return -1, fmt.Errorf("Enum Key of %s Not Expected In GinHttpMethod Keys List", s)
   136  }
   137  
   138  // Key retrieves a GinHttpMethod enum string key
   139  func (i GinHttpMethod) Key() string {
   140  	if val, ok := _GinHttpMethodValueToKeyMap[i]; ok {
   141  		// found
   142  		return val
   143  	} else {
   144  		// not found
   145  		return ""
   146  	}
   147  }
   148  
   149  // Caption retrieves a GinHttpMethod enum string caption
   150  func (i GinHttpMethod) Caption() string {
   151  	if val, ok := _GinHttpMethodValueToCaptionMap[i]; ok {
   152  		// found
   153  		return val
   154  	} else {
   155  		// not found
   156  		return ""
   157  	}
   158  }
   159  
   160  // Description retrieves a GinHttpMethod enum string description
   161  func (i GinHttpMethod) Description() string {
   162  	if val, ok := _GinHttpMethodValueToDescriptionMap[i]; ok {
   163  		// found
   164  		return val
   165  	} else {
   166  		// not found
   167  		return ""
   168  	}
   169  }
   170  
   171  // IntValue gets the intrinsic enum integer value
   172  func (i GinHttpMethod) IntValue() int {
   173  	return int(i)
   174  }
   175  
   176  // IntString gets the intrinsic enum integer value represented in string format
   177  func (i GinHttpMethod) IntString() string {
   178  	return strconv.Itoa(int(i))
   179  }
   180  
   181  // ValueSlice returns all values of the enum GinHttpMethod in a slice
   182  func (i GinHttpMethod) ValueSlice() []GinHttpMethod {
   183  	return _GinHttpMethodValues
   184  }
   185  
   186  // NameMap returns all names of the enum GinHttpMethod in a K:name,V:GinHttpMethod map
   187  func (i GinHttpMethod) NameMap() map[string]GinHttpMethod {
   188  	return _GinHttpMethodNameToValueMap
   189  }
   190  
   191  // KeyMap returns all keys of the enum GinHttpMethod in a K:GinHttpMethod,V:key map
   192  func (i GinHttpMethod) KeyMap() map[GinHttpMethod]string {
   193  	return _GinHttpMethodValueToKeyMap
   194  }
   195  
   196  // CaptionMap returns all captions of the enum GinHttpMethod in a K:GinHttpMethod,V:caption map
   197  func (i GinHttpMethod) CaptionMap() map[GinHttpMethod]string {
   198  	return _GinHttpMethodValueToCaptionMap
   199  }
   200  
   201  // DescriptionMap returns all descriptions of the enum GinHttpMethod in a K:GinHttpMethod,V:description map
   202  func (i GinHttpMethod) DescriptionMap() map[GinHttpMethod]string {
   203  	return _GinHttpMethodValueToDescriptionMap
   204  }