//------------------------------------------------------------------------------
// Automatically generated by the Fast Binary Encoding compiler, do not modify!
// https://github.com/chronoxor/FastBinaryEncoding
// Source: test.fbe
// FBE version: 1.15.0.0
//------------------------------------------------------------------------------

package test

import "strings"
import "errors"
import "../fbe"
import "../proto"

// Workaround for Go unused imports issue
var _ = errors.New
var _ = fbe.Version
var _ = proto.Version

// FlagsEmpty flags key
type FlagsEmptyKey int32

// Convert FlagsEmpty flags key to string
func (k FlagsEmptyKey) String() string {
    return FlagsEmpty(k).String()
}

// FlagsEmpty flags
type FlagsEmpty int32

// FlagsEmpty flags values
//noinspection GoSnakeCaseUsage
const (
)

// Create a new FlagsEmpty flags
func NewFlagsEmpty() *FlagsEmpty {
    return new(FlagsEmpty)
}

// Create a new FlagsEmpty flags from the given flags
func NewFlagsEmptyFromValue(flags int32) *FlagsEmpty {
    result := FlagsEmpty(flags)
    return &result
}

// Is flags set?
func (f FlagsEmpty) HasFlags(flags FlagsEmpty) bool {
    return ((f & flags) != 0) && ((f & flags) == flags)
}

// Set flags
func (f *FlagsEmpty) SetFlags(flags FlagsEmpty) *FlagsEmpty {
    *f |= flags
    return f
}

// Remove flags
func (f *FlagsEmpty) RemoveFlags(flags FlagsEmpty) *FlagsEmpty {
    *f &^= flags
    return f
}

// Get the flags key
func (f FlagsEmpty) Key() FlagsEmptyKey {
    return FlagsEmptyKey(f)
}

// Convert flags to optional
func (f *FlagsEmpty) Optional() *FlagsEmpty {
    return f
}

// Convert flags to string
//noinspection GoBoolExpressions
func (f FlagsEmpty) String() string {
    var sb strings.Builder
    return sb.String()
}

// Convert flags to JSON
func (f FlagsEmpty) MarshalJSON() ([]byte, error) {
    value := int32(f)
    return fbe.Json.Marshal(&value)
}

// Convert JSON to flags
func (f *FlagsEmpty) UnmarshalJSON(buffer []byte) error {
    var result int32
    err := fbe.Json.Unmarshal(buffer, &result)
    if err != nil {
        return err
    }
    *f = FlagsEmpty(result)
    return nil
}
