// Code generated by "enumer -type=DBMode -json -output dbModeEnum.go"; DO NOT EDIT.

package libQuery

import (
	"encoding/json"
	"fmt"
	"strings"
)

const _DBModeName = "OraclePostgresSqlLiteMockDB"

var _DBModeIndex = [...]uint8{0, 6, 14, 21, 27}

const _DBModeLowerName = "oraclepostgressqllitemockdb"

func (i DBMode) String() string {
	if i < 0 || i >= DBMode(len(_DBModeIndex)-1) {
		return fmt.Sprintf("DBMode(%d)", i)
	}
	return _DBModeName[_DBModeIndex[i]:_DBModeIndex[i+1]]
}

// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _DBModeNoOp() {
	var x [1]struct{}
	_ = x[Oracle-(0)]
	_ = x[Postgres-(1)]
	_ = x[SqlLite-(2)]
	_ = x[MockDB-(3)]
}

var _DBModeValues = []DBMode{Oracle, Postgres, SqlLite, MockDB}

var _DBModeNameToValueMap = map[string]DBMode{
	_DBModeName[0:6]:        Oracle,
	_DBModeLowerName[0:6]:   Oracle,
	_DBModeName[6:14]:       Postgres,
	_DBModeLowerName[6:14]:  Postgres,
	_DBModeName[14:21]:      SqlLite,
	_DBModeLowerName[14:21]: SqlLite,
	_DBModeName[21:27]:      MockDB,
	_DBModeLowerName[21:27]: MockDB,
}

var _DBModeNames = []string{
	_DBModeName[0:6],
	_DBModeName[6:14],
	_DBModeName[14:21],
	_DBModeName[21:27],
}

// DBModeString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func DBModeString(s string) (DBMode, error) {
	if val, ok := _DBModeNameToValueMap[s]; ok {
		return val, nil
	}

	if val, ok := _DBModeNameToValueMap[strings.ToLower(s)]; ok {
		return val, nil
	}
	return 0, fmt.Errorf("%s does not belong to DBMode values", s)
}

// DBModeValues returns all values of the enum
func DBModeValues() []DBMode {
	return _DBModeValues
}

// DBModeStrings returns a slice of all String values of the enum
func DBModeStrings() []string {
	strs := make([]string, len(_DBModeNames))
	copy(strs, _DBModeNames)
	return strs
}

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

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

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

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