// Code generated by go-enum DO NOT EDIT.
// Version: example
// Revision: example
// Build Date: example
// Built By: example

//go:build example
// +build example

package example

import (
	"errors"
	"fmt"
)

const (
	// BuggyA is a Buggy of type A.
	BuggyA Buggy = 0
	// BuggyB is a Buggy of type B.
	BuggyB Buggy = 2
	// BuggyC is a Buggy of type C.
	BuggyC Buggy = 1
)

var ErrInvalidBuggy = errors.New("not a valid Buggy")

const _BuggyName = "ABC"

var _BuggyMap = map[Buggy]string{
	BuggyA: _BuggyName[0:1],
	BuggyB: _BuggyName[1:2],
	BuggyC: _BuggyName[2:3],
}

// String implements the Stringer interface.
func (x Buggy) String() string {
	if str, ok := _BuggyMap[x]; ok {
		return str
	}
	return fmt.Sprintf("Buggy(%d)", x)
}

// IsValid provides a quick way to determine if the typed value is
// part of the allowed enumerated values
func (x Buggy) IsValid() bool {
	_, ok := _BuggyMap[x]
	return ok
}

var _BuggyValue = map[string]Buggy{
	_BuggyName[0:1]: BuggyA,
	_BuggyName[1:2]: BuggyB,
	_BuggyName[2:3]: BuggyC,
}

// ParseBuggy attempts to convert a string to a Buggy.
func ParseBuggy(name string) (Buggy, error) {
	if x, ok := _BuggyValue[name]; ok {
		return x, nil
	}
	return Buggy(0), fmt.Errorf("%s is %w", name, ErrInvalidBuggy)
}
