• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Adyen / adyen-java-api-library / #2657

18 Sep 2023 12:01PM UTC coverage: 13.219%. First build
#2657

push

web-flow
Merge 17bcee1e5 into ace7d0cdd

1759 of 1759 new or added lines in 33 files covered. (100.0%)

10287 of 77817 relevant lines covered (13.22%)

0.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/adyen/model/balanceplatform/TransferRouteRequirements.java
1
/*
2
 * Configuration API
3
 *
4
 * The version of the OpenAPI document: 2
5
 * 
6
 *
7
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
8
 * https://openapi-generator.tech
9
 * Do not edit the class manually.
10
 */
11

12

13
package com.adyen.model.balanceplatform;
14

15
import java.util.Objects;
16
import java.util.Arrays;
17
import java.util.Map;
18
import java.util.HashMap;
19
import com.adyen.model.balanceplatform.AddressRequirement;
20
import com.adyen.model.balanceplatform.AmountMinMaxRequirement;
21
import com.adyen.model.balanceplatform.BankAccountIdentificationTypeRequirement;
22
import com.adyen.model.balanceplatform.PaymentInstrumentRequirement;
23
import com.fasterxml.jackson.annotation.JsonInclude;
24
import com.fasterxml.jackson.annotation.JsonProperty;
25
import com.fasterxml.jackson.annotation.JsonCreator;
26
import com.fasterxml.jackson.annotation.JsonTypeName;
27
import com.fasterxml.jackson.annotation.JsonValue;
28
import io.swagger.annotations.ApiModel;
29
import io.swagger.annotations.ApiModelProperty;
30
import java.util.ArrayList;
31
import java.util.List;
32
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
33
import com.fasterxml.jackson.core.JsonProcessingException;
34

35
import com.fasterxml.jackson.core.type.TypeReference;
36

37
import jakarta.ws.rs.core.GenericType;
38
import jakarta.ws.rs.core.Response;
39
import java.io.IOException;
40
import java.util.logging.Level;
41
import java.util.logging.Logger;
42
import java.util.ArrayList;
43
import java.util.Collections;
44
import java.util.HashSet;
45

46
import com.fasterxml.jackson.core.JsonGenerator;
47
import com.fasterxml.jackson.core.JsonParser;
48
import com.fasterxml.jackson.core.JsonProcessingException;
49
import com.fasterxml.jackson.core.JsonToken;
50
import com.fasterxml.jackson.core.type.TypeReference;
51
import com.fasterxml.jackson.databind.DeserializationContext;
52
import com.fasterxml.jackson.databind.JsonMappingException;
53
import com.fasterxml.jackson.databind.JsonNode;
54
import com.fasterxml.jackson.databind.MapperFeature;
55
import com.fasterxml.jackson.databind.ObjectMapper;
56
import com.fasterxml.jackson.databind.SerializerProvider;
57
import com.fasterxml.jackson.databind.DeserializationFeature;
58
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
59
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
60
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
61
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
62

63

