// generated by jsonenums -type=TriggerType; DO NOT EDIT package types import ( "encoding/json" "fmt" ) var ( _TriggerTypeNameToValue = map[string]TriggerType{ "TriggerTypeDefault": TriggerTypeDefault, "TriggerTypePoll": TriggerTypePoll, } _TriggerTypeValueToName = map[TriggerType]string{ TriggerTypeDefault: "TriggerTypeDefault", TriggerTypePoll: "TriggerTypePoll", } ) func init() { var v TriggerType if _, ok := interface{}(v).(fmt.Stringer); ok { _TriggerTypeNameToValue = map[string]TriggerType{ interface{}(TriggerTypeDefault).(fmt.Stringer).String(): TriggerTypeDefault, interface{}(TriggerTypePoll).(fmt.Stringer).String(): TriggerTypePoll, } } } // MarshalJSON is generated so TriggerType satisfies json.Marshaler. func (r TriggerType) MarshalJSON() ([]byte, error) { if s, ok := interface{}(r).(fmt.Stringer); ok { return json.Marshal(s.String()) } s, ok := _TriggerTypeValueToName[r] if !ok { return nil, fmt.Errorf("invalid TriggerType: %d", r) } return json.Marshal(s) } // UnmarshalJSON is generated so TriggerType satisfies json.Unmarshaler. func (r *TriggerType) UnmarshalJSON(data []byte) error { var s string if err := json.Unmarshal(data, &s); err != nil { return fmt.Errorf("TriggerType should be a string, got %s", data) } v, ok := _TriggerTypeNameToValue[s] if !ok { return fmt.Errorf("invalid TriggerType %q", s) } *r = v return nil }