This repository has been archived by the owner on Aug 21, 2023. It is now read-only.
/
model_notification_type.go
235 lines (197 loc) · 6.54 KB
/
model_notification_type.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
/*
File Data Reporting MnS
OAS 3.0.1 definition of the File Data Reporting MnS © 2021, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
API version: 17.1.0
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package openapi_FileDataReportingMnS
import (
"encoding/json"
"fmt"
)
// NotificationType - struct for NotificationType
type NotificationType struct {
AlarmNotificationTypes *AlarmNotificationTypes
CmNotificationTypes *CmNotificationTypes
FileNotificationTypes *FileNotificationTypes
HeartbeatNotificationTypes *HeartbeatNotificationTypes
PerfNotificationTypes *PerfNotificationTypes
}
// AlarmNotificationTypesAsNotificationType is a convenience function that returns AlarmNotificationTypes wrapped in NotificationType
func AlarmNotificationTypesAsNotificationType(v *AlarmNotificationTypes) NotificationType {
return NotificationType{
AlarmNotificationTypes: v,
}
}
// CmNotificationTypesAsNotificationType is a convenience function that returns CmNotificationTypes wrapped in NotificationType
func CmNotificationTypesAsNotificationType(v *CmNotificationTypes) NotificationType {
return NotificationType{
CmNotificationTypes: v,
}
}
// FileNotificationTypesAsNotificationType is a convenience function that returns FileNotificationTypes wrapped in NotificationType
func FileNotificationTypesAsNotificationType(v *FileNotificationTypes) NotificationType {
return NotificationType{
FileNotificationTypes: v,
}
}
// HeartbeatNotificationTypesAsNotificationType is a convenience function that returns HeartbeatNotificationTypes wrapped in NotificationType
func HeartbeatNotificationTypesAsNotificationType(v *HeartbeatNotificationTypes) NotificationType {
return NotificationType{
HeartbeatNotificationTypes: v,
}
}
// PerfNotificationTypesAsNotificationType is a convenience function that returns PerfNotificationTypes wrapped in NotificationType
func PerfNotificationTypesAsNotificationType(v *PerfNotificationTypes) NotificationType {
return NotificationType{
PerfNotificationTypes: v,
}
}
// Unmarshal JSON data into one of the pointers in the struct
func (dst *NotificationType) UnmarshalJSON(data []byte) error {
var err error
match := 0
// try to unmarshal data into AlarmNotificationTypes
err = newStrictDecoder(data).Decode(&dst.AlarmNotificationTypes)
if err == nil {
jsonAlarmNotificationTypes, _ := json.Marshal(dst.AlarmNotificationTypes)
if string(jsonAlarmNotificationTypes) == "{}" { // empty struct
dst.AlarmNotificationTypes = nil
} else {
match++
}
} else {
dst.AlarmNotificationTypes = nil
}
// try to unmarshal data into CmNotificationTypes
err = newStrictDecoder(data).Decode(&dst.CmNotificationTypes)
if err == nil {
jsonCmNotificationTypes, _ := json.Marshal(dst.CmNotificationTypes)
if string(jsonCmNotificationTypes) == "{}" { // empty struct
dst.CmNotificationTypes = nil
} else {
match++
}
} else {
dst.CmNotificationTypes = nil
}
// try to unmarshal data into FileNotificationTypes
err = newStrictDecoder(data).Decode(&dst.FileNotificationTypes)
if err == nil {
jsonFileNotificationTypes, _ := json.Marshal(dst.FileNotificationTypes)
if string(jsonFileNotificationTypes) == "{}" { // empty struct
dst.FileNotificationTypes = nil
} else {
match++
}
} else {
dst.FileNotificationTypes = nil
}
// try to unmarshal data into HeartbeatNotificationTypes
err = newStrictDecoder(data).Decode(&dst.HeartbeatNotificationTypes)
if err == nil {
jsonHeartbeatNotificationTypes, _ := json.Marshal(dst.HeartbeatNotificationTypes)
if string(jsonHeartbeatNotificationTypes) == "{}" { // empty struct
dst.HeartbeatNotificationTypes = nil
} else {
match++
}
} else {
dst.HeartbeatNotificationTypes = nil
}
// try to unmarshal data into PerfNotificationTypes
err = newStrictDecoder(data).Decode(&dst.PerfNotificationTypes)
if err == nil {
jsonPerfNotificationTypes, _ := json.Marshal(dst.PerfNotificationTypes)
if string(jsonPerfNotificationTypes) == "{}" { // empty struct
dst.PerfNotificationTypes = nil
} else {
match++
}
} else {
dst.PerfNotificationTypes = nil
}
if match > 1 { // more than 1 match
// reset to nil
dst.AlarmNotificationTypes = nil
dst.CmNotificationTypes = nil
dst.FileNotificationTypes = nil
dst.HeartbeatNotificationTypes = nil
dst.PerfNotificationTypes = nil
return fmt.Errorf("data matches more than one schema in oneOf(NotificationType)")
} else if match == 1 {
return nil // exactly one match
} else { // no match
return fmt.Errorf("data failed to match schemas in oneOf(NotificationType)")
}
}
// Marshal data from the first non-nil pointers in the struct to JSON
func (src NotificationType) MarshalJSON() ([]byte, error) {
if src.AlarmNotificationTypes != nil {
return json.Marshal(&src.AlarmNotificationTypes)
}
if src.CmNotificationTypes != nil {
return json.Marshal(&src.CmNotificationTypes)
}
if src.FileNotificationTypes != nil {
return json.Marshal(&src.FileNotificationTypes)
}
if src.HeartbeatNotificationTypes != nil {
return json.Marshal(&src.HeartbeatNotificationTypes)
}
if src.PerfNotificationTypes != nil {
return json.Marshal(&src.PerfNotificationTypes)
}
return nil, nil // no data in oneOf schemas
}
// Get the actual instance
func (obj *NotificationType) GetActualInstance() interface{} {
if obj == nil {
return nil
}
if obj.AlarmNotificationTypes != nil {
return obj.AlarmNotificationTypes
}
if obj.CmNotificationTypes != nil {
return obj.CmNotificationTypes
}
if obj.FileNotificationTypes != nil {
return obj.FileNotificationTypes
}
if obj.HeartbeatNotificationTypes != nil {
return obj.HeartbeatNotificationTypes
}
if obj.PerfNotificationTypes != nil {
return obj.PerfNotificationTypes
}
// all schemas are nil
return nil
}
type NullableNotificationType struct {
value *NotificationType
isSet bool
}
func (v NullableNotificationType) Get() *NotificationType {
return v.value
}
func (v *NullableNotificationType) Set(val *NotificationType) {
v.value = val
v.isSet = true
}
func (v NullableNotificationType) IsSet() bool {
return v.isSet
}
func (v *NullableNotificationType) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableNotificationType(val *NotificationType) *NullableNotificationType {
return &NullableNotificationType{value: val, isSet: true}
}
func (v NullableNotificationType) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableNotificationType) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}