-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodel_dfiq_inner.go
188 lines (158 loc) · 4.1 KB
/
model_dfiq_inner.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
/*
FastAPI
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
API version: 0.1.0
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package goyeti
import (
"encoding/json"
"fmt"
"gopkg.in/validator.v2"
)
// DfiqInner - struct for DfiqInner
type DfiqInner struct {
DFIQFacet *DFIQFacet
DFIQQuestion *DFIQQuestion
DFIQScenario *DFIQScenario
}
// DFIQFacetAsDfiqInner is a convenience function that returns DFIQFacet wrapped in DfiqInner
func DFIQFacetAsDfiqInner(v *DFIQFacet) DfiqInner {
return DfiqInner{
DFIQFacet: v,
}
}
// DFIQQuestionAsDfiqInner is a convenience function that returns DFIQQuestion wrapped in DfiqInner
func DFIQQuestionAsDfiqInner(v *DFIQQuestion) DfiqInner {
return DfiqInner{
DFIQQuestion: v,
}
}
// DFIQScenarioAsDfiqInner is a convenience function that returns DFIQScenario wrapped in DfiqInner
func DFIQScenarioAsDfiqInner(v *DFIQScenario) DfiqInner {
return DfiqInner{
DFIQScenario: v,
}
}
// Unmarshal JSON data into one of the pointers in the struct
func (dst *DfiqInner) UnmarshalJSON(data []byte) error {
var err error
match := 0
// try to unmarshal data into DFIQFacet
err = newStrictDecoder(data).Decode(&dst.DFIQFacet)
if err == nil {
jsonDFIQFacet, _ := json.Marshal(dst.DFIQFacet)
if string(jsonDFIQFacet) == "{}" { // empty struct
dst.DFIQFacet = nil
} else {
if err = validator.Validate(dst.DFIQFacet); err != nil {
dst.DFIQFacet = nil
} else {
match++
}
}
} else {
dst.DFIQFacet = nil
}
// try to unmarshal data into DFIQQuestion
err = newStrictDecoder(data).Decode(&dst.DFIQQuestion)
if err == nil {
jsonDFIQQuestion, _ := json.Marshal(dst.DFIQQuestion)
if string(jsonDFIQQuestion) == "{}" { // empty struct
dst.DFIQQuestion = nil
} else {
if err = validator.Validate(dst.DFIQQuestion); err != nil {
dst.DFIQQuestion = nil
} else {
match++
}
}
} else {
dst.DFIQQuestion = nil
}
// try to unmarshal data into DFIQScenario
err = newStrictDecoder(data).Decode(&dst.DFIQScenario)
if err == nil {
jsonDFIQScenario, _ := json.Marshal(dst.DFIQScenario)
if string(jsonDFIQScenario) == "{}" { // empty struct
dst.DFIQScenario = nil
} else {
if err = validator.Validate(dst.DFIQScenario); err != nil {
dst.DFIQScenario = nil
} else {
match++
}
}
} else {
dst.DFIQScenario = nil
}
if match > 1 { // more than 1 match
// reset to nil
dst.DFIQFacet = nil
dst.DFIQQuestion = nil
dst.DFIQScenario = nil
return fmt.Errorf("data matches more than one schema in oneOf(DfiqInner)")
} else if match == 1 {
return nil // exactly one match
} else { // no match
return fmt.Errorf("data failed to match schemas in oneOf(DfiqInner)")
}
}
// Marshal data from the first non-nil pointers in the struct to JSON
func (src DfiqInner) MarshalJSON() ([]byte, error) {
if src.DFIQFacet != nil {
return json.Marshal(&src.DFIQFacet)
}
if src.DFIQQuestion != nil {
return json.Marshal(&src.DFIQQuestion)
}
if src.DFIQScenario != nil {
return json.Marshal(&src.DFIQScenario)
}
return nil, nil // no data in oneOf schemas
}
// Get the actual instance
func (obj *DfiqInner) GetActualInstance() interface{} {
if obj == nil {
return nil
}
if obj.DFIQFacet != nil {
return obj.DFIQFacet
}
if obj.DFIQQuestion != nil {
return obj.DFIQQuestion
}
if obj.DFIQScenario != nil {
return obj.DFIQScenario
}
// all schemas are nil
return nil
}
type NullableDfiqInner struct {
value *DfiqInner
isSet bool
}
func (v NullableDfiqInner) Get() *DfiqInner {
return v.value
}
func (v *NullableDfiqInner) Set(val *DfiqInner) {
v.value = val
v.isSet = true
}
func (v NullableDfiqInner) IsSet() bool {
return v.isSet
}
func (v *NullableDfiqInner) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableDfiqInner(val *DfiqInner) *NullableDfiqInner {
return &NullableDfiqInner{value: val, isSet: true}
}
func (v NullableDfiqInner) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableDfiqInner) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}