// Code generated by "go-enum -type=ResponseStatus"; DO NOT EDIT.

// Install go-enum by `go get -u github.com/searKing/golang/tools/go-enum`
package responsestatus

import (
	"database/sql"
	"database/sql/driver"
	"encoding"
	"encoding/json"
	"fmt"
	"strconv"
)

func _() {
	// An "invalid array index" compiler error signifies that the constant values have changed.
	// Re-run the stringer command to generate them again.
	var x [1]struct{}
	_ = x[Done-1]
	_ = x[Pending-2]
	_ = x[Running-3]
	_ = x[Error-4]
	_ = x[Aborted-5]
}

const _ResponseStatus_name = "DonePendingRunningErrorAborted"

var _ResponseStatus_index = [...]uint8{0, 4, 11, 18, 23, 30}

func _() {
	var _nil_ResponseStatus_value = func() (val ResponseStatus) { return }()

	// An "cannot convert ResponseStatus literal (type ResponseStatus) to type fmt.Stringer" compiler error signifies that the base type have changed.
	// Re-run the go-enum command to generate them again.
	var _ fmt.Stringer = _nil_ResponseStatus_value
}

func (i ResponseStatus) String() string {
	i -= 1
	if i >= ResponseStatus(len(_ResponseStatus_index)-1) {
		return "ResponseStatus(" + strconv.FormatInt(int64(i+1), 10) + ")"
	}
	return _ResponseStatus_name[_ResponseStatus_index[i]:_ResponseStatus_index[i+1]]
}

// New returns a pointer to a new addr filled with the ResponseStatus value passed in.
func (i ResponseStatus) New() *ResponseStatus {
	clone := i
	return &clone
}

var _ResponseStatus_values = []ResponseStatus{1, 2, 3, 4, 5}

var _ResponseStatus_name_to_values = map[string]ResponseStatus{
	_ResponseStatus_name[0:4]:   1,
	_ResponseStatus_name[4:11]:  2,
	_ResponseStatus_name[11:18]: 3,
	_ResponseStatus_name[18:23]: 4,
	_ResponseStatus_name[23:30]: 5,
}

// ParseResponseStatusString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func ParseResponseStatusString(s string) (ResponseStatus, error) {
	if val, ok := _ResponseStatus_name_to_values[s]; ok {
		return val, nil
	}
	return 0, fmt.Errorf("%s does not belong to ResponseStatus values", s)
}

// ResponseStatusValues returns all values of the enum
func ResponseStatusValues() []ResponseStatus {
	return _ResponseStatus_values
}

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

func _() {
	var _nil_ResponseStatus_value = func() (val ResponseStatus) { return }()

	// An "cannot convert ResponseStatus literal (type ResponseStatus) to type encoding.BinaryMarshaler" compiler error signifies that the base type have changed.
	// Re-run the go-enum command to generate them again.
	var _ encoding.BinaryMarshaler = &_nil_ResponseStatus_value

	// An "cannot convert ResponseStatus literal (type ResponseStatus) to type encoding.BinaryUnmarshaler" compiler error signifies that the base type have changed.
	// Re-run the go-enum command to generate them again.
	var _ encoding.BinaryUnmarshaler = &_nil_ResponseStatus_value
}

// MarshalBinary implements the encoding.BinaryMarshaler interface for ResponseStatus
func (i ResponseStatus) MarshalBinary() (data []byte, err error) {
	return []byte(i.String()), nil
}

// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface for ResponseStatus
func (i *ResponseStatus) UnmarshalBinary(data []byte) error {
	var err error
	*i, err = ParseResponseStatusString(string(data))
	return err
}

func _() {
	var _nil_ResponseStatus_value = func() (val ResponseStatus) { return }()

	// An "cannot convert ResponseStatus literal (type ResponseStatus) to type json.Marshaler" compiler error signifies that the base type have changed.
	// Re-run the go-enum command to generate them again.
	var _ json.Marshaler = _nil_ResponseStatus_value

	// An "cannot convert ResponseStatus literal (type ResponseStatus) to type encoding.Unmarshaler" compiler error signifies that the base type have changed.
	// Re-run the go-enum command to generate them again.
	var _ json.Unmarshaler = &_nil_ResponseStatus_value
}

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

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

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

