// Code generated by "enumer -type=Type -json -output requestTypeEnum.go"; DO NOT EDIT.

package libRequest

import (
	"encoding/json"
	"fmt"
	"strings"
)

const _TypeName = "NoBindingJSONJSONWithURIQueryQueryWithURIQueryWithPaginationURIURIAndPagination"

var _TypeIndex = [...]uint8{0, 9, 13, 24, 29, 41, 60, 63, 79}

const _TypeLowerName = "nobindingjsonjsonwithuriqueryquerywithuriquerywithpaginationuriuriandpagination"

func (i Type) String() string {
	if i < 0 || i >= Type(len(_TypeIndex)-1) {
		return fmt.Sprintf("Type(%d)", i)
	}
	return _TypeName[_TypeIndex[i]:_TypeIndex[i+1]]
}

// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _TypeNoOp() {
	var x [1]struct{}
	_ = x[NoBinding-(0)]
	_ = x[JSON-(1)]
	_ = x[JSONWithURI-(2)]
	_ = x[Query-(3)]
	_ = x[QueryWithURI-(4)]
	_ = x[QueryWithPagination-(5)]
	_ = x[URI-(6)]
	_ = x[URIAndPagination-(7)]
}

var _TypeValues = []Type{NoBinding, JSON, JSONWithURI, Query, QueryWithURI, QueryWithPagination, URI, URIAndPagination}

var _TypeNameToValueMap = map[string]Type{
	_TypeName[0:9]:        NoBinding,
	_TypeLowerName[0:9]:   NoBinding,
	_TypeName[9:13]:       JSON,
	_TypeLowerName[9:13]:  JSON,
	_TypeName[13:24]:      JSONWithURI,
	_TypeLowerName[13:24]: JSONWithURI,
	_TypeName[24:29]:      Query,
	_TypeLowerName[24:29]: Query,
	_TypeName[29:41]:      QueryWithURI,
	_TypeLowerName[29:41]: QueryWithURI,
	_TypeName[41:60]:      QueryWithPagination,
	_TypeLowerName[41:60]: QueryWithPagination,
	_TypeName[60:63]:      URI,
	_TypeLowerName[60:63]: URI,
	_TypeName[63:79]:      URIAndPagination,
	_TypeLowerName[63:79]: URIAndPagination,
}

var _TypeNames = []string{
	_TypeName[0:9],
	_TypeName[9:13],
	_TypeName[13:24],
	_TypeName[24:29],
	_TypeName[29:41],
	_TypeName[41:60],
	_TypeName[60:63],
	_TypeName[63:79],
}

// TypeString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func TypeString(s string) (Type, error) {
	if val, ok := _TypeNameToValueMap[s]; ok {
		return val, nil
	}

	if val, ok := _TypeNameToValueMap[strings.ToLower(s)]; ok {
		return val, nil
	}
	return 0, fmt.Errorf("%s does not belong to Type values", s)
}

// TypeValues returns all values of the enum
func TypeValues() []Type {
	return _TypeValues
}

// TypeStrings returns a slice of all String values of the enum
func TypeStrings() []string {
	strs := make([]string, len(_TypeNames))
	copy(strs, _TypeNames)
	return strs
}

// IsAType returns "true" if the value is listed in the enum definition. "false" otherwise
func (i Type) IsAType() bool {
	for _, v := range _TypeValues {
		if i == v {
			return true
		}
	}
	return false
}

// MarshalJSON implements the json.Marshaler interface for Type
func (i Type) MarshalJSON() ([]byte, error) {
	return json.Marshal(i.String())
}

// UnmarshalJSON implements the json.Unmarshaler interface for Type
func (i *Type) UnmarshalJSON(data []byte) error {
	var s string
	if err := json.Unmarshal(data, &s); err != nil {
		return fmt.Errorf("Type should be a string, got %s", data)
	}

	var err error
	*i, err = TypeString(s)
	return err
}
