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

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

18 Sep 2023 12:27PM UTC coverage: 13.146%. First build
#2660

push

web-flow
Merge fdf590561 into ba706cfa8

2480 of 2480 new or added lines in 54 files covered. (100.0%)

10283 of 78224 relevant lines covered (13.15%)

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/configurationwebhooks/PaymentInstrumentBankAccount.java
1
/*
2
 * Configuration webhooks
3
 *
4
 * The version of the OpenAPI document: 1
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.configurationwebhooks;
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.configurationwebhooks.IbanAccountIdentification;
20
import com.adyen.model.configurationwebhooks.USLocalAccountIdentification;
21
import com.fasterxml.jackson.annotation.JsonInclude;
22
import com.fasterxml.jackson.annotation.JsonProperty;
23
import com.fasterxml.jackson.annotation.JsonCreator;
24
import com.fasterxml.jackson.annotation.JsonTypeName;
25
import com.fasterxml.jackson.annotation.JsonValue;
26
import io.swagger.annotations.ApiModel;
27
import io.swagger.annotations.ApiModelProperty;
28
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
29
import com.fasterxml.jackson.core.JsonProcessingException;
30

31
import com.fasterxml.jackson.core.type.TypeReference;
32

33
import jakarta.ws.rs.core.GenericType;
34
import jakarta.ws.rs.core.Response;
35
import java.io.IOException;
36
import java.util.logging.Level;
37
import java.util.logging.Logger;
38
import java.util.ArrayList;
39
import java.util.Collections;
40
import java.util.HashSet;
41

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

59

60
@JsonDeserialize(using = PaymentInstrumentBankAccount.PaymentInstrumentBankAccountDeserializer.class)
61
@JsonSerialize(using = PaymentInstrumentBankAccount.PaymentInstrumentBankAccountSerializer.class)
62
public class PaymentInstrumentBankAccount extends AbstractOpenApiSchema {
63
    private static final Logger log = Logger.getLogger(PaymentInstrumentBankAccount.class.getName());
×
64

65
    public static class PaymentInstrumentBankAccountSerializer extends StdSerializer<PaymentInstrumentBankAccount> {
66
        public PaymentInstrumentBankAccountSerializer(Class<PaymentInstrumentBankAccount> t) {
67
            super(t);
×
68
        }
×
69

70
        public PaymentInstrumentBankAccountSerializer() {
71
            this(null);
×
72
        }
×
73

74
        @Override
75
        public void serialize(PaymentInstrumentBankAccount value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
76
            jgen.writeObject(value.getActualInstance());
×
77
        }
×
78
    }
79

80
    public static class PaymentInstrumentBankAccountDeserializer extends StdDeserializer<PaymentInstrumentBankAccount> {
81
        public PaymentInstrumentBankAccountDeserializer() {
82
            this(PaymentInstrumentBankAccount.class);
×
83
        }
×
84

85
        public PaymentInstrumentBankAccountDeserializer(Class<?> vc) {
86
            super(vc);
×
87
        }
×
88

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

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

124

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

152
            // Throw error if there is no match
153
            if (match == 0) {
×
154
                throw new IOException(String.format("Failed deserialization for PaymentInstrumentBankAccount: %d classes match result, expected 1", match));
×
155
            }
156
            // Log warning if there is more than one match
157
            if (match > 1) {
×
158
                log.log(Level.WARNING, String.format("Warning, indecisive deserialization for PaymentInstrumentBankAccount: %d classes match result, expected 1", match));
×
159
            }
160

161
            PaymentInstrumentBankAccount ret = new PaymentInstrumentBankAccount();
×
162
            ret.setActualInstance(deserialized);
×
163
            return ret;
×
164
        }
165

166
        /**
167
         * Handle deserialization of the 'null' value.
168
         */
169
        @Override
170
        public PaymentInstrumentBankAccount getNullValue(DeserializationContext ctxt) throws JsonMappingException {
171
            throw new JsonMappingException(ctxt.getParser(), "PaymentInstrumentBankAccount cannot be null");
×
172
        }
173
    }
174

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

178
    public PaymentInstrumentBankAccount() {
179
        super("oneOf", Boolean.FALSE);
×
180
    }
×
181

