/
union_null_some_date_obj_record.go
95 lines (83 loc) · 3.14 KB
/
union_null_some_date_obj_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
94
95
// Code generated by github.com/actgardner/gogen-avro. DO NOT EDIT.
package repeats
import (
"encoding/json"
"fmt"
"io"
"github.com/actgardner/gogen-avro/v7/vm"
"github.com/actgardner/gogen-avro/v7/vm/types"
)
type UnionNullSomeDateObj_recordTypeEnum int
const (
UnionNullSomeDateObj_recordTypeEnumSomeDateObj_record UnionNullSomeDateObj_recordTypeEnum = 1
)
type UnionNullSomeDateObj_record struct {
Null *types.NullVal
SomeDateObj_record *SomeDateObj_record
UnionType UnionNullSomeDateObj_recordTypeEnum
}
func writeUnionNullSomeDateObj_record(r *UnionNullSomeDateObj_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 UnionNullSomeDateObj_recordTypeEnumSomeDateObj_record:
return writeSomeDateObj_record(r.SomeDateObj_record, w)
}
return fmt.Errorf("invalid value for *UnionNullSomeDateObj_record")
}
func NewUnionNullSomeDateObj_record() *UnionNullSomeDateObj_record {
return &UnionNullSomeDateObj_record{}
}
func (_ *UnionNullSomeDateObj_record) SetBoolean(v bool) { panic("Unsupported operation") }
func (_ *UnionNullSomeDateObj_record) SetInt(v int32) { panic("Unsupported operation") }
func (_ *UnionNullSomeDateObj_record) SetFloat(v float32) { panic("Unsupported operation") }
func (_ *UnionNullSomeDateObj_record) SetDouble(v float64) { panic("Unsupported operation") }
func (_ *UnionNullSomeDateObj_record) SetBytes(v []byte) { panic("Unsupported operation") }
func (_ *UnionNullSomeDateObj_record) SetString(v string) { panic("Unsupported operation") }
func (r *UnionNullSomeDateObj_record) SetLong(v int64) {
r.UnionType = (UnionNullSomeDateObj_recordTypeEnum)(v)
}
func (r *UnionNullSomeDateObj_record) Get(i int) types.Field {
switch i {
case 0:
return r.Null
case 1:
r.SomeDateObj_record = NewSomeDateObj_record()
return r.SomeDateObj_record
}
panic("Unknown field index")
}
func (_ *UnionNullSomeDateObj_record) NullField(i int) { panic("Unsupported operation") }
func (_ *UnionNullSomeDateObj_record) SetDefault(i int) { panic("Unsupported operation") }
func (_ *UnionNullSomeDateObj_record) AppendMap(key string) types.Field {
panic("Unsupported operation")
}
func (_ *UnionNullSomeDateObj_record) AppendArray() types.Field { panic("Unsupported operation") }
func (_ *UnionNullSomeDateObj_record) Finalize() {}
func (r *UnionNullSomeDateObj_record) MarshalJSON() ([]byte, error) {
if r == nil {
return []byte("null"), nil
}
switch r.UnionType {
case UnionNullSomeDateObj_recordTypeEnumSomeDateObj_record:
return json.Marshal(map[string]interface{}{"someDateObj_record": r.SomeDateObj_record})
}
return nil, fmt.Errorf("invalid value for *UnionNullSomeDateObj_record")
}
func (r *UnionNullSomeDateObj_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["someDateObj_record"]; ok {
r.UnionType = 1
return json.Unmarshal([]byte(value), &r.SomeDateObj_record)
}
return fmt.Errorf("invalid value for *UnionNullSomeDateObj_record")
}