@@ -203,6 +203,32 @@ public DonationPaymentMethod deserialize(JsonParser jp, DeserializationContext c
203203 log .log (Level .FINER , "Input data does not match schema 'PayWithGoogleDonations'" , e );
204204 }
205205
206+ // deserialize SepaDirectDebitDonations
207+ try {
208+ boolean attemptParsing = true ;
209+ if (attemptParsing ) {
210+ // Checks if the unique type of the oneOf json matches any of the object TypeEnum values
211+ boolean typeMatch = false ;
212+ if (tree .findValue ("type" ) != null ) {
213+ typeMatch =
214+ Arrays .stream (SepaDirectDebitDonations .TypeEnum .values ())
215+ .anyMatch ((t ) -> t .getValue ().equals (tree .findValue ("type" ).asText ()));
216+ }
217+
218+ if (typeMatch ) {
219+ deserialized = tree .traverse (jp .getCodec ()).readValueAs (SepaDirectDebitDonations .class );
220+ // TODO: there is no validation against JSON schema constraints
221+ // (min, max, enum, pattern...), this does not perform a strict JSON
222+ // validation, which means the 'match' count may be higher than it should be.
223+ match ++;
224+ log .log (Level .FINER , "Input data matches schema 'SepaDirectDebitDonations'" );
225+ }
226+ }
227+ } catch (Exception e ) {
228+ // deserialization failed, continue
229+ log .log (Level .FINER , "Input data does not match schema 'SepaDirectDebitDonations'" , e );
230+ }
231+
206232 if (match == 1 ) {
207233 DonationPaymentMethod ret = new DonationPaymentMethod ();
208234 ret .setActualInstance (deserialized );
@@ -254,12 +280,18 @@ public DonationPaymentMethod(PayWithGoogleDonations o) {
254280 setActualInstance (o );
255281 }
256282
283+ public DonationPaymentMethod (SepaDirectDebitDonations o ) {
284+ super ("oneOf" , Boolean .FALSE );
285+ setActualInstance (o );
286+ }
287+
257288 static {
258289 schemas .put ("ApplePayDonations" , new GenericType <ApplePayDonations >() {});
259290 schemas .put ("CardDonations" , new GenericType <CardDonations >() {});
260291 schemas .put ("GooglePayDonations" , new GenericType <GooglePayDonations >() {});
261292 schemas .put ("IdealDonations" , new GenericType <IdealDonations >() {});
262293 schemas .put ("PayWithGoogleDonations" , new GenericType <PayWithGoogleDonations >() {});
294+ schemas .put ("SepaDirectDebitDonations" , new GenericType <SepaDirectDebitDonations >() {});
263295 JSON .registerDescendants (DonationPaymentMethod .class , Collections .unmodifiableMap (schemas ));
264296 // Initialize and register the discriminator mappings.
265297 Map <String , Class <?>> mappings = new HashMap <>();
@@ -270,11 +302,13 @@ public DonationPaymentMethod(PayWithGoogleDonations o) {
270302 mappings .put ("networkToken" , CardDonations .class );
271303 mappings .put ("paywithgoogle" , PayWithGoogleDonations .class );
272304 mappings .put ("scheme" , CardDonations .class );
305+ mappings .put ("sepadirectdebit" , SepaDirectDebitDonations .class );
273306 mappings .put ("ApplePayDonations" , ApplePayDonations .class );
274307 mappings .put ("CardDonations" , CardDonations .class );
275308 mappings .put ("GooglePayDonations" , GooglePayDonations .class );
276309 mappings .put ("IdealDonations" , IdealDonations .class );
277310 mappings .put ("PayWithGoogleDonations" , PayWithGoogleDonations .class );
311+ mappings .put ("SepaDirectDebitDonations" , SepaDirectDebitDonations .class );
278312 mappings .put ("DonationPaymentMethod" , DonationPaymentMethod .class );
279313 JSON .registerDiscriminator (DonationPaymentMethod .class , "type" , mappings );
280314 }
@@ -287,7 +321,7 @@ public Map<String, GenericType<?>> getSchemas() {
287321 /**
288322 * Set the instance that matches the oneOf child schema, check the instance parameter is valid
289323 * against the oneOf child schemas: ApplePayDonations, CardDonations, GooglePayDonations,
290- * IdealDonations, PayWithGoogleDonations
324+ * IdealDonations, PayWithGoogleDonations, SepaDirectDebitDonations
291325 *
292326 * <p>It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a
293327 * composed schema (allOf, anyOf, oneOf).
@@ -319,16 +353,21 @@ public void setActualInstance(Object instance) {
319353 return ;
320354 }
321355
356+ if (JSON .isInstanceOf (SepaDirectDebitDonations .class , instance , new HashSet <>())) {
357+ super .setActualInstance (instance );
358+ return ;
359+ }
360+
322361 throw new RuntimeException (
323- "Invalid instance type. Must be ApplePayDonations, CardDonations, GooglePayDonations, IdealDonations, PayWithGoogleDonations" );
362+ "Invalid instance type. Must be ApplePayDonations, CardDonations, GooglePayDonations, IdealDonations, PayWithGoogleDonations, SepaDirectDebitDonations " );
324363 }
325364
326365 /**
327366 * Get the actual instance, which can be the following: ApplePayDonations, CardDonations,
328- * GooglePayDonations, IdealDonations, PayWithGoogleDonations
367+ * GooglePayDonations, IdealDonations, PayWithGoogleDonations, SepaDirectDebitDonations
329368 *
330369 * @return The actual instance (ApplePayDonations, CardDonations, GooglePayDonations,
331- * IdealDonations, PayWithGoogleDonations)
370+ * IdealDonations, PayWithGoogleDonations, SepaDirectDebitDonations )
332371 */
333372 @ Override
334373 public Object getActualInstance () {
@@ -390,6 +429,17 @@ public PayWithGoogleDonations getPayWithGoogleDonations() throws ClassCastExcept
390429 return (PayWithGoogleDonations ) super .getActualInstance ();
391430 }
392431
432+ /**
433+ * Get the actual instance of `SepaDirectDebitDonations`. If the actual instance is not
434+ * `SepaDirectDebitDonations`, the ClassCastException will be thrown.
435+ *
436+ * @return The actual instance of `SepaDirectDebitDonations`
437+ * @throws ClassCastException if the instance is not `SepaDirectDebitDonations`
438+ */
439+ public SepaDirectDebitDonations getSepaDirectDebitDonations () throws ClassCastException {
440+ return (SepaDirectDebitDonations ) super .getActualInstance ();
441+ }
442+
393443 /**
394444 * Create an instance of DonationPaymentMethod given an JSON string
395445 *
0 commit comments