-
Notifications
You must be signed in to change notification settings - Fork 6
/
union_null_meta_record.go
93 lines (81 loc) · 2.87 KB
/
union_null_meta_record.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Code generated by github.com/actgardner/gogen-avro. DO NOT EDIT.
package complex
import (
"encoding/json"
"fmt"
"io"
"github.com/actgardner/gogen-avro/v7/vm"
"github.com/actgardner/gogen-avro/v7/vm/types"
)
type UnionNullMeta_recordTypeEnum int
const (
UnionNullMeta_recordTypeEnumMeta_record UnionNullMeta_recordTypeEnum = 1
)
type UnionNullMeta_record struct {
Null *types.NullVal
Meta_record *Meta_record
UnionType UnionNullMeta_recordTypeEnum
}
func writeUnionNullMeta_record(r *UnionNullMeta_record, w io.Writer) error {
if r == nil {
err := vm.WriteLong(0, w)
return err
}
err := vm.WriteLong(int64(r.UnionType), w)
if err != nil {
return err
}
switch r.UnionType {
case UnionNullMeta_recordTypeEnumMeta_record:
return writeMeta_record(r.Meta_record, w)
}
return fmt.Errorf("invalid value for *UnionNullMeta_record")
}
func NewUnionNullMeta_record() *UnionNullMeta_record {
return &UnionNullMeta_record{}
}
func (_ *UnionNullMeta_record) SetBoolean(v bool) { panic("Unsupported operation") }
func (_ *UnionNullMeta_record) SetInt(v int32) { panic("Unsupported operation") }
func (_ *UnionNullMeta_record) SetFloat(v float32) { panic("Unsupported operation") }
func (_ *UnionNullMeta_record) SetDouble(v float64) { panic("Unsupported operation") }
func (_ *UnionNullMeta_record) SetBytes(v []byte) { panic("Unsupported operation") }
func (_ *UnionNullMeta_record) SetString(v string) { panic("Unsupported operation") }
func (r *UnionNullMeta_record) SetLong(v int64) {
r.UnionType = (UnionNullMeta_recordTypeEnum)(v)
}
func (r *UnionNullMeta_record) Get(i int) types.Field {
switch i {
case 0:
return r.Null
case 1:
r.Meta_record = NewMeta_record()
return r.Meta_record
}
panic("Unknown field index")
}
func (_ *UnionNullMeta_record) NullField(i int) { panic("Unsupported operation") }
func (_ *UnionNullMeta_record) SetDefault(i int) { panic("Unsupported operation") }
func (_ *UnionNullMeta_record) AppendMap(key string) types.Field { panic("Unsupported operation") }
func (_ *UnionNullMeta_record) AppendArray() types.Field { panic("Unsupported operation") }
func (_ *UnionNullMeta_record) Finalize() {}
func (r *UnionNullMeta_record) MarshalJSON() ([]byte, error) {
if r == nil {
return []byte("null"), nil
}
switch r.UnionType {
case UnionNullMeta_recordTypeEnumMeta_record:
return json.Marshal(map[string]interface{}{"meta_record": r.Meta_record})
}
return nil, fmt.Errorf("invalid value for *UnionNullMeta_record")
}
func (r *UnionNullMeta_record) UnmarshalJSON(data []byte) error {
var fields map[string]json.RawMessage
if err := json.Unmarshal(data, &fields); err != nil {
return err
}
if value, ok := fields["meta_record"]; ok {
r.UnionType = 1
return json.Unmarshal([]byte(value), &r.Meta_record)
}
return fmt.Errorf("invalid value for *UnionNullMeta_record")
}