Uniformize enum style

Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
Bryan Frimin
2026-05-20 09:41:22 -07:00
parent bc6d028ef3
commit 30db98455d
191 changed files with 7946 additions and 5129 deletions

View File

@@ -14,7 +14,10 @@
package coredata
import "fmt"
import (
"encoding"
"fmt"
)
type (
DocumentWriteMode string
@@ -25,26 +28,45 @@ const (
DocumentWriteModeGenerated DocumentWriteMode = "GENERATED"
)
func (e DocumentWriteMode) IsValid() bool {
switch e {
case DocumentWriteModeAuthored, DocumentWriteModeGenerated:
var (
_ fmt.Stringer = DocumentWriteMode("")
_ encoding.TextMarshaler = DocumentWriteMode("")
_ encoding.TextUnmarshaler = (*DocumentWriteMode)(nil)
)
func DocumentWriteModes() []DocumentWriteMode {
return []DocumentWriteMode{
DocumentWriteModeAuthored,
DocumentWriteModeGenerated,
}
}
func (v DocumentWriteMode) IsValid() bool {
switch v {
case
DocumentWriteModeAuthored,
DocumentWriteModeGenerated:
return true
}
return false
}
func (e DocumentWriteMode) String() string { return string(e) }
func (v DocumentWriteMode) String() string {
return string(v)
}
func (e *DocumentWriteMode) UnmarshalText(text []byte) error {
*e = DocumentWriteMode(text)
if !e.IsValid() {
return fmt.Errorf("%s is not a valid DocumentWriteMode", string(text))
func (v DocumentWriteMode) MarshalText() ([]byte, error) {
return []byte(v.String()), nil
}
func (v *DocumentWriteMode) UnmarshalText(text []byte) error {
val := DocumentWriteMode(text)
if !val.IsValid() {
return fmt.Errorf("invalid DocumentWriteMode value: %q", string(text))
}
*v = val
return nil
}
func (e DocumentWriteMode) MarshalText() ([]byte, error) {
return []byte(e.String()), nil
}