func (info *BarPropertyInfo) FieldName() string {
	return info.fieldName
}
FieldName returns struct field name of property.
package k
import (
	"encoding/json"
	o1 "github.com/favclip/jwg/misc/other/v1"
	o2 "github.com/favclip/jwg/misc/other/v2"
)
type FooJSON struct {
	Test *o1.Test `json:"test,omitempty"`
}
type FooJSONList []*FooJSON
type FooPropertyEncoder func(src *Foo, dest *FooJSON) error
type FooPropertyDecoder func(src *FooJSON, dest *Foo) error
type FooPropertyInfo struct {
	fieldName string
	jsonName  string
	Encoder   FooPropertyEncoder
	Decoder   FooPropertyDecoder
}
func (info *FooPropertyInfo) FieldName() string {
	return info.fieldName
}
func (info *FooPropertyInfo) JSONName() string {
	return info.jsonName
}
type FooJSONBuilder struct {
	_properties        map[string]*FooPropertyInfo
	_jsonPropertyMap   map[string]*FooPropertyInfo
	_structPropertyMap map[string]*FooPropertyInfo
	Test               *FooPropertyInfo
}
func NewFooJSONBuilder() *FooJSONBuilder {
	jb := &FooJSONBuilder{
		_properties:        map[string]*FooPropertyInfo{},
		_jsonPropertyMap:   map[string]*FooPropertyInfo{},
		_structPropertyMap: map[string]*FooPropertyInfo{},
		Test: &FooPropertyInfo{
			fieldName: "Test",
			jsonName:  "test",
			Encoder: func(src *Foo, dest *FooJSON) error {
				if src == nil {
					return nil
				}
				dest.Test = src.Test
				return nil
			},
			Decoder: func(src *FooJSON, dest *Foo) error {
				if src == nil {
					return nil
				}
				dest.Test = src.Test
				return nil
			},
		},
	}
	jb._structPropertyMap["Test"] = jb.Test
	jb._jsonPropertyMap["test"] = jb.Test
	return jb
}
func (b *FooJSONBuilder) Properties() []*FooPropertyInfo {
	return []*FooPropertyInfo{
		b.Test,
	}
}
func (b *FooJSONBuilder) AddAll() *FooJSONBuilder {
	b._properties["Test"] = b.Test
	return b
}
func (b *FooJSONBuilder) Add(info *FooPropertyInfo) *FooJSONBuilder {
	b._properties[info.fieldName] = info
	return b
}
func (b *FooJSONBuilder) AddByJSONNames(names ...string) *FooJSONBuilder {
	for _, name := range names {
		info := b._jsonPropertyMap[name]
		if info == nil {
			continue
		}
		b._properties[info.fieldName] = info
	}
	return b
}
func (b *FooJSONBuilder) AddByNames(names ...string) *FooJSONBuilder {
	for _, name := range names {
		info := b._structPropertyMap[name]
		if info == nil {
			continue
		}
		b._properties[info.fieldName] = info
	}
	return b
}
func (b *FooJSONBuilder) Remove(info *FooPropertyInfo) *FooJSONBuilder {
	delete(b._properties, info.fieldName)
	return b
}
func (b *FooJSONBuilder) RemoveByJSONNames(names ...string) *FooJSONBuilder {
	for _, name := range names {
		info := b._jsonPropertyMap[name]
		if info == nil {
			continue
		}
		delete(b._properties, info.fieldName)
	}
	return b
}
func (b *FooJSONBuilder) RemoveByNames(names ...string) *FooJSONBuilder {
	for _, name := range names {
		info := b._structPropertyMap[name]
		if info == nil {
			continue
		}
		delete(b._properties, info.fieldName)
	}
	return b
}
func (b *FooJSONBuilder) Convert(orig *Foo) (*FooJSON, error) {
	if orig == nil {
		return nil, nil
	}
	ret := &FooJSON{}
	for _, info := range b._properties {
		if err := info.Encoder(orig, ret); err != nil {
			return nil, err
		}
	}
	return ret, nil
}
func (b *FooJSONBuilder) ConvertList(orig []*Foo) (FooJSONList, error) {
	if orig == nil {
		return nil, nil
	}
	list := make(FooJSONList, len(orig))
	for idx, or := range orig {
		json, err := b.Convert(or)
		if err != nil {
			return nil, err
		}
		list[idx] = json
	}
	return list, nil
}
func (orig *FooJSON) Convert() (*Foo, error) {
	ret := &Foo{}
	b := NewFooJSONBuilder().AddAll()
	for _, info := range b._properties {
		if err := info.Decoder(orig, ret); err != nil {
			return nil, err
		}
	}
	return ret, nil
}
func (jsonList FooJSONList) Convert() ([]*Foo, error) {
	orig := ([]*FooJSON)(jsonList)
	list := make([]*Foo, len(orig))
	for idx, or := range orig {
		obj, err := or.Convert()
		if err != nil {
			return nil, err
		}
		list[idx] = obj
	}
	return list, nil
}
func (b *FooJSONBuilder) Marshal(orig *Foo) ([]byte, error) {
	ret, err := b.Convert(orig)
	if err != nil {
		return nil, err
	}
	return json.Marshal(ret)
}
type BarJSON struct {
	Tests []*o2.Test `json:"tests,omitempty"`
}
type BarJSONList []*BarJSON
type BarPropertyEncoder func(src *Bar, dest *BarJSON) error
type BarPropertyDecoder func(src *BarJSON, dest *Bar) error
type BarPropertyInfo struct {
	fieldName string
	jsonName  string
	Encoder   BarPropertyEncoder
	Decoder   BarPropertyDecoder
}