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

//go:build example
// +build example

package globs

import (
	"errors"
	"fmt"
)

const (
	// Number0 is a Number of type 0.
	Number0 Number = iota
	// Number1 is a Number of type 1.
	Number1
	// Number2 is a Number of type 2.
	Number2
	// Number3 is a Number of type 3.
	Number3
	// Number4 is a Number of type 4.
	Number4
	// Number5 is a Number of type 5.
	Number5
	// Number6 is a Number of type 6.
	Number6
	// Number7 is a Number of type 7.
	Number7
	// Number8 is a Number of type 8.
	Number8
	// Number9 is a Number of type 9.
	Number9
)

var ErrInvalidNumber = errors.New("not a valid Number")

const _NumberName = "0123456789"

var _NumberMap = map[Number]string{
	Number0: _NumberName[0:1],
	Number1: _NumberName[1:2],
	Number2: _NumberName[2:3],
	Number3: _NumberName[3:4],
	Number4: _NumberName[4:5],
	Number5: _NumberName[5:6],
	Number6: _NumberName[6:7],
	Number7: _NumberName[7:8],
	Number8: _NumberName[8:9],
	Number9: _NumberName[9:10],
}

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

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

var _NumberValue = map[string]Number{
	_NumberName[0:1]:  Number0,
	_NumberName[1:2]:  Number1,
	_NumberName[2:3]:  Number2,
	_NumberName[3:4]:  Number3,
	_NumberName[4:5]:  Number4,
	_NumberName[5:6]:  Number5,
	_NumberName[6:7]:  Number6,
	_NumberName[7:8]:  Number7,
	_NumberName[8:9]:  Number8,
	_NumberName[9:10]: Number9,
}

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