64
@JsonDeserialize(using = TransferRouteRequirements.TransferRouteRequirementsDeserializer.class)
65
@JsonSerialize(using = TransferRouteRequirements.TransferRouteRequirementsSerializer.class)
66
public class TransferRouteRequirements extends AbstractOpenApiSchema {
67
    private static final Logger log = Logger.getLogger(TransferRouteRequirements.class.getName());
×
68

69
    public static class TransferRouteRequirementsSerializer extends StdSerializer<TransferRouteRequirements> {
70
        public TransferRouteRequirementsSerializer(Class<TransferRouteRequirements> t) {
71
            super(t);
×
72
        }
×
73

74
        public TransferRouteRequirementsSerializer() {
75
            this(null);
×
76
        }
×
77

78
        @Override
79
        public void serialize(TransferRouteRequirements value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
80
            jgen.writeObject(value.getActualInstance());
×
81
        }
×
82
    }
83

84
    public static class TransferRouteRequirementsDeserializer extends StdDeserializer<TransferRouteRequirements> {
85
        public TransferRouteRequirementsDeserializer() {
86
            this(TransferRouteRequirements.class);
×
87
        }
×
88

89
        public TransferRouteRequirementsDeserializer(Class<?> vc) {
90
            super(vc);
×
91
        }
×
92

93
        @Override
94
        public TransferRouteRequirements deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
95
            JsonNode tree = jp.readValueAsTree();
×
96
            Object deserialized = null;
×
97
            boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
×
98
            int match = 0;
×
99
            JsonToken token = tree.traverse(jp.getCodec()).nextToken();
×
100

101
            // deserialize AddressRequirement
102
            try {
103
                boolean attemptParsing = true;
×
104
                // ensure that we respect type coercion as set on the client ObjectMapper
105
                if (AddressRequirement.class.equals(Integer.class) || AddressRequirement.class.equals(Long.class) || AddressRequirement.class.equals(Float.class) || AddressRequirement.class.equals(Double.class) || AddressRequirement.class.equals(Boolean.class) || AddressRequirement.class.equals(String.class)) {
×
106
                    attemptParsing = typeCoercion;
×
107
                    if (!attemptParsing) {
×
108
                        attemptParsing |= ((AddressRequirement.class.equals(Integer.class) || AddressRequirement.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
×
109
                        attemptParsing |= ((AddressRequirement.class.equals(Float.class) || AddressRequirement.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
×
110
                        attemptParsing |= (AddressRequirement.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
×
111
                        attemptParsing |= (AddressRequirement.class.equals(String.class) && token == JsonToken.VALUE_STRING);
×
112
                    }
113
                }
114
                // Checks if the unique type of the oneOf json matches any of the object TypeEnum values
115
                boolean typeMatch = Arrays.stream(AddressRequirement.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText()));
×
116
                if (attemptParsing || typeMatch) {
×
117
                    // Strict deserialization for oneOf models
118
                    deserialized = JSON.getMapper().readValue(tree.toString(), AddressRequirement.class);
×
119
                    // typeMatch should enforce proper deserialization
120
                    match++;
×
121
                    log.log(Level.FINER, "Input data matches schema 'AddressRequirement'");
×
122
                }
123
            } catch (Exception e) {
×
124
                // deserialization failed, continue
125
                log.log(Level.FINER, "Input data does not match schema 'AddressRequirement'", e);
×
126
            }
×
127

128

129
            // deserialize AmountMinMaxRequirement
130
            try {
131
                boolean attemptParsing = true;
×
132
                // ensure that we respect type coercion as set on the client ObjectMapper
133
                if (AmountMinMaxRequirement.class.equals(Integer.class) || AmountMinMaxRequirement.class.equals(Long.class) || AmountMinMaxRequirement.class.equals(Float.class) || AmountMinMaxRequirement.class.equals(Double.class) || AmountMinMaxRequirement.class.equals(Boolean.class) || AmountMinMaxRequirement.class.equals(String.class)) {
×
134
                    attemptParsing = typeCoercion;
×
135
                    if (!attemptParsing) {
×
136
                        attemptParsing |= ((AmountMinMaxRequirement.class.equals(Integer.class) || AmountMinMaxRequirement.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
×
137
                        attemptParsing |= ((AmountMinMaxRequirement.class.equals(Float.class) || AmountMinMaxRequirement.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
×
138
                        attemptParsing |= (AmountMinMaxRequirement.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
×
139
                        attemptParsing |= (AmountMinMaxRequirement.class.equals(String.class) && token == JsonToken.VALUE_STRING);
×
140
                    }
141
                }
142
                // Checks if the unique type of the oneOf json matches any of the object TypeEnum values
143
                boolean typeMatch = Arrays.stream(AmountMinMaxRequirement.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText()));
×
144
                if (attemptParsing || typeMatch) {
×
145
                    // Strict deserialization for oneOf models
146
                    deserialized = JSON.getMapper().readValue(tree.toString(), AmountMinMaxRequirement.class);
×
147
                    // typeMatch should enforce proper deserialization
148
                    match++;
×
149
                    log.log(Level.FINER, "Input data matches schema 'AmountMinMaxRequirement'");
×
150
                }
151
            } catch (Exception e) {
×
152
                // deserialization failed, continue
153
                log.log(Level.FINER, "Input data does not match schema 'AmountMinMaxRequirement'", e);
×
154
            }
×
155

156

157
            // deserialize BankAccountIdentificationTypeRequirement
158
            try {
159
                boolean attemptParsing = true;
×
160
                // ensure that we respect type coercion as set on the client ObjectMapper
161
                if (BankAccountIdentificationTypeRequirement.class.equals(Integer.class) || BankAccountIdentificationTypeRequirement.class.equals(Long.class) || BankAccountIdentificationTypeRequirement.class.equals(Float.class) || BankAccountIdentificationTypeRequirement.class.equals(Double.class) || BankAccountIdentificationTypeRequirement.class.equals(Boolean.class) || BankAccountIdentificationTypeRequirement.class.equals(String.class)) {
×
162
                    attemptParsing = typeCoercion;
×
163
                    if (!attemptParsing) {
×
164
                        attemptParsing |= ((BankAccountIdentificationTypeRequirement.class.equals(Integer.class) || BankAccountIdentificationTypeRequirement.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
×
165
                        attemptParsing |= ((BankAccountIdentificationTypeRequirement.class.equals(Float.class) || BankAccountIdentificationTypeRequirement.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
×
166
                        attemptParsing |= (BankAccountIdentificationTypeRequirement.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
×
167
                        attemptParsing |= (BankAccountIdentificationTypeRequirement.class.equals(String.class) && token == JsonToken.VALUE_STRING);
×
168
                    }
169
                }
170
                // Checks if the unique type of the oneOf json matches any of the object TypeEnum values
171
                boolean typeMatch = Arrays.stream(BankAccountIdentificationTypeRequirement.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText()));
×
172
                if (attemptParsing || typeMatch) {
×
173
                    // Strict deserialization for oneOf models
174
                    deserialized = JSON.getMapper().readValue(tree.toString(), BankAccountIdentificationTypeRequirement.class);
×
175
                    // typeMatch should enforce proper deserialization
176
                    match++;
×
177
                    log.log(Level.FINER, "Input data matches schema 'BankAccountIdentificationTypeRequirement'");
×
178
                }
179
            } catch (Exception e) {
×
180
                // deserialization failed, continue
181
                log.log(Level.FINER, "Input data does not match schema 'BankAccountIdentificationTypeRequirement'", e);
×
182
            }
×
183

184

185
            // deserialize PaymentInstrumentRequirement
186
            try {
187
                boolean attemptParsing = true;
×
188
                // ensure that we respect type coercion as set on the client ObjectMapper
189
                if (PaymentInstrumentRequirement.class.equals(Integer.class) || PaymentInstrumentRequirement.class.equals(Long.class) || PaymentInstrumentRequirement.class.equals(Float.class) || PaymentInstrumentRequirement.class.equals(Double.class) || PaymentInstrumentRequirement.class.equals(Boolean.class) || PaymentInstrumentRequirement.class.equals(String.class)) {
×
190
                    attemptParsing = typeCoercion;
×
191
                    if (!attemptParsing) {
×
192
                        attemptParsing |= ((PaymentInstrumentRequirement.class.equals(Integer.class) || PaymentInstrumentRequirement.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
×
193
                        attemptParsing |= ((PaymentInstrumentRequirement.class.equals(Float.class) || PaymentInstrumentRequirement.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
×
194
                        attemptParsing |= (PaymentInstrumentRequirement.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
×
195
                        attemptParsing |= (PaymentInstrumentRequirement.class.equals(String.class) && token == JsonToken.VALUE_STRING);
×
196
                    }
197
                }
198
                // Checks if the unique type of the oneOf json matches any of the object TypeEnum values
199
                boolean typeMatch = Arrays.stream(PaymentInstrumentRequirement.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText()));
×
200
                if (attemptParsing || typeMatch) {
×
201
                    // Strict deserialization for oneOf models
202
                    deserialized = JSON.getMapper().readValue(tree.toString(), PaymentInstrumentRequirement.class);
×
203
                    // typeMatch should enforce proper deserialization
204
                    match++;
×
205
                    log.log(Level.FINER, "Input data matches schema 'PaymentInstrumentRequirement'");
×
206
                }
207
            } catch (Exception e) {
×
208
                // deserialization failed, continue
209
                log.log(Level.FINER, "Input data does not match schema 'PaymentInstrumentRequirement'", e);
×
210
            }
×
211

212
            // Throw error if there is no match
213
            if (match == 0) {
×
214
                throw new IOException(String.format("Failed deserialization for TransferRouteRequirements: %d classes match result, expected 1", match));
×
215
            }
216
            // Log warning if there is more than one match
217
            if (match > 1) {
×
218
                log.log(Level.WARNING, String.format("Warning, indecisive deserialization for TransferRouteRequirements: %d classes match result, expected 1", match));
×
219
            }
220

221
            TransferRouteRequirements ret = new TransferRouteRequirements();
×
222
            ret.setActualInstance(deserialized);
×
223
            return ret;
×
224
        }
225

226
        /**
227
         * Handle deserialization of the 'null' value.
228
         */
229
        @Override
230
        public TransferRouteRequirements getNullValue(DeserializationContext ctxt) throws JsonMappingException {
231
            throw new JsonMappingException(ctxt.getParser(), "TransferRouteRequirements cannot be null");
×
232
        }
233
    }
234

235
    // store a list of schema names defined in oneOf
236
    public static final Map<String, GenericType> schemas = new HashMap<String, GenericType>();
×
237

238
    public TransferRouteRequirements() {
239
        super("oneOf", Boolean.FALSE);
×
240
    }
×
241

242
    public TransferRouteRequirements(AddressRequirement o) {
243
        super("oneOf", Boolean.FALSE);
×
244
        setActualInstance(o);
×
245
    }
×
246

247
    public TransferRouteRequirements(AmountMinMaxRequirement o) {
248
        super("oneOf", Boolean.FALSE);
×
249
        setActualInstance(o);
×
250
    }
×
251

252
    public TransferRouteRequirements(BankAccountIdentificationTypeRequirement o) {
253
        super("oneOf", Boolean.FALSE);
×
254
        setActualInstance(o);
×
255
    }
×
256

257
    public TransferRouteRequirements(PaymentInstrumentRequirement o) {
258
        super("oneOf", Boolean.FALSE);
×
259
        setActualInstance(o);
×
260
    }
×
261

262
    static {
263
        schemas.put("AddressRequirement", new GenericType<AddressRequirement>() {
×
264
        });
265
        schemas.put("AmountMinMaxRequirement", new GenericType<AmountMinMaxRequirement>() {
×
266
        });
267
        schemas.put("BankAccountIdentificationTypeRequirement", new GenericType<BankAccountIdentificationTypeRequirement>() {
×
268
        });
269
        schemas.put("PaymentInstrumentRequirement", new GenericType<PaymentInstrumentRequirement>() {
×
270
        });
271
        JSON.registerDescendants(TransferRouteRequirements.class, Collections.unmodifiableMap(schemas));
×
272
    }
×
273

274
    @Override
275
    public Map<String, GenericType> getSchemas() {
276
        return TransferRouteRequirements.schemas;
×
277
    }
278

279
    /**
280
     * Set the instance that matches the oneOf child schema, check
281
     * the instance parameter is valid against the oneOf child schemas:
282
     * AddressRequirement, AmountMinMaxRequirement, BankAccountIdentificationTypeRequirement, PaymentInstrumentRequirement
283
     *
284
     * It could be an instance of the 'oneOf' schemas.
285
     * The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf).
286
     */
287
    @Override
288
    public void setActualInstance(Object instance) {
289
        if (JSON.isInstanceOf(AddressRequirement.class, instance, new HashSet<Class<?>>())) {
×
290
            super.setActualInstance(instance);
×
291
            return;
×
292
        }
293

294
        if (JSON.isInstanceOf(AmountMinMaxRequirement.class, instance, new HashSet<Class<?>>())) {
×
295
            super.setActualInstance(instance);
×
296
            return;
×
297
        }
298

299
        if (JSON.isInstanceOf(BankAccountIdentificationTypeRequirement.class, instance, new HashSet<Class<?>>())) {
×
300
            super.setActualInstance(instance);
×
301
            return;
×
302
        }
303

304
        if (JSON.isInstanceOf(PaymentInstrumentRequirement.class, instance, new HashSet<Class<?>>())) {
×
305
            super.setActualInstance(instance);
×
306
            return;
×
307
        }
308

309
        throw new RuntimeException("Invalid instance type. Must be AddressRequirement, AmountMinMaxRequirement, BankAccountIdentificationTypeRequirement, PaymentInstrumentRequirement");
×
310
    }
311

312
    /**
313
     * Get the actual instance, which can be the following:
314
     * AddressRequirement, AmountMinMaxRequirement, BankAccountIdentificationTypeRequirement, PaymentInstrumentRequirement
315
     *
316
     * @return The actual instance (AddressRequirement, AmountMinMaxRequirement, BankAccountIdentificationTypeRequirement, PaymentInstrumentRequirement)
317
     */
318
    @Override
319
    public Object getActualInstance() {
320
        return super.getActualInstance();
×
321
    }
322

323
    /**
324
     * Get the actual instance of `AddressRequirement`. If the actual instance is not `AddressRequirement`,
325
     * the ClassCastException will be thrown.
326
     *
327
     * @return The actual instance of `AddressRequirement`
328
     * @throws ClassCastException if the instance is not `AddressRequirement`
329
     */
330
    public AddressRequirement getAddressRequirement() throws ClassCastException {
331
        return (AddressRequirement)super.getActualInstance();
×
332
    }
333

334
    /**
335
     * Get the actual instance of `AmountMinMaxRequirement`. If the actual instance is not `AmountMinMaxRequirement`,
336
     * the ClassCastException will be thrown.
337
     *
338
     * @return The actual instance of `AmountMinMaxRequirement`
339
     * @throws ClassCastException if the instance is not `AmountMinMaxRequirement`
340
     */
341
    public AmountMinMaxRequirement getAmountMinMaxRequirement() throws ClassCastException {
342
        return (AmountMinMaxRequirement)super.getActualInstance();
×
343
    }
344

345
    /**
346
     * Get the actual instance of `BankAccountIdentificationTypeRequirement`. If the actual instance is not `BankAccountIdentificationTypeRequirement`,
347
     * the ClassCastException will be thrown.
348
     *
349
     * @return The actual instance of `BankAccountIdentificationTypeRequirement`
350
     * @throws ClassCastException if the instance is not `BankAccountIdentificationTypeRequirement`
351
     */
352
    public BankAccountIdentificationTypeRequirement getBankAccountIdentificationTypeRequirement() throws ClassCastException {
353
        return (BankAccountIdentificationTypeRequirement)super.getActualInstance();
×
354
    }
355

356
    /**
357
     * Get the actual instance of `PaymentInstrumentRequirement`. If the actual instance is not `PaymentInstrumentRequirement`,
358
     * the ClassCastException will be thrown.
359
     *
360
     * @return The actual instance of `PaymentInstrumentRequirement`
361
     * @throws ClassCastException if the instance is not `PaymentInstrumentRequirement`
362
     */
363
    public PaymentInstrumentRequirement getPaymentInstrumentRequirement() throws ClassCastException {
364
        return (PaymentInstrumentRequirement)super.getActualInstance();
×
365
    }
366

367
    /**
368
    * Create an instance of TransferRouteRequirements given an JSON string
369
    *
370
    * @param jsonString JSON string
371
    * @return An instance of TransferRouteRequirements
372
    * @throws IOException if the JSON string is invalid with respect to TransferRouteRequirements
373
    */
374
    public static TransferRouteRequirements fromJson(String jsonString) throws IOException {
375
        return JSON.getMapper().readValue(jsonString, TransferRouteRequirements.class);
×
376
    }
377

378
    /**
379
    * Convert an instance of TransferRouteRequirements to an JSON string
380
    *
381
    * @return JSON string
382
    */
383
    public String toJson() throws JsonProcessingException {
384
        return JSON.getMapper().writeValueAsString(this);
×
385
    }
386
}
387

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc