-
Notifications
You must be signed in to change notification settings - Fork 26
/
model_ui_node_attributes.go
239 lines (198 loc) · 6.55 KB
/
model_ui_node_attributes.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
236
237
/*
Ory Identities API
This is the API specification for Ory Identities with features such as registration, login, recovery, account verification, profile settings, password reset, identity management, session management, email and sms delivery, and more.
API version: v1.0.0
Contact: [email protected]
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package client
import (
"encoding/json"
"fmt"
)
// UiNodeAttributes - struct for UiNodeAttributes
type UiNodeAttributes struct {
UiNodeAnchorAttributes *UiNodeAnchorAttributes
UiNodeImageAttributes *UiNodeImageAttributes
UiNodeInputAttributes *UiNodeInputAttributes
UiNodeScriptAttributes *UiNodeScriptAttributes
UiNodeTextAttributes *UiNodeTextAttributes
}
// UiNodeAnchorAttributesAsUiNodeAttributes is a convenience function that returns UiNodeAnchorAttributes wrapped in UiNodeAttributes
func UiNodeAnchorAttributesAsUiNodeAttributes(v *UiNodeAnchorAttributes) UiNodeAttributes {
return UiNodeAttributes{
UiNodeAnchorAttributes: v,
}
}
// UiNodeImageAttributesAsUiNodeAttributes is a convenience function that returns UiNodeImageAttributes wrapped in UiNodeAttributes
func UiNodeImageAttributesAsUiNodeAttributes(v *UiNodeImageAttributes) UiNodeAttributes {
return UiNodeAttributes{
UiNodeImageAttributes: v,
}
}
// UiNodeInputAttributesAsUiNodeAttributes is a convenience function that returns UiNodeInputAttributes wrapped in UiNodeAttributes
func UiNodeInputAttributesAsUiNodeAttributes(v *UiNodeInputAttributes) UiNodeAttributes {
return UiNodeAttributes{
UiNodeInputAttributes: v,
}
}
// UiNodeScriptAttributesAsUiNodeAttributes is a convenience function that returns UiNodeScriptAttributes wrapped in UiNodeAttributes
func UiNodeScriptAttributesAsUiNodeAttributes(v *UiNodeScriptAttributes) UiNodeAttributes {
return UiNodeAttributes{
UiNodeScriptAttributes: v,
}
}
// UiNodeTextAttributesAsUiNodeAttributes is a convenience function that returns UiNodeTextAttributes wrapped in UiNodeAttributes
func UiNodeTextAttributesAsUiNodeAttributes(v *UiNodeTextAttributes) UiNodeAttributes {
return UiNodeAttributes{
UiNodeTextAttributes: v,
}
}
// Unmarshal JSON data into one of the pointers in the struct
func (dst *UiNodeAttributes) UnmarshalJSON(data []byte) error {
var err error
match := 0
// try to unmarshal data into UiNodeAnchorAttributes
err = newStrictDecoder(data).Decode(&dst.UiNodeAnchorAttributes)
if err == nil {
jsonUiNodeAnchorAttributes, _ := json.Marshal(dst.UiNodeAnchorAttributes)
if string(jsonUiNodeAnchorAttributes) == "{}" { // empty struct
dst.UiNodeAnchorAttributes = nil
} else {
match++
}
} else {
dst.UiNodeAnchorAttributes = nil
}
// try to unmarshal data into UiNodeImageAttributes
err = newStrictDecoder(data).Decode(&dst.UiNodeImageAttributes)
if err == nil {
jsonUiNodeImageAttributes, _ := json.Marshal(dst.UiNodeImageAttributes)
if string(jsonUiNodeImageAttributes) == "{}" { // empty struct
dst.UiNodeImageAttributes = nil
} else {
match++
}
} else {
dst.UiNodeImageAttributes = nil
}
// try to unmarshal data into UiNodeInputAttributes
err = newStrictDecoder(data).Decode(&dst.UiNodeInputAttributes)
if err == nil {
jsonUiNodeInputAttributes, _ := json.Marshal(dst.UiNodeInputAttributes)
if string(jsonUiNodeInputAttributes) == "{}" { // empty struct
dst.UiNodeInputAttributes = nil
} else {
match++
}
} else {
dst.UiNodeInputAttributes = nil
}
// try to unmarshal data into UiNodeScriptAttributes
err = newStrictDecoder(data).Decode(&dst.UiNodeScriptAttributes)
if err == nil {
jsonUiNodeScriptAttributes, _ := json.Marshal(dst.UiNodeScriptAttributes)
if string(jsonUiNodeScriptAttributes) == "{}" { // empty struct
dst.UiNodeScriptAttributes = nil
} else {
match++
}
} else {
dst.UiNodeScriptAttributes = nil
}
// try to unmarshal data into UiNodeTextAttributes
err = newStrictDecoder(data).Decode(&dst.UiNodeTextAttributes)
if err == nil {
jsonUiNodeTextAttributes, _ := json.Marshal(dst.UiNodeTextAttributes)
if string(jsonUiNodeTextAttributes) == "{}" { // empty struct
dst.UiNodeTextAttributes = nil
} else {
match++
}
} else {
dst.UiNodeTextAttributes = nil
}
if match > 1 { // more than 1 match
// reset to nil
dst.UiNodeAnchorAttributes = nil
dst.UiNodeImageAttributes = nil
dst.UiNodeInputAttributes = nil
dst.UiNodeScriptAttributes = nil
dst.UiNodeTextAttributes = nil
return fmt.Errorf("Data matches more than one schema in oneOf(UiNodeAttributes)")
} else if match == 1 {
return nil // exactly one match
} else { // no match
return fmt.Errorf("Data failed to match schemas in oneOf(UiNodeAttributes)")
}
}
// Marshal data from the first non-nil pointers in the struct to JSON
func (src UiNodeAttributes) MarshalJSON() ([]byte, error) {
if src.UiNodeAnchorAttributes != nil {
return json.Marshal(&src.UiNodeAnchorAttributes)
}
if src.UiNodeImageAttributes != nil {
return json.Marshal(&src.UiNodeImageAttributes)
}
if src.UiNodeInputAttributes != nil {
return json.Marshal(&src.UiNodeInputAttributes)
}
if src.UiNodeScriptAttributes != nil {
return json.Marshal(&src.UiNodeScriptAttributes)
}
if src.UiNodeTextAttributes != nil {
return json.Marshal(&src.UiNodeTextAttributes)
}
return nil, nil // no data in oneOf schemas
}
// Get the actual instance
func (obj *UiNodeAttributes) GetActualInstance() (interface{}) {
if obj == nil {
return nil
}
if obj.UiNodeAnchorAttributes != nil {
return obj.UiNodeAnchorAttributes
}
if obj.UiNodeImageAttributes != nil {
return obj.UiNodeImageAttributes
}
if obj.UiNodeInputAttributes != nil {
return obj.UiNodeInputAttributes
}
if obj.UiNodeScriptAttributes != nil {
return obj.UiNodeScriptAttributes
}
if obj.UiNodeTextAttributes != nil {
return obj.UiNodeTextAttributes
}
// all schemas are nil
return nil
}
type NullableUiNodeAttributes struct {
value *UiNodeAttributes
isSet bool
}
func (v NullableUiNodeAttributes) Get() *UiNodeAttributes {
return v.value
}
func (v *NullableUiNodeAttributes) Set(val *UiNodeAttributes) {
v.value = val
v.isSet = true
}
func (v NullableUiNodeAttributes) IsSet() bool {
return v.isSet
}
func (v *NullableUiNodeAttributes) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableUiNodeAttributes(val *UiNodeAttributes) *NullableUiNodeAttributes {
return &NullableUiNodeAttributes{value: val, isSet: true}
}
func (v NullableUiNodeAttributes) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableUiNodeAttributes) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}