// Code generated by "enumer -type=CardType -json"; DO NOT EDIT. // package tome_lib import ( "encoding/json" "fmt" ) const _CardTypeName = "EmptyValueValkAceTwoThreeFourFiveSixSevenEight" var _CardTypeIndex = [...]uint8{0, 10, 14, 17, 20, 25, 29, 33, 36, 41, 46} func (i CardType) String() string { i -= -1 if i < 0 || i >= CardType(len(_CardTypeIndex)-1) { return fmt.Sprintf("CardType(%d)", i+-1) } return _CardTypeName[_CardTypeIndex[i]:_CardTypeIndex[i+1]] } var _CardTypeValues = []CardType{-1, 0, 1, 2, 3, 4, 5, 6, 7, 8} var _CardTypeNameToValueMap = map[string]CardType{ _CardTypeName[0:10]: -1, _CardTypeName[10:14]: 0, _CardTypeName[14:17]: 1, _CardTypeName[17:20]: 2, _CardTypeName[20:25]: 3, _CardTypeName[25:29]: 4, _CardTypeName[29:33]: 5, _CardTypeName[33:36]: 6, _CardTypeName[36:41]: 7, _CardTypeName[41:46]: 8, } // CardTypeString retrieves an enum value from the enum constants string name. // Throws an error if the param is not part of the enum. func CardTypeString(s string) (CardType, error) { if val, ok := _CardTypeNameToValueMap[s]; ok { return val, nil } return 0, fmt.Errorf("%s does not belong to CardType values", s) } // CardTypeValues returns all values of the enum func CardTypeValues() []CardType { return _CardTypeValues } // IsACardType returns "true" if the value is listed in the enum definition. "false" otherwise func (i CardType) IsACardType() bool { for _, v := range _CardTypeValues { if i == v { return true } } return false } // MarshalJSON implements the json.Marshaler interface for CardType func (i CardType) MarshalJSON() ([]byte, error) { return json.Marshal(i.String()) } // UnmarshalJSON implements the json.Unmarshaler interface for CardType func (i *CardType) UnmarshalJSON(data []byte) error { var s string if err := json.Unmarshal(data, &s); err != nil { return fmt.Errorf("CardType should be a string, got %s", data) } var err error *i, err = CardTypeString(s) return err }