viney-shih/go-cache

View on GitHub
event_enum.go

Summary

Maintainability
A
0 mins
Test Coverage
// Code generated by go-enum DO NOT EDIT.
// Version:
// Revision:
// Build Date:
// Built By:

package cache

import (
    "fmt"
    "strings"
)

const (
    // EventTypeNone is a eventType of type None.
    // Not registered Event by default.
    EventTypeNone eventType = iota
    // EventTypeEvict is a eventType of type Evict.
    // Evict presents eviction event.
    EventTypeEvict
)

const _eventTypeName = "NoneEvict"

var _eventTypeMap = map[eventType]string{
    EventTypeNone:  _eventTypeName[0:4],
    EventTypeEvict: _eventTypeName[4:9],
}

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

var _eventTypeValue = map[string]eventType{
    _eventTypeName[0:4]:                  EventTypeNone,
    strings.ToLower(_eventTypeName[0:4]): EventTypeNone,
    _eventTypeName[4:9]:                  EventTypeEvict,
    strings.ToLower(_eventTypeName[4:9]): EventTypeEvict,
}

// ParseeventType attempts to convert a string to a eventType.
func ParseeventType(name string) (eventType, error) {
    if x, ok := _eventTypeValue[name]; ok {
        return x, nil
    }
    // Case insensitive parse, do a separate lookup to prevent unnecessary cost of lowercasing a string if we don't need to.
    if x, ok := _eventTypeValue[strings.ToLower(name)]; ok {
        return x, nil
    }
    return eventType(0), fmt.Errorf("%s is not a valid eventType", name)
}