182
    public PaymentInstrumentBankAccount(IbanAccountIdentification o) {
183
        super("oneOf", Boolean.FALSE);
×
184
        setActualInstance(o);
×
185
    }
×
186

187
    public PaymentInstrumentBankAccount(USLocalAccountIdentification o) {
188
        super("oneOf", Boolean.FALSE);
×
189
        setActualInstance(o);
×
190
    }
×
191

192
    static {
193
        schemas.put("IbanAccountIdentification", new GenericType<IbanAccountIdentification>() {
×
194
        });
195
        schemas.put("USLocalAccountIdentification", new GenericType<USLocalAccountIdentification>() {
×
196
        });
197
        JSON.registerDescendants(PaymentInstrumentBankAccount.class, Collections.unmodifiableMap(schemas));
×
198
    }
×
199

200
    @Override
201
    public Map<String, GenericType> getSchemas() {
202
        return PaymentInstrumentBankAccount.schemas;
×
203
    }
204

205
    /**
206
     * Set the instance that matches the oneOf child schema, check
207
     * the instance parameter is valid against the oneOf child schemas:
208
     * IbanAccountIdentification, USLocalAccountIdentification
209
     *
210
     * It could be an instance of the 'oneOf' schemas.
211
     * The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf).
212
     */
213
    @Override
214
    public void setActualInstance(Object instance) {
215
        if (JSON.isInstanceOf(IbanAccountIdentification.class, instance, new HashSet<Class<?>>())) {
×
216
            super.setActualInstance(instance);
×
217
            return;
×
218
        }
219

220
        if (JSON.isInstanceOf(USLocalAccountIdentification.class, instance, new HashSet<Class<?>>())) {
×
221
            super.setActualInstance(instance);
×
222
            return;
×
223
        }
224

225
        throw new RuntimeException("Invalid instance type. Must be IbanAccountIdentification, USLocalAccountIdentification");
×
226
    }
227

228
    /**
229
     * Get the actual instance, which can be the following:
230
     * IbanAccountIdentification, USLocalAccountIdentification
231
     *
232
     * @return The actual instance (IbanAccountIdentification, USLocalAccountIdentification)
233
     */
234
    @Override
235
    public Object getActualInstance() {
236
        return super.getActualInstance();
×
237
    }
238

239
    /**
240
     * Get the actual instance of `IbanAccountIdentification`. If the actual instance is not `IbanAccountIdentification`,
241
     * the ClassCastException will be thrown.
242
     *
243
     * @return The actual instance of `IbanAccountIdentification`
244
     * @throws ClassCastException if the instance is not `IbanAccountIdentification`
245
     */
246
    public IbanAccountIdentification getIbanAccountIdentification() throws ClassCastException {
247
        return (IbanAccountIdentification)super.getActualInstance();
×
248
    }
249

250
    /**
251
     * Get the actual instance of `USLocalAccountIdentification`. If the actual instance is not `USLocalAccountIdentification`,
252
     * the ClassCastException will be thrown.
253
     *
254
     * @return The actual instance of `USLocalAccountIdentification`
255
     * @throws ClassCastException if the instance is not `USLocalAccountIdentification`
256
     */
257
    public USLocalAccountIdentification getUSLocalAccountIdentification() throws ClassCastException {
258
        return (USLocalAccountIdentification)super.getActualInstance();
×
259
    }
260

261
    /**
262
    * Create an instance of PaymentInstrumentBankAccount given an JSON string
263
    *
264
    * @param jsonString JSON string
265
    * @return An instance of PaymentInstrumentBankAccount
266
    * @throws IOException if the JSON string is invalid with respect to PaymentInstrumentBankAccount
267
    */
268
    public static PaymentInstrumentBankAccount fromJson(String jsonString) throws IOException {
269
        return JSON.getMapper().readValue(jsonString, PaymentInstrumentBankAccount.class);
×
270
    }
271

272
    /**
273
    * Convert an instance of PaymentInstrumentBankAccount to an JSON string
274
    *
275
    * @return JSON string
276
    */
277
    public String toJson() throws JsonProcessingException {
278
        return JSON.getMapper().writeValueAsString(this);
×
279
    }
280
}
281

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

© 2026 Coveralls, Inc