//autogenerated:yes
//nolint:revive,misspell,govet,lll,dupl,gocritic
package common

import (
	"fmt"
	"strconv"
)

type CAN_FILTER_OP uint64

const (
	CAN_FILTER_REPLACE CAN_FILTER_OP = 0
	CAN_FILTER_ADD     CAN_FILTER_OP = 1
	CAN_FILTER_REMOVE  CAN_FILTER_OP = 2
)

var value_to_label_CAN_FILTER_OP = map[CAN_FILTER_OP]string{
	CAN_FILTER_REPLACE: "CAN_FILTER_REPLACE",
	CAN_FILTER_ADD:     "CAN_FILTER_ADD",
	CAN_FILTER_REMOVE:  "CAN_FILTER_REMOVE",
}

var label_to_value_CAN_FILTER_OP = map[string]CAN_FILTER_OP{
	"CAN_FILTER_REPLACE": CAN_FILTER_REPLACE,
	"CAN_FILTER_ADD":     CAN_FILTER_ADD,
	"CAN_FILTER_REMOVE":  CAN_FILTER_REMOVE,
}

// MarshalText implements the encoding.TextMarshaler interface.
func (e CAN_FILTER_OP) MarshalText() ([]byte, error) {
	if name, ok := value_to_label_CAN_FILTER_OP[e]; ok {
		return []byte(name), nil
	}
	return []byte(strconv.Itoa(int(e))), nil
}

// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (e *CAN_FILTER_OP) UnmarshalText(text []byte) error {
	if value, ok := label_to_value_CAN_FILTER_OP[string(text)]; ok {
		*e = value
	} else if value, err := strconv.Atoi(string(text)); err == nil {
		*e = CAN_FILTER_OP(value)
	} else {
		return fmt.Errorf("invalid label '%s'", text)
	}
	return nil
}

// String implements the fmt.Stringer interface.
func (e CAN_FILTER_OP) String() string {
	val, _ := e.MarshalText()
	return string(val)
}
