You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.0 KiB
49 lines
1.0 KiB
package models
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"strconv"
|
|
)
|
|
|
|
// LogImporter describes a model related log importing.
|
|
type LogImporter string
|
|
|
|
const (
|
|
// LogImporterMircLike is a value of LogImporter
|
|
LogImporterMircLike LogImporter = "MircLike"
|
|
// LogImporterForumLog is a value of LogImporter
|
|
LogImporterForumLog LogImporter = "ForumLog"
|
|
)
|
|
|
|
// IsValid returns true if the underlying string is one of the correct values.
|
|
func (e LogImporter) IsValid() bool {
|
|
switch e {
|
|
case LogImporterForumLog, LogImporterMircLike:
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (e LogImporter) String() string {
|
|
return string(e)
|
|
}
|
|
|
|
// UnmarshalGQL unmarshals the underlying graphql value.
|
|
func (e *LogImporter) UnmarshalGQL(v interface{}) error {
|
|
str, ok := v.(string)
|
|
if !ok {
|
|
return fmt.Errorf("enums must be strings")
|
|
}
|
|
|
|
*e = LogImporter(str)
|
|
if !e.IsValid() {
|
|
return fmt.Errorf("%s is not a valid LogImporter", str)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// MarshalGQL marshals the underlying graphql value.
|
|
func (e LogImporter) MarshalGQL(w io.Writer) {
|
|
fmt.Fprint(w, strconv.Quote(e.String()))
|
|
}
|