@@ -93,6 +93,8 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
9393 gson .getDelegateAdapter (this , TypeToken .get (VDSNCDataResult .class ));
9494 final TypeAdapter <VDSDataResult > adapterVDSDataResult =
9595 gson .getDelegateAdapter (this , TypeToken .get (VDSDataResult .class ));
96+ final TypeAdapter <MDLResult > adapterMDLResult =
97+ gson .getDelegateAdapter (this , TypeToken .get (MDLResult .class ));
9698
9799 return (TypeAdapter <T >)
98100 new TypeAdapter <ContainerListListInner >() {
@@ -301,8 +303,15 @@ public void write(JsonWriter out, ContainerListListInner value) throws IOExcepti
301303 elementAdapter .write (out , element );
302304 return ;
303305 }
306+ // check if the actual instance is of the type `MDLResult`
307+ if (value .getActualInstance () instanceof MDLResult ) {
308+ JsonElement element =
309+ adapterMDLResult .toJsonTree ((MDLResult ) value .getActualInstance ());
310+ elementAdapter .write (out , element );
311+ return ;
312+ }
304313 throw new IOException (
305- "Failed to serialize as the type doesn't match oneOf schemas: AuthenticityResult, BarcodePositionResult, ByteArrayResult, ChosenDocumentTypeResult, DocBarCodeInfo, DocumentBinaryInfoResult, DocumentImageResult, DocumentPositionResult, DocumentTypesCandidatesResult, EncryptedRCLResult, FaceDetectionResult, GraphicsResult, ImageQualityResult, ImagesResult, LexicalAnalysisResult, LicenseResult, MRZDetectorResult, MRZPositionResult, MRZTestQualityResult, RFIDGraphicsInfoResult, RFIDTextDataResult, StatusResult, TextDataResult, TextResult, VDSDataResult, VDSNCDataResult" );
314+ "Failed to serialize as the type doesn't match oneOf schemas: AuthenticityResult, BarcodePositionResult, ByteArrayResult, ChosenDocumentTypeResult, DocBarCodeInfo, DocumentBinaryInfoResult, DocumentImageResult, DocumentPositionResult, DocumentTypesCandidatesResult, EncryptedRCLResult, FaceDetectionResult, GraphicsResult, ImageQualityResult, ImagesResult, LexicalAnalysisResult, LicenseResult, MDLResult, MRZDetectorResult, MRZPositionResult, MRZTestQualityResult, RFIDGraphicsInfoResult, RFIDTextDataResult, StatusResult, TextDataResult, TextResult, VDSDataResult, VDSNCDataResult" );
306315 }
307316
308317 @ Override
@@ -699,6 +708,20 @@ public ContainerListListInner read(JsonReader in) throws IOException {
699708 "Deserialization for VDSDataResult failed with `%s`." , e .getMessage ()));
700709 log .log (Level .FINER , "Input data does not match schema 'VDSDataResult'" , e );
701710 }
711+ // deserialize MDLResult
712+ try {
713+ // validate the JSON object to see if any exception is thrown
714+ MDLResult .validateJsonElement (jsonElement );
715+ actualAdapter = adapterMDLResult ;
716+ match ++;
717+ log .log (Level .FINER , "Input data matches schema 'MDLResult'" );
718+ } catch (Exception e ) {
719+ // deserialization failed, continue
720+ errorMessages .add (
721+ String .format (
722+ "Deserialization for MDLResult failed with `%s`." , e .getMessage ()));
723+ log .log (Level .FINER , "Input data does not match schema 'MDLResult'" , e );
724+ }
702725
703726 if (match == 1 ) {
704727 ContainerListListInner ret = new ContainerListListInner ();
@@ -754,6 +777,7 @@ public ContainerListListInner(Object o) {
754777 schemas .put ("RFIDTextDataResult" , RFIDTextDataResult .class );
755778 schemas .put ("VDSNCDataResult" , VDSNCDataResult .class );
756779 schemas .put ("VDSDataResult" , VDSDataResult .class );
780+ schemas .put ("MDLResult" , MDLResult .class );
757781 }
758782
759783 @ Override
@@ -767,7 +791,7 @@ public Map<String, Class<?>> getSchemas() {
767791 * ChosenDocumentTypeResult, DocBarCodeInfo, DocumentBinaryInfoResult, DocumentImageResult,
768792 * DocumentPositionResult, DocumentTypesCandidatesResult, EncryptedRCLResult, FaceDetectionResult,
769793 * GraphicsResult, ImageQualityResult, ImagesResult, LexicalAnalysisResult, LicenseResult,
770- * MRZDetectorResult, MRZPositionResult, MRZTestQualityResult, RFIDGraphicsInfoResult,
794+ * MDLResult, MRZDetectorResult, MRZPositionResult, MRZTestQualityResult, RFIDGraphicsInfoResult,
771795 * RFIDTextDataResult, StatusResult, TextDataResult, TextResult, VDSDataResult, VDSNCDataResult
772796 *
773797 * <p>It could be an instance of the 'oneOf' schemas.
@@ -904,24 +928,29 @@ public void setActualInstance(Object instance) {
904928 return ;
905929 }
906930
931+ if (instance instanceof MDLResult ) {
932+ super .setActualInstance (instance );
933+ return ;
934+ }
935+
907936 throw new RuntimeException (
908- "Invalid instance type. Must be AuthenticityResult, BarcodePositionResult, ByteArrayResult, ChosenDocumentTypeResult, DocBarCodeInfo, DocumentBinaryInfoResult, DocumentImageResult, DocumentPositionResult, DocumentTypesCandidatesResult, EncryptedRCLResult, FaceDetectionResult, GraphicsResult, ImageQualityResult, ImagesResult, LexicalAnalysisResult, LicenseResult, MRZDetectorResult, MRZPositionResult, MRZTestQualityResult, RFIDGraphicsInfoResult, RFIDTextDataResult, StatusResult, TextDataResult, TextResult, VDSDataResult, VDSNCDataResult" );
937+ "Invalid instance type. Must be AuthenticityResult, BarcodePositionResult, ByteArrayResult, ChosenDocumentTypeResult, DocBarCodeInfo, DocumentBinaryInfoResult, DocumentImageResult, DocumentPositionResult, DocumentTypesCandidatesResult, EncryptedRCLResult, FaceDetectionResult, GraphicsResult, ImageQualityResult, ImagesResult, LexicalAnalysisResult, LicenseResult, MDLResult, MRZDetectorResult, MRZPositionResult, MRZTestQualityResult, RFIDGraphicsInfoResult, RFIDTextDataResult, StatusResult, TextDataResult, TextResult, VDSDataResult, VDSNCDataResult" );
909938 }
910939
911940 /**
912941 * Get the actual instance, which can be the following: AuthenticityResult, BarcodePositionResult,
913942 * ByteArrayResult, ChosenDocumentTypeResult, DocBarCodeInfo, DocumentBinaryInfoResult,
914943 * DocumentImageResult, DocumentPositionResult, DocumentTypesCandidatesResult, EncryptedRCLResult,
915944 * FaceDetectionResult, GraphicsResult, ImageQualityResult, ImagesResult, LexicalAnalysisResult,
916- * LicenseResult, MRZDetectorResult, MRZPositionResult, MRZTestQualityResult,
945+ * LicenseResult, MDLResult, MRZDetectorResult, MRZPositionResult, MRZTestQualityResult,
917946 * RFIDGraphicsInfoResult, RFIDTextDataResult, StatusResult, TextDataResult, TextResult,
918947 * VDSDataResult, VDSNCDataResult
919948 *
920949 * @return The actual instance (AuthenticityResult, BarcodePositionResult, ByteArrayResult,
921950 * ChosenDocumentTypeResult, DocBarCodeInfo, DocumentBinaryInfoResult, DocumentImageResult,
922951 * DocumentPositionResult, DocumentTypesCandidatesResult, EncryptedRCLResult,
923952 * FaceDetectionResult, GraphicsResult, ImageQualityResult, ImagesResult,
924- * LexicalAnalysisResult, LicenseResult, MRZDetectorResult, MRZPositionResult,
953+ * LexicalAnalysisResult, LicenseResult, MDLResult, MRZDetectorResult, MRZPositionResult,
925954 * MRZTestQualityResult, RFIDGraphicsInfoResult, RFIDTextDataResult, StatusResult,
926955 * TextDataResult, TextResult, VDSDataResult, VDSNCDataResult)
927956 */
@@ -1218,6 +1247,17 @@ public VDSDataResult getVDSDataResult() throws ClassCastException {
12181247 return (VDSDataResult ) super .getActualInstance ();
12191248 }
12201249
1250+ /**
1251+ * Get the actual instance of `MDLResult`. If the actual instance is not `MDLResult`, the
1252+ * ClassCastException will be thrown.
1253+ *
1254+ * @return The actual instance of `MDLResult`
1255+ * @throws ClassCastException if the instance is not `MDLResult`
1256+ */
1257+ public MDLResult getMDLResult () throws ClassCastException {
1258+ return (MDLResult ) super .getActualInstance ();
1259+ }
1260+
12211261 /**
12221262 * Validates the JSON Element and throws an exception if issues found
12231263 *
@@ -1477,10 +1517,19 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
14771517 String .format ("Deserialization for VDSDataResult failed with `%s`." , e .getMessage ()));
14781518 // continue to the next one
14791519 }
1520+ // validate the json string with MDLResult
1521+ try {
1522+ MDLResult .validateJsonElement (jsonElement );
1523+ validCount ++;
1524+ } catch (Exception e ) {
1525+ errorMessages .add (
1526+ String .format ("Deserialization for MDLResult failed with `%s`." , e .getMessage ()));
1527+ // continue to the next one
1528+ }
14801529 if (validCount != 1 ) {
14811530 throw new IOException (
14821531 String .format (
1483- "The JSON string is invalid for ContainerListListInner with oneOf schemas: AuthenticityResult, BarcodePositionResult, ByteArrayResult, ChosenDocumentTypeResult, DocBarCodeInfo, DocumentBinaryInfoResult, DocumentImageResult, DocumentPositionResult, DocumentTypesCandidatesResult, EncryptedRCLResult, FaceDetectionResult, GraphicsResult, ImageQualityResult, ImagesResult, LexicalAnalysisResult, LicenseResult, MRZDetectorResult, MRZPositionResult, MRZTestQualityResult, RFIDGraphicsInfoResult, RFIDTextDataResult, StatusResult, TextDataResult, TextResult, VDSDataResult, VDSNCDataResult. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s" ,
1532+ "The JSON string is invalid for ContainerListListInner with oneOf schemas: AuthenticityResult, BarcodePositionResult, ByteArrayResult, ChosenDocumentTypeResult, DocBarCodeInfo, DocumentBinaryInfoResult, DocumentImageResult, DocumentPositionResult, DocumentTypesCandidatesResult, EncryptedRCLResult, FaceDetectionResult, GraphicsResult, ImageQualityResult, ImagesResult, LexicalAnalysisResult, LicenseResult, MDLResult, MRZDetectorResult, MRZPositionResult, MRZTestQualityResult, RFIDGraphicsInfoResult, RFIDTextDataResult, StatusResult, TextDataResult, TextResult, VDSDataResult, VDSNCDataResult. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s" ,
14841533 validCount , errorMessages , jsonElement .toString ()));
14851534 }
14861535 }
0 commit comments