// 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 (
	// AcmeIncProductAnvil is a Product of type Anvil.
	AcmeIncProductAnvil Product = iota
	// AcmeIncProductDynamite is a Product of type Dynamite.
	AcmeIncProductDynamite
	// AcmeIncProductGlue is a Product of type Glue.
	AcmeIncProductGlue
)

var ErrInvalidProduct = errors.New("not a valid Product")

const _ProductName = "AnvilDynamiteGlue"

var _ProductMap = map[Product]string{
	AcmeIncProductAnvil:    _ProductName[0:5],
	AcmeIncProductDynamite: _ProductName[5:13],
	AcmeIncProductGlue:     _ProductName[13:17],
}

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

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

var _ProductValue = map[string]Product{
	_ProductName[0:5]:   AcmeIncProductAnvil,
	_ProductName[5:13]:  AcmeIncProductDynamite,
	_ProductName[13:17]: AcmeIncProductGlue,
}

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