// Code generated by "enumer -type=CardType -json"; DO NOT EDIT. // package tome_lib import ( "encoding/json" "fmt" ) const _CardTypeName = "EmptyValueValkSpeedsterCommanderPaladinScholarWarriorFighterSevenShieldWallHealthPotionTreeGoblinGoblinSpawnChupacabraAllyEnemyDuelistVanguard" var _CardTypeIndex = [...]uint8{0, 10, 14, 23, 32, 39, 46, 53, 60, 65, 75, 87, 91, 97, 108, 118, 122, 127, 134, 142} 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, 9, 10, 11, 12, 13, 14, 15, 16, 17} var _CardTypeNameToValueMap = map[string]CardType{ _CardTypeName[0:10]: -1, _CardTypeName[10:14]: 0, _CardTypeName[14:23]: 1, _CardTypeName[23:32]: 2, _CardTypeName[32:39]: 3, _CardTypeName[39:46]: 4, _CardTypeName[46:53]: 5, _CardTypeName[53:60]: 6, _CardTypeName[60:65]: 7, _CardTypeName[65:75]: 8, _CardTypeName[75:87]: 9, _CardTypeName[87:91]: 10, _CardTypeName[91:97]: 11, _CardTypeName[97:108]: 12, _CardTypeName[108:118]: 13, _CardTypeName[118:122]: 14, _CardTypeName[122:127]: 15, _CardTypeName[127:134]: 16, _CardTypeName[134:142]: 17, } // 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 }