func (a *AttributeValue) InsertBOOL(b bool) error {
	if a.BOOL == nil {
		a.BOOL = new(bool)
	}
	*a.BOOL = b
	return nil
}
InsertBOOL will set the BOOL field.
package attributevalue
import (
	"encoding/base64"
	"encoding/json"
	"errors"
	"fmt"
	"github.com/FiloSottile/Heartbleed/server/_third_party/github.com/smugmug/godynamo/types/cast"
	"strconv"
)
type SetList []string
func (s SetList) MarshalJSON() ([]byte, error) {
	m := make(map[string]bool)
	for _, v := range s {
		m[v] = true
	}
	t := make([]string, len(m))
	i := 0
	for k, _ := range m {
		t[i] = k
		i++
	}
	return json.Marshal(t)
}
func (s *SetList) UnmarshalJSON(data []byte) error {
	if s == nil {
		return errors.New("pointer receiver for unmarshal nil")
	}
	t := make([]string, 0)
	um_err := json.Unmarshal(data, &t)
	if um_err != nil {
		return um_err
	}
	m := make(map[string]bool)
	for _, v := range t {
		m[v] = true
	}
	for k, _ := range m {
		*s = append(*s, k)
	}
	return nil
}
type AttributeValue struct {
	N string `json:",omitempty"`
	S string `json:",omitempty"`
	B string `json:",omitempty"`
	BOOL *bool `json:",omitempty"`
	NULL *bool `json:",omitempty"`
	L []*AttributeValue          `json:",omitempty"`
	M map[string]*AttributeValue `json:",omitempty"`
	SS SetList `json:",omitempty"`
	NS SetList `json:",omitempty"`
	BS SetList `json:",omitempty"`
}
func (a *AttributeValue) Empty() bool {
	return a.N == "" &&
		a.S == "" &&
		a.B == "" &&
		len(a.M) == 0 &&
		len(a.L) == 0 &&
		len(a.SS) == 0 &&
		len(a.NS) == 0 &&
		len(a.BS) == 0 &&
		a.BOOL == nil &&
		a.NULL == nil
}
type attributevalue AttributeValue
func (a AttributeValue) MarshalJSON() ([]byte, error) {
	if a.Empty() || (nil == &a) {
		return json.Marshal(nil)
	} else {
		return json.Marshal(attributevalue(a))
	}
}
func (a *AttributeValue) Valid() bool {
	c := 0
	if a.S != "" {
		c++
		if c > 1 {
			return false
		}
	}
	if a.N != "" {
		c++
		if c > 1 {
			return false
		}
	}
	if a.B != "" {
		c++
		if c > 1 {
			return false
		}
	}
	if len(a.M) != 0 {
		c++
		if c > 1 {
			return false
		}
	}
	if len(a.L) != 0 {
		c++
		if c > 1 {
			return false
		}
	}
	if len(a.SS) != 0 {
		c++
		if c > 1 {
			return false
		}
	}
	if len(a.NS) != 0 {
		c++
		if c > 1 {
			return false
		}
	}
	if len(a.BS) != 0 {
		c++
		if c > 1 {
			return false
		}
	}
	if a.BOOL != nil {
		c++
		if c > 1 {
			return false
		}
	}
	if a.NULL != nil {
		c++
		if c > 1 {
			return false
		}
	}
	return true
}
func NewAttributeValue() *AttributeValue {
	a := new(AttributeValue)
	a.L = make([]*AttributeValue, 0)
	a.M = make(map[string]*AttributeValue)
	a.SS = make([]string, 0)
	a.NS = make([]string, 0)
	a.BS = make([]string, 0)
	return a
}
func (a *AttributeValue) Copy(ac *AttributeValue) error {
	if ac == nil {
		return errors.New("copy target attributevalue instance is nil")
	}
	ac.S = a.S
	ac.N = a.N
	ac.B = a.B
	if a.BOOL == nil {
		ac.BOOL = nil
	} else {
		ac.BOOL = new(bool)
		*ac.BOOL = *a.BOOL
	}
	if a.NULL == nil {
		ac.NULL = nil
	} else {
		ac.NULL = new(bool)
		*ac.NULL = *a.NULL
	}
	l_ss := len(a.SS)
	if l_ss != 0 {
		ac.SS = make([]string, l_ss)
		copy(ac.SS, a.SS)
	}
	l_ns := len(a.NS)
	if l_ns != 0 {
		ac.NS = make([]string, l_ns)
		copy(ac.NS, a.NS)
	}
	l_bs := len(a.BS)
	if l_bs != 0 {
		ac.BS = make([]string, l_bs)
		copy(ac.BS, a.BS)
	}
	l_L := len(a.L)
	if l_L != 0 {
		ac.L = make([]*AttributeValue, l_L)
		for i, _ := range a.L {
			ac.L[i] = NewAttributeValue()
			L_i_cp_err := a.L[i].Copy(ac.L[i])
			if L_i_cp_err != nil {
				return L_i_cp_err
			}
		}
	}
	l_M := len(a.M)
	if l_M != 0 {
		ac.M = make(map[string]*AttributeValue, l_M)
		for k, _ := range a.M {
			ac.M[k] = NewAttributeValue()
			M_k_cp_err := a.M[k].Copy(ac.M[k])
			if M_k_cp_err != nil {
				return M_k_cp_err
			}
		}
	}
	return nil
}
func (a *AttributeValue) InsertS(k string) error {
	a.S = k
	return nil
}
func (a *AttributeValue) InsertN(k string) error {
	fs, ferr := cast.AWSParseFloat(k)
	if ferr != nil {
		return ferr
	}
	a.N = fs
	return nil
}
func (a *AttributeValue) InsertN_float64(f float64) error {
	a.N = strconv.FormatFloat(f, 'f', -1, 64)
	return nil
}
func (a *AttributeValue) InsertB(k string) error {
	berr := cast.AWSParseBinary(k)
	if berr != nil {
		return berr
	}
	a.B = k
	return nil
}
func (a *AttributeValue) InsertB_unencoded(k string) error {
	a.B = base64.StdEncoding.EncodeToString([]byte(k))
	return nil
}
func (a *AttributeValue) InsertSS(k string) error {
	for _, v := range a.SS {
		if v == k {
			return nil
		}
	}
	a.SS = append(a.SS, k)
	return nil
}
func (a *AttributeValue) InsertNS(k string) error {
	fs, ferr := cast.AWSParseFloat(k)
	if ferr != nil {
		return ferr
	}
	for _, v := range a.NS {
		if v == fs {
			return nil
		}
	}
	a.NS = append(a.NS, fs)
	return nil
}
func (a *AttributeValue) InsertNS_float64(f float64) error {
	k := strconv.FormatFloat(f, 'f', -1, 64)
	for _, v := range a.NS {
		if v == k {
			return nil
		}
	}
	a.NS = append(a.NS, k)
	return nil
}
func (a *AttributeValue) InsertBS(k string) error {
	berr := cast.AWSParseBinary(k)
	if berr != nil {
		return berr
	}
	for _, v := range a.BS {
		if v == k {
			return nil
		}
	}
	a.BS = append(a.BS, k)
	return nil
}
func (a *AttributeValue) InsertBS_unencoded(k string) error {
	b64_k := base64.StdEncoding.EncodeToString([]byte(k))
	for _, v := range a.BS {
		if v == b64_k {
			return nil
		}
	}
	a.BS = append(a.BS, b64_k)
	return nil
}
func (a *AttributeValue) InsertL(v *AttributeValue) error {
	v_cp := NewAttributeValue()
	cp_err := v.Copy(v_cp)
	if cp_err != nil {
		return cp_err
	}
	a.L = append(a.L, v_cp)
	return nil
}
func (a *AttributeValue) InsertM(k string, v *AttributeValue) error {
	v_cp := NewAttributeValue()
	cp_err := v.Copy(v_cp)
	if cp_err != nil {
		return cp_err
	}
	a.M[k] = v_cp
	return nil
}