blob: aba286e7325767c51c0f9d57a888e9ace895f299 (
plain) (
tree)
|
|
package model
import "fmt"
type BooleanNode struct {
Value bool
}
func (n BooleanNode) Type() NodeType {
return BooleanType
}
func (n *BooleanNode) MarshalJSON() ([]byte, error) {
if n.Value {
return []byte("true"), nil
}
return []byte("false"), nil
}
func (n *BooleanNode) Set(v any) error {
val, ok := v.(bool)
if !ok {
return fmt.Errorf("%v is not boolean", v)
}
n.Value = val
return nil
}
|