/
model_transaction_warning.go
238 lines (197 loc) · 5.9 KB
/
model_transaction_warning.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
/*
Marlowe Runtime REST API
REST API for Marlowe Runtime
API version: 0.0.5.1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package marloweruntime
import (
"encoding/json"
"fmt"
)
// TransactionWarning - A transaction semantics warning.
type TransactionWarning struct {
AssertFail *AssertFail
NonPositiveDeposit *NonPositiveDeposit
NonPositivePayment *NonPositivePayment
PartialPayment *PartialPayment
VariableShadowing *VariableShadowing
}
// AssertFailAsTransactionWarning is a convenience function that returns AssertFail wrapped in TransactionWarning
func AssertFailAsTransactionWarning(v *AssertFail) TransactionWarning {
return TransactionWarning{
AssertFail: v,
}
}
// NonPositiveDepositAsTransactionWarning is a convenience function that returns NonPositiveDeposit wrapped in TransactionWarning
func NonPositiveDepositAsTransactionWarning(v *NonPositiveDeposit) TransactionWarning {
return TransactionWarning{
NonPositiveDeposit: v,
}
}
// NonPositivePaymentAsTransactionWarning is a convenience function that returns NonPositivePayment wrapped in TransactionWarning
func NonPositivePaymentAsTransactionWarning(v *NonPositivePayment) TransactionWarning {
return TransactionWarning{
NonPositivePayment: v,
}
}
// PartialPaymentAsTransactionWarning is a convenience function that returns PartialPayment wrapped in TransactionWarning
func PartialPaymentAsTransactionWarning(v *PartialPayment) TransactionWarning {
return TransactionWarning{
PartialPayment: v,
}
}
// VariableShadowingAsTransactionWarning is a convenience function that returns VariableShadowing wrapped in TransactionWarning
func VariableShadowingAsTransactionWarning(v *VariableShadowing) TransactionWarning {
return TransactionWarning{
VariableShadowing: v,
}
}
// Unmarshal JSON data into one of the pointers in the struct
func (dst *TransactionWarning) UnmarshalJSON(data []byte) error {
var err error
match := 0
// try to unmarshal data into AssertFail
err = newStrictDecoder(data).Decode(&dst.AssertFail)
if err == nil {
jsonAssertFail, _ := json.Marshal(dst.AssertFail)
if string(jsonAssertFail) == "{}" { // empty struct
dst.AssertFail = nil
} else {
match++
}
} else {
dst.AssertFail = nil
}
// try to unmarshal data into NonPositiveDeposit
err = newStrictDecoder(data).Decode(&dst.NonPositiveDeposit)
if err == nil {
jsonNonPositiveDeposit, _ := json.Marshal(dst.NonPositiveDeposit)
if string(jsonNonPositiveDeposit) == "{}" { // empty struct
dst.NonPositiveDeposit = nil
} else {
match++
}
} else {
dst.NonPositiveDeposit = nil
}
// try to unmarshal data into NonPositivePayment
err = newStrictDecoder(data).Decode(&dst.NonPositivePayment)
if err == nil {
jsonNonPositivePayment, _ := json.Marshal(dst.NonPositivePayment)
if string(jsonNonPositivePayment) == "{}" { // empty struct
dst.NonPositivePayment = nil
} else {
match++
}
} else {
dst.NonPositivePayment = nil
}
// try to unmarshal data into PartialPayment
err = newStrictDecoder(data).Decode(&dst.PartialPayment)
if err == nil {
jsonPartialPayment, _ := json.Marshal(dst.PartialPayment)
if string(jsonPartialPayment) == "{}" { // empty struct
dst.PartialPayment = nil
} else {
match++
}
} else {
dst.PartialPayment = nil
}
// try to unmarshal data into VariableShadowing
err = newStrictDecoder(data).Decode(&dst.VariableShadowing)
if err == nil {
jsonVariableShadowing, _ := json.Marshal(dst.VariableShadowing)
if string(jsonVariableShadowing) == "{}" { // empty struct
dst.VariableShadowing = nil
} else {
match++
}
} else {
dst.VariableShadowing = nil
}
if match > 1 { // more than 1 match
// reset to nil
dst.AssertFail = nil
dst.NonPositiveDeposit = nil
dst.NonPositivePayment = nil
dst.PartialPayment = nil
dst.VariableShadowing = nil
return fmt.Errorf("data matches more than one schema in oneOf(TransactionWarning)")
} else if match == 1 {
return nil // exactly one match
} else { // no match
return fmt.Errorf("data failed to match schemas in oneOf(TransactionWarning)")
}
}
// Marshal data from the first non-nil pointers in the struct to JSON
func (src TransactionWarning) MarshalJSON() ([]byte, error) {
if src.AssertFail != nil {
return json.Marshal(&src.AssertFail)
}
if src.NonPositiveDeposit != nil {
return json.Marshal(&src.NonPositiveDeposit)
}
if src.NonPositivePayment != nil {
return json.Marshal(&src.NonPositivePayment)
}
if src.PartialPayment != nil {
return json.Marshal(&src.PartialPayment)
}
if src.VariableShadowing != nil {
return json.Marshal(&src.VariableShadowing)
}
return nil, nil // no data in oneOf schemas
}
// Get the actual instance
func (obj *TransactionWarning) GetActualInstance() (interface{}) {
if obj == nil {
return nil
}
if obj.AssertFail != nil {
return obj.AssertFail
}
if obj.NonPositiveDeposit != nil {
return obj.NonPositiveDeposit
}
if obj.NonPositivePayment != nil {
return obj.NonPositivePayment
}
if obj.PartialPayment != nil {
return obj.PartialPayment
}
if obj.VariableShadowing != nil {
return obj.VariableShadowing
}
// all schemas are nil
return nil
}
type NullableTransactionWarning struct {
value *TransactionWarning
isSet bool
}
func (v NullableTransactionWarning) Get() *TransactionWarning {
return v.value
}
func (v *NullableTransactionWarning) Set(val *TransactionWarning) {
v.value = val
v.isSet = true
}
func (v NullableTransactionWarning) IsSet() bool {
return v.isSet
}
func (v *NullableTransactionWarning) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableTransactionWarning(val *TransactionWarning) *NullableTransactionWarning {
return &NullableTransactionWarning{value: val, isSet: true}
}
func (v NullableTransactionWarning) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableTransactionWarning) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}