// Code generated by "go-enum -type=DeletionType -transform=lower"; DO NOT EDIT.

package enums

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[Hard-0]
	_ = x[Soft-1]
}

const _DeletionType_name = "hardsoft"

var _DeletionType_index = [...]uint8{0, 4, 8}

func _() {
	var _nil_DeletionType_value = func() (val DeletionType) { return }()

	// An "cannot convert DeletionType literal (type DeletionType) 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_DeletionType_value
}

func (i DeletionType) String() string {
	if i < 0 || i >= DeletionType(len(_DeletionType_index)-1) {
		return "DeletionType(" + strconv.FormatInt(int64(i), 10) + ")"
	}
	return _DeletionType_name[_DeletionType_index[i]:_DeletionType_index[i+1]]
}

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

var _DeletionType_values = []DeletionType{0, 1}

var _DeletionType_name_to_values = map[string]DeletionType{
	_DeletionType_name[0:4]: 0,
	_DeletionType_name[4:8]: 1,
}

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

// DeletionTypeValues returns all values of the enum
func DeletionTypeValues() []DeletionType {
	return _DeletionType_values
}

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

func _() {
	var _nil_DeletionType_value = func() (val DeletionType) { return }()

	// An "cannot convert DeletionType literal (type DeletionType) 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_DeletionType_value

	// An "cannot convert DeletionType literal (type DeletionType) 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_DeletionType_value
}

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

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

func _() {
	var _nil_DeletionType_value = func() (val DeletionType) { return }()

	// An "cannot convert DeletionType literal (type DeletionType) 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_DeletionType_value

	// An "cannot convert DeletionType literal (type DeletionType) 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_DeletionType_value
}

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

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

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

func _() {
	var _nil_DeletionType_value = func() (val DeletionType) { return }()

	// An "cannot convert DeletionType literal (type DeletionType) 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_DeletionType_value

	// An "cannot convert DeletionType literal (type DeletionType) 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_DeletionType_value
}

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

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

//func _() {
//	var _nil_DeletionType_value = func() (val DeletionType) { return }()
//
//	// An "cannot convert DeletionType literal (type DeletionType) 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_DeletionType_value
//
//	// An "cannot convert DeletionType literal (type DeletionType) 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_DeletionType_value
//}

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

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

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

func _() {
	var _nil_DeletionType_value = func() (val DeletionType) { return }()

	// An "cannot convert DeletionType literal (type DeletionType) 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_DeletionType_value

	// An "cannot convert DeletionType literal (type DeletionType) 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_DeletionType_value
}

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

func (i *DeletionType) 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 := ParseDeletionTypeString(str)
	if err != nil {
		return err
	}

	*i = val
	return nil
}

// DeletionTypeSliceContains reports whether sunEnums is within enums.
func DeletionTypeSliceContains(enums []DeletionType, sunEnums ...DeletionType) bool {
	var seenEnums = map[DeletionType]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
}

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

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

	return false
}
