2015-01-29 11:35:15 +01:00
|
|
|
// generated by jsonenums -type=ShirtSize; DO NOT EDIT
|
|
|
|
|
2015-01-29 17:00:50 +01:00
|
|
|
package main
|
2015-01-29 11:35:15 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2015-01-31 11:09:02 +01:00
|
|
|
func (r ShirtSize) MarshalJSON() ([]byte, error) {
|
2015-01-31 12:21:55 +01:00
|
|
|
if s, ok := interface{}(r).(fmt.Stringer); ok {
|
2015-01-31 11:09:02 +01:00
|
|
|
return json.Marshal(s.String())
|
|
|
|
}
|
2015-01-31 12:21:55 +01:00
|
|
|
s, ok := map[ShirtSize]string{
|
|
|
|
NA: "NA", XS: "XS", S: "S", M: "M", L: "L", XL: "XL",
|
|
|
|
}[r]
|
2015-01-31 11:09:02 +01:00
|
|
|
if !ok {
|
|
|
|
return nil, fmt.Errorf("invalid ShirtSize: %d", r)
|
2015-01-29 11:35:15 +01:00
|
|
|
}
|
2015-01-31 11:09:02 +01:00
|
|
|
return json.Marshal(s)
|
2015-01-29 11:35:15 +01:00
|
|
|
}
|
|
|
|
|
2015-01-31 11:09:02 +01:00
|
|
|
var _ShirtSizeNameToValue = map[string]ShirtSize{
|
|
|
|
"NA": NA, "XS": XS, "S": S, "M": M, "L": L, "XL": XL,
|
2015-01-29 11:35:15 +01:00
|
|
|
}
|
|
|
|
|
2015-01-31 12:21:55 +01:00
|
|
|
func init() {
|
|
|
|
var v ShirtSize
|
|
|
|
if _, ok := interface{}(v).(fmt.Stringer); ok {
|
|
|
|
_ShirtSizeNameToValue = map[string]ShirtSize{
|
|
|
|
interface{}(NA).(fmt.Stringer).String(): NA, interface{}(XS).(fmt.Stringer).String(): XS, interface{}(S).(fmt.Stringer).String(): S, interface{}(M).(fmt.Stringer).String(): M, interface{}(L).(fmt.Stringer).String(): L, interface{}(XL).(fmt.Stringer).String(): XL,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-29 11:35:15 +01:00
|
|
|
func (r *ShirtSize) UnmarshalJSON(data []byte) error {
|
|
|
|
var s string
|
|
|
|
if err := json.Unmarshal(data, &s); err != nil {
|
|
|
|
return fmt.Errorf("ShirtSize should be a string, got %s", data)
|
|
|
|
}
|
2015-01-31 11:09:02 +01:00
|
|
|
v, ok := _ShirtSizeNameToValue[s]
|
|
|
|
if !ok {
|
2015-01-29 17:00:50 +01:00
|
|
|
return fmt.Errorf("invalid ShirtSize %q", s)
|
2015-01-29 11:35:15 +01:00
|
|
|
}
|
2015-01-31 11:09:02 +01:00
|
|
|
*r = v
|
2015-01-29 11:35:15 +01:00
|
|
|
return nil
|
|
|
|
}
|