func _() {
	var _nil_ResponseStatus_value = func() (val ResponseStatus) { return }()

	// An "cannot convert ResponseStatus literal (type ResponseStatus) to type encoding.TextMarshaler" compiler error signifies that the base type have changed.
	// Re-run the go-enum command to generate them again.
	var _ encoding.TextMarshaler = _nil_ResponseStatus_value

	// An "cannot convert ResponseStatus literal (type ResponseStatus) to type encoding.TextUnmarshaler" compiler error signifies that the base type have changed.
	// Re-run the go-enum command to generate them again.
	var _ encoding.TextUnmarshaler = &_nil_ResponseStatus_value
}

// MarshalText implements the encoding.TextMarshaler interface for ResponseStatus
func (i ResponseStatus) MarshalText() ([]byte, error) {
	return []byte(i.String()), nil
}

// UnmarshalText implements the encoding.TextUnmarshaler interface for ResponseStatus
func (i *ResponseStatus) UnmarshalText(text []byte) error {
	var err error
	*i, err = ParseResponseStatusString(string(text))
	return err
}

//func _() {
//	var _nil_ResponseStatus_value = func() (val ResponseStatus) { return }()
//
//	// An "cannot convert ResponseStatus literal (type ResponseStatus) to type yaml.Marshaler" compiler error signifies that the base type have changed.
//	// Re-run the go-enum command to generate them again.
//	var _ yaml.Marshaler = _nil_ResponseStatus_value
//
//	// An "cannot convert ResponseStatus literal (type ResponseStatus) to type yaml.Unmarshaler" compiler error signifies that the base type have changed.
//	// Re-run the go-enum command to generate them again.
//	var _ yaml.Unmarshaler = &_nil_ResponseStatus_value
//}

// MarshalYAML implements a YAML Marshaler for ResponseStatus
func (i ResponseStatus) MarshalYAML() (interface{}, error) {
	return i.String(), nil
}

// UnmarshalYAML implements a YAML Unmarshaler for ResponseStatus
func (i *ResponseStatus) UnmarshalYAML(unmarshal func(interface{}) error) error {
	var s string
	if err := unmarshal(&s); err != nil {
		return err
	}

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

func _() {
	var _nil_ResponseStatus_value = func() (val ResponseStatus) { return }()

	// An "cannot convert ResponseStatus literal (type ResponseStatus) to type driver.Valuer" compiler error signifies that the base type have changed.
	// Re-run the go-enum command to generate them again.
	var _ driver.Valuer = _nil_ResponseStatus_value

	// An "cannot convert ResponseStatus literal (type ResponseStatus) to type sql.Scanner" compiler error signifies that the base type have changed.
	// Re-run the go-enum command to generate them again.
	var _ sql.Scanner = &_nil_ResponseStatus_value
}

func (i ResponseStatus) Value() (driver.Value, error) {
	return i.String(), nil
}

func (i *ResponseStatus) Scan(value interface{}) error {
	if value == nil {
		return nil
	}

	str, ok := value.(string)
	if !ok {
		bytes, ok := value.([]byte)
		if !ok {
			return fmt.Errorf("value is not a byte slice")
		}

		str = string(bytes[:])
	}

	val, err := ParseResponseStatusString(str)
	if err != nil {
		return err
	}

	*i = val
	return nil
}

// ResponseStatusSliceContains reports whether sunEnums is within enums.
func ResponseStatusSliceContains(enums []ResponseStatus, sunEnums ...ResponseStatus) bool {
	var seenEnums = map[ResponseStatus]bool{}
	for _, e := range sunEnums {
		seenEnums[e] = false
	}

	for _, v := range enums {
		if _, has := seenEnums[v]; has {
			seenEnums[v] = true
		}
	}

	for _, seen := range seenEnums {
		if !seen {
			return false
		}
	}

	return true
}

// ResponseStatusSliceContainsAny reports whether any sunEnum is within enums.
func ResponseStatusSliceContainsAny(enums []ResponseStatus, sunEnums ...ResponseStatus) bool {
	var seenEnums = map[ResponseStatus]struct{}{}
	for _, e := range sunEnums {
		seenEnums[e] = struct{}{}
	}

	for _, v := range enums {
		if _, has := seenEnums[v]; has {
			return true
		}
	}

	return false
}
