From 6302e63a0f56486d9e8affccec6b49b2951136fe Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 16 Jun 2026 12:16:03 +0000 Subject: [PATCH] Update SDK to version v3.93.2 - Generated from OpenAPI spec version v3.93.2 - Auto-generated by GitHub Actions --- .sdk-version | 2 +- README.md | 17 +- build.gradle | 4 +- build.sbt | 4 +- docs/AIDecompFunctionMapping.md | 24 +- docs/APIError.md | 2 +- docs/AnalysesCoreApi.md | 10 +- docs/AnalysisBulkAddTagsResponseItem.md | 4 +- docs/AnalysisCreateRequest.md | 4 +- docs/AnalysisFunctionMatchingRequest.md | 2 +- docs/AnalysisLogMessage.md | 4 +- docs/AnalysisLogs.md | 2 +- docs/AnalysisRecord.md | 4 +- docs/AnalysisReport.md | 30 +- docs/AnalysisStringItem.md | 2 +- docs/Argument.md | 2 +- docs/Artifact.md | 46 + docs/AutoUnstripResponse.md | 10 +- docs/BaseResponse.md | 6 +- ...ResponseAdditionalDetailsStatusResponse.md | 6 +- ...BaseResponseAnalysisBulkAddTagsResponse.md | 6 +- docs/BaseResponseAnalysisCreateResponse.md | 6 +- docs/BaseResponseAnalysisDetailResponse.md | 6 +- docs/BaseResponseAnalysisFunctionMapping.md | 6 +- docs/BaseResponseAnalysisFunctions.md | 6 +- docs/BaseResponseAnalysisFunctionsList.md | 6 +- docs/BaseResponseAnalysisStringsResponse.md | 6 +- ...seResponseAnalysisStringsStatusResponse.md | 6 +- docs/BaseResponseAnalysisTags.md | 6 +- .../BaseResponseAnalysisUpdateTagsResponse.md | 6 +- docs/BaseResponseBasic.md | 6 +- ...seResponseBinariesRelatedStatusResponse.md | 6 +- docs/BaseResponseBinaryAdditionalResponse.md | 6 +- docs/BaseResponseBinaryDetailsResponse.md | 6 +- docs/BaseResponseBinaryExternalsResponse.md | 6 +- docs/BaseResponseBinarySearchResponse.md | 6 +- docs/BaseResponseBool.md | 6 +- ...eResponseCalleesCallerFunctionsResponse.md | 6 +- docs/BaseResponseCapabilities.md | 6 +- docs/BaseResponseCapabilitiesAgentResponse.md | 6 +- docs/BaseResponseChildBinariesResponse.md | 6 +- ...esponseCollectionBinariesUpdateResponse.md | 6 +- docs/BaseResponseCollectionResponse.md | 6 +- docs/BaseResponseCollectionSearchResponse.md | 6 +- ...aseResponseCollectionTagsUpdateResponse.md | 6 +- docs/BaseResponseCommentResponse.md | 6 +- docs/BaseResponseConfigResponse.md | 6 +- docs/BaseResponseCreated.md | 6 +- docs/BaseResponseDict.md | 6 +- docs/BaseResponseExternalResponse.md | 6 +- docs/BaseResponseFunctionBlocksResponse.md | 6 +- .../BaseResponseFunctionCapabilityResponse.md | 6 +- docs/BaseResponseFunctionDataTypes.md | 6 +- docs/BaseResponseFunctionDataTypesList.md | 6 +- docs/BaseResponseFunctionSearchResponse.md | 6 +- docs/BaseResponseFunctionStringsResponse.md | 6 +- docs/BaseResponseFunctionTaskResponse.md | 6 +- docs/BaseResponseFunctionsDetailResponse.md | 6 +- docs/BaseResponseGenerateFunctionDataTypes.md | 6 +- docs/BaseResponseGenerationStatusList.md | 6 +- docs/BaseResponseGetAiDecompilationTask.md | 6 +- docs/BaseResponseGetPublicUserResponse.md | 6 +- ...ponseListCalleesCallerFunctionsResponse.md | 6 +- docs/BaseResponseListCollectionResults.md | 6 +- docs/BaseResponseListCommentResponse.md | 6 +- docs/BaseResponseListDieMatch.md | 6 +- docs/BaseResponseListFunctionNameHistory.md | 6 +- docs/BaseResponseListSBOM.md | 6 +- docs/BaseResponseListUserActivityResponse.md | 6 +- docs/BaseResponseLogs.md | 6 +- docs/BaseResponseModelsResponse.md | 6 +- docs/BaseResponseParams.md | 6 +- .../BaseResponseQueuedWorkflowTaskResponse.md | 6 +- docs/BaseResponseRecent.md | 6 +- docs/BaseResponseReportAnalysisResponse.md | 6 +- docs/BaseResponseStatus.md | 6 +- docs/BaseResponseStr.md | 6 +- docs/BaseResponseTagSearchResponse.md | 6 +- docs/BaseResponseTaskResponse.md | 6 +- docs/BaseResponseTaskStatusResponse.md | 6 +- docs/BaseResponseTriageReportResponse.md | 6 +- ...etAiDecompilationRatingResponseNoneType.md | 6 +- docs/BaseResponseUploadResponse.md | 6 +- docs/BaseResponseVulnerabilities.md | 6 +- docs/BaseResponseXrefResponse.md | 6 +- docs/Basic.md | 6 +- docs/BatchRenameInputBody.md | 2 +- docs/BinaryConfig.md | 2 +- docs/BinarySearchResult.md | 2 +- docs/CalleeFunctionInfo.md | 2 +- docs/CallerFunctionInfo.md | 2 +- docs/ChildBinariesResponse.md | 2 +- docs/CollectionListItem.md | 2 +- docs/CollectionResponse.md | 6 +- docs/CollectionSearchResult.md | 6 +- docs/CollectionsApi.md | 4 +- docs/CommentsData.md | 2 +- docs/Connection.md | 7 +- ...xtractedFiles.md => ConsoleOutputEntry.md} | 4 +- docs/ConversationWithEvents.md | 2 +- docs/ConversationsApi.md | 6 +- docs/CreateCollectionOutputBody.md | 2 +- docs/CreateConversationRequest.md | 2 +- docs/DnsQuery.md | 5 +- docs/DynamicExecutionStatusResponse.md | 2 +- docs/Enumeration.md | 2 +- docs/EventAttemptFailed.md | 2 +- docs/EventAttemptStarted.md | 2 +- docs/EventCONTEXTCOMPACTED.md | 2 +- docs/EventDecompFailed.md | 2 +- docs/EventDecompFinished.md | 2 +- docs/EventProse.md | 2 +- docs/EventRUNCANCELLED.md | 2 +- docs/EventRUNERROR.md | 2 +- docs/EventRUNFINISHED.md | 2 +- docs/EventRUNSTARTED.md | 2 +- docs/EventRenameApplied.md | 2 +- docs/EventSTEPFINISHED.md | 2 +- docs/EventSTEPSTARTED.md | 2 +- docs/EventSourceDelta.md | 2 +- docs/EventSourceReset.md | 2 +- docs/EventTEXTMESSAGECONTENT.md | 2 +- docs/EventTEXTMESSAGEEND.md | 2 +- docs/EventTEXTMESSAGESTART.md | 2 +- docs/EventTITLEUPDATED.md | 2 +- docs/EventTOOLCALLARGSDELTA.md | 2 +- docs/EventTOOLCALLEND.md | 2 +- docs/EventTOOLCALLRESULT.md | 2 +- docs/EventTOOLCALLSTART.md | 2 +- docs/EventTOOLCONFIRMATIONREQUIRED.md | 2 +- docs/EventWarning.md | 2 +- docs/ExtractedFileEntry.md | 22 - docs/ExtractedURL.md | 2 +- docs/FileActivityEntry.md | 2 +- docs/FirmwareApi.md | 4 +- ...InputFuncDepsInner.md => FuncDepsInner.md} | 4 +- docs/FunctionBlockDestinationResponse.md | 2 +- docs/FunctionBlockResponse.md | 2 +- docs/FunctionBlocksResponse.md | 2 +- docs/FunctionBoundary.md | 2 +- docs/FunctionDataTypes.md | 4 +- docs/FunctionDataTypesListItem.md | 4 +- docs/FunctionHeader.md | 2 +- docs/FunctionInfoInput.md | 4 +- docs/FunctionInfoOutput.md | 4 +- docs/FunctionMatchingRequest.md | 2 +- docs/FunctionMatchingResponse.md | 18 +- docs/FunctionTypeInput.md | 4 +- docs/FunctionTypeOutput.md | 20 - docs/FunctionsAiDecompilationApi.md | 6 +- docs/FunctionsCoreApi.md | 12 +- docs/FunctionsRenamingHistoryApi.md | 6 +- docs/GetAiDecompilationRatingResponse.md | 2 +- docs/GetAiDecompilationTask.md | 16 +- docs/GetCollectionOutputBody.md | 2 +- docs/GetProductsOutputBody.md | 2 +- docs/GetSubscriptionOutputBody.md | 4 +- docs/GlobalVariable.md | 2 +- docs/HttpRequest.md | 9 +- docs/IOC.md | 6 +- docs/ListAnalysisStringsOutputBody.md | 2 +- docs/ListCollectionsOutputBody.md | 2 +- docs/ListFunctionStringsOutputBody.md | 2 +- docs/MatchedFunctionSuggestion.md | 2 +- docs/MutexEntry.md | 2 +- docs/NameSourceType.md | 6 +- docs/NetworkActivity.md | 8 +- docs/Params.md | 2 +- docs/PatchCollectionBinariesOutputBody.md | 2 +- docs/PcapBodyInfo.md | 19 + docs/ProcessActivityEntry.md | 2 +- docs/ProcessMemdumps.md | 2 +- docs/ProcessNode.md | 2 +- docs/ProcessTree.md | 2 +- docs/ProductOutput.md | 2 +- docs/ReAnalysisForm.md | 2 +- docs/RegistryOperation.md | 2 +- docs/RelativeBinaryResponse.md | 2 +- docs/ReportEvent.md | 7 +- docs/ReportInfo.md | 4 +- docs/SandboxOptions.md | 2 +- docs/ScheduledTaskEntry.md | 2 +- docs/SearchApi.md | 4 +- docs/SendMessageRequest.md | 2 +- ...ponseInner.md => ServerSentEventsInner.md} | 4 +- ...onseInner.md => ServerSentEventsInner1.md} | 4 +- docs/ServiceEntry.md | 2 +- docs/StackVariable.md | 2 +- docs/Structure.md | 4 +- docs/StructureMember.md | 2 +- docs/SubmitUserFeedbackRequest.md | 2 +- docs/TagItem.md | 2 +- docs/TcpCarvedFile.md | 20 + docs/TokenisedData.md | 2 +- docs/TypeDefinition.md | 2 +- docs/UpsertAiDecomplationRatingRequest.md | 2 +- docs/WorkflowProgress.md | 2 +- docs/XrefFromResponse.md | 2 +- docs/XrefToResponse.md | 2 +- pom.xml | 4 +- .../java/ai/reveng/api/AnalysesCoreApi.java | 32 +- .../java/ai/reveng/api/CollectionsApi.java | 16 +- .../java/ai/reveng/api/ConversationsApi.java | 18 +- src/main/java/ai/reveng/api/FirmwareApi.java | 11 +- .../api/FunctionsAiDecompilationApi.java | 18 +- .../java/ai/reveng/api/FunctionsCoreApi.java | 32 +- .../api/FunctionsRenamingHistoryApi.java | 16 +- src/main/java/ai/reveng/api/SearchApi.java | 16 +- .../java/ai/reveng/invoker/ApiClient.java | 2 +- .../java/ai/reveng/invoker/ApiException.java | 3 +- .../java/ai/reveng/invoker/Configuration.java | 2 +- src/main/java/ai/reveng/invoker/JSON.java | 13 +- .../reveng/model/AIDecompFunctionMapping.java | 114 +-- .../model/AIDecompInverseFunctionMapItem.java | 116 +-- .../model/AIDecompInverseStringMapItem.java | 116 +-- src/main/java/ai/reveng/model/APIError.java | 116 +-- .../reveng/model/AbstractOpenApiSchema.java | 5 +- .../ai/reveng/model/AddCalleeInputBody.java | 116 +-- .../reveng/model/AddUserStringInputBody.java | 116 +-- .../AddUserStringToFunctionInputBody.java | 116 +-- .../AdditionalDetailsStatusResponse.java | 15 +- src/main/java/ai/reveng/model/Addr.java | 22 +- .../reveng/model/AiDecompilationRating.java | 2 - .../model/AiDecompilationTaskStatus.java | 2 - .../ai/reveng/model/AiUnstripRequest.java | 11 +- .../ai/reveng/model/AnalysisAccessInfo.java | 15 +- .../model/AnalysisBasicInfoOutputBody.java | 128 +-- .../model/AnalysisBulkAddTagsRequest.java | 17 +- .../model/AnalysisBulkAddTagsResponse.java | 31 +- .../AnalysisBulkAddTagsResponseItem.java | 21 +- .../java/ai/reveng/model/AnalysisConfig.java | 11 +- .../reveng/model/AnalysisCreateRequest.java | 27 +- .../reveng/model/AnalysisCreateResponse.java | 13 +- .../reveng/model/AnalysisDetailResponse.java | 31 +- .../reveng/model/AnalysisFunctionMapping.java | 13 +- .../AnalysisFunctionMatchingRequest.java | 13 +- .../ai/reveng/model/AnalysisFunctions.java | 31 +- .../reveng/model/AnalysisFunctionsList.java | 31 +- .../ai/reveng/model/AnalysisLogMessage.java | 21 +- .../java/ai/reveng/model/AnalysisLogs.java | 27 +- .../java/ai/reveng/model/AnalysisRecord.java | 33 +- .../java/ai/reveng/model/AnalysisReport.java | 304 +++++-- .../java/ai/reveng/model/AnalysisScope.java | 2 - .../reveng/model/AnalysisStringFunction.java | 114 +-- .../ai/reveng/model/AnalysisStringInput.java | 15 +- .../ai/reveng/model/AnalysisStringItem.java | 132 +-- .../reveng/model/AnalysisStringsResponse.java | 31 +- .../model/AnalysisStringsStatusResponse.java | 13 +- .../java/ai/reveng/model/AnalysisTags.java | 31 +- .../reveng/model/AnalysisUpdateRequest.java | 15 +- .../model/AnalysisUpdateTagsRequest.java | 15 +- .../model/AnalysisUpdateTagsResponse.java | 31 +- src/main/java/ai/reveng/model/ApiCall.java | 144 +-- .../AppApiRestV2AgentSchemaCapability.java | 23 +- .../AppApiRestV2AnalysesEnumsOrderBy.java | 2 - .../AppApiRestV2CollectionsEnumsOrderBy.java | 2 - ...ppApiRestV2FunctionsResponsesFunction.java | 13 +- .../AppApiRestV2FunctionsTypesFunction.java | 17 +- .../AppApiRestV2InfoTypesCapability.java | 17 +- src/main/java/ai/reveng/model/Argument.java | 21 +- src/main/java/ai/reveng/model/Artifact.java | 828 ++++++++++++++++++ .../ai/reveng/model/AttemptFailedEvent.java | 118 +-- .../ai/reveng/model/AttemptStartedEvent.java | 116 +-- .../java/ai/reveng/model/AutoRunAgents.java | 11 +- .../ai/reveng/model/AutoUnstripRequest.java | 11 +- .../ai/reveng/model/AutoUnstripResponse.java | 27 +- .../java/ai/reveng/model/BaseResponse.java | 21 +- ...sponseAdditionalDetailsStatusResponse.java | 21 +- ...seResponseAnalysisBulkAddTagsResponse.java | 21 +- .../BaseResponseAnalysisCreateResponse.java | 21 +- .../BaseResponseAnalysisDetailResponse.java | 21 +- .../BaseResponseAnalysisFunctionMapping.java | 21 +- .../model/BaseResponseAnalysisFunctions.java | 21 +- .../BaseResponseAnalysisFunctionsList.java | 21 +- .../BaseResponseAnalysisStringsResponse.java | 21 +- ...ResponseAnalysisStringsStatusResponse.java | 21 +- .../model/BaseResponseAnalysisTags.java | 21 +- ...aseResponseAnalysisUpdateTagsResponse.java | 21 +- .../ai/reveng/model/BaseResponseBasic.java | 21 +- ...ResponseBinariesRelatedStatusResponse.java | 21 +- .../BaseResponseBinaryAdditionalResponse.java | 21 +- .../BaseResponseBinaryDetailsResponse.java | 21 +- .../BaseResponseBinaryExternalsResponse.java | 21 +- .../BaseResponseBinarySearchResponse.java | 21 +- .../ai/reveng/model/BaseResponseBool.java | 21 +- ...esponseCalleesCallerFunctionsResponse.java | 21 +- .../model/BaseResponseCapabilities.java | 21 +- ...BaseResponseCapabilitiesAgentResponse.java | 21 +- .../BaseResponseChildBinariesResponse.java | 21 +- ...ponseCollectionBinariesUpdateResponse.java | 21 +- .../model/BaseResponseCollectionResponse.java | 21 +- .../BaseResponseCollectionSearchResponse.java | 21 +- ...eResponseCollectionTagsUpdateResponse.java | 21 +- .../model/BaseResponseCommentResponse.java | 21 +- .../model/BaseResponseConfigResponse.java | 21 +- .../ai/reveng/model/BaseResponseCreated.java | 21 +- .../ai/reveng/model/BaseResponseDict.java | 21 +- .../model/BaseResponseExternalResponse.java | 21 +- .../BaseResponseFunctionBlocksResponse.java | 21 +- ...aseResponseFunctionCapabilityResponse.java | 21 +- .../model/BaseResponseFunctionDataTypes.java | 21 +- .../BaseResponseFunctionDataTypesList.java | 21 +- .../BaseResponseFunctionSearchResponse.java | 21 +- .../BaseResponseFunctionStringsResponse.java | 21 +- .../BaseResponseFunctionTaskResponse.java | 21 +- .../BaseResponseFunctionsDetailResponse.java | 21 +- ...BaseResponseGenerateFunctionDataTypes.java | 21 +- .../BaseResponseGenerationStatusList.java | 21 +- .../BaseResponseGetAiDecompilationTask.java | 21 +- .../BaseResponseGetPublicUserResponse.java | 21 +- ...nseListCalleesCallerFunctionsResponse.java | 23 +- .../BaseResponseListCollectionResults.java | 21 +- .../BaseResponseListCommentResponse.java | 23 +- .../model/BaseResponseListDieMatch.java | 23 +- .../BaseResponseListFunctionNameHistory.java | 23 +- .../ai/reveng/model/BaseResponseListSBOM.java | 23 +- .../BaseResponseListUserActivityResponse.java | 23 +- .../ai/reveng/model/BaseResponseLogs.java | 21 +- .../model/BaseResponseModelsResponse.java | 21 +- .../ai/reveng/model/BaseResponseParams.java | 21 +- ...aseResponseQueuedWorkflowTaskResponse.java | 21 +- .../ai/reveng/model/BaseResponseRecent.java | 21 +- .../BaseResponseReportAnalysisResponse.java | 21 +- .../ai/reveng/model/BaseResponseStatus.java | 21 +- .../java/ai/reveng/model/BaseResponseStr.java | 23 +- .../model/BaseResponseTagSearchResponse.java | 21 +- .../model/BaseResponseTaskResponse.java | 21 +- .../model/BaseResponseTaskStatusResponse.java | 21 +- .../BaseResponseTriageReportResponse.java | 21 +- ...AiDecompilationRatingResponseNoneType.java | 21 +- .../model/BaseResponseUploadResponse.java | 21 +- .../model/BaseResponseVulnerabilities.java | 21 +- .../model/BaseResponseXrefResponse.java | 21 +- src/main/java/ai/reveng/model/Basic.java | 33 +- .../ai/reveng/model/BatchRenameInputBody.java | 128 +-- .../java/ai/reveng/model/BatchRenameItem.java | 118 +-- .../reveng/model/BatchRenameOutputBody.java | 114 +-- .../model/BinariesRelatedStatusResponse.java | 15 +- .../ai/reveng/model/BinariesTaskStatus.java | 2 - src/main/java/ai/reveng/model/Binary.java | 118 +-- .../BinaryAdditionalDetailsDataResponse.java | 13 +- .../model/BinaryAdditionalResponse.java | 15 +- .../java/ai/reveng/model/BinaryConfig.java | 13 +- .../reveng/model/BinaryDetailsResponse.java | 39 +- .../reveng/model/BinaryExternalsResponse.java | 15 +- .../ai/reveng/model/BinarySearchResponse.java | 31 +- .../ai/reveng/model/BinarySearchResult.java | 27 +- .../ai/reveng/model/BinaryTaskStatus.java | 2 - .../model/BulkDeleteAnalysesRequest.java | 15 +- .../ai/reveng/model/CalleeFunctionInfo.java | 21 +- .../model/CalleesCallerFunctionsResponse.java | 49 +- .../ai/reveng/model/CallerFunctionInfo.java | 21 +- .../java/ai/reveng/model/Capabilities.java | 31 +- .../model/CapabilitiesAgentResponse.java | 31 +- .../reveng/model/ChildBinariesResponse.java | 33 +- .../ai/reveng/model/CodeSignatureModel.java | 31 +- .../CollectionBinariesUpdateRequest.java | 15 +- .../CollectionBinariesUpdateResponse.java | 31 +- .../model/CollectionBinaryResponse.java | 17 +- .../reveng/model/CollectionCreateRequest.java | 23 +- .../ai/reveng/model/CollectionListItem.java | 27 +- .../reveng/model/CollectionListItemBody.java | 128 +-- .../ai/reveng/model/CollectionResponse.java | 27 +- .../CollectionResponseBinariesInner.java | 18 +- .../java/ai/reveng/model/CollectionScope.java | 2 - .../model/CollectionSearchResponse.java | 31 +- .../reveng/model/CollectionSearchResult.java | 31 +- .../model/CollectionTagsUpdateRequest.java | 15 +- .../model/CollectionTagsUpdateResponse.java | 15 +- .../reveng/model/CollectionUpdateRequest.java | 15 +- .../java/ai/reveng/model/CommentBase.java | 15 +- .../java/ai/reveng/model/CommentResponse.java | 19 +- .../ai/reveng/model/CommentUpdateRequest.java | 15 +- .../java/ai/reveng/model/CommentsData.java | 130 +-- .../java/ai/reveng/model/ConfigResponse.java | 19 +- .../ai/reveng/model/ConfirmToolInputBody.java | 114 +-- src/main/java/ai/reveng/model/Connection.java | 309 ++++--- .../ai/reveng/model/ConsoleOutputEntry.java | 234 +++++ src/main/java/ai/reveng/model/Context.java | 18 +- .../java/ai/reveng/model/Conversation.java | 118 +-- .../ai/reveng/model/ConversationContext.java | 112 +-- .../reveng/model/ConversationWithEvents.java | 132 +-- .../model/CreateAIDecompOutputBody.java | 114 +-- .../model/CreateCheckoutSessionInputBody.java | 19 +- .../model/CreateCollectionInputBody.java | 124 +-- .../model/CreateCollectionOutputBody.java | 138 +-- .../model/CreateConversationRequest.java | 118 +-- .../model/CreatePortalSessionInputBody.java | 15 +- src/main/java/ai/reveng/model/Created.java | 15 +- .../ai/reveng/model/DecompFailedEvent.java | 120 +-- .../ai/reveng/model/DecompFinishedEvent.java | 116 +-- .../model/DecompilationCommentContext.java | 13 +- .../ai/reveng/model/DecompilationData.java | 118 +-- src/main/java/ai/reveng/model/DieMatch.java | 21 +- src/main/java/ai/reveng/model/DnsQuery.java | 222 ++--- .../ai/reveng/model/DrakvufFileMetadata.java | 156 +--- .../reveng/model/DynamicExecutionStatus.java | 2 - .../model/DynamicExecutionStatusResponse.java | 19 +- .../java/ai/reveng/model/ELFImportModel.java | 15 +- src/main/java/ai/reveng/model/ELFModel.java | 139 ++- .../java/ai/reveng/model/ELFRelocation.java | 17 +- src/main/java/ai/reveng/model/ELFSection.java | 19 +- .../java/ai/reveng/model/ELFSecurity.java | 13 +- src/main/java/ai/reveng/model/ELFSegment.java | 17 +- src/main/java/ai/reveng/model/ELFSymbol.java | 21 +- .../java/ai/reveng/model/ElfDynamicEntry.java | 15 +- .../java/ai/reveng/model/EntrypointModel.java | 15 +- .../java/ai/reveng/model/Enumeration.java | 21 +- src/main/java/ai/reveng/model/ErrorBody.java | 124 +-- src/main/java/ai/reveng/model/ErrorModel.java | 17 +- src/main/java/ai/reveng/model/Event.java | 116 +-- .../ai/reveng/model/EventAttemptFailed.java | 17 +- .../ai/reveng/model/EventAttemptStarted.java | 17 +- .../reveng/model/EventCONTEXTCOMPACTED.java | 17 +- .../ai/reveng/model/EventDecompFailed.java | 17 +- .../ai/reveng/model/EventDecompFinished.java | 17 +- src/main/java/ai/reveng/model/EventProse.java | 17 +- .../ai/reveng/model/EventRUNCANCELLED.java | 17 +- .../java/ai/reveng/model/EventRUNERROR.java | 17 +- .../ai/reveng/model/EventRUNFINISHED.java | 17 +- .../java/ai/reveng/model/EventRUNSTARTED.java | 17 +- .../ai/reveng/model/EventRenameApplied.java | 17 +- .../ai/reveng/model/EventSTEPFINISHED.java | 17 +- .../ai/reveng/model/EventSTEPSTARTED.java | 17 +- .../ai/reveng/model/EventSourceDelta.java | 17 +- .../ai/reveng/model/EventSourceReset.java | 17 +- .../reveng/model/EventTEXTMESSAGECONTENT.java | 17 +- .../ai/reveng/model/EventTEXTMESSAGEEND.java | 17 +- .../reveng/model/EventTEXTMESSAGESTART.java | 17 +- .../ai/reveng/model/EventTITLEUPDATED.java | 17 +- .../reveng/model/EventTOOLCALLARGSDELTA.java | 17 +- .../ai/reveng/model/EventTOOLCALLEND.java | 17 +- .../ai/reveng/model/EventTOOLCALLRESULT.java | 17 +- .../ai/reveng/model/EventTOOLCALLSTART.java | 17 +- .../model/EventTOOLCONFIRMATIONREQUIRED.java | 17 +- .../java/ai/reveng/model/EventWarning.java | 17 +- .../java/ai/reveng/model/ExportModel.java | 15 +- .../ai/reveng/model/ExternalResponse.java | 15 +- .../ai/reveng/model/ExtractedFileEntry.java | 558 ------------ .../java/ai/reveng/model/ExtractedURL.java | 142 +-- .../ai/reveng/model/FileActivityEntry.java | 142 +-- src/main/java/ai/reveng/model/FileFormat.java | 2 - src/main/java/ai/reveng/model/FileHashes.java | 29 +- .../java/ai/reveng/model/FileMetadata.java | 15 +- src/main/java/ai/reveng/model/Filters.java | 2 - ...tFuncDepsInner.java => FuncDepsInner.java} | 64 +- .../FunctionBlockDestinationResponse.java | 19 +- .../reveng/model/FunctionBlockResponse.java | 37 +- .../reveng/model/FunctionBlocksResponse.java | 71 +- .../ai/reveng/model/FunctionBoundary.java | 17 +- .../model/FunctionCapabilityResponse.java | 15 +- .../model/FunctionCommentCreateRequest.java | 15 +- .../ai/reveng/model/FunctionDataTypes.java | 19 +- .../reveng/model/FunctionDataTypesList.java | 31 +- .../model/FunctionDataTypesListItem.java | 19 +- .../reveng/model/FunctionDataTypesParams.java | 15 +- .../reveng/model/FunctionDataTypesStatus.java | 15 +- .../java/ai/reveng/model/FunctionHeader.java | 21 +- .../ai/reveng/model/FunctionInfoInput.java | 45 +- .../ai/reveng/model/FunctionInfoOutput.java | 57 +- .../ai/reveng/model/FunctionListItem.java | 19 +- .../model/FunctionLocalVariableResponse.java | 21 +- .../java/ai/reveng/model/FunctionMapping.java | 13 +- .../ai/reveng/model/FunctionMappingFull.java | 13 +- .../java/ai/reveng/model/FunctionMatch.java | 33 +- .../reveng/model/FunctionMatchingFilters.java | 21 +- .../reveng/model/FunctionMatchingRequest.java | 17 +- .../model/FunctionMatchingResponse.java | 37 +- .../ai/reveng/model/FunctionNameHistory.java | 21 +- .../reveng/model/FunctionParamResponse.java | 21 +- .../java/ai/reveng/model/FunctionRename.java | 17 +- .../ai/reveng/model/FunctionRenameMap.java | 17 +- .../reveng/model/FunctionSearchResponse.java | 31 +- .../ai/reveng/model/FunctionSearchResult.java | 21 +- .../ai/reveng/model/FunctionSourceType.java | 2 - .../java/ai/reveng/model/FunctionString.java | 17 +- .../ai/reveng/model/FunctionStringItem.java | 118 +-- .../reveng/model/FunctionStringsResponse.java | 31 +- .../ai/reveng/model/FunctionTaskResponse.java | 15 +- .../ai/reveng/model/FunctionTaskStatus.java | 2 - .../ai/reveng/model/FunctionTypeInput.java | 25 +- .../ai/reveng/model/FunctionTypeOutput.java | 511 ----------- .../reveng/model/FunctionsDetailResponse.java | 23 +- .../ai/reveng/model/FunctionsListRename.java | 31 +- .../model/GenerateFunctionDataTypes.java | 15 +- .../reveng/model/GeneratePDFOutputBody.java | 112 +-- .../ai/reveng/model/GenerationStatusList.java | 31 +- .../model/GetAdditionalDetailsOutputBody.java | 114 +-- .../GetAdditionalDetailsStatusOutputBody.java | 116 +-- .../GetAiDecompilationRatingResponse.java | 17 +- .../reveng/model/GetAiDecompilationTask.java | 43 +- .../GetAnalysisStringsStatusOutputBody.java | 116 +-- .../reveng/model/GetCollectionOutputBody.java | 138 +-- .../reveng/model/GetProductsOutputBody.java | 27 +- .../reveng/model/GetPublicUserResponse.java | 15 +- .../model/GetSubscriptionOutputBody.java | 25 +- .../java/ai/reveng/model/GlobalVariable.java | 23 +- .../java/ai/reveng/model/HistoryEntry.java | 122 +-- .../java/ai/reveng/model/HttpRequest.java | 350 +++++--- src/main/java/ai/reveng/model/IOC.java | 29 +- src/main/java/ai/reveng/model/ISA.java | 2 - src/main/java/ai/reveng/model/IconModel.java | 15 +- .../java/ai/reveng/model/ImportModel.java | 15 +- .../java/ai/reveng/model/InlineComment.java | 116 +-- .../model/InsertAnalysisLogRequest.java | 15 +- .../reveng/model/InverseFunctionMapItem.java | 17 +- .../ai/reveng/model/InverseStringMapItem.java | 15 +- .../java/ai/reveng/model/InverseValue.java | 15 +- .../model/ListAnalysisStringsOutputBody.java | 128 +-- .../reveng/model/ListCollectionResults.java | 31 +- .../model/ListCollectionsOutputBody.java | 128 +-- .../model/ListFunctionStringsOutputBody.java | 128 +-- src/main/java/ai/reveng/model/Logs.java | 15 +- .../java/ai/reveng/model/MITRETechnique.java | 31 +- .../java/ai/reveng/model/MatchedFunction.java | 21 +- .../model/MatchedFunctionSuggestion.java | 19 +- .../java/ai/reveng/model/MemdumpEntry.java | 182 +--- src/main/java/ai/reveng/model/MetaModel.java | 11 +- src/main/java/ai/reveng/model/ModelName.java | 2 - .../java/ai/reveng/model/ModelsResponse.java | 15 +- .../java/ai/reveng/model/ModuleLoadEntry.java | 128 +-- src/main/java/ai/reveng/model/MutexEntry.java | 142 +-- .../java/ai/reveng/model/NameConfidence.java | 15 +- .../java/ai/reveng/model/NameSourceType.java | 21 +- .../java/ai/reveng/model/NetworkActivity.java | 176 ++-- src/main/java/ai/reveng/model/Order.java | 2 - .../java/ai/reveng/model/PDBDebugModel.java | 31 +- src/main/java/ai/reveng/model/PEModel.java | 41 +- .../java/ai/reveng/model/PaginationModel.java | 13 +- src/main/java/ai/reveng/model/Params.java | 25 +- .../PatchCollectionBinariesInputBody.java | 118 +-- .../PatchCollectionBinariesOutputBody.java | 128 +-- .../model/PatchCollectionInputBody.java | 118 +-- .../model/PatchCollectionOutputBody.java | 120 +-- .../model/PatchCollectionTagsInputBody.java | 118 +-- .../model/PatchCollectionTagsOutputBody.java | 118 +-- .../ai/reveng/model/PatchCommentBody.java | 116 +-- .../java/ai/reveng/model/PcapBodyInfo.java | 399 +++++++++ src/main/java/ai/reveng/model/Platform.java | 2 - .../java/ai/reveng/model/PriceOutput.java | 120 +-- .../java/ai/reveng/model/PriceSummary.java | 118 +-- .../ai/reveng/model/ProcessActivityEntry.java | 146 +-- .../reveng/model/ProcessExtractedFiles.java | 344 -------- .../java/ai/reveng/model/ProcessMemdumps.java | 130 +-- .../java/ai/reveng/model/ProcessNode.java | 146 +-- .../java/ai/reveng/model/ProcessTree.java | 128 +-- .../java/ai/reveng/model/ProductOutput.java | 140 +-- .../java/ai/reveng/model/ProductSummary.java | 116 +-- .../java/ai/reveng/model/ProgressMessage.java | 120 +-- src/main/java/ai/reveng/model/ProseEvent.java | 118 +-- .../model/PutAnalysisStringsRequest.java | 31 +- .../model/QueuedWorkflowTaskResponse.java | 15 +- .../java/ai/reveng/model/ReAnalysisForm.java | 19 +- src/main/java/ai/reveng/model/Recent.java | 31 +- .../ai/reveng/model/RegenerateOutputBody.java | 114 +-- .../ai/reveng/model/RegenerateTarget.java | 2 - .../ai/reveng/model/RegistryOperation.java | 142 +-- .../reveng/model/RelativeBinaryResponse.java | 19 +- .../ai/reveng/model/RenameAppliedEvent.java | 122 +-- .../java/ai/reveng/model/RenameInputBody.java | 118 +-- .../ai/reveng/model/RenameOutputBody.java | 114 +-- .../ai/reveng/model/ReplacementValue.java | 116 +-- .../reveng/model/ReportAnalysisResponse.java | 57 +- .../java/ai/reveng/model/ReportEvent.java | 262 +++--- src/main/java/ai/reveng/model/ReportInfo.java | 156 +--- .../java/ai/reveng/model/ReportOptions.java | 130 +-- src/main/java/ai/reveng/model/SBOM.java | 33 +- .../java/ai/reveng/model/SBOMPackage.java | 17 +- .../java/ai/reveng/model/SandboxOptions.java | 17 +- .../ai/reveng/model/SandboxStartMethod.java | 2 - .../java/ai/reveng/model/SandboxTimeout.java | 2 - .../ai/reveng/model/ScheduledTaskEntry.java | 148 +--- .../reveng/model/ScrapeThirdPartyConfig.java | 11 +- .../java/ai/reveng/model/SectionModel.java | 31 +- .../java/ai/reveng/model/SecurityModel.java | 13 +- .../java/ai/reveng/model/SegmentInfo.java | 13 +- .../ai/reveng/model/SendMessageRequest.java | 120 +-- ...eInner.java => ServerSentEventsInner.java} | 122 +-- ...Inner.java => ServerSentEventsInner1.java} | 87 +- .../java/ai/reveng/model/ServiceEntry.java | 138 +-- .../ai/reveng/model/SessionOutputBody.java | 15 +- .../model/SingleCodeCertificateModel.java | 23 +- .../model/SingleCodeSignatureModel.java | 33 +- .../ai/reveng/model/SinglePDBEntryModel.java | 17 +- .../ai/reveng/model/SingleSectionModel.java | 19 +- .../ai/reveng/model/SourceDeltaEvent.java | 118 +-- .../ai/reveng/model/SourceResetEvent.java | 116 +-- .../model/SseEventContextCompactedData.java | 118 +-- .../model/SseEventRunCancelledData.java | 118 +-- .../ai/reveng/model/SseEventRunErrorData.java | 118 +-- .../reveng/model/SseEventRunFinishedData.java | 118 +-- .../reveng/model/SseEventRunStartedData.java | 118 +-- .../model/SseEventStepFinishedData.java | 118 +-- .../reveng/model/SseEventStepStartedData.java | 118 +-- .../model/SseEventTextMessageContentData.java | 118 +-- .../model/SseEventTextMessageEndData.java | 118 +-- .../model/SseEventTextMessageStartData.java | 118 +-- .../model/SseEventTitleUpdatedData.java | 118 +-- .../model/SseEventToolCallArgsDeltaData.java | 118 +-- .../reveng/model/SseEventToolCallEndData.java | 118 +-- .../model/SseEventToolCallResultData.java | 118 +-- .../model/SseEventToolCallStartData.java | 118 +-- .../SseEventToolConfirmationRequiredData.java | 118 +-- .../java/ai/reveng/model/StackVariable.java | 21 +- .../java/ai/reveng/model/StartupInfo.java | 134 +-- .../java/ai/reveng/model/StatusInput.java | 2 - .../java/ai/reveng/model/StatusOutput.java | 15 +- .../java/ai/reveng/model/StatusResponse.java | 120 +-- .../java/ai/reveng/model/StringFunctions.java | 35 +- .../java/ai/reveng/model/StringSource.java | 2 - src/main/java/ai/reveng/model/Structure.java | 23 +- .../java/ai/reveng/model/StructureMember.java | 21 +- .../model/SubmitUserFeedbackRequest.java | 21 +- .../java/ai/reveng/model/SummaryData.java | 120 +-- src/main/java/ai/reveng/model/Symbols.java | 15 +- src/main/java/ai/reveng/model/Tag.java | 15 +- src/main/java/ai/reveng/model/TagItem.java | 19 +- .../java/ai/reveng/model/TagResponse.java | 17 +- .../ai/reveng/model/TagSearchResponse.java | 31 +- .../java/ai/reveng/model/TagSearchResult.java | 15 +- .../java/ai/reveng/model/TaskResponse.java | 15 +- src/main/java/ai/reveng/model/TaskStatus.java | 2 - .../ai/reveng/model/TaskStatusResponse.java | 15 +- .../java/ai/reveng/model/TcpCarvedFile.java | 425 +++++++++ .../java/ai/reveng/model/TimestampModel.java | 13 +- .../java/ai/reveng/model/TokenisedData.java | 124 +-- .../reveng/model/TriageFunctionResponse.java | 17 +- .../ai/reveng/model/TriageReportResponse.java | 33 +- src/main/java/ai/reveng/model/Ttp.java | 124 +-- .../java/ai/reveng/model/TypeDefinition.java | 23 +- .../reveng/model/UpdateFunctionDataTypes.java | 13 +- .../java/ai/reveng/model/UploadFileType.java | 2 - .../java/ai/reveng/model/UploadResponse.java | 17 +- .../UpsertAiDecomplationRatingRequest.java | 17 +- .../ai/reveng/model/UpsertOverridesData.java | 114 +-- .../model/UpsertOverridesInputBody.java | 114 +-- .../ai/reveng/model/UserActivityResponse.java | 23 +- .../java/ai/reveng/model/Vulnerabilities.java | 31 +- .../java/ai/reveng/model/Vulnerability.java | 31 +- .../java/ai/reveng/model/WarningEvent.java | 122 +-- .../ai/reveng/model/WorkflowProgress.java | 132 +-- src/main/java/ai/reveng/model/Workspace.java | 2 - .../ai/reveng/model/XrefFromResponse.java | 31 +- .../java/ai/reveng/model/XrefResponse.java | 49 +- .../java/ai/reveng/model/XrefToResponse.java | 31 +- 645 files changed, 8074 insertions(+), 17471 deletions(-) create mode 100644 docs/Artifact.md rename docs/{ProcessExtractedFiles.md => ConsoleOutputEntry.md} (63%) delete mode 100644 docs/ExtractedFileEntry.md rename docs/{FunctionInfoInputFuncDepsInner.md => FuncDepsInner.md} (83%) delete mode 100644 docs/FunctionTypeOutput.md create mode 100644 docs/PcapBodyInfo.md rename docs/{StreamEvents200ResponseInner.md => ServerSentEventsInner.md} (79%) rename docs/{StreamAiDecompilation200ResponseInner.md => ServerSentEventsInner1.md} (85%) create mode 100644 docs/TcpCarvedFile.md create mode 100644 src/main/java/ai/reveng/model/Artifact.java create mode 100644 src/main/java/ai/reveng/model/ConsoleOutputEntry.java delete mode 100644 src/main/java/ai/reveng/model/ExtractedFileEntry.java rename src/main/java/ai/reveng/model/{FunctionInfoInputFuncDepsInner.java => FuncDepsInner.java} (79%) delete mode 100644 src/main/java/ai/reveng/model/FunctionTypeOutput.java create mode 100644 src/main/java/ai/reveng/model/PcapBodyInfo.java delete mode 100644 src/main/java/ai/reveng/model/ProcessExtractedFiles.java rename src/main/java/ai/reveng/model/{StreamEvents200ResponseInner.java => ServerSentEventsInner.java} (85%) rename src/main/java/ai/reveng/model/{StreamAiDecompilation200ResponseInner.java => ServerSentEventsInner1.java} (83%) create mode 100644 src/main/java/ai/reveng/model/TcpCarvedFile.java diff --git a/.sdk-version b/.sdk-version index b9ecbb2c..c2239b06 100644 --- a/.sdk-version +++ b/.sdk-version @@ -1 +1 @@ -v3.93.1 +v3.93.2 diff --git a/README.md b/README.md index f0be2ee9..f8fe84b0 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Add this dependency to your project's POM: ai.reveng sdk - 3.93.1 + 3.93.2 compile ``` @@ -31,7 +31,7 @@ repositories { } dependencies { - implementation "ai.reveng:sdk:3.93.1" + implementation "ai.reveng:sdk:3.93.2" } ``` @@ -271,6 +271,7 @@ Class | Method | HTTP request | Description - [AppApiRestV2FunctionsTypesFunction](docs/AppApiRestV2FunctionsTypesFunction.md) - [AppApiRestV2InfoTypesCapability](docs/AppApiRestV2InfoTypesCapability.md) - [Argument](docs/Argument.md) + - [Artifact](docs/Artifact.md) - [AttemptFailedEvent](docs/AttemptFailedEvent.md) - [AttemptStartedEvent](docs/AttemptStartedEvent.md) - [AutoRunAgents](docs/AutoRunAgents.md) @@ -387,6 +388,7 @@ Class | Method | HTTP request | Description - [ConfigResponse](docs/ConfigResponse.md) - [ConfirmToolInputBody](docs/ConfirmToolInputBody.md) - [Connection](docs/Connection.md) + - [ConsoleOutputEntry](docs/ConsoleOutputEntry.md) - [Context](docs/Context.md) - [Conversation](docs/Conversation.md) - [ConversationContext](docs/ConversationContext.md) @@ -447,13 +449,13 @@ Class | Method | HTTP request | Description - [EventWarning](docs/EventWarning.md) - [ExportModel](docs/ExportModel.md) - [ExternalResponse](docs/ExternalResponse.md) - - [ExtractedFileEntry](docs/ExtractedFileEntry.md) - [ExtractedURL](docs/ExtractedURL.md) - [FileActivityEntry](docs/FileActivityEntry.md) - [FileFormat](docs/FileFormat.md) - [FileHashes](docs/FileHashes.md) - [FileMetadata](docs/FileMetadata.md) - [Filters](docs/Filters.md) + - [FuncDepsInner](docs/FuncDepsInner.md) - [FunctionBlockDestinationResponse](docs/FunctionBlockDestinationResponse.md) - [FunctionBlockResponse](docs/FunctionBlockResponse.md) - [FunctionBlocksResponse](docs/FunctionBlocksResponse.md) @@ -467,7 +469,6 @@ Class | Method | HTTP request | Description - [FunctionDataTypesStatus](docs/FunctionDataTypesStatus.md) - [FunctionHeader](docs/FunctionHeader.md) - [FunctionInfoInput](docs/FunctionInfoInput.md) - - [FunctionInfoInputFuncDepsInner](docs/FunctionInfoInputFuncDepsInner.md) - [FunctionInfoOutput](docs/FunctionInfoOutput.md) - [FunctionListItem](docs/FunctionListItem.md) - [FunctionLocalVariableResponse](docs/FunctionLocalVariableResponse.md) @@ -490,7 +491,6 @@ Class | Method | HTTP request | Description - [FunctionTaskResponse](docs/FunctionTaskResponse.md) - [FunctionTaskStatus](docs/FunctionTaskStatus.md) - [FunctionTypeInput](docs/FunctionTypeInput.md) - - [FunctionTypeOutput](docs/FunctionTypeOutput.md) - [FunctionsDetailResponse](docs/FunctionsDetailResponse.md) - [FunctionsListRename](docs/FunctionsListRename.md) - [GenerateFunctionDataTypes](docs/GenerateFunctionDataTypes.md) @@ -546,11 +546,11 @@ Class | Method | HTTP request | Description - [PatchCollectionTagsInputBody](docs/PatchCollectionTagsInputBody.md) - [PatchCollectionTagsOutputBody](docs/PatchCollectionTagsOutputBody.md) - [PatchCommentBody](docs/PatchCommentBody.md) + - [PcapBodyInfo](docs/PcapBodyInfo.md) - [Platform](docs/Platform.md) - [PriceOutput](docs/PriceOutput.md) - [PriceSummary](docs/PriceSummary.md) - [ProcessActivityEntry](docs/ProcessActivityEntry.md) - - [ProcessExtractedFiles](docs/ProcessExtractedFiles.md) - [ProcessMemdumps](docs/ProcessMemdumps.md) - [ProcessNode](docs/ProcessNode.md) - [ProcessTree](docs/ProcessTree.md) @@ -585,6 +585,8 @@ Class | Method | HTTP request | Description - [SecurityModel](docs/SecurityModel.md) - [SegmentInfo](docs/SegmentInfo.md) - [SendMessageRequest](docs/SendMessageRequest.md) + - [ServerSentEventsInner](docs/ServerSentEventsInner.md) + - [ServerSentEventsInner1](docs/ServerSentEventsInner1.md) - [ServiceEntry](docs/ServiceEntry.md) - [SessionOutputBody](docs/SessionOutputBody.md) - [SingleCodeCertificateModel](docs/SingleCodeCertificateModel.md) @@ -614,8 +616,6 @@ Class | Method | HTTP request | Description - [StatusInput](docs/StatusInput.md) - [StatusOutput](docs/StatusOutput.md) - [StatusResponse](docs/StatusResponse.md) - - [StreamAiDecompilation200ResponseInner](docs/StreamAiDecompilation200ResponseInner.md) - - [StreamEvents200ResponseInner](docs/StreamEvents200ResponseInner.md) - [StringFunctions](docs/StringFunctions.md) - [StringSource](docs/StringSource.md) - [Structure](docs/Structure.md) @@ -631,6 +631,7 @@ Class | Method | HTTP request | Description - [TaskResponse](docs/TaskResponse.md) - [TaskStatus](docs/TaskStatus.md) - [TaskStatusResponse](docs/TaskStatusResponse.md) + - [TcpCarvedFile](docs/TcpCarvedFile.md) - [TimestampModel](docs/TimestampModel.md) - [TokenisedData](docs/TokenisedData.md) - [TriageFunctionResponse](docs/TriageFunctionResponse.md) diff --git a/build.gradle b/build.gradle index 3479c736..e87fc581 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ apply plugin: 'java' apply plugin: 'com.diffplug.spotless' group = 'ai.reveng' -version = '3.93.1' +version = '3.93.2' @@ -171,7 +171,7 @@ mavenPublishing { publishToMavenCentral(true) signAllPublications() - coordinates("ai.reveng", "sdk", "3.93.1") + coordinates("ai.reveng", "sdk", "3.93.2") pom { name = "sdk" diff --git a/build.sbt b/build.sbt index dd28a3f8..d0cbac64 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ lazy val root = (project in file(".")). settings( organization := "ai.reveng", name := "sdk", - version := "3.93.1", + version := "3.93.2", scalaVersion := "2.11.12", scalacOptions ++= Seq("-feature"), compile / javacOptions ++= Seq("-Xlint:deprecation"), @@ -15,7 +15,7 @@ lazy val root = (project in file(".")). "com.google.code.gson" % "gson" % "2.9.1", "org.apache.commons" % "commons-lang3" % "3.18.0", "jakarta.ws.rs" % "jakarta.ws.rs-api" % "2.1.6", - "org.openapitools" % "jackson-databind-nullable" % "0.2.8", + "org.openapitools" % "jackson-databind-nullable" % "0.2.10", "io.gsonfire" % "gson-fire" % "1.9.0" % "compile", "jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile", "com.google.code.findbugs" % "jsr305" % "3.0.2" % "compile", diff --git a/docs/AIDecompFunctionMapping.md b/docs/AIDecompFunctionMapping.md index 70a7a793..5852b494 100644 --- a/docs/AIDecompFunctionMapping.md +++ b/docs/AIDecompFunctionMapping.md @@ -8,18 +8,18 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**fields** | **Map<String, Map<String, ReplacementValue>>** | | | -|**inverseFunctionMap** | **Map<String, AIDecompInverseFunctionMapItem>** | | | -|**inverseStringMap** | **Map<String, AIDecompInverseStringMapItem>** | | | -|**unmatchedCustomFunctionPointers** | **Map<String, ReplacementValue>** | | | -|**unmatchedCustomTypes** | **Map<String, ReplacementValue>** | | | -|**unmatchedEnums** | **Map<String, ReplacementValue>** | | | -|**unmatchedExternalVars** | **Map<String, ReplacementValue>** | | | -|**unmatchedFunctions** | **Map<String, ReplacementValue>** | | | -|**unmatchedGlobalVars** | **Map<String, ReplacementValue>** | | | -|**unmatchedGoToLabels** | **Map<String, ReplacementValue>** | | | -|**unmatchedStrings** | **Map<String, ReplacementValue>** | | | -|**unmatchedVariadicLists** | **Map<String, ReplacementValue>** | | | -|**unmatchedVars** | **Map<String, ReplacementValue>** | | | +|**inverseFunctionMap** | [**Map<String, AIDecompInverseFunctionMapItem>**](AIDecompInverseFunctionMapItem.md) | | | +|**inverseStringMap** | [**Map<String, AIDecompInverseStringMapItem>**](AIDecompInverseStringMapItem.md) | | | +|**unmatchedCustomFunctionPointers** | [**Map<String, ReplacementValue>**](ReplacementValue.md) | | | +|**unmatchedCustomTypes** | [**Map<String, ReplacementValue>**](ReplacementValue.md) | | | +|**unmatchedEnums** | [**Map<String, ReplacementValue>**](ReplacementValue.md) | | | +|**unmatchedExternalVars** | [**Map<String, ReplacementValue>**](ReplacementValue.md) | | | +|**unmatchedFunctions** | [**Map<String, ReplacementValue>**](ReplacementValue.md) | | | +|**unmatchedGlobalVars** | [**Map<String, ReplacementValue>**](ReplacementValue.md) | | | +|**unmatchedGoToLabels** | [**Map<String, ReplacementValue>**](ReplacementValue.md) | | | +|**unmatchedStrings** | [**Map<String, ReplacementValue>**](ReplacementValue.md) | | | +|**unmatchedVariadicLists** | [**Map<String, ReplacementValue>**](ReplacementValue.md) | | | +|**unmatchedVars** | [**Map<String, ReplacementValue>**](ReplacementValue.md) | | | |**userOverrideMappings** | **Map<String, String>** | | | diff --git a/docs/APIError.md b/docs/APIError.md index 55b5b075..ef1aadbd 100644 --- a/docs/APIError.md +++ b/docs/APIError.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**error** | **ErrorBody** | | | +|**error** | [**ErrorBody**](ErrorBody.md) | | | diff --git a/docs/AnalysesCoreApi.md b/docs/AnalysesCoreApi.md index d785c6c6..acb8ce5d 100644 --- a/docs/AnalysesCoreApi.md +++ b/docs/AnalysesCoreApi.md @@ -28,7 +28,7 @@ All URIs are relative to *https://api.reveng.ai* # **addUserStringToAnalysis** -> Map<String, Object> addUserStringToAnalysis(analysisId, addUserStringInputBody) +> Object addUserStringToAnalysis(analysisId, addUserStringInputBody) Add a user-provided string to an analysis. @@ -59,7 +59,7 @@ public class Example { Long analysisId = 56L; // Long | Analysis ID AddUserStringInputBody addUserStringInputBody = new AddUserStringInputBody(); // AddUserStringInputBody | try { - Map result = apiInstance.addUserStringToAnalysis(analysisId, addUserStringInputBody); + Object result = apiInstance.addUserStringToAnalysis(analysisId, addUserStringInputBody); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling AnalysesCoreApi#addUserStringToAnalysis"); @@ -81,7 +81,7 @@ public class Example { ### Return type -**Map<String, Object>** +**Object** ### Authorization @@ -885,8 +885,8 @@ public class Example { | **sha256Hash** | **String**| | [optional] | | **limit** | **Integer**| | [optional] [default to 20] | | **offset** | **Integer**| | [optional] [default to 0] | -| **orderBy** | [**AppApiRestV2AnalysesEnumsOrderBy**](.md)| | [optional] [enum: created, name, size] | -| **order** | [**Order**](.md)| | [optional] [enum: ASC, DESC] | +| **orderBy** | [**AppApiRestV2AnalysesEnumsOrderBy**](.md)| | [optional] [default to created] [enum: created, name, size] | +| **order** | [**Order**](.md)| | [optional] [default to DESC] [enum: ASC, DESC] | ### Return type diff --git a/docs/AnalysisBulkAddTagsResponseItem.md b/docs/AnalysisBulkAddTagsResponseItem.md index 595418f0..7bd58ca4 100644 --- a/docs/AnalysisBulkAddTagsResponseItem.md +++ b/docs/AnalysisBulkAddTagsResponseItem.md @@ -8,8 +8,8 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**analysisId** | **Integer** | | | -|**message** | **String** | | | -|**error** | **String** | | [optional] | +|**message** | **String** | Success message if the update was successful | | +|**error** | **String** | Error message if the update failed | [optional] | diff --git a/docs/AnalysisCreateRequest.md b/docs/AnalysisCreateRequest.md index 17a1897e..212be48e 100644 --- a/docs/AnalysisCreateRequest.md +++ b/docs/AnalysisCreateRequest.md @@ -11,8 +11,8 @@ |**sha256Hash** | **String** | The sha256 hash of the file | | |**tags** | [**List<Tag>**](Tag.md) | List of tags to assign to an analysis | [optional] | |**analysisScope** | **AnalysisScope** | The scope of the analysis determines who can access it | [optional] | -|**symbols** | [**Symbols**](Symbols.md) | | [optional] | -|**debugHash** | **String** | | [optional] | +|**symbols** | [**Symbols**](Symbols.md) | Symbols are user-defined properties which inform how the binary is decompiled | [optional] | +|**debugHash** | **String** | Hash of the debug file | [optional] | |**analysisConfig** | [**AnalysisConfig**](AnalysisConfig.md) | The analysis config enables the configuration of optional analysis stages | [optional] | |**binaryConfig** | [**BinaryConfig**](BinaryConfig.md) | The binary config can override automatically determined values such as ISA, Platform, File Format, etc | [optional] | |**autoRunAgents** | [**AutoRunAgents**](AutoRunAgents.md) | | [optional] | diff --git a/docs/AnalysisFunctionMatchingRequest.md b/docs/AnalysisFunctionMatchingRequest.md index 8fbc4380..d7c6de82 100644 --- a/docs/AnalysisFunctionMatchingRequest.md +++ b/docs/AnalysisFunctionMatchingRequest.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**minSimilarity** | **BigDecimal** | Minimum similarity expected for a match as a percentage, default is 90 | [optional] | -|**filters** | [**FunctionMatchingFilters**](FunctionMatchingFilters.md) | | [optional] | +|**filters** | [**FunctionMatchingFilters**](FunctionMatchingFilters.md) | Used to limit the search to specific binaries, collections, and functions | [optional] | |**resultsPerFunction** | **Integer** | Maximum number of matches to return per function, default is 1, max is 30 | [optional] | |**page** | **Integer** | Page number for paginated results, default is 1 (first page) | [optional] | |**pageSize** | **Integer** | Number of functions to return per page, default is 0 (all functions), max is 1000 | [optional] | diff --git a/docs/AnalysisLogMessage.md b/docs/AnalysisLogMessage.md index 519d1969..e2b6a7dc 100644 --- a/docs/AnalysisLogMessage.md +++ b/docs/AnalysisLogMessage.md @@ -7,8 +7,8 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**message** | **String** | | | -|**time** | **String** | | | +|**message** | **String** | Search is applied to string value | | +|**time** | **String** | Search is applied to string value | | diff --git a/docs/AnalysisLogs.md b/docs/AnalysisLogs.md index f3bc5f5d..9b8d541b 100644 --- a/docs/AnalysisLogs.md +++ b/docs/AnalysisLogs.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**messageCount** | **Long** | | | -|**messages** | **List<AnalysisLogMessage>** | | | +|**messages** | [**List<AnalysisLogMessage>**](AnalysisLogMessage.md) | | | diff --git a/docs/AnalysisRecord.md b/docs/AnalysisRecord.md index a79033de..df315f7d 100644 --- a/docs/AnalysisRecord.md +++ b/docs/AnalysisRecord.md @@ -20,8 +20,8 @@ |**functionBoundariesHash** | **String** | The hash of the function boundaries | | |**binarySize** | **Integer** | The size of the binary | | |**username** | **String** | The username of the analysis owner | | -|**dynamicExecutionStatus** | **DynamicExecutionStatus** | | [optional] | -|**dynamicExecutionTaskId** | **Integer** | | [optional] | +|**dynamicExecutionStatus** | **DynamicExecutionStatus** | If searching for dynamic execution, the status of the task | [optional] | +|**dynamicExecutionTaskId** | **Integer** | If searching for dynamic execution, the task ID of the task | [optional] | |**baseAddress** | **BigInteger** | The base address of the binary | | |**tags** | [**List<TagItem>**](TagItem.md) | List of tags associated with the analysis | [optional] | diff --git a/docs/AnalysisReport.md b/docs/AnalysisReport.md index b80b7461..8aa44f60 100644 --- a/docs/AnalysisReport.md +++ b/docs/AnalysisReport.md @@ -7,21 +7,21 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**extractedFiles** | **List<ProcessExtractedFiles>** | | [optional] | -|**fileActivity** | **List<FileActivityEntry>** | | [optional] | -|**info** | **ReportInfo** | | | -|**memdumps** | **List<ProcessMemdumps>** | | [optional] | -|**moduleLoadAddresses** | **List<ModuleLoadEntry>** | | [optional] | -|**mutexes** | **List<MutexEntry>** | | [optional] | -|**networkActivity** | **NetworkActivity** | | [optional] | -|**processActivity** | **List<ProcessActivityEntry>** | | [optional] | -|**processTree** | **ProcessTree** | | [optional] | -|**registryOperations** | **List<RegistryOperation>** | | [optional] | -|**scheduledTasks** | **List<ScheduledTaskEntry>** | | [optional] | -|**services** | **List<ServiceEntry>** | | [optional] | -|**startup** | **StartupInfo** | | [optional] | -|**threatScore** | **Long** | | | -|**ttps** | **List<Ttp>** | | [optional] | +|**artifacts** | [**List<Artifact>**](Artifact.md) | | [optional] | +|**consoleOutput** | [**List<ConsoleOutputEntry>**](ConsoleOutputEntry.md) | | [optional] | +|**fileActivity** | [**List<FileActivityEntry>**](FileActivityEntry.md) | | [optional] | +|**info** | [**ReportInfo**](ReportInfo.md) | | | +|**memdumps** | [**List<ProcessMemdumps>**](ProcessMemdumps.md) | | [optional] | +|**moduleLoadAddresses** | [**List<ModuleLoadEntry>**](ModuleLoadEntry.md) | | [optional] | +|**mutexes** | [**List<MutexEntry>**](MutexEntry.md) | | [optional] | +|**networkActivity** | [**NetworkActivity**](NetworkActivity.md) | | [optional] | +|**processActivity** | [**List<ProcessActivityEntry>**](ProcessActivityEntry.md) | | [optional] | +|**processTree** | [**ProcessTree**](ProcessTree.md) | | [optional] | +|**registryOperations** | [**List<RegistryOperation>**](RegistryOperation.md) | | [optional] | +|**scheduledTasks** | [**List<ScheduledTaskEntry>**](ScheduledTaskEntry.md) | | [optional] | +|**services** | [**List<ServiceEntry>**](ServiceEntry.md) | | [optional] | +|**startup** | [**StartupInfo**](StartupInfo.md) | | [optional] | +|**ttps** | [**List<Ttp>**](Ttp.md) | | [optional] | diff --git a/docs/AnalysisStringItem.md b/docs/AnalysisStringItem.md index 43c049de..b72632d9 100644 --- a/docs/AnalysisStringItem.md +++ b/docs/AnalysisStringItem.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**functions** | **List<AnalysisStringFunction>** | | | +|**functions** | [**List<AnalysisStringFunction>**](AnalysisStringFunction.md) | | | |**source** | **String** | | | |**value** | **String** | | | diff --git a/docs/Argument.md b/docs/Argument.md index 9da3375b..3e2dcda0 100644 --- a/docs/Argument.md +++ b/docs/Argument.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**lastChange** | **String** | | [optional] | +|**lastChange** | **String** | Timestamp of the last change to this argument | [optional] | |**offset** | **Integer** | Offset of the argument in the function signature | | |**name** | **String** | Name of the argument | | |**type** | **String** | Data type of the argument | | diff --git a/docs/Artifact.md b/docs/Artifact.md new file mode 100644 index 00000000..14957dbf --- /dev/null +++ b/docs/Artifact.md @@ -0,0 +1,46 @@ + + +# Artifact + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**direction** | **String** | | [optional] | +|**dumpAddr** | **String** | | [optional] | +|**dumpPid** | **Long** | | [optional] | +|**fileType** | **String** | | [optional] | +|**host** | **String** | | [optional] | +|**isPe** | **Boolean** | | | +|**mimeType** | **String** | | [optional] | +|**name** | **String** | | | +|**networkSource** | **String** | | [optional] | +|**originalFilename** | **String** | | [optional] | +|**path** | **String** | | | +|**processSeqid** | **Long** | | [optional] | +|**reason** | [**ReasonEnum**](#ReasonEnum) | | | +|**responseStatus** | **Long** | | [optional] | +|**sha256** | **String** | | [optional] | +|**size** | **Long** | | | +|**source** | **String** | | | +|**uri** | **String** | | [optional] | +|**wasMapped** | **Boolean** | | [optional] | +|**yaraHits** | **List<String>** | | [optional] | + + + +## Enum: ReasonEnum + +| Name | Value | +|---- | -----| +| WRITTEN_BY_TARGET_PROCESS | "written_by_target_process" | +| BINARY_DETECTED | "binary_detected" | +| SHELLCODE_DETECTED | "shellcode_detected" | +| FILE_TYPE_DETECTED | "file_type_detected" | +| YARA_MATCH | "yara_match" | +| NETWORK_REQUEST | "network_request" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/AutoUnstripResponse.md b/docs/AutoUnstripResponse.md index 6e648663..e32d97cd 100644 --- a/docs/AutoUnstripResponse.md +++ b/docs/AutoUnstripResponse.md @@ -8,11 +8,11 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**progress** | **Integer** | Progress of the auto-unstrip operation, represented as a percentage | [optional] | -|**status** | **String** | | [optional] | -|**totalTime** | **Integer** | | [optional] | -|**matches** | [**List<MatchedFunctionSuggestion>**](MatchedFunctionSuggestion.md) | | [optional] | -|**applied** | **Boolean** | | [optional] | -|**errorMessage** | **String** | | [optional] | +|**status** | **String** | Status of the function matching operation | [optional] | +|**totalTime** | **Integer** | Total time taken for the auto-unstrip operation in seconds | [optional] | +|**matches** | [**List<MatchedFunctionSuggestion>**](MatchedFunctionSuggestion.md) | Map of function IDs to their matching results with best match information | [optional] | +|**applied** | **Boolean** | Indicates whether the matched function names were applied to the target binary | [optional] | +|**errorMessage** | **String** | Error message if the operation failed | [optional] | diff --git a/docs/BaseResponse.md b/docs/BaseResponse.md index 7572fbf9..0666328f 100644 --- a/docs/BaseResponse.md +++ b/docs/BaseResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | **Object** | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | **Object** | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseAdditionalDetailsStatusResponse.md b/docs/BaseResponseAdditionalDetailsStatusResponse.md index 78bf60a5..f2f6d2d3 100644 --- a/docs/BaseResponseAdditionalDetailsStatusResponse.md +++ b/docs/BaseResponseAdditionalDetailsStatusResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**AdditionalDetailsStatusResponse**](AdditionalDetailsStatusResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**AdditionalDetailsStatusResponse**](AdditionalDetailsStatusResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseAnalysisBulkAddTagsResponse.md b/docs/BaseResponseAnalysisBulkAddTagsResponse.md index 82af94f2..4d17a533 100644 --- a/docs/BaseResponseAnalysisBulkAddTagsResponse.md +++ b/docs/BaseResponseAnalysisBulkAddTagsResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**AnalysisBulkAddTagsResponse**](AnalysisBulkAddTagsResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**AnalysisBulkAddTagsResponse**](AnalysisBulkAddTagsResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseAnalysisCreateResponse.md b/docs/BaseResponseAnalysisCreateResponse.md index d12fecdc..74256af5 100644 --- a/docs/BaseResponseAnalysisCreateResponse.md +++ b/docs/BaseResponseAnalysisCreateResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**AnalysisCreateResponse**](AnalysisCreateResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**AnalysisCreateResponse**](AnalysisCreateResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseAnalysisDetailResponse.md b/docs/BaseResponseAnalysisDetailResponse.md index b3a5d929..369f81c2 100644 --- a/docs/BaseResponseAnalysisDetailResponse.md +++ b/docs/BaseResponseAnalysisDetailResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**AnalysisDetailResponse**](AnalysisDetailResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**AnalysisDetailResponse**](AnalysisDetailResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseAnalysisFunctionMapping.md b/docs/BaseResponseAnalysisFunctionMapping.md index 884732d0..4f7fa6c7 100644 --- a/docs/BaseResponseAnalysisFunctionMapping.md +++ b/docs/BaseResponseAnalysisFunctionMapping.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**AnalysisFunctionMapping**](AnalysisFunctionMapping.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**AnalysisFunctionMapping**](AnalysisFunctionMapping.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseAnalysisFunctions.md b/docs/BaseResponseAnalysisFunctions.md index 5346a857..62eea18a 100644 --- a/docs/BaseResponseAnalysisFunctions.md +++ b/docs/BaseResponseAnalysisFunctions.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**AnalysisFunctions**](AnalysisFunctions.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**AnalysisFunctions**](AnalysisFunctions.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseAnalysisFunctionsList.md b/docs/BaseResponseAnalysisFunctionsList.md index 46ea744a..61b0ef80 100644 --- a/docs/BaseResponseAnalysisFunctionsList.md +++ b/docs/BaseResponseAnalysisFunctionsList.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**AnalysisFunctionsList**](AnalysisFunctionsList.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**AnalysisFunctionsList**](AnalysisFunctionsList.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseAnalysisStringsResponse.md b/docs/BaseResponseAnalysisStringsResponse.md index b2a02d34..e51f701b 100644 --- a/docs/BaseResponseAnalysisStringsResponse.md +++ b/docs/BaseResponseAnalysisStringsResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**AnalysisStringsResponse**](AnalysisStringsResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**AnalysisStringsResponse**](AnalysisStringsResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseAnalysisStringsStatusResponse.md b/docs/BaseResponseAnalysisStringsStatusResponse.md index 71f06797..a194a5ac 100644 --- a/docs/BaseResponseAnalysisStringsStatusResponse.md +++ b/docs/BaseResponseAnalysisStringsStatusResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**AnalysisStringsStatusResponse**](AnalysisStringsStatusResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**AnalysisStringsStatusResponse**](AnalysisStringsStatusResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseAnalysisTags.md b/docs/BaseResponseAnalysisTags.md index f030b053..1ca5c6cc 100644 --- a/docs/BaseResponseAnalysisTags.md +++ b/docs/BaseResponseAnalysisTags.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**AnalysisTags**](AnalysisTags.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**AnalysisTags**](AnalysisTags.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseAnalysisUpdateTagsResponse.md b/docs/BaseResponseAnalysisUpdateTagsResponse.md index d650dbd5..9ae42c59 100644 --- a/docs/BaseResponseAnalysisUpdateTagsResponse.md +++ b/docs/BaseResponseAnalysisUpdateTagsResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**AnalysisUpdateTagsResponse**](AnalysisUpdateTagsResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**AnalysisUpdateTagsResponse**](AnalysisUpdateTagsResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseBasic.md b/docs/BaseResponseBasic.md index ede9b874..88d2092b 100644 --- a/docs/BaseResponseBasic.md +++ b/docs/BaseResponseBasic.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**Basic**](Basic.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**Basic**](Basic.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseBinariesRelatedStatusResponse.md b/docs/BaseResponseBinariesRelatedStatusResponse.md index dfc9f09a..ee5a0010 100644 --- a/docs/BaseResponseBinariesRelatedStatusResponse.md +++ b/docs/BaseResponseBinariesRelatedStatusResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**BinariesRelatedStatusResponse**](BinariesRelatedStatusResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**BinariesRelatedStatusResponse**](BinariesRelatedStatusResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseBinaryAdditionalResponse.md b/docs/BaseResponseBinaryAdditionalResponse.md index dcfaddc7..9796fdcd 100644 --- a/docs/BaseResponseBinaryAdditionalResponse.md +++ b/docs/BaseResponseBinaryAdditionalResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**BinaryAdditionalResponse**](BinaryAdditionalResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**BinaryAdditionalResponse**](BinaryAdditionalResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseBinaryDetailsResponse.md b/docs/BaseResponseBinaryDetailsResponse.md index d6f31b69..56bb40c0 100644 --- a/docs/BaseResponseBinaryDetailsResponse.md +++ b/docs/BaseResponseBinaryDetailsResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**BinaryDetailsResponse**](BinaryDetailsResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**BinaryDetailsResponse**](BinaryDetailsResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseBinaryExternalsResponse.md b/docs/BaseResponseBinaryExternalsResponse.md index 630b000d..cdc22167 100644 --- a/docs/BaseResponseBinaryExternalsResponse.md +++ b/docs/BaseResponseBinaryExternalsResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**BinaryExternalsResponse**](BinaryExternalsResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**BinaryExternalsResponse**](BinaryExternalsResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseBinarySearchResponse.md b/docs/BaseResponseBinarySearchResponse.md index 700f9f4c..f747d596 100644 --- a/docs/BaseResponseBinarySearchResponse.md +++ b/docs/BaseResponseBinarySearchResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**BinarySearchResponse**](BinarySearchResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**BinarySearchResponse**](BinarySearchResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseBool.md b/docs/BaseResponseBool.md index 9b0360cf..02a6c422 100644 --- a/docs/BaseResponseBool.md +++ b/docs/BaseResponseBool.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | **Boolean** | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | **Boolean** | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseCalleesCallerFunctionsResponse.md b/docs/BaseResponseCalleesCallerFunctionsResponse.md index 7a782414..e77133b9 100644 --- a/docs/BaseResponseCalleesCallerFunctionsResponse.md +++ b/docs/BaseResponseCalleesCallerFunctionsResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**CalleesCallerFunctionsResponse**](CalleesCallerFunctionsResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**CalleesCallerFunctionsResponse**](CalleesCallerFunctionsResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseCapabilities.md b/docs/BaseResponseCapabilities.md index 711c4f24..76eb6ac7 100644 --- a/docs/BaseResponseCapabilities.md +++ b/docs/BaseResponseCapabilities.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**Capabilities**](Capabilities.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**Capabilities**](Capabilities.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseCapabilitiesAgentResponse.md b/docs/BaseResponseCapabilitiesAgentResponse.md index 8ac1ff1c..db534b55 100644 --- a/docs/BaseResponseCapabilitiesAgentResponse.md +++ b/docs/BaseResponseCapabilitiesAgentResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**CapabilitiesAgentResponse**](CapabilitiesAgentResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**CapabilitiesAgentResponse**](CapabilitiesAgentResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseChildBinariesResponse.md b/docs/BaseResponseChildBinariesResponse.md index f0223ba0..06fdee4d 100644 --- a/docs/BaseResponseChildBinariesResponse.md +++ b/docs/BaseResponseChildBinariesResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**ChildBinariesResponse**](ChildBinariesResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**ChildBinariesResponse**](ChildBinariesResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseCollectionBinariesUpdateResponse.md b/docs/BaseResponseCollectionBinariesUpdateResponse.md index c7101f5c..4bc771f1 100644 --- a/docs/BaseResponseCollectionBinariesUpdateResponse.md +++ b/docs/BaseResponseCollectionBinariesUpdateResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**CollectionBinariesUpdateResponse**](CollectionBinariesUpdateResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**CollectionBinariesUpdateResponse**](CollectionBinariesUpdateResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseCollectionResponse.md b/docs/BaseResponseCollectionResponse.md index 74bdee94..ba86979f 100644 --- a/docs/BaseResponseCollectionResponse.md +++ b/docs/BaseResponseCollectionResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**CollectionResponse**](CollectionResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**CollectionResponse**](CollectionResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseCollectionSearchResponse.md b/docs/BaseResponseCollectionSearchResponse.md index 52c06fb1..0f4383ec 100644 --- a/docs/BaseResponseCollectionSearchResponse.md +++ b/docs/BaseResponseCollectionSearchResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**CollectionSearchResponse**](CollectionSearchResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**CollectionSearchResponse**](CollectionSearchResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseCollectionTagsUpdateResponse.md b/docs/BaseResponseCollectionTagsUpdateResponse.md index aff71ba7..d220ce26 100644 --- a/docs/BaseResponseCollectionTagsUpdateResponse.md +++ b/docs/BaseResponseCollectionTagsUpdateResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**CollectionTagsUpdateResponse**](CollectionTagsUpdateResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**CollectionTagsUpdateResponse**](CollectionTagsUpdateResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseCommentResponse.md b/docs/BaseResponseCommentResponse.md index a3b8f6b8..31df0e2a 100644 --- a/docs/BaseResponseCommentResponse.md +++ b/docs/BaseResponseCommentResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**CommentResponse**](CommentResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**CommentResponse**](CommentResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseConfigResponse.md b/docs/BaseResponseConfigResponse.md index 01e910a7..791bfabe 100644 --- a/docs/BaseResponseConfigResponse.md +++ b/docs/BaseResponseConfigResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**ConfigResponse**](ConfigResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**ConfigResponse**](ConfigResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseCreated.md b/docs/BaseResponseCreated.md index ae74d228..b69f560b 100644 --- a/docs/BaseResponseCreated.md +++ b/docs/BaseResponseCreated.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**Created**](Created.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**Created**](Created.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseDict.md b/docs/BaseResponseDict.md index 1cbd395d..f4ac7a2e 100644 --- a/docs/BaseResponseDict.md +++ b/docs/BaseResponseDict.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | **Map<String, Object>** | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | **Map<String, Object>** | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseExternalResponse.md b/docs/BaseResponseExternalResponse.md index e792d35c..4a6990d8 100644 --- a/docs/BaseResponseExternalResponse.md +++ b/docs/BaseResponseExternalResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**ExternalResponse**](ExternalResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**ExternalResponse**](ExternalResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseFunctionBlocksResponse.md b/docs/BaseResponseFunctionBlocksResponse.md index 22f65709..55cc297c 100644 --- a/docs/BaseResponseFunctionBlocksResponse.md +++ b/docs/BaseResponseFunctionBlocksResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**FunctionBlocksResponse**](FunctionBlocksResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**FunctionBlocksResponse**](FunctionBlocksResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseFunctionCapabilityResponse.md b/docs/BaseResponseFunctionCapabilityResponse.md index 6d56132a..5c013f52 100644 --- a/docs/BaseResponseFunctionCapabilityResponse.md +++ b/docs/BaseResponseFunctionCapabilityResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**FunctionCapabilityResponse**](FunctionCapabilityResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**FunctionCapabilityResponse**](FunctionCapabilityResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseFunctionDataTypes.md b/docs/BaseResponseFunctionDataTypes.md index f9d85e3c..63ad39c1 100644 --- a/docs/BaseResponseFunctionDataTypes.md +++ b/docs/BaseResponseFunctionDataTypes.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**FunctionDataTypes**](FunctionDataTypes.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**FunctionDataTypes**](FunctionDataTypes.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseFunctionDataTypesList.md b/docs/BaseResponseFunctionDataTypesList.md index c857f1e5..6e562b38 100644 --- a/docs/BaseResponseFunctionDataTypesList.md +++ b/docs/BaseResponseFunctionDataTypesList.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**FunctionDataTypesList**](FunctionDataTypesList.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**FunctionDataTypesList**](FunctionDataTypesList.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseFunctionSearchResponse.md b/docs/BaseResponseFunctionSearchResponse.md index 93cfbea9..d9d1176c 100644 --- a/docs/BaseResponseFunctionSearchResponse.md +++ b/docs/BaseResponseFunctionSearchResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**FunctionSearchResponse**](FunctionSearchResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**FunctionSearchResponse**](FunctionSearchResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseFunctionStringsResponse.md b/docs/BaseResponseFunctionStringsResponse.md index f1a04e56..3ae8b7c6 100644 --- a/docs/BaseResponseFunctionStringsResponse.md +++ b/docs/BaseResponseFunctionStringsResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**FunctionStringsResponse**](FunctionStringsResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**FunctionStringsResponse**](FunctionStringsResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseFunctionTaskResponse.md b/docs/BaseResponseFunctionTaskResponse.md index a0598587..687c3307 100644 --- a/docs/BaseResponseFunctionTaskResponse.md +++ b/docs/BaseResponseFunctionTaskResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**FunctionTaskResponse**](FunctionTaskResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**FunctionTaskResponse**](FunctionTaskResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseFunctionsDetailResponse.md b/docs/BaseResponseFunctionsDetailResponse.md index eb6c17bd..744ae6c6 100644 --- a/docs/BaseResponseFunctionsDetailResponse.md +++ b/docs/BaseResponseFunctionsDetailResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**FunctionsDetailResponse**](FunctionsDetailResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**FunctionsDetailResponse**](FunctionsDetailResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseGenerateFunctionDataTypes.md b/docs/BaseResponseGenerateFunctionDataTypes.md index c0baf800..a34b8e7e 100644 --- a/docs/BaseResponseGenerateFunctionDataTypes.md +++ b/docs/BaseResponseGenerateFunctionDataTypes.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**GenerateFunctionDataTypes**](GenerateFunctionDataTypes.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**GenerateFunctionDataTypes**](GenerateFunctionDataTypes.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseGenerationStatusList.md b/docs/BaseResponseGenerationStatusList.md index f03dbdbb..46664809 100644 --- a/docs/BaseResponseGenerationStatusList.md +++ b/docs/BaseResponseGenerationStatusList.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**GenerationStatusList**](GenerationStatusList.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**GenerationStatusList**](GenerationStatusList.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseGetAiDecompilationTask.md b/docs/BaseResponseGetAiDecompilationTask.md index 309b7cec..90b2dc2d 100644 --- a/docs/BaseResponseGetAiDecompilationTask.md +++ b/docs/BaseResponseGetAiDecompilationTask.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**GetAiDecompilationTask**](GetAiDecompilationTask.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**GetAiDecompilationTask**](GetAiDecompilationTask.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseGetPublicUserResponse.md b/docs/BaseResponseGetPublicUserResponse.md index 26ba58da..3391416d 100644 --- a/docs/BaseResponseGetPublicUserResponse.md +++ b/docs/BaseResponseGetPublicUserResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**GetPublicUserResponse**](GetPublicUserResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**GetPublicUserResponse**](GetPublicUserResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseListCalleesCallerFunctionsResponse.md b/docs/BaseResponseListCalleesCallerFunctionsResponse.md index a110c404..63a7df44 100644 --- a/docs/BaseResponseListCalleesCallerFunctionsResponse.md +++ b/docs/BaseResponseListCalleesCallerFunctionsResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**List<CalleesCallerFunctionsResponse>**](CalleesCallerFunctionsResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**List<CalleesCallerFunctionsResponse>**](CalleesCallerFunctionsResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseListCollectionResults.md b/docs/BaseResponseListCollectionResults.md index 118b684b..1ff0dfcb 100644 --- a/docs/BaseResponseListCollectionResults.md +++ b/docs/BaseResponseListCollectionResults.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**ListCollectionResults**](ListCollectionResults.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**ListCollectionResults**](ListCollectionResults.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseListCommentResponse.md b/docs/BaseResponseListCommentResponse.md index 3bfe5835..ec3f7185 100644 --- a/docs/BaseResponseListCommentResponse.md +++ b/docs/BaseResponseListCommentResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**List<CommentResponse>**](CommentResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**List<CommentResponse>**](CommentResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseListDieMatch.md b/docs/BaseResponseListDieMatch.md index e2448e9e..b872a85e 100644 --- a/docs/BaseResponseListDieMatch.md +++ b/docs/BaseResponseListDieMatch.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**List<DieMatch>**](DieMatch.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**List<DieMatch>**](DieMatch.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseListFunctionNameHistory.md b/docs/BaseResponseListFunctionNameHistory.md index 803b6a4e..f3a5adab 100644 --- a/docs/BaseResponseListFunctionNameHistory.md +++ b/docs/BaseResponseListFunctionNameHistory.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**List<FunctionNameHistory>**](FunctionNameHistory.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**List<FunctionNameHistory>**](FunctionNameHistory.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseListSBOM.md b/docs/BaseResponseListSBOM.md index 6a4ccc33..a6464dbb 100644 --- a/docs/BaseResponseListSBOM.md +++ b/docs/BaseResponseListSBOM.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**List<SBOM>**](SBOM.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**List<SBOM>**](SBOM.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseListUserActivityResponse.md b/docs/BaseResponseListUserActivityResponse.md index a62ed06f..c96574b8 100644 --- a/docs/BaseResponseListUserActivityResponse.md +++ b/docs/BaseResponseListUserActivityResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**List<UserActivityResponse>**](UserActivityResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**List<UserActivityResponse>**](UserActivityResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseLogs.md b/docs/BaseResponseLogs.md index 06e624c9..4f070c75 100644 --- a/docs/BaseResponseLogs.md +++ b/docs/BaseResponseLogs.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**Logs**](Logs.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**Logs**](Logs.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseModelsResponse.md b/docs/BaseResponseModelsResponse.md index 29da8bad..e85d4a36 100644 --- a/docs/BaseResponseModelsResponse.md +++ b/docs/BaseResponseModelsResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**ModelsResponse**](ModelsResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**ModelsResponse**](ModelsResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseParams.md b/docs/BaseResponseParams.md index a4c98936..71086c8b 100644 --- a/docs/BaseResponseParams.md +++ b/docs/BaseResponseParams.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**Params**](Params.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**Params**](Params.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseQueuedWorkflowTaskResponse.md b/docs/BaseResponseQueuedWorkflowTaskResponse.md index 1fff1b28..645c4208 100644 --- a/docs/BaseResponseQueuedWorkflowTaskResponse.md +++ b/docs/BaseResponseQueuedWorkflowTaskResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**QueuedWorkflowTaskResponse**](QueuedWorkflowTaskResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**QueuedWorkflowTaskResponse**](QueuedWorkflowTaskResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseRecent.md b/docs/BaseResponseRecent.md index 69906905..a5ac022e 100644 --- a/docs/BaseResponseRecent.md +++ b/docs/BaseResponseRecent.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**Recent**](Recent.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**Recent**](Recent.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseReportAnalysisResponse.md b/docs/BaseResponseReportAnalysisResponse.md index 1369341b..05caff21 100644 --- a/docs/BaseResponseReportAnalysisResponse.md +++ b/docs/BaseResponseReportAnalysisResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**ReportAnalysisResponse**](ReportAnalysisResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**ReportAnalysisResponse**](ReportAnalysisResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseStatus.md b/docs/BaseResponseStatus.md index d2d585b9..d02b3598 100644 --- a/docs/BaseResponseStatus.md +++ b/docs/BaseResponseStatus.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**StatusOutput**](StatusOutput.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**StatusOutput**](StatusOutput.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseStr.md b/docs/BaseResponseStr.md index 066806e8..0b4c4e21 100644 --- a/docs/BaseResponseStr.md +++ b/docs/BaseResponseStr.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | **String** | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | **String** | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseTagSearchResponse.md b/docs/BaseResponseTagSearchResponse.md index d8fcf8c0..98cb5d8d 100644 --- a/docs/BaseResponseTagSearchResponse.md +++ b/docs/BaseResponseTagSearchResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**TagSearchResponse**](TagSearchResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**TagSearchResponse**](TagSearchResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseTaskResponse.md b/docs/BaseResponseTaskResponse.md index 35b4ae8c..ca9d0383 100644 --- a/docs/BaseResponseTaskResponse.md +++ b/docs/BaseResponseTaskResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**TaskResponse**](TaskResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**TaskResponse**](TaskResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseTaskStatusResponse.md b/docs/BaseResponseTaskStatusResponse.md index bc72e9e6..4b6e206e 100644 --- a/docs/BaseResponseTaskStatusResponse.md +++ b/docs/BaseResponseTaskStatusResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**TaskStatusResponse**](TaskStatusResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**TaskStatusResponse**](TaskStatusResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseTriageReportResponse.md b/docs/BaseResponseTriageReportResponse.md index 62c2e891..2fe21e52 100644 --- a/docs/BaseResponseTriageReportResponse.md +++ b/docs/BaseResponseTriageReportResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**TriageReportResponse**](TriageReportResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**TriageReportResponse**](TriageReportResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseUnionGetAiDecompilationRatingResponseNoneType.md b/docs/BaseResponseUnionGetAiDecompilationRatingResponseNoneType.md index 19bff492..3167247b 100644 --- a/docs/BaseResponseUnionGetAiDecompilationRatingResponseNoneType.md +++ b/docs/BaseResponseUnionGetAiDecompilationRatingResponseNoneType.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**GetAiDecompilationRatingResponse**](GetAiDecompilationRatingResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**GetAiDecompilationRatingResponse**](GetAiDecompilationRatingResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseUploadResponse.md b/docs/BaseResponseUploadResponse.md index 15daeb0d..efb913bd 100644 --- a/docs/BaseResponseUploadResponse.md +++ b/docs/BaseResponseUploadResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**UploadResponse**](UploadResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**UploadResponse**](UploadResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseVulnerabilities.md b/docs/BaseResponseVulnerabilities.md index 5b0ed9c5..8024972c 100644 --- a/docs/BaseResponseVulnerabilities.md +++ b/docs/BaseResponseVulnerabilities.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**Vulnerabilities**](Vulnerabilities.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**Vulnerabilities**](Vulnerabilities.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/BaseResponseXrefResponse.md b/docs/BaseResponseXrefResponse.md index 275a552f..18f2358e 100644 --- a/docs/BaseResponseXrefResponse.md +++ b/docs/BaseResponseXrefResponse.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **Boolean** | Response status on whether the request succeeded | [optional] | -|**data** | [**XrefResponse**](XrefResponse.md) | | [optional] | -|**message** | **String** | | [optional] | -|**errors** | [**List<ErrorModel>**](ErrorModel.md) | | [optional] | +|**data** | [**XrefResponse**](XrefResponse.md) | Response data | [optional] | +|**message** | **String** | Response message | [optional] | +|**errors** | [**List<ErrorModel>**](ErrorModel.md) | List of errors | [optional] | |**meta** | [**MetaModel**](MetaModel.md) | Metadata | [optional] | diff --git a/docs/Basic.md b/docs/Basic.md index cb24fc9f..571d396a 100644 --- a/docs/Basic.md +++ b/docs/Basic.md @@ -21,9 +21,9 @@ |**debug** | **Boolean** | Whether the current analysis was analysed with debug symbols | | |**functionCount** | **Integer** | The number of functions in the binary | | |**isAdvanced** | **Boolean** | Whether the analysis was advanced | | -|**baseAddress** | **Integer** | | | -|**binaryUuid** | **String** | | [optional] | -|**sequencerVersion** | **String** | | [optional] | +|**baseAddress** | **Integer** | The base address of the binary | | +|**binaryUuid** | **String** | The UUID of the binary | [optional] | +|**sequencerVersion** | **String** | The sequencer version used for analysis | [optional] | |**teamId** | **Integer** | The team ID of the analysis | | diff --git a/docs/BatchRenameInputBody.md b/docs/BatchRenameInputBody.md index 4d7ac679..54261089 100644 --- a/docs/BatchRenameInputBody.md +++ b/docs/BatchRenameInputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**functions** | **List<BatchRenameItem>** | List of functions to rename | | +|**functions** | [**List<BatchRenameItem>**](BatchRenameItem.md) | List of functions to rename | | diff --git a/docs/BinaryConfig.md b/docs/BinaryConfig.md index 1e55ef97..ff69e9c1 100644 --- a/docs/BinaryConfig.md +++ b/docs/BinaryConfig.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**isa** | **ISA** | | [optional] | +|**isa** | **ISA** | Instruction Set Architecture | [optional] | |**platform** | **Platform** | | [optional] | |**fileFormat** | **FileFormat** | | [optional] | diff --git a/docs/BinarySearchResult.md b/docs/BinarySearchResult.md index 27700923..680094c2 100644 --- a/docs/BinarySearchResult.md +++ b/docs/BinarySearchResult.md @@ -11,7 +11,7 @@ |**binaryName** | **String** | The name of the binary | | |**analysisId** | **Integer** | The analysis ID | | |**sha256Hash** | **String** | The SHA-256 hash of the binary | | -|**tags** | **List<String>** | | | +|**tags** | **List<String>** | The tags of the binary | | |**createdAt** | **OffsetDateTime** | The creation date of the binary | | |**modelId** | **Integer** | The model ID of the binary | | |**modelName** | **String** | The name of the model | | diff --git a/docs/CalleeFunctionInfo.md b/docs/CalleeFunctionInfo.md index eedf81d7..88b1820c 100644 --- a/docs/CalleeFunctionInfo.md +++ b/docs/CalleeFunctionInfo.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**functionId** | **Long** | Unique identifier of the function | | -|**matchedFunctionId** | **Integer** | | | +|**matchedFunctionId** | **Integer** | Unique identifier of the matched function | | |**dashboardUrl** | **String** | | | |**isExternal** | **Boolean** | Indicates if the function is external | [optional] | |**calleeName** | **String** | Name of the called function | | diff --git a/docs/CallerFunctionInfo.md b/docs/CallerFunctionInfo.md index 2a705803..1c7b0db3 100644 --- a/docs/CallerFunctionInfo.md +++ b/docs/CallerFunctionInfo.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**functionId** | **Long** | Unique identifier of the function | | -|**matchedFunctionId** | **Integer** | | | +|**matchedFunctionId** | **Integer** | Unique identifier of the matched function | | |**dashboardUrl** | **String** | | | |**isExternal** | **Boolean** | Indicates if the function is external | [optional] | |**callerName** | **String** | Name of the calling function | | diff --git a/docs/ChildBinariesResponse.md b/docs/ChildBinariesResponse.md index 3bc4c4a1..57fae559 100644 --- a/docs/ChildBinariesResponse.md +++ b/docs/ChildBinariesResponse.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**children** | [**List<RelativeBinaryResponse>**](RelativeBinaryResponse.md) | List of child binaries associated with the parent binary | | -|**parent** | [**RelativeBinaryResponse**](RelativeBinaryResponse.md) | | [optional] | +|**parent** | [**RelativeBinaryResponse**](RelativeBinaryResponse.md) | Details of the parent binary if it exists | [optional] | diff --git a/docs/CollectionListItem.md b/docs/CollectionListItem.md index d967ffc1..3153e1f6 100644 --- a/docs/CollectionListItem.md +++ b/docs/CollectionListItem.md @@ -17,7 +17,7 @@ |**collectionId** | **Integer** | The ID of the collection | | |**creation** | **OffsetDateTime** | The datetime of when the collection was created | | |**modelName** | **String** | The model being used for the collection | | -|**teamId** | **Integer** | | [optional] | +|**teamId** | **Integer** | The team ID for the collection | [optional] | diff --git a/docs/CollectionResponse.md b/docs/CollectionResponse.md index c87011eb..dab9c02a 100644 --- a/docs/CollectionResponse.md +++ b/docs/CollectionResponse.md @@ -12,12 +12,12 @@ |**description** | **String** | Collection description | | |**modelId** | **Integer** | Collection model ID | | |**userId** | **Integer** | Collection user ID | | -|**teamId** | **Integer** | | [optional] | +|**teamId** | **Integer** | Collection team ID | [optional] | |**collectionScope** | **CollectionScope** | Collection public status | | |**createdAt** | **OffsetDateTime** | Collection creation date | | |**updatedAt** | **OffsetDateTime** | Collection last update date | | -|**tags** | **List<String>** | | [optional] | -|**binaries** | [**List<CollectionResponseBinariesInner>**](CollectionResponseBinariesInner.md) | | [optional] | +|**tags** | **List<String>** | Collection tags | [optional] | +|**binaries** | [**List<CollectionResponseBinariesInner>**](CollectionResponseBinariesInner.md) | Collection binaries | [optional] | diff --git a/docs/CollectionSearchResult.md b/docs/CollectionSearchResult.md index 67e3310d..cadc3cce 100644 --- a/docs/CollectionSearchResult.md +++ b/docs/CollectionSearchResult.md @@ -15,10 +15,10 @@ |**modelId** | **Integer** | The model ID of the binary | | |**modelName** | **String** | The name of the model | | |**ownedBy** | **String** | The owner of the collection | | -|**tags** | **List<String>** | | [optional] | -|**size** | **Integer** | | [optional] | +|**tags** | **List<String>** | The tags of the collection | [optional] | +|**size** | **Integer** | The number of binaries in the collection | [optional] | |**description** | **String** | The description of the collection | | -|**teamId** | **Integer** | | [optional] | +|**teamId** | **Integer** | The team ID of the collection | [optional] | diff --git a/docs/CollectionsApi.md b/docs/CollectionsApi.md index b38f6434..bd6f31e3 100644 --- a/docs/CollectionsApi.md +++ b/docs/CollectionsApi.md @@ -298,8 +298,8 @@ public class Example { | **filters** | [**List<Filters>**](Filters.md)| | [optional] | | **limit** | **Integer**| | [optional] [default to 20] | | **offset** | **Integer**| | [optional] [default to 0] | -| **orderBy** | [**AppApiRestV2CollectionsEnumsOrderBy**](.md)| | [optional] [enum: created, collection, model, owner, collection_size, updated] | -| **order** | [**Order**](.md)| | [optional] [enum: ASC, DESC] | +| **orderBy** | [**AppApiRestV2CollectionsEnumsOrderBy**](.md)| | [optional] [default to collection] [enum: created, collection, model, owner, collection_size, updated] | +| **order** | [**Order**](.md)| | [optional] [default to ASC] [enum: ASC, DESC] | ### Return type diff --git a/docs/CommentsData.md b/docs/CommentsData.md index 38f9136e..96254081 100644 --- a/docs/CommentsData.md +++ b/docs/CommentsData.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**inlineComments** | **List<InlineComment>** | Structured inline comments with line numbers | | +|**inlineComments** | [**List<InlineComment>**](InlineComment.md) | Structured inline comments with line numbers | | |**taskStatus** | [**TaskStatusEnum**](#TaskStatusEnum) | Task status | | diff --git a/docs/Connection.md b/docs/Connection.md index 8e163dac..b0b3643b 100644 --- a/docs/Connection.md +++ b/docs/Connection.md @@ -7,12 +7,17 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**events** | **List<ReportEvent>** | | [optional] | +|**bytesReceived** | **Long** | | [optional] | +|**bytesSent** | **Long** | | [optional] | +|**events** | [**List<ReportEvent>**](ReportEvent.md) | | [optional] | +|**ja3** | **String** | | [optional] | +|**ja3s** | **String** | | [optional] | |**localIp** | **String** | | | |**localPort** | **Object** | | | |**protocol** | **String** | | | |**remoteIp** | **String** | | | |**remotePort** | **Object** | | | +|**tcpCarvedFiles** | [**List<TcpCarvedFile>**](TcpCarvedFile.md) | | [optional] | diff --git a/docs/ProcessExtractedFiles.md b/docs/ConsoleOutputEntry.md similarity index 63% rename from docs/ProcessExtractedFiles.md rename to docs/ConsoleOutputEntry.md index 6c3b7cb9..a859e712 100644 --- a/docs/ProcessExtractedFiles.md +++ b/docs/ConsoleOutputEntry.md @@ -1,13 +1,13 @@ -# ProcessExtractedFiles +# ConsoleOutputEntry ## Properties | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**files** | **List<ExtractedFileEntry>** | | [optional] | +|**output** | **String** | | | |**processSeqid** | **Long** | | | diff --git a/docs/ConversationWithEvents.md b/docs/ConversationWithEvents.md index d570b0ef..22853f7b 100644 --- a/docs/ConversationWithEvents.md +++ b/docs/ConversationWithEvents.md @@ -10,7 +10,7 @@ |**context** | **Object** | | [optional] | |**conversationUuid** | **String** | | | |**createdAt** | **OffsetDateTime** | | | -|**events** | **List<Event>** | | | +|**events** | [**List<Event>**](Event.md) | | | |**title** | **String** | | | |**updatedAt** | **OffsetDateTime** | | | |**userId** | **Long** | | | diff --git a/docs/ConversationsApi.md b/docs/ConversationsApi.md index abad2734..df8be5b4 100644 --- a/docs/ConversationsApi.md +++ b/docs/ConversationsApi.md @@ -452,7 +452,7 @@ public class Example { # **streamEvents** -> List<StreamEvents200ResponseInner> streamEvents(id, lastEventId) +> List<ServerSentEventsInner> streamEvents(id, lastEventId) Stream conversation events (SSE) @@ -483,7 +483,7 @@ public class Example { UUID id = UUID.randomUUID(); // UUID | Conversation UUID Long lastEventId = 56L; // Long | Replay events after this ID try { - List result = apiInstance.streamEvents(id, lastEventId); + List result = apiInstance.streamEvents(id, lastEventId); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling ConversationsApi#streamEvents"); @@ -505,7 +505,7 @@ public class Example { ### Return type -[**List<StreamEvents200ResponseInner>**](StreamEvents200ResponseInner.md) +[**List<ServerSentEventsInner>**](ServerSentEventsInner.md) ### Authorization diff --git a/docs/CreateCollectionOutputBody.md b/docs/CreateCollectionOutputBody.md index 8c8c77fd..b9aeff55 100644 --- a/docs/CreateCollectionOutputBody.md +++ b/docs/CreateCollectionOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**binaries** | **List<Binary>** | | [optional] | +|**binaries** | [**List<Binary>**](Binary.md) | | [optional] | |**collectionId** | **Long** | | | |**collectionName** | **String** | | | |**collectionScope** | **String** | | | diff --git a/docs/CreateConversationRequest.md b/docs/CreateConversationRequest.md index cdacf9ad..b05699d0 100644 --- a/docs/CreateConversationRequest.md +++ b/docs/CreateConversationRequest.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**context** | **ConversationContext** | | [optional] | +|**context** | [**ConversationContext**](ConversationContext.md) | | [optional] | |**title** | **String** | | [optional] | diff --git a/docs/DnsQuery.md b/docs/DnsQuery.md index 324b53bb..1305ea42 100644 --- a/docs/DnsQuery.md +++ b/docs/DnsQuery.md @@ -7,8 +7,11 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| +|**cnameChain** | **List<String>** | | [optional] | |**domain** | **String** | | | -|**events** | **List<ReportEvent>** | | [optional] | +|**events** | [**List<ReportEvent>**](ReportEvent.md) | | [optional] | +|**minTtl** | **Long** | | [optional] | +|**resolvedIps** | **List<String>** | | [optional] | diff --git a/docs/DynamicExecutionStatusResponse.md b/docs/DynamicExecutionStatusResponse.md index b45a0be8..9b28bf1d 100644 --- a/docs/DynamicExecutionStatusResponse.md +++ b/docs/DynamicExecutionStatusResponse.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**errorMessage** | **String** | Error detail, set when status is ERROR | [optional] | -|**logs** | **AnalysisLogs** | Sandbox status log messages captured during the run. Contains a single \"No logs available\" message when none have been captured yet. | | +|**logs** | [**AnalysisLogs**](AnalysisLogs.md) | Sandbox status log messages captured during the run. Contains a single \"No logs available\" message when none have been captured yet. | | |**status** | **String** | Task status: UNINITIALISED, PENDING, RUNNING, COMPLETED, or ERROR | | diff --git a/docs/Enumeration.md b/docs/Enumeration.md index d9d31c23..c79166fe 100644 --- a/docs/Enumeration.md +++ b/docs/Enumeration.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**lastChange** | **String** | | [optional] | +|**lastChange** | **String** | Timestamp of the last change to this enumeration | [optional] | |**name** | **String** | Name of the enumeration | | |**members** | **Map<String, Integer>** | Dictionary of enumeration members and their values | | |**artifactType** | **String** | Type of artifact that the enumeration is associated with | [optional] | diff --git a/docs/EventAttemptFailed.md b/docs/EventAttemptFailed.md index d0785f8d..0e762936 100644 --- a/docs/EventAttemptFailed.md +++ b/docs/EventAttemptFailed.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **AttemptFailedEvent** | | | +|**data** | [**AttemptFailedEvent**](AttemptFailedEvent.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventAttemptStarted.md b/docs/EventAttemptStarted.md index 79bf23f5..dad1fe57 100644 --- a/docs/EventAttemptStarted.md +++ b/docs/EventAttemptStarted.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **AttemptStartedEvent** | | | +|**data** | [**AttemptStartedEvent**](AttemptStartedEvent.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventCONTEXTCOMPACTED.md b/docs/EventCONTEXTCOMPACTED.md index 1908eb58..bf346d62 100644 --- a/docs/EventCONTEXTCOMPACTED.md +++ b/docs/EventCONTEXTCOMPACTED.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **SseEventContextCompactedData** | | | +|**data** | [**SseEventContextCompactedData**](SseEventContextCompactedData.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventDecompFailed.md b/docs/EventDecompFailed.md index b35cd520..37cee435 100644 --- a/docs/EventDecompFailed.md +++ b/docs/EventDecompFailed.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **DecompFailedEvent** | | | +|**data** | [**DecompFailedEvent**](DecompFailedEvent.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventDecompFinished.md b/docs/EventDecompFinished.md index 0a0d346f..53a89e2a 100644 --- a/docs/EventDecompFinished.md +++ b/docs/EventDecompFinished.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **DecompFinishedEvent** | | | +|**data** | [**DecompFinishedEvent**](DecompFinishedEvent.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventProse.md b/docs/EventProse.md index d1259f78..be636af9 100644 --- a/docs/EventProse.md +++ b/docs/EventProse.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **ProseEvent** | | | +|**data** | [**ProseEvent**](ProseEvent.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventRUNCANCELLED.md b/docs/EventRUNCANCELLED.md index 7885d32b..5cf796d5 100644 --- a/docs/EventRUNCANCELLED.md +++ b/docs/EventRUNCANCELLED.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **SseEventRunCancelledData** | | | +|**data** | [**SseEventRunCancelledData**](SseEventRunCancelledData.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventRUNERROR.md b/docs/EventRUNERROR.md index 98aa3d83..ca39024c 100644 --- a/docs/EventRUNERROR.md +++ b/docs/EventRUNERROR.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **SseEventRunErrorData** | | | +|**data** | [**SseEventRunErrorData**](SseEventRunErrorData.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventRUNFINISHED.md b/docs/EventRUNFINISHED.md index 73b8959a..1632ea8a 100644 --- a/docs/EventRUNFINISHED.md +++ b/docs/EventRUNFINISHED.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **SseEventRunFinishedData** | | | +|**data** | [**SseEventRunFinishedData**](SseEventRunFinishedData.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventRUNSTARTED.md b/docs/EventRUNSTARTED.md index e5feb036..8cef2498 100644 --- a/docs/EventRUNSTARTED.md +++ b/docs/EventRUNSTARTED.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **SseEventRunStartedData** | | | +|**data** | [**SseEventRunStartedData**](SseEventRunStartedData.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventRenameApplied.md b/docs/EventRenameApplied.md index 14272f71..c8005916 100644 --- a/docs/EventRenameApplied.md +++ b/docs/EventRenameApplied.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **RenameAppliedEvent** | | | +|**data** | [**RenameAppliedEvent**](RenameAppliedEvent.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventSTEPFINISHED.md b/docs/EventSTEPFINISHED.md index a0274a7d..90b815d0 100644 --- a/docs/EventSTEPFINISHED.md +++ b/docs/EventSTEPFINISHED.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **SseEventStepFinishedData** | | | +|**data** | [**SseEventStepFinishedData**](SseEventStepFinishedData.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventSTEPSTARTED.md b/docs/EventSTEPSTARTED.md index 6cf63ead..24c9d297 100644 --- a/docs/EventSTEPSTARTED.md +++ b/docs/EventSTEPSTARTED.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **SseEventStepStartedData** | | | +|**data** | [**SseEventStepStartedData**](SseEventStepStartedData.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventSourceDelta.md b/docs/EventSourceDelta.md index fd47d40e..c17af258 100644 --- a/docs/EventSourceDelta.md +++ b/docs/EventSourceDelta.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **SourceDeltaEvent** | | | +|**data** | [**SourceDeltaEvent**](SourceDeltaEvent.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventSourceReset.md b/docs/EventSourceReset.md index 3771eab9..d89f32f8 100644 --- a/docs/EventSourceReset.md +++ b/docs/EventSourceReset.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **SourceResetEvent** | | | +|**data** | [**SourceResetEvent**](SourceResetEvent.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventTEXTMESSAGECONTENT.md b/docs/EventTEXTMESSAGECONTENT.md index 686a8151..628710a5 100644 --- a/docs/EventTEXTMESSAGECONTENT.md +++ b/docs/EventTEXTMESSAGECONTENT.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **SseEventTextMessageContentData** | | | +|**data** | [**SseEventTextMessageContentData**](SseEventTextMessageContentData.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventTEXTMESSAGEEND.md b/docs/EventTEXTMESSAGEEND.md index fe89c0d2..62dda38b 100644 --- a/docs/EventTEXTMESSAGEEND.md +++ b/docs/EventTEXTMESSAGEEND.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **SseEventTextMessageEndData** | | | +|**data** | [**SseEventTextMessageEndData**](SseEventTextMessageEndData.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventTEXTMESSAGESTART.md b/docs/EventTEXTMESSAGESTART.md index 95d3c1f3..c73748a3 100644 --- a/docs/EventTEXTMESSAGESTART.md +++ b/docs/EventTEXTMESSAGESTART.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **SseEventTextMessageStartData** | | | +|**data** | [**SseEventTextMessageStartData**](SseEventTextMessageStartData.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventTITLEUPDATED.md b/docs/EventTITLEUPDATED.md index e649defb..0a3f2b75 100644 --- a/docs/EventTITLEUPDATED.md +++ b/docs/EventTITLEUPDATED.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **SseEventTitleUpdatedData** | | | +|**data** | [**SseEventTitleUpdatedData**](SseEventTitleUpdatedData.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventTOOLCALLARGSDELTA.md b/docs/EventTOOLCALLARGSDELTA.md index 87771992..d0591f26 100644 --- a/docs/EventTOOLCALLARGSDELTA.md +++ b/docs/EventTOOLCALLARGSDELTA.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **SseEventToolCallArgsDeltaData** | | | +|**data** | [**SseEventToolCallArgsDeltaData**](SseEventToolCallArgsDeltaData.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventTOOLCALLEND.md b/docs/EventTOOLCALLEND.md index 3a885fc9..db4cd41c 100644 --- a/docs/EventTOOLCALLEND.md +++ b/docs/EventTOOLCALLEND.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **SseEventToolCallEndData** | | | +|**data** | [**SseEventToolCallEndData**](SseEventToolCallEndData.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventTOOLCALLRESULT.md b/docs/EventTOOLCALLRESULT.md index e3721d52..9d5595ca 100644 --- a/docs/EventTOOLCALLRESULT.md +++ b/docs/EventTOOLCALLRESULT.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **SseEventToolCallResultData** | | | +|**data** | [**SseEventToolCallResultData**](SseEventToolCallResultData.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventTOOLCALLSTART.md b/docs/EventTOOLCALLSTART.md index 9d296203..bcb7fb57 100644 --- a/docs/EventTOOLCALLSTART.md +++ b/docs/EventTOOLCALLSTART.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **SseEventToolCallStartData** | | | +|**data** | [**SseEventToolCallStartData**](SseEventToolCallStartData.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventTOOLCONFIRMATIONREQUIRED.md b/docs/EventTOOLCONFIRMATIONREQUIRED.md index a5b57459..b38229c0 100644 --- a/docs/EventTOOLCONFIRMATIONREQUIRED.md +++ b/docs/EventTOOLCONFIRMATIONREQUIRED.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **SseEventToolConfirmationRequiredData** | | | +|**data** | [**SseEventToolConfirmationRequiredData**](SseEventToolConfirmationRequiredData.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/EventWarning.md b/docs/EventWarning.md index d7cd5cf0..2313d861 100644 --- a/docs/EventWarning.md +++ b/docs/EventWarning.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **WarningEvent** | | | +|**data** | [**WarningEvent**](WarningEvent.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/ExtractedFileEntry.md b/docs/ExtractedFileEntry.md deleted file mode 100644 index 156ce940..00000000 --- a/docs/ExtractedFileEntry.md +++ /dev/null @@ -1,22 +0,0 @@ - - -# ExtractedFileEntry - - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**fileHash** | **String** | | [optional] | -|**fileSize** | **Long** | | | -|**fileType** | **String** | | [optional] | -|**filename** | **String** | | | -|**isPe** | **Boolean** | | [optional] | -|**mimeType** | **String** | | [optional] | -|**reason** | **String** | | [optional] | -|**seqNum** | **Long** | | | -|**sha256** | **String** | | [optional] | -|**zipFilename** | **String** | | | - - - diff --git a/docs/ExtractedURL.md b/docs/ExtractedURL.md index a4b464de..c02a2410 100644 --- a/docs/ExtractedURL.md +++ b/docs/ExtractedURL.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**events** | **List<ReportEvent>** | | [optional] | +|**events** | [**List<ReportEvent>**](ReportEvent.md) | | [optional] | |**url** | **String** | | | diff --git a/docs/FileActivityEntry.md b/docs/FileActivityEntry.md index 2b8edbe4..14eade42 100644 --- a/docs/FileActivityEntry.md +++ b/docs/FileActivityEntry.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**events** | **List<ReportEvent>** | | [optional] | +|**events** | [**List<ReportEvent>**](ReportEvent.md) | | [optional] | |**path** | **String** | | | diff --git a/docs/FirmwareApi.md b/docs/FirmwareApi.md index c0a20c13..697c7090 100644 --- a/docs/FirmwareApi.md +++ b/docs/FirmwareApi.md @@ -108,7 +108,7 @@ public class Example { //APIKey.setApiKeyPrefix("Token"); FirmwareApi apiInstance = new FirmwareApi(defaultClient); - String _file = "_file_example"; // String | + File _file = new File("/path/to/file"); // File | String password = "password_example"; // String | try { Object result = apiInstance.uploadFirmware(_file, password); @@ -128,7 +128,7 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **_file** | **String**| | | +| **_file** | **File**| | | | **password** | **String**| | [optional] | ### Return type diff --git a/docs/FunctionInfoInputFuncDepsInner.md b/docs/FuncDepsInner.md similarity index 83% rename from docs/FunctionInfoInputFuncDepsInner.md rename to docs/FuncDepsInner.md index 065aa269..ef74ffd3 100644 --- a/docs/FunctionInfoInputFuncDepsInner.md +++ b/docs/FuncDepsInner.md @@ -1,13 +1,13 @@ -# FunctionInfoInputFuncDepsInner +# FuncDepsInner ## Properties | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**lastChange** | **String** | | [optional] | +|**lastChange** | **String** | Timestamp of the last change to this global variable | [optional] | |**name** | **String** | Name of the global variable | | |**size** | **Integer** | Size of the global variable in bytes | | |**members** | **Map<String, Integer>** | Dictionary of enumeration members and their values | | diff --git a/docs/FunctionBlockDestinationResponse.md b/docs/FunctionBlockDestinationResponse.md index e17de664..e330b60a 100644 --- a/docs/FunctionBlockDestinationResponse.md +++ b/docs/FunctionBlockDestinationResponse.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**destinationBlockId** | **Integer** | | | +|**destinationBlockId** | **Integer** | The block where execution can flow to from the current block | | |**flowtype** | **String** | The type of execution flow between chunks | | |**vaddr** | **String** | The vaddr of the destination where the execution flow continues from | | diff --git a/docs/FunctionBlockResponse.md b/docs/FunctionBlockResponse.md index 2f89b346..ad8f0320 100644 --- a/docs/FunctionBlockResponse.md +++ b/docs/FunctionBlockResponse.md @@ -12,7 +12,7 @@ |**minAddr** | **Integer** | The minimum vaddr of the block | | |**maxAddr** | **Integer** | The maximum vaddr of the block | | |**destinations** | [**List<FunctionBlockDestinationResponse>**](FunctionBlockDestinationResponse.md) | The potential execution flow destinations from this block | | -|**comment** | **String** | | [optional] | +|**comment** | **String** | An optional comment associated with this block, if any | [optional] | diff --git a/docs/FunctionBlocksResponse.md b/docs/FunctionBlocksResponse.md index 735ab558..e8a3fcef 100644 --- a/docs/FunctionBlocksResponse.md +++ b/docs/FunctionBlocksResponse.md @@ -11,7 +11,7 @@ Response for returning disassembly of a function. |**blocks** | [**List<FunctionBlockResponse>**](FunctionBlockResponse.md) | Disassembly is broken into control flow blocks | | |**localVariables** | [**List<FunctionLocalVariableResponse>**](FunctionLocalVariableResponse.md) | Local variables associated with this function | | |**params** | [**List<FunctionParamResponse>**](FunctionParamResponse.md) | Params associated with this function | | -|**overviewComment** | **String** | | [optional] | +|**overviewComment** | **String** | An overview comment for the whole function | [optional] | diff --git a/docs/FunctionBoundary.md b/docs/FunctionBoundary.md index ea6e6dc6..8ce1e713 100644 --- a/docs/FunctionBoundary.md +++ b/docs/FunctionBoundary.md @@ -10,7 +10,7 @@ |**mangledName** | **String** | | | |**startAddress** | **Long** | | | |**endAddress** | **Long** | | | -|**includeInAnalysis** | **Boolean** | | [optional] | +|**includeInAnalysis** | **Boolean** | Indicates whether the function should be included in the analysis | [optional] | diff --git a/docs/FunctionDataTypes.md b/docs/FunctionDataTypes.md index 921ea8cc..a169f6ca 100644 --- a/docs/FunctionDataTypes.md +++ b/docs/FunctionDataTypes.md @@ -9,8 +9,8 @@ |------------ | ------------- | ------------- | -------------| |**completed** | **Boolean** | Whether the service has completed data types generation | | |**status** | **String** | The current status of the data types service | | -|**dataTypes** | [**FunctionInfoOutput**](FunctionInfoOutput.md) | | [optional] | -|**dataTypesVersion** | **Integer** | | [optional] | +|**dataTypes** | [**FunctionInfoOutput**](FunctionInfoOutput.md) | Function data types information if available | [optional] | +|**dataTypesVersion** | **Integer** | If the data types information has been updated by the user, this field will be populated | [optional] | diff --git a/docs/FunctionDataTypesListItem.md b/docs/FunctionDataTypesListItem.md index 4904417f..83ac4e1d 100644 --- a/docs/FunctionDataTypesListItem.md +++ b/docs/FunctionDataTypesListItem.md @@ -9,8 +9,8 @@ |------------ | ------------- | ------------- | -------------| |**completed** | **Boolean** | Whether the service has completed data types generation | | |**status** | **String** | The current status of the data types service | | -|**dataTypes** | [**FunctionInfoOutput**](FunctionInfoOutput.md) | | [optional] | -|**dataTypesVersion** | **Integer** | | [optional] | +|**dataTypes** | [**FunctionInfoOutput**](FunctionInfoOutput.md) | Function data types information if available | [optional] | +|**dataTypesVersion** | **Integer** | If the data types information has been updated by the user, this field will be populated | [optional] | |**functionId** | **Long** | Function id | | diff --git a/docs/FunctionHeader.md b/docs/FunctionHeader.md index 8b7a9eff..5e4cf776 100644 --- a/docs/FunctionHeader.md +++ b/docs/FunctionHeader.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**lastChange** | **String** | | [optional] | +|**lastChange** | **String** | Timestamp of the last change to this function header | [optional] | |**name** | **String** | Name of the function | | |**addr** | **Integer** | Memory address of the function | | |**type** | **String** | Return type of the function | | diff --git a/docs/FunctionInfoInput.md b/docs/FunctionInfoInput.md index 02b5a59b..ba6215f4 100644 --- a/docs/FunctionInfoInput.md +++ b/docs/FunctionInfoInput.md @@ -7,8 +7,8 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**funcTypes** | [**FunctionTypeInput**](FunctionTypeInput.md) | | [optional] | -|**funcDeps** | [**List<FunctionInfoInputFuncDepsInner>**](FunctionInfoInputFuncDepsInner.md) | List of function dependencies | | +|**funcTypes** | [**FunctionTypeInput**](FunctionTypeInput.md) | Function type information | [optional] | +|**funcDeps** | [**List<FuncDepsInner>**](FuncDepsInner.md) | List of function dependencies | | diff --git a/docs/FunctionInfoOutput.md b/docs/FunctionInfoOutput.md index 075340ef..9fc46c97 100644 --- a/docs/FunctionInfoOutput.md +++ b/docs/FunctionInfoOutput.md @@ -7,8 +7,8 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**funcTypes** | [**FunctionTypeOutput**](FunctionTypeOutput.md) | | [optional] | -|**funcDeps** | [**List<FunctionInfoInputFuncDepsInner>**](FunctionInfoInputFuncDepsInner.md) | List of function dependencies | | +|**funcTypes** | [**FunctionTypeInput**](FunctionTypeInput.md) | Function type information | [optional] | +|**funcDeps** | [**List<FuncDepsInner>**](FuncDepsInner.md) | List of function dependencies | | diff --git a/docs/FunctionMatchingRequest.md b/docs/FunctionMatchingRequest.md index 45c0acb0..ecbe7d7a 100644 --- a/docs/FunctionMatchingRequest.md +++ b/docs/FunctionMatchingRequest.md @@ -10,7 +10,7 @@ |**modelId** | **Integer** | ID of the model used for function matching, used to determine the embedding model | | |**functionIds** | **List<Long>** | ID's of functions to find matches for, must be at least one function ID | | |**minSimilarity** | **BigDecimal** | Minimum similarity expected for a match as a percentage, default is 90 | [optional] | -|**filters** | [**FunctionMatchingFilters**](FunctionMatchingFilters.md) | | [optional] | +|**filters** | [**FunctionMatchingFilters**](FunctionMatchingFilters.md) | Used to limit the search to specific binaries, collections, and functions | [optional] | |**resultsPerFunction** | **Integer** | Maximum number of matches to return per function, default is 1, max is 50 | [optional] | |**page** | **Integer** | Page number for paginated results, default is 1 (first page) | [optional] | |**pageSize** | **Integer** | Number of functions to return per page, default is 0 (all functions), max is 1000 | [optional] | diff --git a/docs/FunctionMatchingResponse.md b/docs/FunctionMatchingResponse.md index c9edcd92..bf309f67 100644 --- a/docs/FunctionMatchingResponse.md +++ b/docs/FunctionMatchingResponse.md @@ -8,15 +8,15 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**progress** | **Integer** | Progress of the matching operation, represented as a percentage | [optional] | -|**status** | **String** | | [optional] | -|**totalTime** | **Integer** | | [optional] | -|**errorMessage** | **String** | | [optional] | -|**currentPage** | **Integer** | | [optional] | -|**totalPages** | **Integer** | | [optional] | -|**matches** | [**List<FunctionMatch>**](FunctionMatch.md) | | [optional] | -|**numMatches** | **Integer** | | [optional] | -|**numDebugMatches** | **Integer** | | [optional] | -|**updatedAt** | **String** | | [optional] | +|**status** | **String** | Status of the function matching operation | [optional] | +|**totalTime** | **Integer** | Total time taken for the matching operation in seconds | [optional] | +|**errorMessage** | **String** | Optional message providing additional information about the operation | [optional] | +|**currentPage** | **Integer** | Current page number of the results, if pagination is used | [optional] | +|**totalPages** | **Integer** | Total number of pages available, if pagination is used | [optional] | +|**matches** | [**List<FunctionMatch>**](FunctionMatch.md) | List of function matching results with best match information | [optional] | +|**numMatches** | **Integer** | Total number of function matches found | [optional] | +|**numDebugMatches** | **Integer** | Total number of debug function matches found | [optional] | +|**updatedAt** | **String** | Timestamp of the last time function matching with the same request parameters was performed | [optional] | diff --git a/docs/FunctionTypeInput.md b/docs/FunctionTypeInput.md index 0fa3f38c..b0772025 100644 --- a/docs/FunctionTypeInput.md +++ b/docs/FunctionTypeInput.md @@ -7,11 +7,11 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**lastChange** | **String** | | [optional] | +|**lastChange** | **String** | Timestamp of the last change to this function type | [optional] | |**addr** | **Integer** | Memory address of the function | | |**size** | **Integer** | Size of the function in bytes | | |**header** | [**FunctionHeader**](FunctionHeader.md) | Function header information | | -|**stackVars** | [**Map<String, StackVariable>**](StackVariable.md) | | [optional] | +|**stackVars** | [**Map<String, StackVariable>**](StackVariable.md) | Dictionary of stack variables | [optional] | |**name** | **String** | Name of the function | | |**type** | **String** | Return type of the function | | |**artifactType** | **String** | Type of artifact that the structure is associated with | [optional] | diff --git a/docs/FunctionTypeOutput.md b/docs/FunctionTypeOutput.md deleted file mode 100644 index a27ae3d1..00000000 --- a/docs/FunctionTypeOutput.md +++ /dev/null @@ -1,20 +0,0 @@ - - -# FunctionTypeOutput - - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**lastChange** | **String** | | [optional] | -|**addr** | **Integer** | Memory address of the function | | -|**size** | **Integer** | Size of the function in bytes | | -|**header** | [**FunctionHeader**](FunctionHeader.md) | Function header information | | -|**stackVars** | [**Map<String, StackVariable>**](StackVariable.md) | | [optional] | -|**name** | **String** | Name of the function | | -|**type** | **String** | Return type of the function | | -|**artifactType** | **String** | Type of artifact that the structure is associated with | [optional] | - - - diff --git a/docs/FunctionsAiDecompilationApi.md b/docs/FunctionsAiDecompilationApi.md index 622640ae..02d8ab0e 100644 --- a/docs/FunctionsAiDecompilationApi.md +++ b/docs/FunctionsAiDecompilationApi.md @@ -1421,7 +1421,7 @@ public class Example { # **streamAiDecompilation** -> List<StreamAiDecompilation200ResponseInner> streamAiDecompilation(functionId) +> List<ServerSentEventsInner1> streamAiDecompilation(functionId) Stream live AI decompilation output (SSE) @@ -1451,7 +1451,7 @@ public class Example { FunctionsAiDecompilationApi apiInstance = new FunctionsAiDecompilationApi(defaultClient); Long functionId = 56L; // Long | Function ID try { - List result = apiInstance.streamAiDecompilation(functionId); + List result = apiInstance.streamAiDecompilation(functionId); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling FunctionsAiDecompilationApi#streamAiDecompilation"); @@ -1472,7 +1472,7 @@ public class Example { ### Return type -[**List<StreamAiDecompilation200ResponseInner>**](StreamAiDecompilation200ResponseInner.md) +[**List<ServerSentEventsInner1>**](ServerSentEventsInner1.md) ### Authorization diff --git a/docs/FunctionsCoreApi.md b/docs/FunctionsCoreApi.md index 0197a3e4..43c2fc9d 100644 --- a/docs/FunctionsCoreApi.md +++ b/docs/FunctionsCoreApi.md @@ -25,7 +25,7 @@ All URIs are relative to *https://api.reveng.ai* # **addFunctionCallee** -> Map<String, Object> addFunctionCallee(functionId, addCalleeInputBody) +> Object addFunctionCallee(functionId, addCalleeInputBody) Add a callee to a function @@ -56,7 +56,7 @@ public class Example { Long functionId = 56L; // Long | Function ID AddCalleeInputBody addCalleeInputBody = new AddCalleeInputBody(); // AddCalleeInputBody | try { - Map result = apiInstance.addFunctionCallee(functionId, addCalleeInputBody); + Object result = apiInstance.addFunctionCallee(functionId, addCalleeInputBody); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling FunctionsCoreApi#addFunctionCallee"); @@ -78,7 +78,7 @@ public class Example { ### Return type -**Map<String, Object>** +**Object** ### Authorization @@ -101,7 +101,7 @@ public class Example { # **addUserStringToFunction** -> Map<String, Object> addUserStringToFunction(functionId, addUserStringToFunctionInputBody) +> Object addUserStringToFunction(functionId, addUserStringToFunctionInputBody) Add a user-provided string to a function. @@ -132,7 +132,7 @@ public class Example { Long functionId = 56L; // Long | Function ID AddUserStringToFunctionInputBody addUserStringToFunctionInputBody = new AddUserStringToFunctionInputBody(); // AddUserStringToFunctionInputBody | try { - Map result = apiInstance.addUserStringToFunction(functionId, addUserStringToFunctionInputBody); + Object result = apiInstance.addUserStringToFunction(functionId, addUserStringToFunctionInputBody); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling FunctionsCoreApi#addUserStringToFunction"); @@ -154,7 +154,7 @@ public class Example { ### Return type -**Map<String, Object>** +**Object** ### Authorization diff --git a/docs/FunctionsRenamingHistoryApi.md b/docs/FunctionsRenamingHistoryApi.md index 5003a54c..12d40bf9 100644 --- a/docs/FunctionsRenamingHistoryApi.md +++ b/docs/FunctionsRenamingHistoryApi.md @@ -521,7 +521,7 @@ public class Example { # **revertFunctionName_0** -> Map<String, Object> revertFunctionName_0(functionId, historyId) +> Object revertFunctionName_0(functionId, historyId) Revert function name @@ -552,7 +552,7 @@ public class Example { Long functionId = 56L; // Long | Function ID Long historyId = 56L; // Long | History ID to revert to try { - Map result = apiInstance.revertFunctionName_0(functionId, historyId); + Object result = apiInstance.revertFunctionName_0(functionId, historyId); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling FunctionsRenamingHistoryApi#revertFunctionName_0"); @@ -574,7 +574,7 @@ public class Example { ### Return type -**Map<String, Object>** +**Object** ### Authorization diff --git a/docs/GetAiDecompilationRatingResponse.md b/docs/GetAiDecompilationRatingResponse.md index 78805bf8..22100b6b 100644 --- a/docs/GetAiDecompilationRatingResponse.md +++ b/docs/GetAiDecompilationRatingResponse.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**rating** | **AiDecompilationRating** | The rating the user has given to the AI decompilation response | | -|**reason** | **String** | | | +|**reason** | **String** | The optional reason the user has given for the rating | | diff --git a/docs/GetAiDecompilationTask.md b/docs/GetAiDecompilationTask.md index bda4b105..a4ec5b54 100644 --- a/docs/GetAiDecompilationTask.md +++ b/docs/GetAiDecompilationTask.md @@ -8,14 +8,14 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**status** | **AiDecompilationTaskStatus** | The status of the AI decompilation task | | -|**decompilation** | **String** | | | -|**rawDecompilation** | **String** | | | -|**functionMapping** | [**Map<String, InverseFunctionMapItem>**](InverseFunctionMapItem.md) | | | -|**functionMappingFull** | [**FunctionMappingFull**](FunctionMappingFull.md) | | | -|**summary** | **String** | | [optional] | -|**aiSummary** | **String** | | [optional] | -|**rawAiSummary** | **String** | | [optional] | -|**predictedFunctionName** | **String** | | [optional] | +|**decompilation** | **String** | The AI decompilation string with values from function mappings already replaced | | +|**rawDecompilation** | **String** | The unedited AI Decompilation string | | +|**functionMapping** | [**Map<String, InverseFunctionMapItem>**](InverseFunctionMapItem.md) | Deprecated structure | | +|**functionMappingFull** | [**FunctionMappingFull**](FunctionMappingFull.md) | The full mapping, useful for swapping out values within raw_decompilation | | +|**summary** | **String** | The summary comment for the decompilation (deprecated, please use raw_ai_summary instead) | [optional] | +|**aiSummary** | **String** | The summary comment for the decompilation with values from function mappings already replaced | [optional] | +|**rawAiSummary** | **String** | The summary comment for the decompilation with no replacements | [optional] | +|**predictedFunctionName** | **String** | The predicted function name from the AI model | [optional] | diff --git a/docs/GetCollectionOutputBody.md b/docs/GetCollectionOutputBody.md index fca6b9db..cf7a012d 100644 --- a/docs/GetCollectionOutputBody.md +++ b/docs/GetCollectionOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**binaries** | **List<Binary>** | | [optional] | +|**binaries** | [**List<Binary>**](Binary.md) | | [optional] | |**collectionId** | **Long** | | | |**collectionName** | **String** | | | |**collectionScope** | **String** | | | diff --git a/docs/GetProductsOutputBody.md b/docs/GetProductsOutputBody.md index d15aa7bd..9683ddd7 100644 --- a/docs/GetProductsOutputBody.md +++ b/docs/GetProductsOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**products** | **List<ProductOutput>** | List of available products | | +|**products** | [**List<ProductOutput>**](ProductOutput.md) | List of available products | | diff --git a/docs/GetSubscriptionOutputBody.md b/docs/GetSubscriptionOutputBody.md index 506d9694..a542f03c 100644 --- a/docs/GetSubscriptionOutputBody.md +++ b/docs/GetSubscriptionOutputBody.md @@ -8,8 +8,8 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**endsAt** | **OffsetDateTime** | Date access ends (CANCELING only). | [optional] | -|**price** | **PriceSummary** | Current price (ACTIVE / CANCELING / PAYMENT_ISSUE only). | [optional] | -|**product** | **ProductSummary** | Subscribed product (ACTIVE / CANCELING / PAYMENT_ISSUE only). | [optional] | +|**price** | [**PriceSummary**](PriceSummary.md) | Current price (ACTIVE / CANCELING / PAYMENT_ISSUE only). | [optional] | +|**product** | [**ProductSummary**](ProductSummary.md) | Subscribed product (ACTIVE / CANCELING / PAYMENT_ISSUE only). | [optional] | |**renewsAt** | **OffsetDateTime** | Next billing date (ACTIVE only). | [optional] | |**status** | [**StatusEnum**](#StatusEnum) | Subscription state. | | |**tier** | [**TierEnum**](#TierEnum) | User's effective tier. | | diff --git a/docs/GlobalVariable.md b/docs/GlobalVariable.md index ae590bf6..8ff59460 100644 --- a/docs/GlobalVariable.md +++ b/docs/GlobalVariable.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**lastChange** | **String** | | [optional] | +|**lastChange** | **String** | Timestamp of the last change to this global variable | [optional] | |**addr** | **Integer** | Memory address of the global variable | | |**name** | **String** | Name of the global variable | | |**type** | **String** | Data type of the global variable | | diff --git a/docs/HttpRequest.md b/docs/HttpRequest.md index 23a19c55..f70b1ccf 100644 --- a/docs/HttpRequest.md +++ b/docs/HttpRequest.md @@ -7,15 +7,22 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**events** | **List<ReportEvent>** | | [optional] | +|**bytesReceived** | **Long** | | [optional] | +|**bytesSent** | **Long** | | [optional] | +|**events** | [**List<ReportEvent>**](ReportEvent.md) | | [optional] | |**extraHeaders** | **List<String>** | | [optional] | |**flags** | **Long** | | [optional] | |**password** | **String** | | [optional] | |**path** | **String** | | [optional] | +|**pcapStreamId** | **Long** | | [optional] | |**postData** | **String** | | [optional] | |**proxy** | **String** | | [optional] | |**proxyBypass** | **String** | | [optional] | |**referer** | **String** | | [optional] | +|**requestBody** | [**PcapBodyInfo**](PcapBodyInfo.md) | | [optional] | +|**responseBody** | [**PcapBodyInfo**](PcapBodyInfo.md) | | [optional] | +|**responseStatus** | **Long** | | [optional] | +|**serverIp** | **String** | | [optional] | |**serverName** | **String** | | [optional] | |**serverPort** | **Long** | | [optional] | |**service** | **Long** | | [optional] | diff --git a/docs/IOC.md b/docs/IOC.md index 7ce8a4d1..4b5ac0c1 100644 --- a/docs/IOC.md +++ b/docs/IOC.md @@ -10,9 +10,9 @@ |**type** | [**TypeEnum**](#TypeEnum) | Type of the IOC | | |**value** | **String** | Value of the IOC | | |**description** | **String** | Description of the IOC | | -|**source** | **String** | | [optional] | -|**functionId** | **Integer** | | [optional] | -|**functionName** | **String** | | [optional] | +|**source** | **String** | The source address where the IOC can be found in the binary if possible. | [optional] | +|**functionId** | **Integer** | Unique identifier of the function containing the IOC | [optional] | +|**functionName** | **String** | Name of the function containing the IOC | [optional] | diff --git a/docs/ListAnalysisStringsOutputBody.md b/docs/ListAnalysisStringsOutputBody.md index 3c7e8404..8877ae0f 100644 --- a/docs/ListAnalysisStringsOutputBody.md +++ b/docs/ListAnalysisStringsOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**strings** | **List<AnalysisStringItem>** | | | +|**strings** | [**List<AnalysisStringItem>**](AnalysisStringItem.md) | | | |**totalStrings** | **Long** | | | diff --git a/docs/ListCollectionsOutputBody.md b/docs/ListCollectionsOutputBody.md index edbad9ba..87f139a5 100644 --- a/docs/ListCollectionsOutputBody.md +++ b/docs/ListCollectionsOutputBody.md @@ -10,7 +10,7 @@ |**hasNextPage** | **Boolean** | | | |**pageNumber** | **Long** | | | |**pageSize** | **Long** | | | -|**results** | **List<CollectionListItemBody>** | | | +|**results** | [**List<CollectionListItemBody>**](CollectionListItemBody.md) | | | diff --git a/docs/ListFunctionStringsOutputBody.md b/docs/ListFunctionStringsOutputBody.md index 75e90ef0..ba483690 100644 --- a/docs/ListFunctionStringsOutputBody.md +++ b/docs/ListFunctionStringsOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**strings** | **List<FunctionStringItem>** | | | +|**strings** | [**List<FunctionStringItem>**](FunctionStringItem.md) | | | |**totalStrings** | **Long** | | | diff --git a/docs/MatchedFunctionSuggestion.md b/docs/MatchedFunctionSuggestion.md index 32fef317..2e3e87b9 100644 --- a/docs/MatchedFunctionSuggestion.md +++ b/docs/MatchedFunctionSuggestion.md @@ -9,7 +9,7 @@ |------------ | ------------- | ------------- | -------------| |**functionId** | **Long** | Unique identifier of the matched function | | |**functionVaddr** | **Long** | Virtual address of the matched function | | -|**suggestedName** | **String** | | [optional] | +|**suggestedName** | **String** | Mangled name of the function group that contains the matched functions | [optional] | |**suggestedDemangledName** | **String** | De-mangled name of the function group that contains the matched functions | | diff --git a/docs/MutexEntry.md b/docs/MutexEntry.md index 5abc90dc..a664797b 100644 --- a/docs/MutexEntry.md +++ b/docs/MutexEntry.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**events** | **List<ReportEvent>** | | [optional] | +|**events** | [**List<ReportEvent>**](ReportEvent.md) | | [optional] | |**name** | **String** | | | diff --git a/docs/NameSourceType.md b/docs/NameSourceType.md index 4f63b145..28c40f8d 100644 --- a/docs/NameSourceType.md +++ b/docs/NameSourceType.md @@ -8,9 +8,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**type** | [**TypeEnum**](#TypeEnum) | The source (process) the function name came from | | -|**functionId** | **Integer** | | [optional] | -|**binaryId** | **Integer** | | [optional] | -|**analysisId** | **Integer** | | [optional] | +|**functionId** | **Integer** | The function id of the function the function name was copied from. | [optional] | +|**binaryId** | **Integer** | The binary id of the function that the function name was copied from. | [optional] | +|**analysisId** | **Integer** | The analysis id of the function that the function name was copied from. | [optional] | diff --git a/docs/NetworkActivity.md b/docs/NetworkActivity.md index 398ade54..6df65e9b 100644 --- a/docs/NetworkActivity.md +++ b/docs/NetworkActivity.md @@ -7,10 +7,10 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**connections** | **List<Connection>** | | [optional] | -|**dnsQueries** | **List<DnsQuery>** | | [optional] | -|**extractedUrls** | **List<ExtractedURL>** | | [optional] | -|**httpRequests** | **List<HttpRequest>** | | [optional] | +|**connections** | [**List<Connection>**](Connection.md) | | [optional] | +|**dnsQueries** | [**List<DnsQuery>**](DnsQuery.md) | | [optional] | +|**extractedUrls** | [**List<ExtractedURL>**](ExtractedURL.md) | | [optional] | +|**httpRequests** | [**List<HttpRequest>**](HttpRequest.md) | | [optional] | diff --git a/docs/Params.md b/docs/Params.md index 305c3c9d..8a64d20e 100644 --- a/docs/Params.md +++ b/docs/Params.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**debugHash** | **String** | | | +|**debugHash** | **String** | The debug hash, if one was supplied | | |**binarySize** | **Integer** | The size of the binary data | | |**architecture** | **String** | The architecture of the binary data | | |**binaryType** | **String** | The type of binary data | | diff --git a/docs/PatchCollectionBinariesOutputBody.md b/docs/PatchCollectionBinariesOutputBody.md index da1eec56..6bb642f1 100644 --- a/docs/PatchCollectionBinariesOutputBody.md +++ b/docs/PatchCollectionBinariesOutputBody.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**binaries** | **List<Binary>** | | | +|**binaries** | [**List<Binary>**](Binary.md) | | | diff --git a/docs/PcapBodyInfo.md b/docs/PcapBodyInfo.md new file mode 100644 index 00000000..50eb387b --- /dev/null +++ b/docs/PcapBodyInfo.md @@ -0,0 +1,19 @@ + + +# PcapBodyInfo + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**filename** | **String** | | [optional] | +|**isPe** | **Boolean** | | | +|**mimeType** | **String** | | [optional] | +|**preview** | **String** | | [optional] | +|**sha256** | **String** | | [optional] | +|**size** | **Long** | | | +|**yaraHits** | **List<String>** | | [optional] | + + + diff --git a/docs/ProcessActivityEntry.md b/docs/ProcessActivityEntry.md index 730cfbb7..fac0f3f8 100644 --- a/docs/ProcessActivityEntry.md +++ b/docs/ProcessActivityEntry.md @@ -9,7 +9,7 @@ |------------ | ------------- | ------------- | -------------| |**args** | **List<String>** | | [optional] | |**childSeqid** | **Long** | | | -|**events** | **List<ReportEvent>** | | [optional] | +|**events** | [**List<ReportEvent>**](ReportEvent.md) | | [optional] | |**exitCode** | **Long** | | [optional] | |**exitCodeStr** | **String** | | [optional] | |**name** | **String** | | | diff --git a/docs/ProcessMemdumps.md b/docs/ProcessMemdumps.md index 5c180f92..f4da9250 100644 --- a/docs/ProcessMemdumps.md +++ b/docs/ProcessMemdumps.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**dumps** | **List<MemdumpEntry>** | | [optional] | +|**dumps** | [**List<MemdumpEntry>**](MemdumpEntry.md) | | [optional] | |**processSeqid** | **Long** | | | diff --git a/docs/ProcessNode.md b/docs/ProcessNode.md index b2d2c0c7..bbbaeb83 100644 --- a/docs/ProcessNode.md +++ b/docs/ProcessNode.md @@ -9,7 +9,7 @@ |------------ | ------------- | ------------- | -------------| |**args** | **List<String>** | | [optional] | |**attributed** | **Boolean** | | | -|**children** | **List<ProcessNode>** | | [optional] | +|**children** | [**List<ProcessNode>**](ProcessNode.md) | | [optional] | |**exitCode** | **Long** | | [optional] | |**exitCodeStr** | **String** | | [optional] | |**exitedAt** | **Double** | | [optional] | diff --git a/docs/ProcessTree.md b/docs/ProcessTree.md index 6df7d7e3..b73d3309 100644 --- a/docs/ProcessTree.md +++ b/docs/ProcessTree.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**nodes** | **List<ProcessNode>** | | [optional] | +|**nodes** | [**List<ProcessNode>**](ProcessNode.md) | | [optional] | |**sampleSeqid** | **Long** | | [optional] | diff --git a/docs/ProductOutput.md b/docs/ProductOutput.md index dcfe6d08..97242366 100644 --- a/docs/ProductOutput.md +++ b/docs/ProductOutput.md @@ -12,7 +12,7 @@ |**features** | **List<String>** | Marketing feature list for this product. | | |**id** | **String** | Product ID. | | |**name** | **String** | Human-readable product name. | | -|**prices** | **List<PriceOutput>** | All active recurring prices for this product. | | +|**prices** | [**List<PriceOutput>**](PriceOutput.md) | All active recurring prices for this product. | | |**tier** | **String** | User tier associated with this product, if any. | [optional] | diff --git a/docs/ReAnalysisForm.md b/docs/ReAnalysisForm.md index 3ed77bcf..894a06a5 100644 --- a/docs/ReAnalysisForm.md +++ b/docs/ReAnalysisForm.md @@ -12,7 +12,7 @@ Form Model for receiving the analysis request |**commandLineArgs** | **String** | Command line arguments for dynamic execution | [optional] | |**priority** | **Integer** | Priority of the analysis | [optional] | |**essential** | **Boolean** | Only runs essential parts of the analysis, skips tags/sbom/cves etc. | [optional] | -|**modelName** | **String** | | [optional] | +|**modelName** | **String** | Model name allows reprocessing using a different model | [optional] | |**noCache** | **Boolean** | When enabled, skips using cached data within the processing. | [optional] | diff --git a/docs/RegistryOperation.md b/docs/RegistryOperation.md index 6545fe1d..cf816c66 100644 --- a/docs/RegistryOperation.md +++ b/docs/RegistryOperation.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**events** | **List<ReportEvent>** | | [optional] | +|**events** | [**List<ReportEvent>**](ReportEvent.md) | | [optional] | |**key** | **String** | | | diff --git a/docs/RelativeBinaryResponse.md b/docs/RelativeBinaryResponse.md index 32cd9106..7c9fd53c 100644 --- a/docs/RelativeBinaryResponse.md +++ b/docs/RelativeBinaryResponse.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**binaryId** | **Integer** | ID of the relative binary | | -|**analysisId** | **Integer** | | [optional] | +|**analysisId** | **Integer** | ID of the active analysis for this binary | [optional] | |**name** | **String** | Name of the relative binary | | |**sha256** | **String** | SHA256 hash of the relative binary | | diff --git a/docs/ReportEvent.md b/docs/ReportEvent.md index 9cc4a23d..ec32ed88 100644 --- a/docs/ReportEvent.md +++ b/docs/ReportEvent.md @@ -7,13 +7,14 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**apiCalls** | **List<ApiCall>** | | [optional] | +|**apiCalls** | [**List<ApiCall>**](ApiCall.md) | | [optional] | +|**count** | **Long** | | [optional] | +|**desiredAccess** | **List<String>** | | [optional] | |**processSeqid** | **Long** | | [optional] | -|**totalBytesRequested** | **Long** | | [optional] | +|**totalBytes** | **Long** | | [optional] | |**type** | **String** | | | |**value** | **String** | | [optional] | |**valueName** | **String** | | [optional] | -|**writeCount** | **Long** | | [optional] | diff --git a/docs/ReportInfo.md b/docs/ReportInfo.md index 408758e6..d343a34b 100644 --- a/docs/ReportInfo.md +++ b/docs/ReportInfo.md @@ -7,9 +7,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**_file** | **DrakvufFileMetadata** | | [optional] | +|**_file** | [**DrakvufFileMetadata**](DrakvufFileMetadata.md) | | [optional] | |**id** | **String** | | | -|**options** | **ReportOptions** | | [optional] | +|**options** | [**ReportOptions**](ReportOptions.md) | | [optional] | |**osProfile** | **String** | | [optional] | |**status** | **String** | | [optional] | |**timeAnalysisFinished** | **String** | | [optional] | diff --git a/docs/SandboxOptions.md b/docs/SandboxOptions.md index 47e7a4c3..e2ffb626 100644 --- a/docs/SandboxOptions.md +++ b/docs/SandboxOptions.md @@ -9,7 +9,7 @@ |------------ | ------------- | ------------- | -------------| |**enabled** | **Boolean** | | [optional] | |**commandLineArgs** | **String** | The command line parameters to pass to the dynamic execution sandbox. Requires `sandbox` to be True. | [optional] | -|**startMethod** | **SandboxStartMethod** | | [optional] | +|**startMethod** | **SandboxStartMethod** | The method used by the sandbox to launch the sample. | [optional] | |**timeout** | **SandboxTimeout** | Maximum execution time for the sandbox run, in seconds. Allowed values: 120 (2m), 180 (3m), 300 (5m), 600 (10m). | [optional] | diff --git a/docs/ScheduledTaskEntry.md b/docs/ScheduledTaskEntry.md index 385c366a..1f4883c1 100644 --- a/docs/ScheduledTaskEntry.md +++ b/docs/ScheduledTaskEntry.md @@ -10,7 +10,7 @@ |**command** | **String** | | [optional] | |**day** | **String** | | [optional] | |**endDate** | **String** | | [optional] | -|**events** | **List<ReportEvent>** | | [optional] | +|**events** | [**List<ReportEvent>**](ReportEvent.md) | | [optional] | |**executable** | **String** | | [optional] | |**modifier** | **String** | | [optional] | |**runAs** | **String** | | [optional] | diff --git a/docs/SearchApi.md b/docs/SearchApi.md index 5eb2ae82..098cc435 100644 --- a/docs/SearchApi.md +++ b/docs/SearchApi.md @@ -160,8 +160,8 @@ public class Example { | **tags** | [**List<String>**](String.md)| The tags to be searched for | [optional] | | **modelName** | **String**| The name of the model used to analyze the binary the function belongs to | [optional] | | **filters** | [**List<Filters>**](Filters.md)| The filters to be used for the search | [optional] | -| **orderBy** | [**AppApiRestV2CollectionsEnumsOrderBy**](.md)| The field to sort the order by in the results | [optional] [enum: created, collection, model, owner, collection_size, updated] | -| **orderByDirection** | [**Order**](.md)| The order direction in which to return results | [optional] [enum: ASC, DESC] | +| **orderBy** | [**AppApiRestV2CollectionsEnumsOrderBy**](.md)| The field to sort the order by in the results | [optional] [default to created] [enum: created, collection, model, owner, collection_size, updated] | +| **orderByDirection** | [**Order**](.md)| The order direction in which to return results | [optional] [default to DESC] [enum: ASC, DESC] | ### Return type diff --git a/docs/SendMessageRequest.md b/docs/SendMessageRequest.md index 5994244d..b48f45ba 100644 --- a/docs/SendMessageRequest.md +++ b/docs/SendMessageRequest.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**content** | **String** | | | -|**context** | **ConversationContext** | | [optional] | +|**context** | [**ConversationContext**](ConversationContext.md) | | [optional] | diff --git a/docs/StreamEvents200ResponseInner.md b/docs/ServerSentEventsInner.md similarity index 79% rename from docs/StreamEvents200ResponseInner.md rename to docs/ServerSentEventsInner.md index fa99d1d7..45012048 100644 --- a/docs/StreamEvents200ResponseInner.md +++ b/docs/ServerSentEventsInner.md @@ -1,13 +1,13 @@ -# StreamEvents200ResponseInner +# ServerSentEventsInner ## Properties | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **SseEventToolConfirmationRequiredData** | | | +|**data** | [**SseEventToolConfirmationRequiredData**](SseEventToolConfirmationRequiredData.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/StreamAiDecompilation200ResponseInner.md b/docs/ServerSentEventsInner1.md similarity index 85% rename from docs/StreamAiDecompilation200ResponseInner.md rename to docs/ServerSentEventsInner1.md index 0905c645..71b4fc7a 100644 --- a/docs/StreamAiDecompilation200ResponseInner.md +++ b/docs/ServerSentEventsInner1.md @@ -1,13 +1,13 @@ -# StreamAiDecompilation200ResponseInner +# ServerSentEventsInner1 ## Properties | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**data** | **WarningEvent** | | | +|**data** | [**WarningEvent**](WarningEvent.md) | | | |**event** | [**EventEnum**](#EventEnum) | The event name. | | |**id** | **Integer** | The event ID. | [optional] | |**retry** | **Integer** | The retry time in milliseconds. | [optional] | diff --git a/docs/ServiceEntry.md b/docs/ServiceEntry.md index 24dab9f1..df172a08 100644 --- a/docs/ServiceEntry.md +++ b/docs/ServiceEntry.md @@ -9,7 +9,7 @@ |------------ | ------------- | ------------- | -------------| |**binaryPath** | **String** | | [optional] | |**displayName** | **String** | | [optional] | -|**events** | **List<ReportEvent>** | | [optional] | +|**events** | [**List<ReportEvent>**](ReportEvent.md) | | [optional] | |**name** | **String** | | [optional] | |**serviceType** | **String** | | [optional] | |**startType** | **String** | | [optional] | diff --git a/docs/StackVariable.md b/docs/StackVariable.md index dd309185..2e7c9b83 100644 --- a/docs/StackVariable.md +++ b/docs/StackVariable.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**lastChange** | **String** | | [optional] | +|**lastChange** | **String** | Timestamp of the last change to this stack variable | [optional] | |**offset** | **Integer** | Offset of the stack variable | | |**name** | **String** | Name of the stack variable | | |**type** | **String** | Data type of the stack variable | | diff --git a/docs/Structure.md b/docs/Structure.md index b3aa4b1f..fee259b0 100644 --- a/docs/Structure.md +++ b/docs/Structure.md @@ -7,9 +7,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**lastChange** | **String** | | [optional] | +|**lastChange** | **String** | Timestamp of the last change to this structure | [optional] | |**name** | **String** | Name of the structure | | -|**size** | **Integer** | | [optional] | +|**size** | **Integer** | Total size of the structure in bytes | [optional] | |**members** | [**Map<String, StructureMember>**](StructureMember.md) | Dictionary of structure members | | |**artifactType** | **String** | Type of artifact that the structure is associated with | [optional] | diff --git a/docs/StructureMember.md b/docs/StructureMember.md index f7929f0a..43ec1c2c 100644 --- a/docs/StructureMember.md +++ b/docs/StructureMember.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**lastChange** | **String** | | [optional] | +|**lastChange** | **String** | Timestamp of the last change to this structure member | [optional] | |**name** | **String** | Name of the structure member | | |**offset** | **Integer** | Offset of the member within the structure | | |**type** | **String** | Data type of the structure member | | diff --git a/docs/SubmitUserFeedbackRequest.md b/docs/SubmitUserFeedbackRequest.md index 6662fd9d..6d7f6e9e 100644 --- a/docs/SubmitUserFeedbackRequest.md +++ b/docs/SubmitUserFeedbackRequest.md @@ -9,7 +9,7 @@ |------------ | ------------- | ------------- | -------------| |**currentRoute** | **String** | The route from where the feedback was submitted | | |**feedback** | **String** | The user's feedback | | -|**screenCaptureUrl** | **String** | | [optional] | +|**screenCaptureUrl** | **String** | An optional URL to a screen capture related to the feedback | [optional] | diff --git a/docs/TagItem.md b/docs/TagItem.md index a2849707..84a374d2 100644 --- a/docs/TagItem.md +++ b/docs/TagItem.md @@ -9,7 +9,7 @@ |------------ | ------------- | ------------- | -------------| |**name** | **String** | | | |**origin** | **String** | | | -|**collectionId** | **Integer** | | [optional] | +|**collectionId** | **Integer** | The ID of the analysis owner's associated collection | [optional] | diff --git a/docs/TcpCarvedFile.md b/docs/TcpCarvedFile.md new file mode 100644 index 00000000..d74012ba --- /dev/null +++ b/docs/TcpCarvedFile.md @@ -0,0 +1,20 @@ + + +# TcpCarvedFile + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**direction** | **String** | | | +|**filename** | **String** | | [optional] | +|**isPe** | **Boolean** | | | +|**mimeType** | **String** | | [optional] | +|**offset** | **Long** | | | +|**sha256** | **String** | | | +|**size** | **Long** | | | +|**yaraHits** | **List<String>** | | [optional] | + + + diff --git a/docs/TokenisedData.md b/docs/TokenisedData.md index fefb4d51..7275b133 100644 --- a/docs/TokenisedData.md +++ b/docs/TokenisedData.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**functionMapping** | **AIDecompFunctionMapping** | Complete mapping data for token resolution | [optional] | +|**functionMapping** | [**AIDecompFunctionMapping**](AIDecompFunctionMapping.md) | Complete mapping data for token resolution | [optional] | |**predictedFunctionName** | **String** | Predicted function name from the AI model | [optional] | |**status** | [**StatusEnum**](#StatusEnum) | Task status | | |**tokenisedDecompilation** | **String** | Source code with placeholder tokens | [optional] | diff --git a/docs/TypeDefinition.md b/docs/TypeDefinition.md index c4c8e8fb..3aa1e79a 100644 --- a/docs/TypeDefinition.md +++ b/docs/TypeDefinition.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**lastChange** | **String** | | [optional] | +|**lastChange** | **String** | Timestamp of the last change to this type definition | [optional] | |**name** | **String** | Name of the type definition | | |**type** | **String** | Underlying type of the type definition | | |**artifactType** | **String** | Type of artifact the type definition is associated with | [optional] | diff --git a/docs/UpsertAiDecomplationRatingRequest.md b/docs/UpsertAiDecomplationRatingRequest.md index 8ddc8c8d..f01df24e 100644 --- a/docs/UpsertAiDecomplationRatingRequest.md +++ b/docs/UpsertAiDecomplationRatingRequest.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**rating** | **AiDecompilationRating** | The rating for the AI decompilation response | | -|**reason** | **String** | | | +|**reason** | **String** | An optional reason for the rating | | diff --git a/docs/WorkflowProgress.md b/docs/WorkflowProgress.md index 18ec6d13..9ace5cb4 100644 --- a/docs/WorkflowProgress.md +++ b/docs/WorkflowProgress.md @@ -7,7 +7,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**messages** | **List<ProgressMessage>** | Log messages emitted during execution | | +|**messages** | [**List<ProgressMessage>**](ProgressMessage.md) | Log messages emitted during execution | | |**status** | [**StatusEnum**](#StatusEnum) | Current workflow status | | |**step** | **String** | Name of the current step | | |**stepIndex** | **Long** | Zero-based index of the current step | | diff --git a/docs/XrefFromResponse.md b/docs/XrefFromResponse.md index a042e780..5bfab718 100644 --- a/docs/XrefFromResponse.md +++ b/docs/XrefFromResponse.md @@ -12,7 +12,7 @@ |**isCall** | **Boolean** | | [optional] | |**isData** | **Boolean** | | [optional] | |**isString** | **Boolean** | | [optional] | -|**rawData** | **String** | | [optional] | +|**rawData** | **File** | | [optional] | |**segment** | [**SegmentInfo**](SegmentInfo.md) | | [optional] | |**origStrEncoding** | **String** | | [optional] | |**xrefTo** | **String** | | | diff --git a/docs/XrefToResponse.md b/docs/XrefToResponse.md index 36955f06..040234ba 100644 --- a/docs/XrefToResponse.md +++ b/docs/XrefToResponse.md @@ -12,7 +12,7 @@ |**isCall** | **Boolean** | | [optional] | |**isData** | **Boolean** | | [optional] | |**isString** | **Boolean** | | [optional] | -|**rawData** | **String** | | [optional] | +|**rawData** | **File** | | [optional] | |**segment** | [**SegmentInfo**](SegmentInfo.md) | | [optional] | |**origStrEncoding** | **String** | | [optional] | |**xrefFrom** | **String** | | | diff --git a/pom.xml b/pom.xml index f8190f6b..f4b278b1 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ sdk jar sdk - 3.93.1 + 3.93.2 https://github.com/RevEngAI/sdk-java Java SDK for the RevEng.AI API @@ -327,7 +327,7 @@ 4.12.0 2.10.1 3.18.0 - 0.2.8 + 0.2.10 1.3.5 2.0.2 5.10.3 diff --git a/src/main/java/ai/reveng/api/AnalysesCoreApi.java b/src/main/java/ai/reveng/api/AnalysesCoreApi.java index 58423194..442d72d5 100644 --- a/src/main/java/ai/reveng/api/AnalysesCoreApi.java +++ b/src/main/java/ai/reveng/api/AnalysesCoreApi.java @@ -187,7 +187,7 @@ private okhttp3.Call addUserStringToAnalysisValidateBeforeCall(@javax.annotation * Attaches a user-provided string to an analysis at the given virtual address. The string is stored with source `USER` and complements strings discovered automatically during analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied * @param analysisId Analysis ID (required) * @param addUserStringInputBody (required) - * @return Map<String, Object> + * @return Object * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -200,8 +200,8 @@ private okhttp3.Call addUserStringToAnalysisValidateBeforeCall(@javax.annotation
500 Internal Server Error -
*/ - public Map addUserStringToAnalysis(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull AddUserStringInputBody addUserStringInputBody) throws ApiException { - ApiResponse> localVarResp = addUserStringToAnalysisWithHttpInfo(analysisId, addUserStringInputBody); + public Object addUserStringToAnalysis(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull AddUserStringInputBody addUserStringInputBody) throws ApiException { + ApiResponse localVarResp = addUserStringToAnalysisWithHttpInfo(analysisId, addUserStringInputBody); return localVarResp.getData(); } @@ -210,7 +210,7 @@ public Map addUserStringToAnalysis(@javax.annotation.Nonnull Lon * Attaches a user-provided string to an analysis at the given virtual address. The string is stored with source `USER` and complements strings discovered automatically during analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied * @param analysisId Analysis ID (required) * @param addUserStringInputBody (required) - * @return ApiResponse<Map<String, Object>> + * @return ApiResponse<Object> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -223,9 +223,9 @@ public Map addUserStringToAnalysis(@javax.annotation.Nonnull Lon
500 Internal Server Error -
*/ - public ApiResponse> addUserStringToAnalysisWithHttpInfo(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull AddUserStringInputBody addUserStringInputBody) throws ApiException { + public ApiResponse addUserStringToAnalysisWithHttpInfo(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull AddUserStringInputBody addUserStringInputBody) throws ApiException { okhttp3.Call localVarCall = addUserStringToAnalysisValidateBeforeCall(analysisId, addUserStringInputBody, null); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -248,10 +248,10 @@ public ApiResponse> addUserStringToAnalysisWithHttpInfo(@jav 500 Internal Server Error - */ - public okhttp3.Call addUserStringToAnalysisAsync(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull AddUserStringInputBody addUserStringInputBody, final ApiCallback> _callback) throws ApiException { + public okhttp3.Call addUserStringToAnalysisAsync(@javax.annotation.Nonnull Long analysisId, @javax.annotation.Nonnull AddUserStringInputBody addUserStringInputBody, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = addUserStringToAnalysisValidateBeforeCall(analysisId, addUserStringInputBody, _callback); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } @@ -1652,8 +1652,8 @@ public okhttp3.Call insertAnalysisLogAsync(@javax.annotation.Nonnull Integer ana * @param sha256Hash (optional) * @param limit (optional, default to 20) * @param offset (optional, default to 0) - * @param orderBy (optional) - * @param order (optional) + * @param orderBy (optional, default to created) + * @param order (optional, default to DESC) * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object @@ -1771,8 +1771,8 @@ private okhttp3.Call listAnalysesValidateBeforeCall(@javax.annotation.Nullable S * @param sha256Hash (optional) * @param limit (optional, default to 20) * @param offset (optional, default to 0) - * @param orderBy (optional) - * @param order (optional) + * @param orderBy (optional, default to created) + * @param order (optional, default to DESC) * @return BaseResponseRecent * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -1800,8 +1800,8 @@ public BaseResponseRecent listAnalyses(@javax.annotation.Nullable String searchT * @param sha256Hash (optional) * @param limit (optional, default to 20) * @param offset (optional, default to 0) - * @param orderBy (optional) - * @param order (optional) + * @param orderBy (optional, default to created) + * @param order (optional, default to DESC) * @return ApiResponse<BaseResponseRecent> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -1830,8 +1830,8 @@ public ApiResponse listAnalysesWithHttpInfo(@javax.annotatio * @param sha256Hash (optional) * @param limit (optional, default to 20) * @param offset (optional, default to 0) - * @param orderBy (optional) - * @param order (optional) + * @param orderBy (optional, default to created) + * @param order (optional, default to DESC) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object diff --git a/src/main/java/ai/reveng/api/CollectionsApi.java b/src/main/java/ai/reveng/api/CollectionsApi.java index 87eb72e8..1d73e4e8 100644 --- a/src/main/java/ai/reveng/api/CollectionsApi.java +++ b/src/main/java/ai/reveng/api/CollectionsApi.java @@ -560,8 +560,8 @@ public okhttp3.Call getCollectionAsync(@javax.annotation.Nonnull Integer collect * @param filters (optional) * @param limit (optional, default to 20) * @param offset (optional, default to 0) - * @param orderBy (optional) - * @param order (optional) + * @param orderBy (optional, default to collection) + * @param order (optional, default to ASC) * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object @@ -657,8 +657,8 @@ private okhttp3.Call listCollectionsValidateBeforeCall(@javax.annotation.Nullabl * @param filters (optional) * @param limit (optional, default to 20) * @param offset (optional, default to 0) - * @param orderBy (optional) - * @param order (optional) + * @param orderBy (optional, default to collection) + * @param order (optional, default to ASC) * @return BaseResponseListCollectionResults * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -683,8 +683,8 @@ public BaseResponseListCollectionResults listCollections(@javax.annotation.Nulla * @param filters (optional) * @param limit (optional, default to 20) * @param offset (optional, default to 0) - * @param orderBy (optional) - * @param order (optional) + * @param orderBy (optional, default to collection) + * @param order (optional, default to ASC) * @return ApiResponse<BaseResponseListCollectionResults> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -710,8 +710,8 @@ public ApiResponse listCollectionsWithHttpInf * @param filters (optional) * @param limit (optional, default to 20) * @param offset (optional, default to 0) - * @param orderBy (optional) - * @param order (optional) + * @param orderBy (optional, default to collection) + * @param order (optional, default to ASC) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object diff --git a/src/main/java/ai/reveng/api/ConversationsApi.java b/src/main/java/ai/reveng/api/ConversationsApi.java index b8bc354b..236d789c 100644 --- a/src/main/java/ai/reveng/api/ConversationsApi.java +++ b/src/main/java/ai/reveng/api/ConversationsApi.java @@ -32,8 +32,8 @@ import ai.reveng.model.ConversationWithEvents; import ai.reveng.model.CreateConversationRequest; import ai.reveng.model.SendMessageRequest; +import ai.reveng.model.ServerSentEventsInner; import ai.reveng.model.StatusResponse; -import ai.reveng.model.StreamEvents200ResponseInner; import java.util.UUID; import java.lang.reflect.Type; @@ -1024,7 +1024,7 @@ private okhttp3.Call streamEventsValidateBeforeCall(@javax.annotation.Nonnull UU * Opens a Server-Sent Events stream for the given conversation. Events include run lifecycle updates, streaming text deltas, tool call progress, and more. Use the `last_event_id` query parameter to replay missed events after a reconnection. * @param id Conversation UUID (required) * @param lastEventId Replay events after this ID (optional) - * @return List<StreamEvents200ResponseInner> + * @return List<ServerSentEventsInner> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -1034,8 +1034,8 @@ private okhttp3.Call streamEventsValidateBeforeCall(@javax.annotation.Nonnull UU
0 Error -
*/ - public List streamEvents(@javax.annotation.Nonnull UUID id, @javax.annotation.Nullable Long lastEventId) throws ApiException { - ApiResponse> localVarResp = streamEventsWithHttpInfo(id, lastEventId); + public List streamEvents(@javax.annotation.Nonnull UUID id, @javax.annotation.Nullable Long lastEventId) throws ApiException { + ApiResponse> localVarResp = streamEventsWithHttpInfo(id, lastEventId); return localVarResp.getData(); } @@ -1044,7 +1044,7 @@ public List streamEvents(@javax.annotation.Nonnull * Opens a Server-Sent Events stream for the given conversation. Events include run lifecycle updates, streaming text deltas, tool call progress, and more. Use the `last_event_id` query parameter to replay missed events after a reconnection. * @param id Conversation UUID (required) * @param lastEventId Replay events after this ID (optional) - * @return ApiResponse<List<StreamEvents200ResponseInner>> + * @return ApiResponse<List<ServerSentEventsInner>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -1054,9 +1054,9 @@ public List streamEvents(@javax.annotation.Nonnull
0 Error -
*/ - public ApiResponse> streamEventsWithHttpInfo(@javax.annotation.Nonnull UUID id, @javax.annotation.Nullable Long lastEventId) throws ApiException { + public ApiResponse> streamEventsWithHttpInfo(@javax.annotation.Nonnull UUID id, @javax.annotation.Nullable Long lastEventId) throws ApiException { okhttp3.Call localVarCall = streamEventsValidateBeforeCall(id, lastEventId, null); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken>(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -1076,10 +1076,10 @@ public ApiResponse> streamEventsWithHttpInfo( 0 Error - */ - public okhttp3.Call streamEventsAsync(@javax.annotation.Nonnull UUID id, @javax.annotation.Nullable Long lastEventId, final ApiCallback> _callback) throws ApiException { + public okhttp3.Call streamEventsAsync(@javax.annotation.Nonnull UUID id, @javax.annotation.Nullable Long lastEventId, final ApiCallback> _callback) throws ApiException { okhttp3.Call localVarCall = streamEventsValidateBeforeCall(id, lastEventId, _callback); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken>(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } diff --git a/src/main/java/ai/reveng/api/FirmwareApi.java b/src/main/java/ai/reveng/api/FirmwareApi.java index 431d2bde..fba276ab 100644 --- a/src/main/java/ai/reveng/api/FirmwareApi.java +++ b/src/main/java/ai/reveng/api/FirmwareApi.java @@ -27,6 +27,7 @@ import ai.reveng.model.BaseResponse; +import java.io.File; import java.lang.reflect.Type; import java.util.ArrayList; @@ -218,7 +219,7 @@ public okhttp3.Call getBinariesForFirmwareTaskAsync(@javax.annotation.Nonnull St 500 Internal Server Error - */ - public okhttp3.Call uploadFirmwareCall(@javax.annotation.Nonnull String _file, @javax.annotation.Nullable String password, final ApiCallback _callback) throws ApiException { + public okhttp3.Call uploadFirmwareCall(@javax.annotation.Nonnull File _file, @javax.annotation.Nullable String password, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -272,7 +273,7 @@ public okhttp3.Call uploadFirmwareCall(@javax.annotation.Nonnull String _file, @ } @SuppressWarnings("rawtypes") - private okhttp3.Call uploadFirmwareValidateBeforeCall(@javax.annotation.Nonnull String _file, @javax.annotation.Nullable String password, final ApiCallback _callback) throws ApiException { + private okhttp3.Call uploadFirmwareValidateBeforeCall(@javax.annotation.Nonnull File _file, @javax.annotation.Nullable String password, final ApiCallback _callback) throws ApiException { // verify the required parameter '_file' is set if (_file == null) { throw new ApiException("Missing the required parameter '_file' when calling uploadFirmware(Async)"); @@ -298,7 +299,7 @@ private okhttp3.Call uploadFirmwareValidateBeforeCall(@javax.annotation.Nonnull 500 Internal Server Error - */ - public Object uploadFirmware(@javax.annotation.Nonnull String _file, @javax.annotation.Nullable String password) throws ApiException { + public Object uploadFirmware(@javax.annotation.Nonnull File _file, @javax.annotation.Nullable String password) throws ApiException { ApiResponse localVarResp = uploadFirmwareWithHttpInfo(_file, password); return localVarResp.getData(); } @@ -319,7 +320,7 @@ public Object uploadFirmware(@javax.annotation.Nonnull String _file, @javax.anno 500 Internal Server Error - */ - public ApiResponse uploadFirmwareWithHttpInfo(@javax.annotation.Nonnull String _file, @javax.annotation.Nullable String password) throws ApiException { + public ApiResponse uploadFirmwareWithHttpInfo(@javax.annotation.Nonnull File _file, @javax.annotation.Nullable String password) throws ApiException { okhttp3.Call localVarCall = uploadFirmwareValidateBeforeCall(_file, password, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); @@ -342,7 +343,7 @@ public ApiResponse uploadFirmwareWithHttpInfo(@javax.annotation.Nonnull 500 Internal Server Error - */ - public okhttp3.Call uploadFirmwareAsync(@javax.annotation.Nonnull String _file, @javax.annotation.Nullable String password, final ApiCallback _callback) throws ApiException { + public okhttp3.Call uploadFirmwareAsync(@javax.annotation.Nonnull File _file, @javax.annotation.Nullable String password, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = uploadFirmwareValidateBeforeCall(_file, password, _callback); Type localVarReturnType = new TypeToken(){}.getType(); diff --git a/src/main/java/ai/reveng/api/FunctionsAiDecompilationApi.java b/src/main/java/ai/reveng/api/FunctionsAiDecompilationApi.java index ed1de762..e8842e27 100644 --- a/src/main/java/ai/reveng/api/FunctionsAiDecompilationApi.java +++ b/src/main/java/ai/reveng/api/FunctionsAiDecompilationApi.java @@ -42,7 +42,7 @@ import ai.reveng.model.PatchCommentBody; import ai.reveng.model.RegenerateOutputBody; import ai.reveng.model.RegenerateTarget; -import ai.reveng.model.StreamAiDecompilation200ResponseInner; +import ai.reveng.model.ServerSentEventsInner1; import ai.reveng.model.SummaryData; import ai.reveng.model.TokenisedData; import ai.reveng.model.UpsertAiDecomplationRatingRequest; @@ -2948,7 +2948,7 @@ private okhttp3.Call streamAiDecompilationValidateBeforeCall(@javax.annotation.N * Stream live AI decompilation output (SSE) * Opens a Server-Sent Events stream of incremental decompilation events for the given function. Each event has a `type` discriminator (also used as the SSE `event:` line) and a per-attempt monotonic `seq`. Terminal events: `decomp_finished` (success) or `decomp_failed` (all retries exhausted). `attempt_failed` is per-attempt and non-terminal — Temporal may retry the activity. Clients should treat `attempt` changes as a reset signal. `last_event_id` is not supported — clients fall back to polling the standard GET endpoint after the stream ends. * @param functionId Function ID (required) - * @return List<StreamAiDecompilation200ResponseInner> + * @return List<ServerSentEventsInner1> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -2958,8 +2958,8 @@ private okhttp3.Call streamAiDecompilationValidateBeforeCall(@javax.annotation.N
0 Error -
*/ - public List streamAiDecompilation(@javax.annotation.Nonnull Long functionId) throws ApiException { - ApiResponse> localVarResp = streamAiDecompilationWithHttpInfo(functionId); + public List streamAiDecompilation(@javax.annotation.Nonnull Long functionId) throws ApiException { + ApiResponse> localVarResp = streamAiDecompilationWithHttpInfo(functionId); return localVarResp.getData(); } @@ -2967,7 +2967,7 @@ public List streamAiDecompilation(@javax. * Stream live AI decompilation output (SSE) * Opens a Server-Sent Events stream of incremental decompilation events for the given function. Each event has a `type` discriminator (also used as the SSE `event:` line) and a per-attempt monotonic `seq`. Terminal events: `decomp_finished` (success) or `decomp_failed` (all retries exhausted). `attempt_failed` is per-attempt and non-terminal — Temporal may retry the activity. Clients should treat `attempt` changes as a reset signal. `last_event_id` is not supported — clients fall back to polling the standard GET endpoint after the stream ends. * @param functionId Function ID (required) - * @return ApiResponse<List<StreamAiDecompilation200ResponseInner>> + * @return ApiResponse<List<ServerSentEventsInner1>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -2977,9 +2977,9 @@ public List streamAiDecompilation(@javax.
0 Error -
*/ - public ApiResponse> streamAiDecompilationWithHttpInfo(@javax.annotation.Nonnull Long functionId) throws ApiException { + public ApiResponse> streamAiDecompilationWithHttpInfo(@javax.annotation.Nonnull Long functionId) throws ApiException { okhttp3.Call localVarCall = streamAiDecompilationValidateBeforeCall(functionId, null); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken>(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -2998,10 +2998,10 @@ public ApiResponse> streamAiDecompil 0 Error - */ - public okhttp3.Call streamAiDecompilationAsync(@javax.annotation.Nonnull Long functionId, final ApiCallback> _callback) throws ApiException { + public okhttp3.Call streamAiDecompilationAsync(@javax.annotation.Nonnull Long functionId, final ApiCallback> _callback) throws ApiException { okhttp3.Call localVarCall = streamAiDecompilationValidateBeforeCall(functionId, _callback); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken>(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } diff --git a/src/main/java/ai/reveng/api/FunctionsCoreApi.java b/src/main/java/ai/reveng/api/FunctionsCoreApi.java index cff55c93..c9bfff67 100644 --- a/src/main/java/ai/reveng/api/FunctionsCoreApi.java +++ b/src/main/java/ai/reveng/api/FunctionsCoreApi.java @@ -175,7 +175,7 @@ private okhttp3.Call addFunctionCalleeValidateBeforeCall(@javax.annotation.Nonnu * Records an outgoing call edge from the given function to a callee. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `400` [`BAD_REQUEST`](/errors/BAD_REQUEST) — Bad Request * @param functionId Function ID (required) * @param addCalleeInputBody (required) - * @return Map<String, Object> + * @return Object * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -189,8 +189,8 @@ private okhttp3.Call addFunctionCalleeValidateBeforeCall(@javax.annotation.Nonnu
500 Internal Server Error -
*/ - public Map addFunctionCallee(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull AddCalleeInputBody addCalleeInputBody) throws ApiException { - ApiResponse> localVarResp = addFunctionCalleeWithHttpInfo(functionId, addCalleeInputBody); + public Object addFunctionCallee(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull AddCalleeInputBody addCalleeInputBody) throws ApiException { + ApiResponse localVarResp = addFunctionCalleeWithHttpInfo(functionId, addCalleeInputBody); return localVarResp.getData(); } @@ -199,7 +199,7 @@ public Map addFunctionCallee(@javax.annotation.Nonnull Long func * Records an outgoing call edge from the given function to a callee. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `400` [`BAD_REQUEST`](/errors/BAD_REQUEST) — Bad Request * @param functionId Function ID (required) * @param addCalleeInputBody (required) - * @return ApiResponse<Map<String, Object>> + * @return ApiResponse<Object> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -213,9 +213,9 @@ public Map addFunctionCallee(@javax.annotation.Nonnull Long func
500 Internal Server Error -
*/ - public ApiResponse> addFunctionCalleeWithHttpInfo(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull AddCalleeInputBody addCalleeInputBody) throws ApiException { + public ApiResponse addFunctionCalleeWithHttpInfo(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull AddCalleeInputBody addCalleeInputBody) throws ApiException { okhttp3.Call localVarCall = addFunctionCalleeValidateBeforeCall(functionId, addCalleeInputBody, null); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -239,10 +239,10 @@ public ApiResponse> addFunctionCalleeWithHttpInfo(@javax.ann 500 Internal Server Error - */ - public okhttp3.Call addFunctionCalleeAsync(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull AddCalleeInputBody addCalleeInputBody, final ApiCallback> _callback) throws ApiException { + public okhttp3.Call addFunctionCalleeAsync(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull AddCalleeInputBody addCalleeInputBody, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = addFunctionCalleeValidateBeforeCall(functionId, addCalleeInputBody, _callback); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } @@ -331,7 +331,7 @@ private okhttp3.Call addUserStringToFunctionValidateBeforeCall(@javax.annotation * Attaches a user-provided string to a function at the given virtual address. The string is stored with source `USER` and complements strings discovered automatically during analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied * @param functionId Function ID (required) * @param addUserStringToFunctionInputBody (required) - * @return Map<String, Object> + * @return Object * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -344,8 +344,8 @@ private okhttp3.Call addUserStringToFunctionValidateBeforeCall(@javax.annotation
500 Internal Server Error -
*/ - public Map addUserStringToFunction(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull AddUserStringToFunctionInputBody addUserStringToFunctionInputBody) throws ApiException { - ApiResponse> localVarResp = addUserStringToFunctionWithHttpInfo(functionId, addUserStringToFunctionInputBody); + public Object addUserStringToFunction(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull AddUserStringToFunctionInputBody addUserStringToFunctionInputBody) throws ApiException { + ApiResponse localVarResp = addUserStringToFunctionWithHttpInfo(functionId, addUserStringToFunctionInputBody); return localVarResp.getData(); } @@ -354,7 +354,7 @@ public Map addUserStringToFunction(@javax.annotation.Nonnull Lon * Attaches a user-provided string to a function at the given virtual address. The string is stored with source `USER` and complements strings discovered automatically during analysis. **Error codes:** - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied * @param functionId Function ID (required) * @param addUserStringToFunctionInputBody (required) - * @return ApiResponse<Map<String, Object>> + * @return ApiResponse<Object> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -367,9 +367,9 @@ public Map addUserStringToFunction(@javax.annotation.Nonnull Lon
500 Internal Server Error -
*/ - public ApiResponse> addUserStringToFunctionWithHttpInfo(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull AddUserStringToFunctionInputBody addUserStringToFunctionInputBody) throws ApiException { + public ApiResponse addUserStringToFunctionWithHttpInfo(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull AddUserStringToFunctionInputBody addUserStringToFunctionInputBody) throws ApiException { okhttp3.Call localVarCall = addUserStringToFunctionValidateBeforeCall(functionId, addUserStringToFunctionInputBody, null); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -392,10 +392,10 @@ public ApiResponse> addUserStringToFunctionWithHttpInfo(@jav 500 Internal Server Error - */ - public okhttp3.Call addUserStringToFunctionAsync(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull AddUserStringToFunctionInputBody addUserStringToFunctionInputBody, final ApiCallback> _callback) throws ApiException { + public okhttp3.Call addUserStringToFunctionAsync(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull AddUserStringToFunctionInputBody addUserStringToFunctionInputBody, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = addUserStringToFunctionValidateBeforeCall(functionId, addUserStringToFunctionInputBody, _callback); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } diff --git a/src/main/java/ai/reveng/api/FunctionsRenamingHistoryApi.java b/src/main/java/ai/reveng/api/FunctionsRenamingHistoryApi.java index 6dc7ef6d..fdf8c734 100644 --- a/src/main/java/ai/reveng/api/FunctionsRenamingHistoryApi.java +++ b/src/main/java/ai/reveng/api/FunctionsRenamingHistoryApi.java @@ -1148,7 +1148,7 @@ private okhttp3.Call revertFunctionName_0ValidateBeforeCall(@javax.annotation.No * Reverts a function's name to a previous value from its history. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found * @param functionId Function ID (required) * @param historyId History ID to revert to (required) - * @return Map<String, Object> + * @return Object * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -1161,8 +1161,8 @@ private okhttp3.Call revertFunctionName_0ValidateBeforeCall(@javax.annotation.No
500 Internal Server Error -
*/ - public Map revertFunctionName_0(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull Long historyId) throws ApiException { - ApiResponse> localVarResp = revertFunctionName_0WithHttpInfo(functionId, historyId); + public Object revertFunctionName_0(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull Long historyId) throws ApiException { + ApiResponse localVarResp = revertFunctionName_0WithHttpInfo(functionId, historyId); return localVarResp.getData(); } @@ -1171,7 +1171,7 @@ public Map revertFunctionName_0(@javax.annotation.Nonnull Long f * Reverts a function's name to a previous value from its history. **Error codes:** - `403` [`ACCESS_DENIED`](/errors/ACCESS_DENIED) — Access Denied - `404` [`NOT_FOUND`](/errors/NOT_FOUND) — Not Found * @param functionId Function ID (required) * @param historyId History ID to revert to (required) - * @return ApiResponse<Map<String, Object>> + * @return ApiResponse<Object> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -1184,9 +1184,9 @@ public Map revertFunctionName_0(@javax.annotation.Nonnull Long f
500 Internal Server Error -
*/ - public ApiResponse> revertFunctionName_0WithHttpInfo(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull Long historyId) throws ApiException { + public ApiResponse revertFunctionName_0WithHttpInfo(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull Long historyId) throws ApiException { okhttp3.Call localVarCall = revertFunctionName_0ValidateBeforeCall(functionId, historyId, null); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -1209,10 +1209,10 @@ public ApiResponse> revertFunctionName_0WithHttpInfo(@javax. 500 Internal Server Error - */ - public okhttp3.Call revertFunctionName_0Async(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull Long historyId, final ApiCallback> _callback) throws ApiException { + public okhttp3.Call revertFunctionName_0Async(@javax.annotation.Nonnull Long functionId, @javax.annotation.Nonnull Long historyId, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = revertFunctionName_0ValidateBeforeCall(functionId, historyId, _callback); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } diff --git a/src/main/java/ai/reveng/api/SearchApi.java b/src/main/java/ai/reveng/api/SearchApi.java index 3850436d..5b355496 100644 --- a/src/main/java/ai/reveng/api/SearchApi.java +++ b/src/main/java/ai/reveng/api/SearchApi.java @@ -273,8 +273,8 @@ public okhttp3.Call searchBinariesAsync(@javax.annotation.Nullable Integer page, * @param tags The tags to be searched for (optional) * @param modelName The name of the model used to analyze the binary the function belongs to (optional) * @param filters The filters to be used for the search (optional) - * @param orderBy The field to sort the order by in the results (optional) - * @param orderByDirection The order direction in which to return results (optional) + * @param orderBy The field to sort the order by in the results (optional, default to created) + * @param orderByDirection The order direction in which to return results (optional, default to DESC) * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object @@ -388,8 +388,8 @@ private okhttp3.Call searchCollectionsValidateBeforeCall(@javax.annotation.Nulla * @param tags The tags to be searched for (optional) * @param modelName The name of the model used to analyze the binary the function belongs to (optional) * @param filters The filters to be used for the search (optional) - * @param orderBy The field to sort the order by in the results (optional) - * @param orderByDirection The order direction in which to return results (optional) + * @param orderBy The field to sort the order by in the results (optional, default to created) + * @param orderByDirection The order direction in which to return results (optional, default to DESC) * @return BaseResponseCollectionSearchResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -417,8 +417,8 @@ public BaseResponseCollectionSearchResponse searchCollections(@javax.annotation. * @param tags The tags to be searched for (optional) * @param modelName The name of the model used to analyze the binary the function belongs to (optional) * @param filters The filters to be used for the search (optional) - * @param orderBy The field to sort the order by in the results (optional) - * @param orderByDirection The order direction in which to return results (optional) + * @param orderBy The field to sort the order by in the results (optional, default to created) + * @param orderByDirection The order direction in which to return results (optional, default to DESC) * @return ApiResponse<BaseResponseCollectionSearchResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -447,8 +447,8 @@ public ApiResponse searchCollectionsWithHt * @param tags The tags to be searched for (optional) * @param modelName The name of the model used to analyze the binary the function belongs to (optional) * @param filters The filters to be used for the search (optional) - * @param orderBy The field to sort the order by in the results (optional) - * @param orderByDirection The order direction in which to return results (optional) + * @param orderBy The field to sort the order by in the results (optional, default to created) + * @param orderByDirection The order direction in which to return results (optional, default to DESC) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object diff --git a/src/main/java/ai/reveng/invoker/ApiClient.java b/src/main/java/ai/reveng/invoker/ApiClient.java index 131e4a3d..828ae2f6 100644 --- a/src/main/java/ai/reveng/invoker/ApiClient.java +++ b/src/main/java/ai/reveng/invoker/ApiClient.java @@ -146,7 +146,7 @@ protected void init() { json = new JSON(); // Set default User-Agent. - setUserAgent("OpenAPI-Generator/3.93.1/java"); + setUserAgent("OpenAPI-Generator/3.93.2/java"); authentications = new HashMap(); } diff --git a/src/main/java/ai/reveng/invoker/ApiException.java b/src/main/java/ai/reveng/invoker/ApiException.java index ca9df705..b84cc537 100644 --- a/src/main/java/ai/reveng/invoker/ApiException.java +++ b/src/main/java/ai/reveng/invoker/ApiException.java @@ -14,7 +14,6 @@ import java.util.Map; import java.util.List; -import java.util.Locale; /** @@ -161,7 +160,7 @@ public String getResponseBody() { * @return The exception message */ public String getMessage() { - return String.format(Locale.ROOT, "Message: %s%nHTTP response code: %s%nHTTP response body: %s%nHTTP response headers: %s", + return String.format(java.util.Locale.ROOT, "Message: %s%nHTTP response code: %s%nHTTP response body: %s%nHTTP response headers: %s", super.getMessage(), this.getCode(), this.getResponseBody(), this.getResponseHeaders()); } } diff --git a/src/main/java/ai/reveng/invoker/Configuration.java b/src/main/java/ai/reveng/invoker/Configuration.java index 3f80da40..334d4ea0 100644 --- a/src/main/java/ai/reveng/invoker/Configuration.java +++ b/src/main/java/ai/reveng/invoker/Configuration.java @@ -18,7 +18,7 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Configuration { - public static final String VERSION = "3.93.1"; + public static final String VERSION = "3.93.2"; private static final AtomicReference defaultApiClient = new AtomicReference<>(); private static volatile Supplier apiClientFactory = ApiClient::new; diff --git a/src/main/java/ai/reveng/invoker/JSON.java b/src/main/java/ai/reveng/invoker/JSON.java index e1cc6294..b63b2ecd 100644 --- a/src/main/java/ai/reveng/invoker/JSON.java +++ b/src/main/java/ai/reveng/invoker/JSON.java @@ -140,6 +140,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.AppApiRestV2FunctionsTypesFunction.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.AppApiRestV2InfoTypesCapability.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Argument.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Artifact.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.AttemptFailedEvent.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.AttemptStartedEvent.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.AutoRunAgents.CustomTypeAdapterFactory()); @@ -253,6 +254,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ConfigResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ConfirmToolInputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Connection.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ConsoleOutputEntry.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Context.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Conversation.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ConversationContext.CustomTypeAdapterFactory()); @@ -312,11 +314,11 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.EventWarning.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ExportModel.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ExternalResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ExtractedFileEntry.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ExtractedURL.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FileActivityEntry.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FileHashes.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FileMetadata.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FuncDepsInner.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionBlockDestinationResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionBlockResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionBlocksResponse.CustomTypeAdapterFactory()); @@ -330,7 +332,6 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionDataTypesStatus.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionHeader.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionInfoInput.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionInfoInputFuncDepsInner.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionInfoOutput.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionListItem.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionLocalVariableResponse.CustomTypeAdapterFactory()); @@ -351,7 +352,6 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionStringsResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionTaskResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionTypeInput.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionTypeOutput.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionsDetailResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.FunctionsListRename.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.GenerateFunctionDataTypes.CustomTypeAdapterFactory()); @@ -404,10 +404,10 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.PatchCollectionTagsInputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.PatchCollectionTagsOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.PatchCommentBody.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.PcapBodyInfo.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.PriceOutput.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.PriceSummary.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ProcessActivityEntry.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ProcessExtractedFiles.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ProcessMemdumps.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ProcessNode.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ProcessTree.CustomTypeAdapterFactory()); @@ -439,6 +439,8 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SecurityModel.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SegmentInfo.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SendMessageRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ServerSentEventsInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ServerSentEventsInner1.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ServiceEntry.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SessionOutputBody.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SingleCodeCertificateModel.CustomTypeAdapterFactory()); @@ -467,8 +469,6 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.StartupInfo.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.StatusOutput.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.StatusResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.StreamAiDecompilation200ResponseInner.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.StreamEvents200ResponseInner.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.StringFunctions.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Structure.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.StructureMember.CustomTypeAdapterFactory()); @@ -482,6 +482,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TagSearchResult.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TaskResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TaskStatusResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TcpCarvedFile.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TimestampModel.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TokenisedData.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TriageFunctionResponse.CustomTypeAdapterFactory()); diff --git a/src/main/java/ai/reveng/model/AIDecompFunctionMapping.java b/src/main/java/ai/reveng/model/AIDecompFunctionMapping.java index 1640a597..b00e39ab 100644 --- a/src/main/java/ai/reveng/model/AIDecompFunctionMapping.java +++ b/src/main/java/ai/reveng/model/AIDecompFunctionMapping.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AIDecompInverseFunctionMapItem; import ai.reveng.model.AIDecompInverseStringMapItem; import ai.reveng.model.ReplacementValue; @@ -47,7 +46,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -506,50 +504,6 @@ public void setUserOverrideMappings(@javax.annotation.Nonnull Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the AIDecompFunctionMapping instance itself - */ - public AIDecompFunctionMapping putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -574,13 +528,12 @@ public boolean equals(Object o) { Objects.equals(this.unmatchedStrings, aiDecompFunctionMapping.unmatchedStrings) && Objects.equals(this.unmatchedVariadicLists, aiDecompFunctionMapping.unmatchedVariadicLists) && Objects.equals(this.unmatchedVars, aiDecompFunctionMapping.unmatchedVars) && - Objects.equals(this.userOverrideMappings, aiDecompFunctionMapping.userOverrideMappings)&& - Objects.equals(this.additionalProperties, aiDecompFunctionMapping.additionalProperties); + Objects.equals(this.userOverrideMappings, aiDecompFunctionMapping.userOverrideMappings); } @Override public int hashCode() { - return Objects.hash(fields, inverseFunctionMap, inverseStringMap, unmatchedCustomFunctionPointers, unmatchedCustomTypes, unmatchedEnums, unmatchedExternalVars, unmatchedFunctions, unmatchedGlobalVars, unmatchedGoToLabels, unmatchedStrings, unmatchedVariadicLists, unmatchedVars, userOverrideMappings, additionalProperties); + return Objects.hash(fields, inverseFunctionMap, inverseStringMap, unmatchedCustomFunctionPointers, unmatchedCustomTypes, unmatchedEnums, unmatchedExternalVars, unmatchedFunctions, unmatchedGlobalVars, unmatchedGoToLabels, unmatchedStrings, unmatchedVariadicLists, unmatchedVars, userOverrideMappings); } @Override @@ -601,7 +554,6 @@ public String toString() { sb.append(" unmatchedVariadicLists: ").append(toIndentedString(unmatchedVariadicLists)).append("\n"); sb.append(" unmatchedVars: ").append(toIndentedString(unmatchedVars)).append("\n"); sb.append(" userOverrideMappings: ").append(toIndentedString(userOverrideMappings)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -611,10 +563,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -638,14 +587,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AIDecompFunctionMapping.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AIDecompFunctionMapping is not found in the empty JSON string", AIDecompFunctionMapping.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AIDecompFunctionMapping is not found in the empty JSON string", AIDecompFunctionMapping.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!AIDecompFunctionMapping.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AIDecompFunctionMapping` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AIDecompFunctionMapping.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -666,28 +623,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AIDecompFunctionMapping value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -695,28 +630,7 @@ else if (entry.getValue() instanceof Character) public AIDecompFunctionMapping read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - AIDecompFunctionMapping instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AIDecompInverseFunctionMapItem.java b/src/main/java/ai/reveng/model/AIDecompInverseFunctionMapItem.java index 23a87dc1..9f40aa1e 100644 --- a/src/main/java/ai/reveng/model/AIDecompInverseFunctionMapItem.java +++ b/src/main/java/ai/reveng/model/AIDecompInverseFunctionMapItem.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -125,50 +123,6 @@ public void setName(@javax.annotation.Nonnull String name) { this.name = name; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the AIDecompInverseFunctionMapItem instance itself - */ - public AIDecompInverseFunctionMapItem putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -182,13 +136,12 @@ public boolean equals(Object o) { AIDecompInverseFunctionMapItem aiDecompInverseFunctionMapItem = (AIDecompInverseFunctionMapItem) o; return Objects.equals(this.addr, aiDecompInverseFunctionMapItem.addr) && Objects.equals(this.isExternal, aiDecompInverseFunctionMapItem.isExternal) && - Objects.equals(this.name, aiDecompInverseFunctionMapItem.name)&& - Objects.equals(this.additionalProperties, aiDecompInverseFunctionMapItem.additionalProperties); + Objects.equals(this.name, aiDecompInverseFunctionMapItem.name); } @Override public int hashCode() { - return Objects.hash(addr, isExternal, name, additionalProperties); + return Objects.hash(addr, isExternal, name); } @Override @@ -198,7 +151,6 @@ public String toString() { sb.append(" addr: ").append(toIndentedString(addr)).append("\n"); sb.append(" isExternal: ").append(toIndentedString(isExternal)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -208,10 +160,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -235,19 +184,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AIDecompInverseFunctionMapItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AIDecompInverseFunctionMapItem is not found in the empty JSON string", AIDecompInverseFunctionMapItem.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AIDecompInverseFunctionMapItem is not found in the empty JSON string", AIDecompInverseFunctionMapItem.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!AIDecompInverseFunctionMapItem.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AIDecompInverseFunctionMapItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AIDecompInverseFunctionMapItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } } @@ -266,28 +223,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AIDecompInverseFunctionMapItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -295,28 +230,7 @@ else if (entry.getValue() instanceof Character) public AIDecompInverseFunctionMapItem read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - AIDecompInverseFunctionMapItem instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AIDecompInverseStringMapItem.java b/src/main/java/ai/reveng/model/AIDecompInverseStringMapItem.java index 2a82b65f..aeae72d0 100644 --- a/src/main/java/ai/reveng/model/AIDecompInverseStringMapItem.java +++ b/src/main/java/ai/reveng/model/AIDecompInverseStringMapItem.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -101,50 +99,6 @@ public void setString(@javax.annotation.Nonnull String string) { this.string = string; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the AIDecompInverseStringMapItem instance itself - */ - public AIDecompInverseStringMapItem putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -157,13 +111,12 @@ public boolean equals(Object o) { } AIDecompInverseStringMapItem aiDecompInverseStringMapItem = (AIDecompInverseStringMapItem) o; return Objects.equals(this.addr, aiDecompInverseStringMapItem.addr) && - Objects.equals(this.string, aiDecompInverseStringMapItem.string)&& - Objects.equals(this.additionalProperties, aiDecompInverseStringMapItem.additionalProperties); + Objects.equals(this.string, aiDecompInverseStringMapItem.string); } @Override public int hashCode() { - return Objects.hash(addr, string, additionalProperties); + return Objects.hash(addr, string); } @Override @@ -172,7 +125,6 @@ public String toString() { sb.append("class AIDecompInverseStringMapItem {\n"); sb.append(" addr: ").append(toIndentedString(addr)).append("\n"); sb.append(" string: ").append(toIndentedString(string)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -182,10 +134,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -209,19 +158,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AIDecompInverseStringMapItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AIDecompInverseStringMapItem is not found in the empty JSON string", AIDecompInverseStringMapItem.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AIDecompInverseStringMapItem is not found in the empty JSON string", AIDecompInverseStringMapItem.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!AIDecompInverseStringMapItem.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AIDecompInverseStringMapItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AIDecompInverseStringMapItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("string").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `string` to be a primitive type in the JSON string but got `%s`", jsonObj.get("string").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `string` to be a primitive type in the JSON string but got `%s`", jsonObj.get("string").toString())); } } @@ -240,28 +197,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AIDecompInverseStringMapItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -269,28 +204,7 @@ else if (entry.getValue() instanceof Character) public AIDecompInverseStringMapItem read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - AIDecompInverseStringMapItem instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/APIError.java b/src/main/java/ai/reveng/model/APIError.java index 21b2f986..50170018 100644 --- a/src/main/java/ai/reveng/model/APIError.java +++ b/src/main/java/ai/reveng/model/APIError.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorBody; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -78,50 +76,6 @@ public void setError(@javax.annotation.Nonnull ErrorBody error) { this.error = error; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the APIError instance itself - */ - public APIError putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -133,13 +87,12 @@ public boolean equals(Object o) { return false; } APIError apIError = (APIError) o; - return Objects.equals(this.error, apIError.error)&& - Objects.equals(this.additionalProperties, apIError.additionalProperties); + return Objects.equals(this.error, apIError.error); } @Override public int hashCode() { - return Objects.hash(error, additionalProperties); + return Objects.hash(error); } @Override @@ -147,7 +100,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class APIError {\n"); sb.append(" error: ").append(toIndentedString(error)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -157,10 +109,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -184,17 +133,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!APIError.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in APIError is not found in the empty JSON string", APIError.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in APIError is not found in the empty JSON string", APIError.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!APIError.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APIError` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APIError.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `error` + ErrorBody.validateJsonElement(jsonObj.get("error")); } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -212,28 +171,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APIError value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -241,28 +178,7 @@ else if (entry.getValue() instanceof Character) public APIError read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - APIError instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AbstractOpenApiSchema.java b/src/main/java/ai/reveng/model/AbstractOpenApiSchema.java index 213df3b6..5674a300 100644 --- a/src/main/java/ai/reveng/model/AbstractOpenApiSchema.java +++ b/src/main/java/ai/reveng/model/AbstractOpenApiSchema.java @@ -103,10 +103,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } public boolean equals(Object o) { diff --git a/src/main/java/ai/reveng/model/AddCalleeInputBody.java b/src/main/java/ai/reveng/model/AddCalleeInputBody.java index fe47374b..53831529 100644 --- a/src/main/java/ai/reveng/model/AddCalleeInputBody.java +++ b/src/main/java/ai/reveng/model/AddCalleeInputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -175,50 +173,6 @@ public void setThunkedVaddr(@javax.annotation.Nullable Long thunkedVaddr) { this.thunkedVaddr = thunkedVaddr; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the AddCalleeInputBody instance itself - */ - public AddCalleeInputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -234,13 +188,12 @@ public boolean equals(Object o) { Objects.equals(this.calleeName, addCalleeInputBody.calleeName) && Objects.equals(this.calleeVaddr, addCalleeInputBody.calleeVaddr) && Objects.equals(this.isExternal, addCalleeInputBody.isExternal) && - Objects.equals(this.thunkedVaddr, addCalleeInputBody.thunkedVaddr)&& - Objects.equals(this.additionalProperties, addCalleeInputBody.additionalProperties); + Objects.equals(this.thunkedVaddr, addCalleeInputBody.thunkedVaddr); } @Override public int hashCode() { - return Objects.hash(calleeFunctionId, calleeName, calleeVaddr, isExternal, thunkedVaddr, additionalProperties); + return Objects.hash(calleeFunctionId, calleeName, calleeVaddr, isExternal, thunkedVaddr); } @Override @@ -252,7 +205,6 @@ public String toString() { sb.append(" calleeVaddr: ").append(toIndentedString(calleeVaddr)).append("\n"); sb.append(" isExternal: ").append(toIndentedString(isExternal)).append("\n"); sb.append(" thunkedVaddr: ").append(toIndentedString(thunkedVaddr)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -262,10 +214,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -289,19 +238,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AddCalleeInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AddCalleeInputBody is not found in the empty JSON string", AddCalleeInputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AddCalleeInputBody is not found in the empty JSON string", AddCalleeInputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!AddCalleeInputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AddCalleeInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AddCalleeInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("callee_name") != null && !jsonObj.get("callee_name").isJsonNull()) && !jsonObj.get("callee_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `callee_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("callee_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `callee_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("callee_name").toString())); } } @@ -320,28 +277,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AddCalleeInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -349,28 +284,7 @@ else if (entry.getValue() instanceof Character) public AddCalleeInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - AddCalleeInputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AddUserStringInputBody.java b/src/main/java/ai/reveng/model/AddUserStringInputBody.java index fbccd499..dd6c92b2 100644 --- a/src/main/java/ai/reveng/model/AddUserStringInputBody.java +++ b/src/main/java/ai/reveng/model/AddUserStringInputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -102,50 +100,6 @@ public void setVirtualAddress(@javax.annotation.Nonnull Long virtualAddress) { this.virtualAddress = virtualAddress; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the AddUserStringInputBody instance itself - */ - public AddUserStringInputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -158,13 +112,12 @@ public boolean equals(Object o) { } AddUserStringInputBody addUserStringInputBody = (AddUserStringInputBody) o; return Objects.equals(this.string, addUserStringInputBody.string) && - Objects.equals(this.virtualAddress, addUserStringInputBody.virtualAddress)&& - Objects.equals(this.additionalProperties, addUserStringInputBody.additionalProperties); + Objects.equals(this.virtualAddress, addUserStringInputBody.virtualAddress); } @Override public int hashCode() { - return Objects.hash(string, virtualAddress, additionalProperties); + return Objects.hash(string, virtualAddress); } @Override @@ -173,7 +126,6 @@ public String toString() { sb.append("class AddUserStringInputBody {\n"); sb.append(" string: ").append(toIndentedString(string)).append("\n"); sb.append(" virtualAddress: ").append(toIndentedString(virtualAddress)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -183,10 +135,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -210,19 +159,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AddUserStringInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AddUserStringInputBody is not found in the empty JSON string", AddUserStringInputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AddUserStringInputBody is not found in the empty JSON string", AddUserStringInputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!AddUserStringInputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AddUserStringInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AddUserStringInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("string").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `string` to be a primitive type in the JSON string but got `%s`", jsonObj.get("string").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `string` to be a primitive type in the JSON string but got `%s`", jsonObj.get("string").toString())); } } @@ -241,28 +198,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AddUserStringInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -270,28 +205,7 @@ else if (entry.getValue() instanceof Character) public AddUserStringInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - AddUserStringInputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AddUserStringToFunctionInputBody.java b/src/main/java/ai/reveng/model/AddUserStringToFunctionInputBody.java index fe3ba06b..4cc233d5 100644 --- a/src/main/java/ai/reveng/model/AddUserStringToFunctionInputBody.java +++ b/src/main/java/ai/reveng/model/AddUserStringToFunctionInputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -102,50 +100,6 @@ public void setVirtualAddress(@javax.annotation.Nonnull Long virtualAddress) { this.virtualAddress = virtualAddress; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the AddUserStringToFunctionInputBody instance itself - */ - public AddUserStringToFunctionInputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -158,13 +112,12 @@ public boolean equals(Object o) { } AddUserStringToFunctionInputBody addUserStringToFunctionInputBody = (AddUserStringToFunctionInputBody) o; return Objects.equals(this.string, addUserStringToFunctionInputBody.string) && - Objects.equals(this.virtualAddress, addUserStringToFunctionInputBody.virtualAddress)&& - Objects.equals(this.additionalProperties, addUserStringToFunctionInputBody.additionalProperties); + Objects.equals(this.virtualAddress, addUserStringToFunctionInputBody.virtualAddress); } @Override public int hashCode() { - return Objects.hash(string, virtualAddress, additionalProperties); + return Objects.hash(string, virtualAddress); } @Override @@ -173,7 +126,6 @@ public String toString() { sb.append("class AddUserStringToFunctionInputBody {\n"); sb.append(" string: ").append(toIndentedString(string)).append("\n"); sb.append(" virtualAddress: ").append(toIndentedString(virtualAddress)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -183,10 +135,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -210,19 +159,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AddUserStringToFunctionInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AddUserStringToFunctionInputBody is not found in the empty JSON string", AddUserStringToFunctionInputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AddUserStringToFunctionInputBody is not found in the empty JSON string", AddUserStringToFunctionInputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!AddUserStringToFunctionInputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AddUserStringToFunctionInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AddUserStringToFunctionInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("string").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `string` to be a primitive type in the JSON string but got `%s`", jsonObj.get("string").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `string` to be a primitive type in the JSON string but got `%s`", jsonObj.get("string").toString())); } } @@ -241,28 +198,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AddUserStringToFunctionInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -270,28 +205,7 @@ else if (entry.getValue() instanceof Character) public AddUserStringToFunctionInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - AddUserStringToFunctionInputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AdditionalDetailsStatusResponse.java b/src/main/java/ai/reveng/model/AdditionalDetailsStatusResponse.java index d2be8348..98559efc 100644 --- a/src/main/java/ai/reveng/model/AdditionalDetailsStatusResponse.java +++ b/src/main/java/ai/reveng/model/AdditionalDetailsStatusResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -156,10 +154,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,19 +178,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AdditionalDetailsStatusResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AdditionalDetailsStatusResponse is not found in the empty JSON string", AdditionalDetailsStatusResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AdditionalDetailsStatusResponse is not found in the empty JSON string", AdditionalDetailsStatusResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AdditionalDetailsStatusResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); } } @@ -256,7 +251,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/Addr.java b/src/main/java/ai/reveng/model/Addr.java index 60c86320..f38a448f 100644 --- a/src/main/java/ai/reveng/model/Addr.java +++ b/src/main/java/ai/reveng/model/Addr.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; @@ -27,7 +26,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Locale; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -101,7 +99,7 @@ public Addr read(JsonReader in) throws IOException { try { // validate the JSON object to see if any exception is thrown if (!jsonElement.getAsJsonPrimitive().isNumber()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString())); } actualAdapter = adapterLong; Addr ret = new Addr(); @@ -109,14 +107,14 @@ public Addr read(JsonReader in) throws IOException { return ret; } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for Long failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for Long failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'Long'", e); } // deserialize String try { // validate the JSON object to see if any exception is thrown if (!jsonElement.getAsJsonPrimitive().isString()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be of type String in the JSON string but got `%s`", jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected json element to be of type String in the JSON string but got `%s`", jsonElement.toString())); } actualAdapter = adapterString; Addr ret = new Addr(); @@ -124,11 +122,11 @@ public Addr read(JsonReader in) throws IOException { return ret; } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for String failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for String failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'String'", e); } - throw new IOException(String.format(Locale.ROOT, "Failed deserialization for Addr: no class matches result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); + throw new IOException(String.format(java.util.Locale.ROOT, "Failed deserialization for Addr: no class matches result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); } }.nullSafe(); } @@ -229,24 +227,24 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the json string with Long try { if (!jsonElement.getAsJsonPrimitive().isNumber()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString())); } return; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for Long failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for Long failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with String try { if (!jsonElement.getAsJsonPrimitive().isString()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be of type String in the JSON string but got `%s`", jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected json element to be of type String in the JSON string but got `%s`", jsonElement.toString())); } return; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for String failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for String failed with `%s`.", e.getMessage())); // continue to the next one } - throw new IOException(String.format(Locale.ROOT, "The JSON string is invalid for Addr with anyOf schemas: Long, String. no class match the result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); + throw new IOException(String.format(java.util.Locale.ROOT, "The JSON string is invalid for Addr with anyOf schemas: Long, String. no class match the result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); } /** diff --git a/src/main/java/ai/reveng/model/AiDecompilationRating.java b/src/main/java/ai/reveng/model/AiDecompilationRating.java index 0d179888..42690d4a 100644 --- a/src/main/java/ai/reveng/model/AiDecompilationRating.java +++ b/src/main/java/ai/reveng/model/AiDecompilationRating.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/AiDecompilationTaskStatus.java b/src/main/java/ai/reveng/model/AiDecompilationTaskStatus.java index b700b808..96528657 100644 --- a/src/main/java/ai/reveng/model/AiDecompilationTaskStatus.java +++ b/src/main/java/ai/reveng/model/AiDecompilationTaskStatus.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/AiUnstripRequest.java b/src/main/java/ai/reveng/model/AiUnstripRequest.java index 21f5b0f5..1db12cfc 100644 --- a/src/main/java/ai/reveng/model/AiUnstripRequest.java +++ b/src/main/java/ai/reveng/model/AiUnstripRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -156,10 +154,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,7 +178,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AiUnstripRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AiUnstripRequest is not found in the empty JSON string", AiUnstripRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AiUnstripRequest is not found in the empty JSON string", AiUnstripRequest.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -246,7 +241,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisAccessInfo.java b/src/main/java/ai/reveng/model/AnalysisAccessInfo.java index d43232d0..d2194956 100644 --- a/src/main/java/ai/reveng/model/AnalysisAccessInfo.java +++ b/src/main/java/ai/reveng/model/AnalysisAccessInfo.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -182,10 +180,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -209,19 +204,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisAccessInfo.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisAccessInfo is not found in the empty JSON string", AnalysisAccessInfo.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisAccessInfo is not found in the empty JSON string", AnalysisAccessInfo.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisAccessInfo.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("username").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); } } @@ -282,7 +277,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisBasicInfoOutputBody.java b/src/main/java/ai/reveng/model/AnalysisBasicInfoOutputBody.java index d1401310..d993ee17 100644 --- a/src/main/java/ai/reveng/model/AnalysisBasicInfoOutputBody.java +++ b/src/main/java/ai/reveng/model/AnalysisBasicInfoOutputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -542,50 +540,6 @@ public void setTeamId(@javax.annotation.Nonnull Long teamId) { this.teamId = teamId; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the AnalysisBasicInfoOutputBody instance itself - */ - public AnalysisBasicInfoOutputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -614,13 +568,12 @@ public boolean equals(Object o) { Objects.equals(this.ownerUsername, analysisBasicInfoOutputBody.ownerUsername) && Objects.equals(this.sequencerVersion, analysisBasicInfoOutputBody.sequencerVersion) && Objects.equals(this.sha256Hash, analysisBasicInfoOutputBody.sha256Hash) && - Objects.equals(this.teamId, analysisBasicInfoOutputBody.teamId)&& - Objects.equals(this.additionalProperties, analysisBasicInfoOutputBody.additionalProperties); + Objects.equals(this.teamId, analysisBasicInfoOutputBody.teamId); } @Override public int hashCode() { - return Objects.hash(analysisScope, baseAddress, binaryId, binaryName, binarySize, binaryUuid, creation, debug, functionCount, isAdvanced, isOwner, isSystem, modelId, modelName, ownerUsername, sequencerVersion, sha256Hash, teamId, additionalProperties); + return Objects.hash(analysisScope, baseAddress, binaryId, binaryName, binarySize, binaryUuid, creation, debug, functionCount, isAdvanced, isOwner, isSystem, modelId, modelName, ownerUsername, sequencerVersion, sha256Hash, teamId); } @Override @@ -645,7 +598,6 @@ public String toString() { sb.append(" sequencerVersion: ").append(toIndentedString(sequencerVersion)).append("\n"); sb.append(" sha256Hash: ").append(toIndentedString(sha256Hash)).append("\n"); sb.append(" teamId: ").append(toIndentedString(teamId)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -655,10 +607,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -682,39 +631,47 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisBasicInfoOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisBasicInfoOutputBody is not found in the empty JSON string", AnalysisBasicInfoOutputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisBasicInfoOutputBody is not found in the empty JSON string", AnalysisBasicInfoOutputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!AnalysisBasicInfoOutputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisBasicInfoOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisBasicInfoOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("analysis_scope").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `analysis_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("analysis_scope").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `analysis_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("analysis_scope").toString())); } // validate the required field `analysis_scope` AnalysisScopeEnum.validateJsonElement(jsonObj.get("analysis_scope")); if (!jsonObj.get("binary_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); } if ((jsonObj.get("binary_uuid") != null && !jsonObj.get("binary_uuid").isJsonNull()) && !jsonObj.get("binary_uuid").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binary_uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_uuid").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binary_uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_uuid").toString())); } if (!jsonObj.get("model_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); } if (!jsonObj.get("owner_username").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `owner_username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owner_username").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `owner_username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owner_username").toString())); } if ((jsonObj.get("sequencer_version") != null && !jsonObj.get("sequencer_version").isJsonNull()) && !jsonObj.get("sequencer_version").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sequencer_version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sequencer_version").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sequencer_version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sequencer_version").toString())); } if (!jsonObj.get("sha_256_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); } } @@ -733,28 +690,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisBasicInfoOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -762,28 +697,7 @@ else if (entry.getValue() instanceof Character) public AnalysisBasicInfoOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - AnalysisBasicInfoOutputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AnalysisBulkAddTagsRequest.java b/src/main/java/ai/reveng/model/AnalysisBulkAddTagsRequest.java index 9561d871..5cd0cf5b 100644 --- a/src/main/java/ai/reveng/model/AnalysisBulkAddTagsRequest.java +++ b/src/main/java/ai/reveng/model/AnalysisBulkAddTagsRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -200,10 +198,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -227,14 +222,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisBulkAddTagsRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisBulkAddTagsRequest is not found in the empty JSON string", AnalysisBulkAddTagsRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisBulkAddTagsRequest is not found in the empty JSON string", AnalysisBulkAddTagsRequest.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisBulkAddTagsRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -242,13 +237,13 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("tags") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); } // ensure the required json array is present if (jsonObj.get("analysis_ids") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("analysis_ids").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `analysis_ids` to be an array in the JSON string but got `%s`", jsonObj.get("analysis_ids").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `analysis_ids` to be an array in the JSON string but got `%s`", jsonObj.get("analysis_ids").toString())); } } @@ -309,7 +304,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisBulkAddTagsResponse.java b/src/main/java/ai/reveng/model/AnalysisBulkAddTagsResponse.java index ccf481c6..d8731e80 100644 --- a/src/main/java/ai/reveng/model/AnalysisBulkAddTagsResponse.java +++ b/src/main/java/ai/reveng/model/AnalysisBulkAddTagsResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AnalysisBulkAddTagsResponseItem; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -167,10 +165,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,27 +189,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisBulkAddTagsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisBulkAddTagsResponse is not found in the empty JSON string", AnalysisBulkAddTagsResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisBulkAddTagsResponse is not found in the empty JSON string", AnalysisBulkAddTagsResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisBulkAddTagsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("results").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); + if (jsonObj.get("results") != null) { + if (!jsonObj.get("results").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); + } + JsonArray jsonArrayresults = jsonObj.getAsJsonArray("results"); + // validate the required field `results` (array) + for (int i = 0; i < jsonArrayresults.size(); i++) { + AnalysisBulkAddTagsResponseItem.validateJsonElement(jsonArrayresults.get(i)); + } } - - JsonArray jsonArrayresults = jsonObj.getAsJsonArray("results"); - // validate the required field `results` (array) - for (int i = 0; i < jsonArrayresults.size(); i++) { - AnalysisBulkAddTagsResponseItem.validateJsonElement(jsonArrayresults.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -274,7 +269,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisBulkAddTagsResponseItem.java b/src/main/java/ai/reveng/model/AnalysisBulkAddTagsResponseItem.java index 26dde805..21b43db0 100644 --- a/src/main/java/ai/reveng/model/AnalysisBulkAddTagsResponseItem.java +++ b/src/main/java/ai/reveng/model/AnalysisBulkAddTagsResponseItem.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -95,7 +93,7 @@ public AnalysisBulkAddTagsResponseItem message(@javax.annotation.Nullable String } /** - * Get message + * Success message if the update was successful * @return message */ @javax.annotation.Nullable @@ -114,7 +112,7 @@ public AnalysisBulkAddTagsResponseItem error(@javax.annotation.Nullable String e } /** - * Get error + * Error message if the update failed * @return error */ @javax.annotation.Nullable @@ -220,10 +218,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -247,22 +242,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisBulkAddTagsResponseItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisBulkAddTagsResponseItem is not found in the empty JSON string", AnalysisBulkAddTagsResponseItem.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisBulkAddTagsResponseItem is not found in the empty JSON string", AnalysisBulkAddTagsResponseItem.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisBulkAddTagsResponseItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if ((jsonObj.get("error") != null && !jsonObj.get("error").isJsonNull()) && !jsonObj.get("error").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `error` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `error` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error").toString())); } } @@ -323,7 +318,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisConfig.java b/src/main/java/ai/reveng/model/AnalysisConfig.java index 7a8a71fc..f01d5935 100644 --- a/src/main/java/ai/reveng/model/AnalysisConfig.java +++ b/src/main/java/ai/reveng/model/AnalysisConfig.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SandboxOptions; import ai.reveng.model.ScrapeThirdPartyConfig; import com.google.gson.TypeAdapter; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -314,10 +312,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -341,7 +336,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisConfig.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisConfig is not found in the empty JSON string", AnalysisConfig.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisConfig is not found in the empty JSON string", AnalysisConfig.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -412,7 +407,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisCreateRequest.java b/src/main/java/ai/reveng/model/AnalysisCreateRequest.java index a5a18f63..cca8999d 100644 --- a/src/main/java/ai/reveng/model/AnalysisCreateRequest.java +++ b/src/main/java/ai/reveng/model/AnalysisCreateRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AnalysisConfig; import ai.reveng.model.AnalysisScope; import ai.reveng.model.AutoRunAgents; @@ -51,7 +50,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -78,7 +76,7 @@ public class AnalysisCreateRequest { public static final String SERIALIZED_NAME_ANALYSIS_SCOPE = "analysis_scope"; @SerializedName(SERIALIZED_NAME_ANALYSIS_SCOPE) @javax.annotation.Nullable - private AnalysisScope analysisScope; + private AnalysisScope analysisScope = AnalysisScope.PRIVATE; public static final String SERIALIZED_NAME_SYMBOLS = "symbols"; @SerializedName(SERIALIZED_NAME_SYMBOLS) @@ -198,7 +196,7 @@ public AnalysisCreateRequest symbols(@javax.annotation.Nullable Symbols symbols) } /** - * Get symbols + * Symbols are user-defined properties which inform how the binary is decompiled * @return symbols */ @javax.annotation.Nullable @@ -217,7 +215,7 @@ public AnalysisCreateRequest debugHash(@javax.annotation.Nullable String debugHa } /** - * Get debugHash + * Hash of the debug file * @return debugHash */ @javax.annotation.Nullable @@ -392,10 +390,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -419,29 +414,29 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisCreateRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisCreateRequest is not found in the empty JSON string", AnalysisCreateRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisCreateRequest is not found in the empty JSON string", AnalysisCreateRequest.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisCreateRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("filename").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `filename` to be a primitive type in the JSON string but got `%s`", jsonObj.get("filename").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `filename` to be a primitive type in the JSON string but got `%s`", jsonObj.get("filename").toString())); } if (!jsonObj.get("sha_256_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); } if (jsonObj.get("tags") != null && !jsonObj.get("tags").isJsonNull()) { JsonArray jsonArraytags = jsonObj.getAsJsonArray("tags"); if (jsonArraytags != null) { // ensure the json data is an array if (!jsonObj.get("tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); } // validate the optional field `tags` (array) @@ -459,7 +454,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti Symbols.validateJsonElement(jsonObj.get("symbols")); } if ((jsonObj.get("debug_hash") != null && !jsonObj.get("debug_hash").isJsonNull()) && !jsonObj.get("debug_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `debug_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("debug_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `debug_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("debug_hash").toString())); } // validate the optional field `analysis_config` if (jsonObj.get("analysis_config") != null && !jsonObj.get("analysis_config").isJsonNull()) { @@ -532,7 +527,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisCreateResponse.java b/src/main/java/ai/reveng/model/AnalysisCreateResponse.java index 444c468d..c2b5b880 100644 --- a/src/main/java/ai/reveng/model/AnalysisCreateResponse.java +++ b/src/main/java/ai/reveng/model/AnalysisCreateResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -182,10 +180,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -209,14 +204,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisCreateResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisCreateResponse is not found in the empty JSON string", AnalysisCreateResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisCreateResponse is not found in the empty JSON string", AnalysisCreateResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisCreateResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -279,7 +274,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisDetailResponse.java b/src/main/java/ai/reveng/model/AnalysisDetailResponse.java index 68c97412..90fbcb0b 100644 --- a/src/main/java/ai/reveng/model/AnalysisDetailResponse.java +++ b/src/main/java/ai/reveng/model/AnalysisDetailResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AnalysisAccessInfo; import ai.reveng.model.AutoRunAgents; import com.google.gson.TypeAdapter; @@ -47,7 +46,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -570,10 +568,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -597,45 +592,45 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisDetailResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisDetailResponse is not found in the empty JSON string", AnalysisDetailResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisDetailResponse is not found in the empty JSON string", AnalysisDetailResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisDetailResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the required field `access` AnalysisAccessInfo.validateJsonElement(jsonObj.get("access")); if (!jsonObj.get("analysis_scope").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `analysis_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("analysis_scope").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `analysis_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("analysis_scope").toString())); } if (!jsonObj.get("architecture").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `architecture` to be a primitive type in the JSON string but got `%s`", jsonObj.get("architecture").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `architecture` to be a primitive type in the JSON string but got `%s`", jsonObj.get("architecture").toString())); } if (!jsonObj.get("binary_format").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binary_format` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_format").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binary_format` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_format").toString())); } if (!jsonObj.get("binary_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); } if (!jsonObj.get("binary_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binary_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binary_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_type").toString())); } if (!jsonObj.get("creation").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `creation` to be a primitive type in the JSON string but got `%s`", jsonObj.get("creation").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `creation` to be a primitive type in the JSON string but got `%s`", jsonObj.get("creation").toString())); } if (!jsonObj.get("dashboard_url").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `dashboard_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("dashboard_url").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `dashboard_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("dashboard_url").toString())); } if (!jsonObj.get("model_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); } if (!jsonObj.get("sha_256_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); } // validate the required field `auto_run_agents` AutoRunAgents.validateJsonElement(jsonObj.get("auto_run_agents")); @@ -698,7 +693,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisFunctionMapping.java b/src/main/java/ai/reveng/model/AnalysisFunctionMapping.java index 1cceaee1..544c7345 100644 --- a/src/main/java/ai/reveng/model/AnalysisFunctionMapping.java +++ b/src/main/java/ai/reveng/model/AnalysisFunctionMapping.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FunctionMapping; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -157,10 +155,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -184,14 +179,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisFunctionMapping.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisFunctionMapping is not found in the empty JSON string", AnalysisFunctionMapping.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisFunctionMapping is not found in the empty JSON string", AnalysisFunctionMapping.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisFunctionMapping.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -256,7 +251,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisFunctionMatchingRequest.java b/src/main/java/ai/reveng/model/AnalysisFunctionMatchingRequest.java index c6955c81..99053559 100644 --- a/src/main/java/ai/reveng/model/AnalysisFunctionMatchingRequest.java +++ b/src/main/java/ai/reveng/model/AnalysisFunctionMatchingRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FunctionMatchingFilters; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -127,7 +125,7 @@ public AnalysisFunctionMatchingRequest filters(@javax.annotation.Nullable Functi } /** - * Get filters + * Used to limit the search to specific binaries, collections, and functions * @return filters */ @javax.annotation.Nullable @@ -374,10 +372,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -401,7 +396,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisFunctionMatchingRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisFunctionMatchingRequest is not found in the empty JSON string", AnalysisFunctionMatchingRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisFunctionMatchingRequest is not found in the empty JSON string", AnalysisFunctionMatchingRequest.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -468,7 +463,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisFunctions.java b/src/main/java/ai/reveng/model/AnalysisFunctions.java index 70085c1e..8e4d4a6e 100644 --- a/src/main/java/ai/reveng/model/AnalysisFunctions.java +++ b/src/main/java/ai/reveng/model/AnalysisFunctions.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AppApiRestV2FunctionsTypesFunction; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -167,10 +165,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,27 +189,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisFunctions.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisFunctions is not found in the empty JSON string", AnalysisFunctions.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisFunctions is not found in the empty JSON string", AnalysisFunctions.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisFunctions.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("functions").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); + if (jsonObj.get("functions") != null) { + if (!jsonObj.get("functions").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); + } + JsonArray jsonArrayfunctions = jsonObj.getAsJsonArray("functions"); + // validate the required field `functions` (array) + for (int i = 0; i < jsonArrayfunctions.size(); i++) { + AppApiRestV2FunctionsTypesFunction.validateJsonElement(jsonArrayfunctions.get(i)); + } } - - JsonArray jsonArrayfunctions = jsonObj.getAsJsonArray("functions"); - // validate the required field `functions` (array) - for (int i = 0; i < jsonArrayfunctions.size(); i++) { - AppApiRestV2FunctionsTypesFunction.validateJsonElement(jsonArrayfunctions.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -274,7 +269,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisFunctionsList.java b/src/main/java/ai/reveng/model/AnalysisFunctionsList.java index 8b9360bd..d51ceb74 100644 --- a/src/main/java/ai/reveng/model/AnalysisFunctionsList.java +++ b/src/main/java/ai/reveng/model/AnalysisFunctionsList.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FunctionListItem; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -167,10 +165,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,27 +189,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisFunctionsList.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisFunctionsList is not found in the empty JSON string", AnalysisFunctionsList.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisFunctionsList is not found in the empty JSON string", AnalysisFunctionsList.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisFunctionsList.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("functions").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); + if (jsonObj.get("functions") != null) { + if (!jsonObj.get("functions").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); + } + JsonArray jsonArrayfunctions = jsonObj.getAsJsonArray("functions"); + // validate the required field `functions` (array) + for (int i = 0; i < jsonArrayfunctions.size(); i++) { + FunctionListItem.validateJsonElement(jsonArrayfunctions.get(i)); + } } - - JsonArray jsonArrayfunctions = jsonObj.getAsJsonArray("functions"); - // validate the required field `functions` (array) - for (int i = 0; i < jsonArrayfunctions.size(); i++) { - FunctionListItem.validateJsonElement(jsonArrayfunctions.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -274,7 +269,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisLogMessage.java b/src/main/java/ai/reveng/model/AnalysisLogMessage.java index cd5c9d22..1234f719 100644 --- a/src/main/java/ai/reveng/model/AnalysisLogMessage.java +++ b/src/main/java/ai/reveng/model/AnalysisLogMessage.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -70,7 +68,7 @@ public AnalysisLogMessage message(@javax.annotation.Nullable String message) { } /** - * Get message + * Search is applied to string value * @return message */ @javax.annotation.Nullable @@ -89,7 +87,7 @@ public AnalysisLogMessage time(@javax.annotation.Nullable String time) { } /** - * Get time + * Search is applied to string value * @return time */ @javax.annotation.Nullable @@ -182,10 +180,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -209,22 +204,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisLogMessage.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisLogMessage is not found in the empty JSON string", AnalysisLogMessage.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisLogMessage is not found in the empty JSON string", AnalysisLogMessage.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisLogMessage.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if ((jsonObj.get("time") != null && !jsonObj.get("time").isJsonNull()) && !jsonObj.get("time").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `time` to be a primitive type in the JSON string but got `%s`", jsonObj.get("time").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `time` to be a primitive type in the JSON string but got `%s`", jsonObj.get("time").toString())); } } @@ -285,7 +280,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisLogs.java b/src/main/java/ai/reveng/model/AnalysisLogs.java index 426c4108..d507c5dc 100644 --- a/src/main/java/ai/reveng/model/AnalysisLogs.java +++ b/src/main/java/ai/reveng/model/AnalysisLogs.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AnalysisLogMessage; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -193,10 +191,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -220,22 +215,26 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisLogs.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisLogs is not found in the empty JSON string", AnalysisLogs.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisLogs is not found in the empty JSON string", AnalysisLogs.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisLogs.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the required json array is present - if (jsonObj.get("messages") == null) { - throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); - } else if (!jsonObj.get("messages").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `messages` to be an array in the JSON string but got `%s`", jsonObj.get("messages").toString())); + if (jsonObj.get("messages") != null && !jsonObj.get("messages").isJsonNull()) { + if (!jsonObj.get("messages").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `messages` to be an array in the JSON string but got `%s`", jsonObj.get("messages").toString())); + } + JsonArray jsonArraymessages = jsonObj.getAsJsonArray("messages"); + // validate the required field `messages` (array) + for (int i = 0; i < jsonArraymessages.size(); i++) { + AnalysisLogMessage.validateJsonElement(jsonArraymessages.get(i)); + } } } @@ -296,7 +295,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisRecord.java b/src/main/java/ai/reveng/model/AnalysisRecord.java index f49dc004..95d7d95d 100644 --- a/src/main/java/ai/reveng/model/AnalysisRecord.java +++ b/src/main/java/ai/reveng/model/AnalysisRecord.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.DynamicExecutionStatus; import ai.reveng.model.TagItem; import com.google.gson.TypeAdapter; @@ -49,7 +48,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -399,7 +397,7 @@ public AnalysisRecord dynamicExecutionStatus(@javax.annotation.Nullable DynamicE } /** - * Get dynamicExecutionStatus + * If searching for dynamic execution, the status of the task * @return dynamicExecutionStatus */ @javax.annotation.Nullable @@ -418,7 +416,7 @@ public AnalysisRecord dynamicExecutionTaskId(@javax.annotation.Nullable Integer } /** - * Get dynamicExecutionTaskId + * If searching for dynamic execution, the task ID of the task * @return dynamicExecutionTaskId */ @javax.annotation.Nullable @@ -598,10 +596,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -625,37 +620,37 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisRecord.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisRecord is not found in the empty JSON string", AnalysisRecord.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisRecord is not found in the empty JSON string", AnalysisRecord.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisRecord.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("analysis_scope").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `analysis_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("analysis_scope").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `analysis_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("analysis_scope").toString())); } if (!jsonObj.get("model_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); } if (!jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); } if (!jsonObj.get("binary_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); } if (!jsonObj.get("sha_256_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); } if (!jsonObj.get("function_boundaries_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `function_boundaries_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_boundaries_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_boundaries_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_boundaries_hash").toString())); } if (!jsonObj.get("username").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); } // validate the optional field `dynamic_execution_status` if (jsonObj.get("dynamic_execution_status") != null && !jsonObj.get("dynamic_execution_status").isJsonNull()) { @@ -666,7 +661,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonArraytags != null) { // ensure the json data is an array if (!jsonObj.get("tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); } // validate the optional field `tags` (array) @@ -734,7 +729,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisReport.java b/src/main/java/ai/reveng/model/AnalysisReport.java index a77eb5c7..6fb0af31 100644 --- a/src/main/java/ai/reveng/model/AnalysisReport.java +++ b/src/main/java/ai/reveng/model/AnalysisReport.java @@ -13,13 +13,13 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; +import ai.reveng.model.Artifact; +import ai.reveng.model.ConsoleOutputEntry; import ai.reveng.model.FileActivityEntry; import ai.reveng.model.ModuleLoadEntry; import ai.reveng.model.MutexEntry; import ai.reveng.model.NetworkActivity; import ai.reveng.model.ProcessActivityEntry; -import ai.reveng.model.ProcessExtractedFiles; import ai.reveng.model.ProcessMemdumps; import ai.reveng.model.ProcessTree; import ai.reveng.model.RegistryOperation; @@ -59,7 +59,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -68,10 +67,15 @@ */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class AnalysisReport { - public static final String SERIALIZED_NAME_EXTRACTED_FILES = "extracted_files"; - @SerializedName(SERIALIZED_NAME_EXTRACTED_FILES) + public static final String SERIALIZED_NAME_ARTIFACTS = "artifacts"; + @SerializedName(SERIALIZED_NAME_ARTIFACTS) @javax.annotation.Nullable - private List extractedFiles; + private List artifacts; + + public static final String SERIALIZED_NAME_CONSOLE_OUTPUT = "console_output"; + @SerializedName(SERIALIZED_NAME_CONSOLE_OUTPUT) + @javax.annotation.Nullable + private List consoleOutput; public static final String SERIALIZED_NAME_FILE_ACTIVITY = "file_activity"; @SerializedName(SERIALIZED_NAME_FILE_ACTIVITY) @@ -133,11 +137,6 @@ public class AnalysisReport { @javax.annotation.Nullable private StartupInfo startup; - public static final String SERIALIZED_NAME_THREAT_SCORE = "threat_score"; - @SerializedName(SERIALIZED_NAME_THREAT_SCORE) - @javax.annotation.Nonnull - private Long threatScore; - public static final String SERIALIZED_NAME_TTPS = "ttps"; @SerializedName(SERIALIZED_NAME_TTPS) @javax.annotation.Nullable @@ -146,30 +145,57 @@ public class AnalysisReport { public AnalysisReport() { } - public AnalysisReport extractedFiles(@javax.annotation.Nullable List extractedFiles) { - this.extractedFiles = extractedFiles; + public AnalysisReport artifacts(@javax.annotation.Nullable List artifacts) { + this.artifacts = artifacts; return this; } - public AnalysisReport addExtractedFilesItem(ProcessExtractedFiles extractedFilesItem) { - if (this.extractedFiles == null) { - this.extractedFiles = new ArrayList<>(); + public AnalysisReport addArtifactsItem(Artifact artifactsItem) { + if (this.artifacts == null) { + this.artifacts = new ArrayList<>(); } - this.extractedFiles.add(extractedFilesItem); + this.artifacts.add(artifactsItem); return this; } /** - * Get extractedFiles - * @return extractedFiles + * Get artifacts + * @return artifacts */ @javax.annotation.Nullable - public List getExtractedFiles() { - return extractedFiles; + public List getArtifacts() { + return artifacts; + } + + public void setArtifacts(@javax.annotation.Nullable List artifacts) { + this.artifacts = artifacts; } - public void setExtractedFiles(@javax.annotation.Nullable List extractedFiles) { - this.extractedFiles = extractedFiles; + + public AnalysisReport consoleOutput(@javax.annotation.Nullable List consoleOutput) { + this.consoleOutput = consoleOutput; + return this; + } + + public AnalysisReport addConsoleOutputItem(ConsoleOutputEntry consoleOutputItem) { + if (this.consoleOutput == null) { + this.consoleOutput = new ArrayList<>(); + } + this.consoleOutput.add(consoleOutputItem); + return this; + } + + /** + * Get consoleOutput + * @return consoleOutput + */ + @javax.annotation.Nullable + public List getConsoleOutput() { + return consoleOutput; + } + + public void setConsoleOutput(@javax.annotation.Nullable List consoleOutput) { + this.consoleOutput = consoleOutput; } @@ -465,25 +491,6 @@ public void setStartup(@javax.annotation.Nullable StartupInfo startup) { } - public AnalysisReport threatScore(@javax.annotation.Nonnull Long threatScore) { - this.threatScore = threatScore; - return this; - } - - /** - * Get threatScore - * @return threatScore - */ - @javax.annotation.Nonnull - public Long getThreatScore() { - return threatScore; - } - - public void setThreatScore(@javax.annotation.Nonnull Long threatScore) { - this.threatScore = threatScore; - } - - public AnalysisReport ttps(@javax.annotation.Nullable List ttps) { this.ttps = ttps; return this; @@ -565,7 +572,8 @@ public boolean equals(Object o) { return false; } AnalysisReport analysisReport = (AnalysisReport) o; - return Objects.equals(this.extractedFiles, analysisReport.extractedFiles) && + return Objects.equals(this.artifacts, analysisReport.artifacts) && + Objects.equals(this.consoleOutput, analysisReport.consoleOutput) && Objects.equals(this.fileActivity, analysisReport.fileActivity) && Objects.equals(this.info, analysisReport.info) && Objects.equals(this.memdumps, analysisReport.memdumps) && @@ -578,7 +586,6 @@ public boolean equals(Object o) { Objects.equals(this.scheduledTasks, analysisReport.scheduledTasks) && Objects.equals(this.services, analysisReport.services) && Objects.equals(this.startup, analysisReport.startup) && - Objects.equals(this.threatScore, analysisReport.threatScore) && Objects.equals(this.ttps, analysisReport.ttps)&& Objects.equals(this.additionalProperties, analysisReport.additionalProperties); } @@ -589,7 +596,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(extractedFiles, fileActivity, info, memdumps, moduleLoadAddresses, mutexes, networkActivity, processActivity, processTree, registryOperations, scheduledTasks, services, startup, threatScore, ttps, additionalProperties); + return Objects.hash(artifacts, consoleOutput, fileActivity, info, memdumps, moduleLoadAddresses, mutexes, networkActivity, processActivity, processTree, registryOperations, scheduledTasks, services, startup, ttps, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -603,7 +610,8 @@ private static int hashCodeNullable(JsonNullable a) { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class AnalysisReport {\n"); - sb.append(" extractedFiles: ").append(toIndentedString(extractedFiles)).append("\n"); + sb.append(" artifacts: ").append(toIndentedString(artifacts)).append("\n"); + sb.append(" consoleOutput: ").append(toIndentedString(consoleOutput)).append("\n"); sb.append(" fileActivity: ").append(toIndentedString(fileActivity)).append("\n"); sb.append(" info: ").append(toIndentedString(info)).append("\n"); sb.append(" memdumps: ").append(toIndentedString(memdumps)).append("\n"); @@ -616,7 +624,6 @@ public String toString() { sb.append(" scheduledTasks: ").append(toIndentedString(scheduledTasks)).append("\n"); sb.append(" services: ").append(toIndentedString(services)).append("\n"); sb.append(" startup: ").append(toIndentedString(startup)).append("\n"); - sb.append(" threatScore: ").append(toIndentedString(threatScore)).append("\n"); sb.append(" ttps: ").append(toIndentedString(ttps)).append("\n"); sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); @@ -628,10 +635,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -640,10 +644,10 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("extracted_files", "file_activity", "info", "memdumps", "module_load_addresses", "mutexes", "network_activity", "process_activity", "process_tree", "registry_operations", "scheduled_tasks", "services", "startup", "threat_score", "ttps")); + openapiFields = new HashSet(Arrays.asList("artifacts", "console_output", "file_activity", "info", "memdumps", "module_load_addresses", "mutexes", "network_activity", "process_activity", "process_tree", "registry_operations", "scheduled_tasks", "services", "startup", "ttps")); // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(Arrays.asList("info", "threat_score")); + openapiRequiredFields = new HashSet(Arrays.asList("info")); } /** @@ -655,56 +659,184 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisReport.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisReport is not found in the empty JSON string", AnalysisReport.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisReport is not found in the empty JSON string", AnalysisReport.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisReport.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the optional json data is an array if present - if (jsonObj.get("extracted_files") != null && !jsonObj.get("extracted_files").isJsonNull() && !jsonObj.get("extracted_files").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `extracted_files` to be an array in the JSON string but got `%s`", jsonObj.get("extracted_files").toString())); + if (jsonObj.get("artifacts") != null && !jsonObj.get("artifacts").isJsonNull()) { + JsonArray jsonArrayartifacts = jsonObj.getAsJsonArray("artifacts"); + if (jsonArrayartifacts != null) { + // ensure the json data is an array + if (!jsonObj.get("artifacts").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `artifacts` to be an array in the JSON string but got `%s`", jsonObj.get("artifacts").toString())); + } + + // validate the optional field `artifacts` (array) + for (int i = 0; i < jsonArrayartifacts.size(); i++) { + Artifact.validateJsonElement(jsonArrayartifacts.get(i)); + }; + } } - // ensure the optional json data is an array if present - if (jsonObj.get("file_activity") != null && !jsonObj.get("file_activity").isJsonNull() && !jsonObj.get("file_activity").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `file_activity` to be an array in the JSON string but got `%s`", jsonObj.get("file_activity").toString())); + if (jsonObj.get("console_output") != null && !jsonObj.get("console_output").isJsonNull()) { + JsonArray jsonArrayconsoleOutput = jsonObj.getAsJsonArray("console_output"); + if (jsonArrayconsoleOutput != null) { + // ensure the json data is an array + if (!jsonObj.get("console_output").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `console_output` to be an array in the JSON string but got `%s`", jsonObj.get("console_output").toString())); + } + + // validate the optional field `console_output` (array) + for (int i = 0; i < jsonArrayconsoleOutput.size(); i++) { + ConsoleOutputEntry.validateJsonElement(jsonArrayconsoleOutput.get(i)); + }; + } } - // ensure the optional json data is an array if present - if (jsonObj.get("memdumps") != null && !jsonObj.get("memdumps").isJsonNull() && !jsonObj.get("memdumps").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `memdumps` to be an array in the JSON string but got `%s`", jsonObj.get("memdumps").toString())); + if (jsonObj.get("file_activity") != null && !jsonObj.get("file_activity").isJsonNull()) { + JsonArray jsonArrayfileActivity = jsonObj.getAsJsonArray("file_activity"); + if (jsonArrayfileActivity != null) { + // ensure the json data is an array + if (!jsonObj.get("file_activity").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `file_activity` to be an array in the JSON string but got `%s`", jsonObj.get("file_activity").toString())); + } + + // validate the optional field `file_activity` (array) + for (int i = 0; i < jsonArrayfileActivity.size(); i++) { + FileActivityEntry.validateJsonElement(jsonArrayfileActivity.get(i)); + }; + } } - // ensure the optional json data is an array if present - if (jsonObj.get("module_load_addresses") != null && !jsonObj.get("module_load_addresses").isJsonNull() && !jsonObj.get("module_load_addresses").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `module_load_addresses` to be an array in the JSON string but got `%s`", jsonObj.get("module_load_addresses").toString())); + // validate the required field `info` + ReportInfo.validateJsonElement(jsonObj.get("info")); + if (jsonObj.get("memdumps") != null && !jsonObj.get("memdumps").isJsonNull()) { + JsonArray jsonArraymemdumps = jsonObj.getAsJsonArray("memdumps"); + if (jsonArraymemdumps != null) { + // ensure the json data is an array + if (!jsonObj.get("memdumps").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `memdumps` to be an array in the JSON string but got `%s`", jsonObj.get("memdumps").toString())); + } + + // validate the optional field `memdumps` (array) + for (int i = 0; i < jsonArraymemdumps.size(); i++) { + ProcessMemdumps.validateJsonElement(jsonArraymemdumps.get(i)); + }; + } } - // ensure the optional json data is an array if present - if (jsonObj.get("mutexes") != null && !jsonObj.get("mutexes").isJsonNull() && !jsonObj.get("mutexes").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `mutexes` to be an array in the JSON string but got `%s`", jsonObj.get("mutexes").toString())); + if (jsonObj.get("module_load_addresses") != null && !jsonObj.get("module_load_addresses").isJsonNull()) { + JsonArray jsonArraymoduleLoadAddresses = jsonObj.getAsJsonArray("module_load_addresses"); + if (jsonArraymoduleLoadAddresses != null) { + // ensure the json data is an array + if (!jsonObj.get("module_load_addresses").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `module_load_addresses` to be an array in the JSON string but got `%s`", jsonObj.get("module_load_addresses").toString())); + } + + // validate the optional field `module_load_addresses` (array) + for (int i = 0; i < jsonArraymoduleLoadAddresses.size(); i++) { + ModuleLoadEntry.validateJsonElement(jsonArraymoduleLoadAddresses.get(i)); + }; + } + } + if (jsonObj.get("mutexes") != null && !jsonObj.get("mutexes").isJsonNull()) { + JsonArray jsonArraymutexes = jsonObj.getAsJsonArray("mutexes"); + if (jsonArraymutexes != null) { + // ensure the json data is an array + if (!jsonObj.get("mutexes").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `mutexes` to be an array in the JSON string but got `%s`", jsonObj.get("mutexes").toString())); + } + + // validate the optional field `mutexes` (array) + for (int i = 0; i < jsonArraymutexes.size(); i++) { + MutexEntry.validateJsonElement(jsonArraymutexes.get(i)); + }; + } } - // ensure the optional json data is an array if present - if (jsonObj.get("process_activity") != null && !jsonObj.get("process_activity").isJsonNull() && !jsonObj.get("process_activity").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `process_activity` to be an array in the JSON string but got `%s`", jsonObj.get("process_activity").toString())); + // validate the optional field `network_activity` + if (jsonObj.get("network_activity") != null && !jsonObj.get("network_activity").isJsonNull()) { + NetworkActivity.validateJsonElement(jsonObj.get("network_activity")); } - // ensure the optional json data is an array if present - if (jsonObj.get("registry_operations") != null && !jsonObj.get("registry_operations").isJsonNull() && !jsonObj.get("registry_operations").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `registry_operations` to be an array in the JSON string but got `%s`", jsonObj.get("registry_operations").toString())); + if (jsonObj.get("process_activity") != null && !jsonObj.get("process_activity").isJsonNull()) { + JsonArray jsonArrayprocessActivity = jsonObj.getAsJsonArray("process_activity"); + if (jsonArrayprocessActivity != null) { + // ensure the json data is an array + if (!jsonObj.get("process_activity").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `process_activity` to be an array in the JSON string but got `%s`", jsonObj.get("process_activity").toString())); + } + + // validate the optional field `process_activity` (array) + for (int i = 0; i < jsonArrayprocessActivity.size(); i++) { + ProcessActivityEntry.validateJsonElement(jsonArrayprocessActivity.get(i)); + }; + } } - // ensure the optional json data is an array if present - if (jsonObj.get("scheduled_tasks") != null && !jsonObj.get("scheduled_tasks").isJsonNull() && !jsonObj.get("scheduled_tasks").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `scheduled_tasks` to be an array in the JSON string but got `%s`", jsonObj.get("scheduled_tasks").toString())); + // validate the optional field `process_tree` + if (jsonObj.get("process_tree") != null && !jsonObj.get("process_tree").isJsonNull()) { + ProcessTree.validateJsonElement(jsonObj.get("process_tree")); } - // ensure the optional json data is an array if present - if (jsonObj.get("services") != null && !jsonObj.get("services").isJsonNull() && !jsonObj.get("services").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `services` to be an array in the JSON string but got `%s`", jsonObj.get("services").toString())); + if (jsonObj.get("registry_operations") != null && !jsonObj.get("registry_operations").isJsonNull()) { + JsonArray jsonArrayregistryOperations = jsonObj.getAsJsonArray("registry_operations"); + if (jsonArrayregistryOperations != null) { + // ensure the json data is an array + if (!jsonObj.get("registry_operations").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `registry_operations` to be an array in the JSON string but got `%s`", jsonObj.get("registry_operations").toString())); + } + + // validate the optional field `registry_operations` (array) + for (int i = 0; i < jsonArrayregistryOperations.size(); i++) { + RegistryOperation.validateJsonElement(jsonArrayregistryOperations.get(i)); + }; + } } - // ensure the optional json data is an array if present - if (jsonObj.get("ttps") != null && !jsonObj.get("ttps").isJsonNull() && !jsonObj.get("ttps").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `ttps` to be an array in the JSON string but got `%s`", jsonObj.get("ttps").toString())); + if (jsonObj.get("scheduled_tasks") != null && !jsonObj.get("scheduled_tasks").isJsonNull()) { + JsonArray jsonArrayscheduledTasks = jsonObj.getAsJsonArray("scheduled_tasks"); + if (jsonArrayscheduledTasks != null) { + // ensure the json data is an array + if (!jsonObj.get("scheduled_tasks").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `scheduled_tasks` to be an array in the JSON string but got `%s`", jsonObj.get("scheduled_tasks").toString())); + } + + // validate the optional field `scheduled_tasks` (array) + for (int i = 0; i < jsonArrayscheduledTasks.size(); i++) { + ScheduledTaskEntry.validateJsonElement(jsonArrayscheduledTasks.get(i)); + }; + } + } + if (jsonObj.get("services") != null && !jsonObj.get("services").isJsonNull()) { + JsonArray jsonArrayservices = jsonObj.getAsJsonArray("services"); + if (jsonArrayservices != null) { + // ensure the json data is an array + if (!jsonObj.get("services").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `services` to be an array in the JSON string but got `%s`", jsonObj.get("services").toString())); + } + + // validate the optional field `services` (array) + for (int i = 0; i < jsonArrayservices.size(); i++) { + ServiceEntry.validateJsonElement(jsonArrayservices.get(i)); + }; + } + } + // validate the optional field `startup` + if (jsonObj.get("startup") != null && !jsonObj.get("startup").isJsonNull()) { + StartupInfo.validateJsonElement(jsonObj.get("startup")); + } + if (jsonObj.get("ttps") != null && !jsonObj.get("ttps").isJsonNull()) { + JsonArray jsonArrayttps = jsonObj.getAsJsonArray("ttps"); + if (jsonArrayttps != null) { + // ensure the json data is an array + if (!jsonObj.get("ttps").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `ttps` to be an array in the JSON string but got `%s`", jsonObj.get("ttps").toString())); + } + + // validate the optional field `ttps` (array) + for (int i = 0; i < jsonArrayttps.size(); i++) { + Ttp.validateJsonElement(jsonArrayttps.get(i)); + }; + } } } @@ -765,7 +897,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisScope.java b/src/main/java/ai/reveng/model/AnalysisScope.java index e1700c42..201e1f93 100644 --- a/src/main/java/ai/reveng/model/AnalysisScope.java +++ b/src/main/java/ai/reveng/model/AnalysisScope.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/AnalysisStringFunction.java b/src/main/java/ai/reveng/model/AnalysisStringFunction.java index c8a06f21..482cc8df 100644 --- a/src/main/java/ai/reveng/model/AnalysisStringFunction.java +++ b/src/main/java/ai/reveng/model/AnalysisStringFunction.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -101,50 +99,6 @@ public void setFunctionVaddr(@javax.annotation.Nonnull Long functionVaddr) { this.functionVaddr = functionVaddr; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the AnalysisStringFunction instance itself - */ - public AnalysisStringFunction putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -157,13 +111,12 @@ public boolean equals(Object o) { } AnalysisStringFunction analysisStringFunction = (AnalysisStringFunction) o; return Objects.equals(this.functionId, analysisStringFunction.functionId) && - Objects.equals(this.functionVaddr, analysisStringFunction.functionVaddr)&& - Objects.equals(this.additionalProperties, analysisStringFunction.additionalProperties); + Objects.equals(this.functionVaddr, analysisStringFunction.functionVaddr); } @Override public int hashCode() { - return Objects.hash(functionId, functionVaddr, additionalProperties); + return Objects.hash(functionId, functionVaddr); } @Override @@ -172,7 +125,6 @@ public String toString() { sb.append("class AnalysisStringFunction {\n"); sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); sb.append(" functionVaddr: ").append(toIndentedString(functionVaddr)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -182,10 +134,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -209,14 +158,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisStringFunction.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisStringFunction is not found in the empty JSON string", AnalysisStringFunction.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisStringFunction is not found in the empty JSON string", AnalysisStringFunction.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!AnalysisStringFunction.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisStringFunction` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisStringFunction.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -237,28 +194,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisStringFunction value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -266,28 +201,7 @@ else if (entry.getValue() instanceof Character) public AnalysisStringFunction read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - AnalysisStringFunction instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AnalysisStringInput.java b/src/main/java/ai/reveng/model/AnalysisStringInput.java index 2d36b61b..d6e36a12 100644 --- a/src/main/java/ai/reveng/model/AnalysisStringInput.java +++ b/src/main/java/ai/reveng/model/AnalysisStringInput.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.StringSource; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -209,10 +207,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -236,19 +231,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisStringInput.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisStringInput is not found in the empty JSON string", AnalysisStringInput.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisStringInput is not found in the empty JSON string", AnalysisStringInput.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisStringInput.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("value").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); } // validate the required field `source` StringSource.validateJsonElement(jsonObj.get("source")); @@ -311,7 +306,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisStringItem.java b/src/main/java/ai/reveng/model/AnalysisStringItem.java index 02a2d2a6..722aa24f 100644 --- a/src/main/java/ai/reveng/model/AnalysisStringItem.java +++ b/src/main/java/ai/reveng/model/AnalysisStringItem.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AnalysisStringFunction; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -136,50 +134,6 @@ public void setValue(@javax.annotation.Nonnull String value) { this.value = value; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the AnalysisStringItem instance itself - */ - public AnalysisStringItem putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -193,13 +147,12 @@ public boolean equals(Object o) { AnalysisStringItem analysisStringItem = (AnalysisStringItem) o; return Objects.equals(this.functions, analysisStringItem.functions) && Objects.equals(this.source, analysisStringItem.source) && - Objects.equals(this.value, analysisStringItem.value)&& - Objects.equals(this.additionalProperties, analysisStringItem.additionalProperties); + Objects.equals(this.value, analysisStringItem.value); } @Override public int hashCode() { - return Objects.hash(functions, source, value, additionalProperties); + return Objects.hash(functions, source, value); } @Override @@ -209,7 +162,6 @@ public String toString() { sb.append(" functions: ").append(toIndentedString(functions)).append("\n"); sb.append(" source: ").append(toIndentedString(source)).append("\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -219,10 +171,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -246,28 +195,40 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisStringItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisStringItem is not found in the empty JSON string", AnalysisStringItem.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisStringItem is not found in the empty JSON string", AnalysisStringItem.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!AnalysisStringItem.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisStringItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisStringItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the required json array is present - if (jsonObj.get("functions") == null) { - throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); - } else if (!jsonObj.get("functions").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); + if (jsonObj.get("functions") != null && !jsonObj.get("functions").isJsonNull()) { + if (!jsonObj.get("functions").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); + } + JsonArray jsonArrayfunctions = jsonObj.getAsJsonArray("functions"); + // validate the required field `functions` (array) + for (int i = 0; i < jsonArrayfunctions.size(); i++) { + AnalysisStringFunction.validateJsonElement(jsonArrayfunctions.get(i)); + } } if (!jsonObj.get("source").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source").toString())); } if (!jsonObj.get("value").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); } } @@ -286,28 +247,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisStringItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -315,28 +254,7 @@ else if (entry.getValue() instanceof Character) public AnalysisStringItem read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - AnalysisStringItem instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AnalysisStringsResponse.java b/src/main/java/ai/reveng/model/AnalysisStringsResponse.java index c7554f9b..c7d5db82 100644 --- a/src/main/java/ai/reveng/model/AnalysisStringsResponse.java +++ b/src/main/java/ai/reveng/model/AnalysisStringsResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.StringFunctions; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -193,10 +191,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -220,27 +215,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisStringsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisStringsResponse is not found in the empty JSON string", AnalysisStringsResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisStringsResponse is not found in the empty JSON string", AnalysisStringsResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisStringsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("strings").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `strings` to be an array in the JSON string but got `%s`", jsonObj.get("strings").toString())); + if (jsonObj.get("strings") != null) { + if (!jsonObj.get("strings").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `strings` to be an array in the JSON string but got `%s`", jsonObj.get("strings").toString())); + } + JsonArray jsonArraystrings = jsonObj.getAsJsonArray("strings"); + // validate the required field `strings` (array) + for (int i = 0; i < jsonArraystrings.size(); i++) { + StringFunctions.validateJsonElement(jsonArraystrings.get(i)); + } } - - JsonArray jsonArraystrings = jsonObj.getAsJsonArray("strings"); - // validate the required field `strings` (array) - for (int i = 0; i < jsonArraystrings.size(); i++) { - StringFunctions.validateJsonElement(jsonArraystrings.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -300,7 +295,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisStringsStatusResponse.java b/src/main/java/ai/reveng/model/AnalysisStringsStatusResponse.java index 467d57b2..0bb08a21 100644 --- a/src/main/java/ai/reveng/model/AnalysisStringsStatusResponse.java +++ b/src/main/java/ai/reveng/model/AnalysisStringsStatusResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.BinariesTaskStatus; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -157,10 +155,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -184,14 +179,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisStringsStatusResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisStringsStatusResponse is not found in the empty JSON string", AnalysisStringsStatusResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisStringsStatusResponse is not found in the empty JSON string", AnalysisStringsStatusResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisStringsStatusResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -256,7 +251,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisTags.java b/src/main/java/ai/reveng/model/AnalysisTags.java index 64eb49ad..6ada52fa 100644 --- a/src/main/java/ai/reveng/model/AnalysisTags.java +++ b/src/main/java/ai/reveng/model/AnalysisTags.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.TagItem; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -167,10 +165,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,27 +189,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisTags.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisTags is not found in the empty JSON string", AnalysisTags.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisTags is not found in the empty JSON string", AnalysisTags.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisTags.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("analysis_tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `analysis_tags` to be an array in the JSON string but got `%s`", jsonObj.get("analysis_tags").toString())); + if (jsonObj.get("analysis_tags") != null) { + if (!jsonObj.get("analysis_tags").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `analysis_tags` to be an array in the JSON string but got `%s`", jsonObj.get("analysis_tags").toString())); + } + JsonArray jsonArrayanalysisTags = jsonObj.getAsJsonArray("analysis_tags"); + // validate the required field `analysis_tags` (array) + for (int i = 0; i < jsonArrayanalysisTags.size(); i++) { + TagItem.validateJsonElement(jsonArrayanalysisTags.get(i)); + } } - - JsonArray jsonArrayanalysisTags = jsonObj.getAsJsonArray("analysis_tags"); - // validate the required field `analysis_tags` (array) - for (int i = 0; i < jsonArrayanalysisTags.size(); i++) { - TagItem.validateJsonElement(jsonArrayanalysisTags.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -274,7 +269,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisUpdateRequest.java b/src/main/java/ai/reveng/model/AnalysisUpdateRequest.java index 3ded1964..7b46a6f5 100644 --- a/src/main/java/ai/reveng/model/AnalysisUpdateRequest.java +++ b/src/main/java/ai/reveng/model/AnalysisUpdateRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -248,10 +246,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -275,15 +270,15 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisUpdateRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisUpdateRequest is not found in the empty JSON string", AnalysisUpdateRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisUpdateRequest is not found in the empty JSON string", AnalysisUpdateRequest.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("binary_name") != null && !jsonObj.get("binary_name").isJsonNull()) && !jsonObj.get("binary_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); } if ((jsonObj.get("analysis_scope") != null && !jsonObj.get("analysis_scope").isJsonNull()) && !jsonObj.get("analysis_scope").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `analysis_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("analysis_scope").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `analysis_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("analysis_scope").toString())); } // validate the optional field `analysis_scope` if (jsonObj.get("analysis_scope") != null && !jsonObj.get("analysis_scope").isJsonNull()) { @@ -348,7 +343,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisUpdateTagsRequest.java b/src/main/java/ai/reveng/model/AnalysisUpdateTagsRequest.java index 21eb34f3..5a15c4eb 100644 --- a/src/main/java/ai/reveng/model/AnalysisUpdateTagsRequest.java +++ b/src/main/java/ai/reveng/model/AnalysisUpdateTagsRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -166,10 +164,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -193,14 +188,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisUpdateTagsRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisUpdateTagsRequest is not found in the empty JSON string", AnalysisUpdateTagsRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisUpdateTagsRequest is not found in the empty JSON string", AnalysisUpdateTagsRequest.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisUpdateTagsRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -208,7 +203,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("tags") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); } } @@ -269,7 +264,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AnalysisUpdateTagsResponse.java b/src/main/java/ai/reveng/model/AnalysisUpdateTagsResponse.java index f2af8157..1f44a459 100644 --- a/src/main/java/ai/reveng/model/AnalysisUpdateTagsResponse.java +++ b/src/main/java/ai/reveng/model/AnalysisUpdateTagsResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.TagResponse; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -167,10 +165,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,27 +189,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AnalysisUpdateTagsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisUpdateTagsResponse is not found in the empty JSON string", AnalysisUpdateTagsResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AnalysisUpdateTagsResponse is not found in the empty JSON string", AnalysisUpdateTagsResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisUpdateTagsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + if (jsonObj.get("tags") != null) { + if (!jsonObj.get("tags").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + } + JsonArray jsonArraytags = jsonObj.getAsJsonArray("tags"); + // validate the required field `tags` (array) + for (int i = 0; i < jsonArraytags.size(); i++) { + TagResponse.validateJsonElement(jsonArraytags.get(i)); + } } - - JsonArray jsonArraytags = jsonObj.getAsJsonArray("tags"); - // validate the required field `tags` (array) - for (int i = 0; i < jsonArraytags.size(); i++) { - TagResponse.validateJsonElement(jsonArraytags.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -274,7 +269,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ApiCall.java b/src/main/java/ai/reveng/model/ApiCall.java index 8d7774da..737e860c 100644 --- a/src/main/java/ai/reveng/model/ApiCall.java +++ b/src/main/java/ai/reveng/model/ApiCall.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -21,7 +20,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; -import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -43,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -69,7 +66,7 @@ public class ApiCall { public static final String SERIALIZED_NAME_METHOD = "method"; @SerializedName(SERIALIZED_NAME_METHOD) - @javax.annotation.Nullable + @javax.annotation.Nonnull private String method; public ApiCall() { @@ -132,7 +129,7 @@ public void setFromModule(@javax.annotation.Nullable String fromModule) { } - public ApiCall method(@javax.annotation.Nullable String method) { + public ApiCall method(@javax.annotation.Nonnull String method) { this.method = method; return this; } @@ -141,59 +138,15 @@ public ApiCall method(@javax.annotation.Nullable String method) { * Get method * @return method */ - @javax.annotation.Nullable + @javax.annotation.Nonnull public String getMethod() { return method; } - public void setMethod(@javax.annotation.Nullable String method) { + public void setMethod(@javax.annotation.Nonnull String method) { this.method = method; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ApiCall instance itself - */ - public ApiCall putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -208,24 +161,12 @@ public boolean equals(Object o) { return Objects.equals(this.calledFrom, apiCall.calledFrom) && Objects.equals(this.calledFromRva, apiCall.calledFromRva) && Objects.equals(this.fromModule, apiCall.fromModule) && - Objects.equals(this.method, apiCall.method)&& - Objects.equals(this.additionalProperties, apiCall.additionalProperties); - } - - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + Objects.equals(this.method, apiCall.method); } @Override public int hashCode() { - return Objects.hash(calledFrom, calledFromRva, fromModule, method, additionalProperties); - } - - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + return Objects.hash(calledFrom, calledFromRva, fromModule, method); } @Override @@ -236,7 +177,6 @@ public String toString() { sb.append(" calledFromRva: ").append(toIndentedString(calledFromRva)).append("\n"); sb.append(" fromModule: ").append(toIndentedString(fromModule)).append("\n"); sb.append(" method: ").append(toIndentedString(method)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -246,10 +186,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -273,28 +210,36 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ApiCall.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ApiCall is not found in the empty JSON string", ApiCall.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ApiCall is not found in the empty JSON string", ApiCall.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ApiCall.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ApiCall` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ApiCall.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("called_from") != null && !jsonObj.get("called_from").isJsonNull()) && !jsonObj.get("called_from").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `called_from` to be a primitive type in the JSON string but got `%s`", jsonObj.get("called_from").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `called_from` to be a primitive type in the JSON string but got `%s`", jsonObj.get("called_from").toString())); } if ((jsonObj.get("called_from_rva") != null && !jsonObj.get("called_from_rva").isJsonNull()) && !jsonObj.get("called_from_rva").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `called_from_rva` to be a primitive type in the JSON string but got `%s`", jsonObj.get("called_from_rva").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `called_from_rva` to be a primitive type in the JSON string but got `%s`", jsonObj.get("called_from_rva").toString())); } if ((jsonObj.get("from_module") != null && !jsonObj.get("from_module").isJsonNull()) && !jsonObj.get("from_module").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `from_module` to be a primitive type in the JSON string but got `%s`", jsonObj.get("from_module").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `from_module` to be a primitive type in the JSON string but got `%s`", jsonObj.get("from_module").toString())); } - if ((jsonObj.get("method") != null && !jsonObj.get("method").isJsonNull()) && !jsonObj.get("method").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `method` to be a primitive type in the JSON string but got `%s`", jsonObj.get("method").toString())); + if (!jsonObj.get("method").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `method` to be a primitive type in the JSON string but got `%s`", jsonObj.get("method").toString())); } } @@ -313,28 +258,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ApiCall value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -342,28 +265,7 @@ else if (entry.getValue() instanceof Character) public ApiCall read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ApiCall instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AppApiRestV2AgentSchemaCapability.java b/src/main/java/ai/reveng/model/AppApiRestV2AgentSchemaCapability.java index 4001ae3d..89127d24 100644 --- a/src/main/java/ai/reveng/model/AppApiRestV2AgentSchemaCapability.java +++ b/src/main/java/ai/reveng/model/AppApiRestV2AgentSchemaCapability.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -354,10 +352,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -381,33 +376,33 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AppApiRestV2AgentSchemaCapability.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AppApiRestV2AgentSchemaCapability is not found in the empty JSON string", AppApiRestV2AgentSchemaCapability.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AppApiRestV2AgentSchemaCapability is not found in the empty JSON string", AppApiRestV2AgentSchemaCapability.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AppApiRestV2AgentSchemaCapability.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("function_vaddr").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `function_vaddr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_vaddr").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_vaddr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_vaddr").toString())); } if (!jsonObj.get("description").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); } if (!jsonObj.get("capability").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `capability` to be a primitive type in the JSON string but got `%s`", jsonObj.get("capability").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `capability` to be a primitive type in the JSON string but got `%s`", jsonObj.get("capability").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } // validate the required field `type` TypeEnum.validateJsonElement(jsonObj.get("type")); if (!jsonObj.get("function_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); } } @@ -468,7 +463,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AppApiRestV2AnalysesEnumsOrderBy.java b/src/main/java/ai/reveng/model/AppApiRestV2AnalysesEnumsOrderBy.java index 8d534705..9ec34173 100644 --- a/src/main/java/ai/reveng/model/AppApiRestV2AnalysesEnumsOrderBy.java +++ b/src/main/java/ai/reveng/model/AppApiRestV2AnalysesEnumsOrderBy.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/AppApiRestV2CollectionsEnumsOrderBy.java b/src/main/java/ai/reveng/model/AppApiRestV2CollectionsEnumsOrderBy.java index f70ec95d..f0456dec 100644 --- a/src/main/java/ai/reveng/model/AppApiRestV2CollectionsEnumsOrderBy.java +++ b/src/main/java/ai/reveng/model/AppApiRestV2CollectionsEnumsOrderBy.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/AppApiRestV2FunctionsResponsesFunction.java b/src/main/java/ai/reveng/model/AppApiRestV2FunctionsResponsesFunction.java index b388c3ef..ef0a9e95 100644 --- a/src/main/java/ai/reveng/model/AppApiRestV2FunctionsResponsesFunction.java +++ b/src/main/java/ai/reveng/model/AppApiRestV2FunctionsResponsesFunction.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -194,10 +192,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -221,14 +216,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AppApiRestV2FunctionsResponsesFunction.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AppApiRestV2FunctionsResponsesFunction is not found in the empty JSON string", AppApiRestV2FunctionsResponsesFunction.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AppApiRestV2FunctionsResponsesFunction is not found in the empty JSON string", AppApiRestV2FunctionsResponsesFunction.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AppApiRestV2FunctionsResponsesFunction.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -291,7 +286,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AppApiRestV2FunctionsTypesFunction.java b/src/main/java/ai/reveng/model/AppApiRestV2FunctionsTypesFunction.java index be1ec911..84237b54 100644 --- a/src/main/java/ai/reveng/model/AppApiRestV2FunctionsTypesFunction.java +++ b/src/main/java/ai/reveng/model/AppApiRestV2FunctionsTypesFunction.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -286,10 +284,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -313,22 +308,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AppApiRestV2FunctionsTypesFunction.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AppApiRestV2FunctionsTypesFunction is not found in the empty JSON string", AppApiRestV2FunctionsTypesFunction.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AppApiRestV2FunctionsTypesFunction is not found in the empty JSON string", AppApiRestV2FunctionsTypesFunction.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AppApiRestV2FunctionsTypesFunction.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("function_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); } if (!jsonObj.get("function_mangled_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `function_mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_mangled_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_mangled_name").toString())); } } @@ -389,7 +384,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AppApiRestV2InfoTypesCapability.java b/src/main/java/ai/reveng/model/AppApiRestV2InfoTypesCapability.java index a1e502c8..c72e8237 100644 --- a/src/main/java/ai/reveng/model/AppApiRestV2InfoTypesCapability.java +++ b/src/main/java/ai/reveng/model/AppApiRestV2InfoTypesCapability.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -218,10 +216,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -245,25 +240,25 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AppApiRestV2InfoTypesCapability.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AppApiRestV2InfoTypesCapability is not found in the empty JSON string", AppApiRestV2InfoTypesCapability.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AppApiRestV2InfoTypesCapability is not found in the empty JSON string", AppApiRestV2InfoTypesCapability.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AppApiRestV2InfoTypesCapability.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("function_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); } // ensure the required json array is present if (jsonObj.get("capabilities") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("capabilities").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `capabilities` to be an array in the JSON string but got `%s`", jsonObj.get("capabilities").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `capabilities` to be an array in the JSON string but got `%s`", jsonObj.get("capabilities").toString())); } } @@ -324,7 +319,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/Argument.java b/src/main/java/ai/reveng/model/Argument.java index 6cf540f7..796ee044 100644 --- a/src/main/java/ai/reveng/model/Argument.java +++ b/src/main/java/ai/reveng/model/Argument.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -86,7 +84,7 @@ public Argument lastChange(@javax.annotation.Nullable String lastChange) { } /** - * Get lastChange + * Timestamp of the last change to this argument * @return lastChange */ @javax.annotation.Nullable @@ -272,10 +270,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -299,25 +294,25 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Argument.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Argument is not found in the empty JSON string", Argument.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Argument is not found in the empty JSON string", Argument.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Argument.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("last_change") != null && !jsonObj.get("last_change").isJsonNull()) && !jsonObj.get("last_change").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `last_change` to be a primitive type in the JSON string but got `%s`", jsonObj.get("last_change").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `last_change` to be a primitive type in the JSON string but got `%s`", jsonObj.get("last_change").toString())); } if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -378,7 +373,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/Artifact.java b/src/main/java/ai/reveng/model/Artifact.java new file mode 100644 index 00000000..b7afbadc --- /dev/null +++ b/src/main/java/ai/reveng/model/Artifact.java @@ -0,0 +1,828 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * Artifact + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class Artifact { + public static final String SERIALIZED_NAME_DIRECTION = "direction"; + @SerializedName(SERIALIZED_NAME_DIRECTION) + @javax.annotation.Nullable + private String direction; + + public static final String SERIALIZED_NAME_DUMP_ADDR = "dump_addr"; + @SerializedName(SERIALIZED_NAME_DUMP_ADDR) + @javax.annotation.Nullable + private String dumpAddr; + + public static final String SERIALIZED_NAME_DUMP_PID = "dump_pid"; + @SerializedName(SERIALIZED_NAME_DUMP_PID) + @javax.annotation.Nullable + private Long dumpPid; + + public static final String SERIALIZED_NAME_FILE_TYPE = "file_type"; + @SerializedName(SERIALIZED_NAME_FILE_TYPE) + @javax.annotation.Nullable + private String fileType; + + public static final String SERIALIZED_NAME_HOST = "host"; + @SerializedName(SERIALIZED_NAME_HOST) + @javax.annotation.Nullable + private String host; + + public static final String SERIALIZED_NAME_IS_PE = "is_pe"; + @SerializedName(SERIALIZED_NAME_IS_PE) + @javax.annotation.Nonnull + private Boolean isPe; + + public static final String SERIALIZED_NAME_MIME_TYPE = "mime_type"; + @SerializedName(SERIALIZED_NAME_MIME_TYPE) + @javax.annotation.Nullable + private String mimeType; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_NETWORK_SOURCE = "network_source"; + @SerializedName(SERIALIZED_NAME_NETWORK_SOURCE) + @javax.annotation.Nullable + private String networkSource; + + public static final String SERIALIZED_NAME_ORIGINAL_FILENAME = "original_filename"; + @SerializedName(SERIALIZED_NAME_ORIGINAL_FILENAME) + @javax.annotation.Nullable + private String originalFilename; + + public static final String SERIALIZED_NAME_PATH = "path"; + @SerializedName(SERIALIZED_NAME_PATH) + @javax.annotation.Nonnull + private String path; + + public static final String SERIALIZED_NAME_PROCESS_SEQID = "process_seqid"; + @SerializedName(SERIALIZED_NAME_PROCESS_SEQID) + @javax.annotation.Nullable + private Long processSeqid; + + /** + * Gets or Sets reason + */ + @JsonAdapter(ReasonEnum.Adapter.class) + public enum ReasonEnum { + WRITTEN_BY_TARGET_PROCESS("written_by_target_process"), + + BINARY_DETECTED("binary_detected"), + + SHELLCODE_DETECTED("shellcode_detected"), + + FILE_TYPE_DETECTED("file_type_detected"), + + YARA_MATCH("yara_match"), + + NETWORK_REQUEST("network_request"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + ReasonEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ReasonEnum fromValue(String value) { + for (ReasonEnum b : ReasonEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ReasonEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ReasonEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ReasonEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + ReasonEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_REASON = "reason"; + @SerializedName(SERIALIZED_NAME_REASON) + @javax.annotation.Nonnull + private ReasonEnum reason; + + public static final String SERIALIZED_NAME_RESPONSE_STATUS = "response_status"; + @SerializedName(SERIALIZED_NAME_RESPONSE_STATUS) + @javax.annotation.Nullable + private Long responseStatus; + + public static final String SERIALIZED_NAME_SHA256 = "sha256"; + @SerializedName(SERIALIZED_NAME_SHA256) + @javax.annotation.Nullable + private String sha256; + + public static final String SERIALIZED_NAME_SIZE = "size"; + @SerializedName(SERIALIZED_NAME_SIZE) + @javax.annotation.Nonnull + private Long size; + + public static final String SERIALIZED_NAME_SOURCE = "source"; + @SerializedName(SERIALIZED_NAME_SOURCE) + @javax.annotation.Nonnull + private String source; + + public static final String SERIALIZED_NAME_URI = "uri"; + @SerializedName(SERIALIZED_NAME_URI) + @javax.annotation.Nullable + private String uri; + + public static final String SERIALIZED_NAME_WAS_MAPPED = "was_mapped"; + @SerializedName(SERIALIZED_NAME_WAS_MAPPED) + @javax.annotation.Nullable + private Boolean wasMapped; + + public static final String SERIALIZED_NAME_YARA_HITS = "yara_hits"; + @SerializedName(SERIALIZED_NAME_YARA_HITS) + @javax.annotation.Nullable + private List yaraHits; + + public Artifact() { + } + + public Artifact direction(@javax.annotation.Nullable String direction) { + this.direction = direction; + return this; + } + + /** + * Get direction + * @return direction + */ + @javax.annotation.Nullable + public String getDirection() { + return direction; + } + + public void setDirection(@javax.annotation.Nullable String direction) { + this.direction = direction; + } + + + public Artifact dumpAddr(@javax.annotation.Nullable String dumpAddr) { + this.dumpAddr = dumpAddr; + return this; + } + + /** + * Get dumpAddr + * @return dumpAddr + */ + @javax.annotation.Nullable + public String getDumpAddr() { + return dumpAddr; + } + + public void setDumpAddr(@javax.annotation.Nullable String dumpAddr) { + this.dumpAddr = dumpAddr; + } + + + public Artifact dumpPid(@javax.annotation.Nullable Long dumpPid) { + this.dumpPid = dumpPid; + return this; + } + + /** + * Get dumpPid + * @return dumpPid + */ + @javax.annotation.Nullable + public Long getDumpPid() { + return dumpPid; + } + + public void setDumpPid(@javax.annotation.Nullable Long dumpPid) { + this.dumpPid = dumpPid; + } + + + public Artifact fileType(@javax.annotation.Nullable String fileType) { + this.fileType = fileType; + return this; + } + + /** + * Get fileType + * @return fileType + */ + @javax.annotation.Nullable + public String getFileType() { + return fileType; + } + + public void setFileType(@javax.annotation.Nullable String fileType) { + this.fileType = fileType; + } + + + public Artifact host(@javax.annotation.Nullable String host) { + this.host = host; + return this; + } + + /** + * Get host + * @return host + */ + @javax.annotation.Nullable + public String getHost() { + return host; + } + + public void setHost(@javax.annotation.Nullable String host) { + this.host = host; + } + + + public Artifact isPe(@javax.annotation.Nonnull Boolean isPe) { + this.isPe = isPe; + return this; + } + + /** + * Get isPe + * @return isPe + */ + @javax.annotation.Nonnull + public Boolean getIsPe() { + return isPe; + } + + public void setIsPe(@javax.annotation.Nonnull Boolean isPe) { + this.isPe = isPe; + } + + + public Artifact mimeType(@javax.annotation.Nullable String mimeType) { + this.mimeType = mimeType; + return this; + } + + /** + * Get mimeType + * @return mimeType + */ + @javax.annotation.Nullable + public String getMimeType() { + return mimeType; + } + + public void setMimeType(@javax.annotation.Nullable String mimeType) { + this.mimeType = mimeType; + } + + + public Artifact name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public Artifact networkSource(@javax.annotation.Nullable String networkSource) { + this.networkSource = networkSource; + return this; + } + + /** + * Get networkSource + * @return networkSource + */ + @javax.annotation.Nullable + public String getNetworkSource() { + return networkSource; + } + + public void setNetworkSource(@javax.annotation.Nullable String networkSource) { + this.networkSource = networkSource; + } + + + public Artifact originalFilename(@javax.annotation.Nullable String originalFilename) { + this.originalFilename = originalFilename; + return this; + } + + /** + * Get originalFilename + * @return originalFilename + */ + @javax.annotation.Nullable + public String getOriginalFilename() { + return originalFilename; + } + + public void setOriginalFilename(@javax.annotation.Nullable String originalFilename) { + this.originalFilename = originalFilename; + } + + + public Artifact path(@javax.annotation.Nonnull String path) { + this.path = path; + return this; + } + + /** + * Get path + * @return path + */ + @javax.annotation.Nonnull + public String getPath() { + return path; + } + + public void setPath(@javax.annotation.Nonnull String path) { + this.path = path; + } + + + public Artifact processSeqid(@javax.annotation.Nullable Long processSeqid) { + this.processSeqid = processSeqid; + return this; + } + + /** + * Get processSeqid + * @return processSeqid + */ + @javax.annotation.Nullable + public Long getProcessSeqid() { + return processSeqid; + } + + public void setProcessSeqid(@javax.annotation.Nullable Long processSeqid) { + this.processSeqid = processSeqid; + } + + + public Artifact reason(@javax.annotation.Nonnull ReasonEnum reason) { + this.reason = reason; + return this; + } + + /** + * Get reason + * @return reason + */ + @javax.annotation.Nonnull + public ReasonEnum getReason() { + return reason; + } + + public void setReason(@javax.annotation.Nonnull ReasonEnum reason) { + this.reason = reason; + } + + + public Artifact responseStatus(@javax.annotation.Nullable Long responseStatus) { + this.responseStatus = responseStatus; + return this; + } + + /** + * Get responseStatus + * @return responseStatus + */ + @javax.annotation.Nullable + public Long getResponseStatus() { + return responseStatus; + } + + public void setResponseStatus(@javax.annotation.Nullable Long responseStatus) { + this.responseStatus = responseStatus; + } + + + public Artifact sha256(@javax.annotation.Nullable String sha256) { + this.sha256 = sha256; + return this; + } + + /** + * Get sha256 + * @return sha256 + */ + @javax.annotation.Nullable + public String getSha256() { + return sha256; + } + + public void setSha256(@javax.annotation.Nullable String sha256) { + this.sha256 = sha256; + } + + + public Artifact size(@javax.annotation.Nonnull Long size) { + this.size = size; + return this; + } + + /** + * Get size + * @return size + */ + @javax.annotation.Nonnull + public Long getSize() { + return size; + } + + public void setSize(@javax.annotation.Nonnull Long size) { + this.size = size; + } + + + public Artifact source(@javax.annotation.Nonnull String source) { + this.source = source; + return this; + } + + /** + * Get source + * @return source + */ + @javax.annotation.Nonnull + public String getSource() { + return source; + } + + public void setSource(@javax.annotation.Nonnull String source) { + this.source = source; + } + + + public Artifact uri(@javax.annotation.Nullable String uri) { + this.uri = uri; + return this; + } + + /** + * Get uri + * @return uri + */ + @javax.annotation.Nullable + public String getUri() { + return uri; + } + + public void setUri(@javax.annotation.Nullable String uri) { + this.uri = uri; + } + + + public Artifact wasMapped(@javax.annotation.Nullable Boolean wasMapped) { + this.wasMapped = wasMapped; + return this; + } + + /** + * Get wasMapped + * @return wasMapped + */ + @javax.annotation.Nullable + public Boolean getWasMapped() { + return wasMapped; + } + + public void setWasMapped(@javax.annotation.Nullable Boolean wasMapped) { + this.wasMapped = wasMapped; + } + + + public Artifact yaraHits(@javax.annotation.Nullable List yaraHits) { + this.yaraHits = yaraHits; + return this; + } + + public Artifact addYaraHitsItem(String yaraHitsItem) { + if (this.yaraHits == null) { + this.yaraHits = new ArrayList<>(); + } + this.yaraHits.add(yaraHitsItem); + return this; + } + + /** + * Get yaraHits + * @return yaraHits + */ + @javax.annotation.Nullable + public List getYaraHits() { + return yaraHits; + } + + public void setYaraHits(@javax.annotation.Nullable List yaraHits) { + this.yaraHits = yaraHits; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Artifact artifact = (Artifact) o; + return Objects.equals(this.direction, artifact.direction) && + Objects.equals(this.dumpAddr, artifact.dumpAddr) && + Objects.equals(this.dumpPid, artifact.dumpPid) && + Objects.equals(this.fileType, artifact.fileType) && + Objects.equals(this.host, artifact.host) && + Objects.equals(this.isPe, artifact.isPe) && + Objects.equals(this.mimeType, artifact.mimeType) && + Objects.equals(this.name, artifact.name) && + Objects.equals(this.networkSource, artifact.networkSource) && + Objects.equals(this.originalFilename, artifact.originalFilename) && + Objects.equals(this.path, artifact.path) && + Objects.equals(this.processSeqid, artifact.processSeqid) && + Objects.equals(this.reason, artifact.reason) && + Objects.equals(this.responseStatus, artifact.responseStatus) && + Objects.equals(this.sha256, artifact.sha256) && + Objects.equals(this.size, artifact.size) && + Objects.equals(this.source, artifact.source) && + Objects.equals(this.uri, artifact.uri) && + Objects.equals(this.wasMapped, artifact.wasMapped) && + Objects.equals(this.yaraHits, artifact.yaraHits); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(direction, dumpAddr, dumpPid, fileType, host, isPe, mimeType, name, networkSource, originalFilename, path, processSeqid, reason, responseStatus, sha256, size, source, uri, wasMapped, yaraHits); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Artifact {\n"); + sb.append(" direction: ").append(toIndentedString(direction)).append("\n"); + sb.append(" dumpAddr: ").append(toIndentedString(dumpAddr)).append("\n"); + sb.append(" dumpPid: ").append(toIndentedString(dumpPid)).append("\n"); + sb.append(" fileType: ").append(toIndentedString(fileType)).append("\n"); + sb.append(" host: ").append(toIndentedString(host)).append("\n"); + sb.append(" isPe: ").append(toIndentedString(isPe)).append("\n"); + sb.append(" mimeType: ").append(toIndentedString(mimeType)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" networkSource: ").append(toIndentedString(networkSource)).append("\n"); + sb.append(" originalFilename: ").append(toIndentedString(originalFilename)).append("\n"); + sb.append(" path: ").append(toIndentedString(path)).append("\n"); + sb.append(" processSeqid: ").append(toIndentedString(processSeqid)).append("\n"); + sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); + sb.append(" responseStatus: ").append(toIndentedString(responseStatus)).append("\n"); + sb.append(" sha256: ").append(toIndentedString(sha256)).append("\n"); + sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" source: ").append(toIndentedString(source)).append("\n"); + sb.append(" uri: ").append(toIndentedString(uri)).append("\n"); + sb.append(" wasMapped: ").append(toIndentedString(wasMapped)).append("\n"); + sb.append(" yaraHits: ").append(toIndentedString(yaraHits)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("direction", "dump_addr", "dump_pid", "file_type", "host", "is_pe", "mime_type", "name", "network_source", "original_filename", "path", "process_seqid", "reason", "response_status", "sha256", "size", "source", "uri", "was_mapped", "yara_hits")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("is_pe", "name", "path", "reason", "size", "source")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Artifact + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Artifact.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Artifact is not found in the empty JSON string", Artifact.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!Artifact.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Artifact` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Artifact.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("direction") != null && !jsonObj.get("direction").isJsonNull()) && !jsonObj.get("direction").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `direction` to be a primitive type in the JSON string but got `%s`", jsonObj.get("direction").toString())); + } + if ((jsonObj.get("dump_addr") != null && !jsonObj.get("dump_addr").isJsonNull()) && !jsonObj.get("dump_addr").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `dump_addr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("dump_addr").toString())); + } + if ((jsonObj.get("file_type") != null && !jsonObj.get("file_type").isJsonNull()) && !jsonObj.get("file_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `file_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("file_type").toString())); + } + if ((jsonObj.get("host") != null && !jsonObj.get("host").isJsonNull()) && !jsonObj.get("host").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `host` to be a primitive type in the JSON string but got `%s`", jsonObj.get("host").toString())); + } + if ((jsonObj.get("mime_type") != null && !jsonObj.get("mime_type").isJsonNull()) && !jsonObj.get("mime_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `mime_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mime_type").toString())); + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if ((jsonObj.get("network_source") != null && !jsonObj.get("network_source").isJsonNull()) && !jsonObj.get("network_source").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `network_source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("network_source").toString())); + } + if ((jsonObj.get("original_filename") != null && !jsonObj.get("original_filename").isJsonNull()) && !jsonObj.get("original_filename").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `original_filename` to be a primitive type in the JSON string but got `%s`", jsonObj.get("original_filename").toString())); + } + if (!jsonObj.get("path").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `path` to be a primitive type in the JSON string but got `%s`", jsonObj.get("path").toString())); + } + if (!jsonObj.get("reason").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); + } + // validate the required field `reason` + ReasonEnum.validateJsonElement(jsonObj.get("reason")); + if ((jsonObj.get("sha256") != null && !jsonObj.get("sha256").isJsonNull()) && !jsonObj.get("sha256").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha256` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha256").toString())); + } + if (!jsonObj.get("source").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source").toString())); + } + if ((jsonObj.get("uri") != null && !jsonObj.get("uri").isJsonNull()) && !jsonObj.get("uri").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `uri` to be a primitive type in the JSON string but got `%s`", jsonObj.get("uri").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("yara_hits") != null && !jsonObj.get("yara_hits").isJsonNull() && !jsonObj.get("yara_hits").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `yara_hits` to be an array in the JSON string but got `%s`", jsonObj.get("yara_hits").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Artifact.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Artifact' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Artifact.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Artifact value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Artifact read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Artifact given an JSON string + * + * @param jsonString JSON string + * @return An instance of Artifact + * @throws IOException if the JSON string is invalid with respect to Artifact + */ + public static Artifact fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Artifact.class); + } + + /** + * Convert an instance of Artifact to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/AttemptFailedEvent.java b/src/main/java/ai/reveng/model/AttemptFailedEvent.java index 8d2e9712..003db5a9 100644 --- a/src/main/java/ai/reveng/model/AttemptFailedEvent.java +++ b/src/main/java/ai/reveng/model/AttemptFailedEvent.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -149,50 +147,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the AttemptFailedEvent instance itself - */ - public AttemptFailedEvent putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -207,13 +161,12 @@ public boolean equals(Object o) { return Objects.equals(this.attempt, attemptFailedEvent.attempt) && Objects.equals(this.error, attemptFailedEvent.error) && Objects.equals(this.seq, attemptFailedEvent.seq) && - Objects.equals(this.type, attemptFailedEvent.type)&& - Objects.equals(this.additionalProperties, attemptFailedEvent.additionalProperties); + Objects.equals(this.type, attemptFailedEvent.type); } @Override public int hashCode() { - return Objects.hash(attempt, error, seq, type, additionalProperties); + return Objects.hash(attempt, error, seq, type); } @Override @@ -224,7 +177,6 @@ public String toString() { sb.append(" error: ").append(toIndentedString(error)).append("\n"); sb.append(" seq: ").append(toIndentedString(seq)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -234,10 +186,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,22 +210,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AttemptFailedEvent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AttemptFailedEvent is not found in the empty JSON string", AttemptFailedEvent.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AttemptFailedEvent is not found in the empty JSON string", AttemptFailedEvent.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!AttemptFailedEvent.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AttemptFailedEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AttemptFailedEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("error").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `error` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `error` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -295,28 +252,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AttemptFailedEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -324,28 +259,7 @@ else if (entry.getValue() instanceof Character) public AttemptFailedEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - AttemptFailedEvent instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AttemptStartedEvent.java b/src/main/java/ai/reveng/model/AttemptStartedEvent.java index ef236a8b..aaae9421 100644 --- a/src/main/java/ai/reveng/model/AttemptStartedEvent.java +++ b/src/main/java/ai/reveng/model/AttemptStartedEvent.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -125,50 +123,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the AttemptStartedEvent instance itself - */ - public AttemptStartedEvent putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -182,13 +136,12 @@ public boolean equals(Object o) { AttemptStartedEvent attemptStartedEvent = (AttemptStartedEvent) o; return Objects.equals(this.attempt, attemptStartedEvent.attempt) && Objects.equals(this.seq, attemptStartedEvent.seq) && - Objects.equals(this.type, attemptStartedEvent.type)&& - Objects.equals(this.additionalProperties, attemptStartedEvent.additionalProperties); + Objects.equals(this.type, attemptStartedEvent.type); } @Override public int hashCode() { - return Objects.hash(attempt, seq, type, additionalProperties); + return Objects.hash(attempt, seq, type); } @Override @@ -198,7 +151,6 @@ public String toString() { sb.append(" attempt: ").append(toIndentedString(attempt)).append("\n"); sb.append(" seq: ").append(toIndentedString(seq)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -208,10 +160,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -235,19 +184,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AttemptStartedEvent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AttemptStartedEvent is not found in the empty JSON string", AttemptStartedEvent.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AttemptStartedEvent is not found in the empty JSON string", AttemptStartedEvent.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!AttemptStartedEvent.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AttemptStartedEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AttemptStartedEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -266,28 +223,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AttemptStartedEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -295,28 +230,7 @@ else if (entry.getValue() instanceof Character) public AttemptStartedEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - AttemptStartedEvent instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/AutoRunAgents.java b/src/main/java/ai/reveng/model/AutoRunAgents.java index f1134bed..6395eca3 100644 --- a/src/main/java/ai/reveng/model/AutoRunAgents.java +++ b/src/main/java/ai/reveng/model/AutoRunAgents.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -156,10 +154,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,7 +178,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AutoRunAgents.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AutoRunAgents is not found in the empty JSON string", AutoRunAgents.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AutoRunAgents is not found in the empty JSON string", AutoRunAgents.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -246,7 +241,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AutoUnstripRequest.java b/src/main/java/ai/reveng/model/AutoUnstripRequest.java index 51045f77..e324a7d2 100644 --- a/src/main/java/ai/reveng/model/AutoUnstripRequest.java +++ b/src/main/java/ai/reveng/model/AutoUnstripRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -349,10 +347,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -376,7 +371,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AutoUnstripRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AutoUnstripRequest is not found in the empty JSON string", AutoUnstripRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AutoUnstripRequest is not found in the empty JSON string", AutoUnstripRequest.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -439,7 +434,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/AutoUnstripResponse.java b/src/main/java/ai/reveng/model/AutoUnstripResponse.java index a7bbfcd4..e0bab583 100644 --- a/src/main/java/ai/reveng/model/AutoUnstripResponse.java +++ b/src/main/java/ai/reveng/model/AutoUnstripResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.MatchedFunctionSuggestion; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -118,7 +116,7 @@ public AutoUnstripResponse status(@javax.annotation.Nullable String status) { } /** - * Get status + * Status of the function matching operation * @return status */ @javax.annotation.Nullable @@ -137,7 +135,7 @@ public AutoUnstripResponse totalTime(@javax.annotation.Nullable Integer totalTim } /** - * Get totalTime + * Total time taken for the auto-unstrip operation in seconds * @return totalTime */ @javax.annotation.Nullable @@ -164,7 +162,7 @@ public AutoUnstripResponse addMatchesItem(MatchedFunctionSuggestion matchesItem) } /** - * Get matches + * Map of function IDs to their matching results with best match information * @return matches */ @javax.annotation.Nullable @@ -183,7 +181,7 @@ public AutoUnstripResponse applied(@javax.annotation.Nullable Boolean applied) { } /** - * Get applied + * Indicates whether the matched function names were applied to the target binary * @return applied */ @javax.annotation.Nullable @@ -202,7 +200,7 @@ public AutoUnstripResponse errorMessage(@javax.annotation.Nullable String errorM } /** - * Get errorMessage + * Error message if the operation failed * @return errorMessage */ @javax.annotation.Nullable @@ -314,10 +312,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -341,19 +336,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AutoUnstripResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AutoUnstripResponse is not found in the empty JSON string", AutoUnstripResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in AutoUnstripResponse is not found in the empty JSON string", AutoUnstripResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); } if (jsonObj.get("matches") != null && !jsonObj.get("matches").isJsonNull()) { JsonArray jsonArraymatches = jsonObj.getAsJsonArray("matches"); if (jsonArraymatches != null) { // ensure the json data is an array if (!jsonObj.get("matches").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `matches` to be an array in the JSON string but got `%s`", jsonObj.get("matches").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `matches` to be an array in the JSON string but got `%s`", jsonObj.get("matches").toString())); } // validate the optional field `matches` (array) @@ -363,7 +358,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } if ((jsonObj.get("error_message") != null && !jsonObj.get("error_message").isJsonNull()) && !jsonObj.get("error_message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `error_message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error_message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `error_message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error_message").toString())); } } @@ -424,7 +419,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponse.java b/src/main/java/ai/reveng/model/BaseResponse.java index 162c088d..7e796842 100644 --- a/src/main/java/ai/reveng/model/BaseResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; import com.google.gson.TypeAdapter; @@ -47,7 +46,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -109,7 +107,7 @@ public BaseResponse data(@javax.annotation.Nullable Object data) { } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -128,7 +126,7 @@ public BaseResponse message(@javax.annotation.Nullable String message) { } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -155,7 +153,7 @@ public BaseResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -284,10 +282,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -311,19 +306,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponse is not found in the empty JSON string", BaseResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponse is not found in the empty JSON string", BaseResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -395,7 +390,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseAdditionalDetailsStatusResponse.java b/src/main/java/ai/reveng/model/BaseResponseAdditionalDetailsStatusResponse.java index d0ba4bbd..fb7e08e4 100644 --- a/src/main/java/ai/reveng/model/BaseResponseAdditionalDetailsStatusResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseAdditionalDetailsStatusResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AdditionalDetailsStatusResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseAdditionalDetailsStatusResponse data(@javax.annotation.Nullab } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseAdditionalDetailsStatusResponse message(@javax.annotation.Nul } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseAdditionalDetailsStatusResponse addErrorsItem(ErrorModel erro } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseAdditionalDetailsStatusResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseAdditionalDetailsStatusResponse is not found in the empty JSON string", BaseResponseAdditionalDetailsStatusResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseAdditionalDetailsStatusResponse is not found in the empty JSON string", BaseResponseAdditionalDetailsStatusResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti AdditionalDetailsStatusResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseAnalysisBulkAddTagsResponse.java b/src/main/java/ai/reveng/model/BaseResponseAnalysisBulkAddTagsResponse.java index aedf7d33..360c6253 100644 --- a/src/main/java/ai/reveng/model/BaseResponseAnalysisBulkAddTagsResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseAnalysisBulkAddTagsResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AnalysisBulkAddTagsResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseAnalysisBulkAddTagsResponse data(@javax.annotation.Nullable A } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseAnalysisBulkAddTagsResponse message(@javax.annotation.Nullabl } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseAnalysisBulkAddTagsResponse addErrorsItem(ErrorModel errorsIt } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseAnalysisBulkAddTagsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisBulkAddTagsResponse is not found in the empty JSON string", BaseResponseAnalysisBulkAddTagsResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisBulkAddTagsResponse is not found in the empty JSON string", BaseResponseAnalysisBulkAddTagsResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti AnalysisBulkAddTagsResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseAnalysisCreateResponse.java b/src/main/java/ai/reveng/model/BaseResponseAnalysisCreateResponse.java index a3916d2d..0cb854ab 100644 --- a/src/main/java/ai/reveng/model/BaseResponseAnalysisCreateResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseAnalysisCreateResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AnalysisCreateResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseAnalysisCreateResponse data(@javax.annotation.Nullable Analys } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseAnalysisCreateResponse message(@javax.annotation.Nullable Str } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseAnalysisCreateResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseAnalysisCreateResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisCreateResponse is not found in the empty JSON string", BaseResponseAnalysisCreateResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisCreateResponse is not found in the empty JSON string", BaseResponseAnalysisCreateResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti AnalysisCreateResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseAnalysisDetailResponse.java b/src/main/java/ai/reveng/model/BaseResponseAnalysisDetailResponse.java index e715ba6e..db9527d4 100644 --- a/src/main/java/ai/reveng/model/BaseResponseAnalysisDetailResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseAnalysisDetailResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AnalysisDetailResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseAnalysisDetailResponse data(@javax.annotation.Nullable Analys } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseAnalysisDetailResponse message(@javax.annotation.Nullable Str } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseAnalysisDetailResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseAnalysisDetailResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisDetailResponse is not found in the empty JSON string", BaseResponseAnalysisDetailResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisDetailResponse is not found in the empty JSON string", BaseResponseAnalysisDetailResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti AnalysisDetailResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseAnalysisFunctionMapping.java b/src/main/java/ai/reveng/model/BaseResponseAnalysisFunctionMapping.java index b901a339..c8e4c206 100644 --- a/src/main/java/ai/reveng/model/BaseResponseAnalysisFunctionMapping.java +++ b/src/main/java/ai/reveng/model/BaseResponseAnalysisFunctionMapping.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AnalysisFunctionMapping; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseAnalysisFunctionMapping data(@javax.annotation.Nullable Analy } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseAnalysisFunctionMapping message(@javax.annotation.Nullable St } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseAnalysisFunctionMapping addErrorsItem(ErrorModel errorsItem) } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseAnalysisFunctionMapping.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisFunctionMapping is not found in the empty JSON string", BaseResponseAnalysisFunctionMapping.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisFunctionMapping is not found in the empty JSON string", BaseResponseAnalysisFunctionMapping.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti AnalysisFunctionMapping.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseAnalysisFunctions.java b/src/main/java/ai/reveng/model/BaseResponseAnalysisFunctions.java index 135fd043..313e5068 100644 --- a/src/main/java/ai/reveng/model/BaseResponseAnalysisFunctions.java +++ b/src/main/java/ai/reveng/model/BaseResponseAnalysisFunctions.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AnalysisFunctions; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseAnalysisFunctions data(@javax.annotation.Nullable AnalysisFun } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseAnalysisFunctions message(@javax.annotation.Nullable String m } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseAnalysisFunctions addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseAnalysisFunctions.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisFunctions is not found in the empty JSON string", BaseResponseAnalysisFunctions.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisFunctions is not found in the empty JSON string", BaseResponseAnalysisFunctions.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti AnalysisFunctions.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseAnalysisFunctionsList.java b/src/main/java/ai/reveng/model/BaseResponseAnalysisFunctionsList.java index 2712808a..6de5b775 100644 --- a/src/main/java/ai/reveng/model/BaseResponseAnalysisFunctionsList.java +++ b/src/main/java/ai/reveng/model/BaseResponseAnalysisFunctionsList.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AnalysisFunctionsList; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseAnalysisFunctionsList data(@javax.annotation.Nullable Analysi } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseAnalysisFunctionsList message(@javax.annotation.Nullable Stri } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseAnalysisFunctionsList addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseAnalysisFunctionsList.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisFunctionsList is not found in the empty JSON string", BaseResponseAnalysisFunctionsList.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisFunctionsList is not found in the empty JSON string", BaseResponseAnalysisFunctionsList.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti AnalysisFunctionsList.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseAnalysisStringsResponse.java b/src/main/java/ai/reveng/model/BaseResponseAnalysisStringsResponse.java index 1fb50fd6..686e8953 100644 --- a/src/main/java/ai/reveng/model/BaseResponseAnalysisStringsResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseAnalysisStringsResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AnalysisStringsResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseAnalysisStringsResponse data(@javax.annotation.Nullable Analy } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseAnalysisStringsResponse message(@javax.annotation.Nullable St } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseAnalysisStringsResponse addErrorsItem(ErrorModel errorsItem) } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseAnalysisStringsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisStringsResponse is not found in the empty JSON string", BaseResponseAnalysisStringsResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisStringsResponse is not found in the empty JSON string", BaseResponseAnalysisStringsResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti AnalysisStringsResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseAnalysisStringsStatusResponse.java b/src/main/java/ai/reveng/model/BaseResponseAnalysisStringsStatusResponse.java index 32e9b757..ff0f8b09 100644 --- a/src/main/java/ai/reveng/model/BaseResponseAnalysisStringsStatusResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseAnalysisStringsStatusResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AnalysisStringsStatusResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseAnalysisStringsStatusResponse data(@javax.annotation.Nullable } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseAnalysisStringsStatusResponse message(@javax.annotation.Nulla } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseAnalysisStringsStatusResponse addErrorsItem(ErrorModel errors } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseAnalysisStringsStatusResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisStringsStatusResponse is not found in the empty JSON string", BaseResponseAnalysisStringsStatusResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisStringsStatusResponse is not found in the empty JSON string", BaseResponseAnalysisStringsStatusResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti AnalysisStringsStatusResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseAnalysisTags.java b/src/main/java/ai/reveng/model/BaseResponseAnalysisTags.java index 1373f91d..b5b001bf 100644 --- a/src/main/java/ai/reveng/model/BaseResponseAnalysisTags.java +++ b/src/main/java/ai/reveng/model/BaseResponseAnalysisTags.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AnalysisTags; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseAnalysisTags data(@javax.annotation.Nullable AnalysisTags dat } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseAnalysisTags message(@javax.annotation.Nullable String messag } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseAnalysisTags addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseAnalysisTags.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisTags is not found in the empty JSON string", BaseResponseAnalysisTags.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisTags is not found in the empty JSON string", BaseResponseAnalysisTags.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti AnalysisTags.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseAnalysisUpdateTagsResponse.java b/src/main/java/ai/reveng/model/BaseResponseAnalysisUpdateTagsResponse.java index da98f7ee..09eeab07 100644 --- a/src/main/java/ai/reveng/model/BaseResponseAnalysisUpdateTagsResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseAnalysisUpdateTagsResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AnalysisUpdateTagsResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseAnalysisUpdateTagsResponse data(@javax.annotation.Nullable An } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseAnalysisUpdateTagsResponse message(@javax.annotation.Nullable } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseAnalysisUpdateTagsResponse addErrorsItem(ErrorModel errorsIte } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseAnalysisUpdateTagsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisUpdateTagsResponse is not found in the empty JSON string", BaseResponseAnalysisUpdateTagsResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisUpdateTagsResponse is not found in the empty JSON string", BaseResponseAnalysisUpdateTagsResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti AnalysisUpdateTagsResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseBasic.java b/src/main/java/ai/reveng/model/BaseResponseBasic.java index 3550bc5c..2f390d75 100644 --- a/src/main/java/ai/reveng/model/BaseResponseBasic.java +++ b/src/main/java/ai/reveng/model/BaseResponseBasic.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.Basic; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseBasic data(@javax.annotation.Nullable Basic data) { } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseBasic message(@javax.annotation.Nullable String message) { } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseBasic addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseBasic.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseBasic is not found in the empty JSON string", BaseResponseBasic.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseBasic is not found in the empty JSON string", BaseResponseBasic.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti Basic.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseBinariesRelatedStatusResponse.java b/src/main/java/ai/reveng/model/BaseResponseBinariesRelatedStatusResponse.java index e47c0568..90f517a2 100644 --- a/src/main/java/ai/reveng/model/BaseResponseBinariesRelatedStatusResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseBinariesRelatedStatusResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.BinariesRelatedStatusResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseBinariesRelatedStatusResponse data(@javax.annotation.Nullable } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseBinariesRelatedStatusResponse message(@javax.annotation.Nulla } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseBinariesRelatedStatusResponse addErrorsItem(ErrorModel errors } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseBinariesRelatedStatusResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseBinariesRelatedStatusResponse is not found in the empty JSON string", BaseResponseBinariesRelatedStatusResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseBinariesRelatedStatusResponse is not found in the empty JSON string", BaseResponseBinariesRelatedStatusResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti BinariesRelatedStatusResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseBinaryAdditionalResponse.java b/src/main/java/ai/reveng/model/BaseResponseBinaryAdditionalResponse.java index eff5c18b..861dee4c 100644 --- a/src/main/java/ai/reveng/model/BaseResponseBinaryAdditionalResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseBinaryAdditionalResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.BinaryAdditionalResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseBinaryAdditionalResponse data(@javax.annotation.Nullable Bina } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseBinaryAdditionalResponse message(@javax.annotation.Nullable S } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseBinaryAdditionalResponse addErrorsItem(ErrorModel errorsItem) } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseBinaryAdditionalResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseBinaryAdditionalResponse is not found in the empty JSON string", BaseResponseBinaryAdditionalResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseBinaryAdditionalResponse is not found in the empty JSON string", BaseResponseBinaryAdditionalResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti BinaryAdditionalResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseBinaryDetailsResponse.java b/src/main/java/ai/reveng/model/BaseResponseBinaryDetailsResponse.java index fe990208..4a185ef8 100644 --- a/src/main/java/ai/reveng/model/BaseResponseBinaryDetailsResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseBinaryDetailsResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.BinaryDetailsResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseBinaryDetailsResponse data(@javax.annotation.Nullable BinaryD } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseBinaryDetailsResponse message(@javax.annotation.Nullable Stri } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseBinaryDetailsResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseBinaryDetailsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseBinaryDetailsResponse is not found in the empty JSON string", BaseResponseBinaryDetailsResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseBinaryDetailsResponse is not found in the empty JSON string", BaseResponseBinaryDetailsResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti BinaryDetailsResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseBinaryExternalsResponse.java b/src/main/java/ai/reveng/model/BaseResponseBinaryExternalsResponse.java index 56040b15..e3b43ccf 100644 --- a/src/main/java/ai/reveng/model/BaseResponseBinaryExternalsResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseBinaryExternalsResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.BinaryExternalsResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseBinaryExternalsResponse data(@javax.annotation.Nullable Binar } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseBinaryExternalsResponse message(@javax.annotation.Nullable St } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseBinaryExternalsResponse addErrorsItem(ErrorModel errorsItem) } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseBinaryExternalsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseBinaryExternalsResponse is not found in the empty JSON string", BaseResponseBinaryExternalsResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseBinaryExternalsResponse is not found in the empty JSON string", BaseResponseBinaryExternalsResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti BinaryExternalsResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseBinarySearchResponse.java b/src/main/java/ai/reveng/model/BaseResponseBinarySearchResponse.java index b668d8ef..d7745a02 100644 --- a/src/main/java/ai/reveng/model/BaseResponseBinarySearchResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseBinarySearchResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.BinarySearchResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseBinarySearchResponse data(@javax.annotation.Nullable BinarySe } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseBinarySearchResponse message(@javax.annotation.Nullable Strin } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseBinarySearchResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseBinarySearchResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseBinarySearchResponse is not found in the empty JSON string", BaseResponseBinarySearchResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseBinarySearchResponse is not found in the empty JSON string", BaseResponseBinarySearchResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti BinarySearchResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseBool.java b/src/main/java/ai/reveng/model/BaseResponseBool.java index 425ca500..e17baf27 100644 --- a/src/main/java/ai/reveng/model/BaseResponseBool.java +++ b/src/main/java/ai/reveng/model/BaseResponseBool.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; import com.google.gson.TypeAdapter; @@ -47,7 +46,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -109,7 +107,7 @@ public BaseResponseBool data(@javax.annotation.Nullable Boolean data) { } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -128,7 +126,7 @@ public BaseResponseBool message(@javax.annotation.Nullable String message) { } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -155,7 +153,7 @@ public BaseResponseBool addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -284,10 +282,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -311,19 +306,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseBool.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseBool is not found in the empty JSON string", BaseResponseBool.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseBool is not found in the empty JSON string", BaseResponseBool.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -395,7 +390,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseCalleesCallerFunctionsResponse.java b/src/main/java/ai/reveng/model/BaseResponseCalleesCallerFunctionsResponse.java index aaa42155..5f623552 100644 --- a/src/main/java/ai/reveng/model/BaseResponseCalleesCallerFunctionsResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseCalleesCallerFunctionsResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.CalleesCallerFunctionsResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseCalleesCallerFunctionsResponse data(@javax.annotation.Nullabl } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseCalleesCallerFunctionsResponse message(@javax.annotation.Null } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseCalleesCallerFunctionsResponse addErrorsItem(ErrorModel error } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseCalleesCallerFunctionsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseCalleesCallerFunctionsResponse is not found in the empty JSON string", BaseResponseCalleesCallerFunctionsResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseCalleesCallerFunctionsResponse is not found in the empty JSON string", BaseResponseCalleesCallerFunctionsResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti CalleesCallerFunctionsResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseCapabilities.java b/src/main/java/ai/reveng/model/BaseResponseCapabilities.java index bbfe481a..d22206db 100644 --- a/src/main/java/ai/reveng/model/BaseResponseCapabilities.java +++ b/src/main/java/ai/reveng/model/BaseResponseCapabilities.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.Capabilities; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseCapabilities data(@javax.annotation.Nullable Capabilities dat } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseCapabilities message(@javax.annotation.Nullable String messag } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseCapabilities addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseCapabilities.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseCapabilities is not found in the empty JSON string", BaseResponseCapabilities.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseCapabilities is not found in the empty JSON string", BaseResponseCapabilities.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti Capabilities.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseCapabilitiesAgentResponse.java b/src/main/java/ai/reveng/model/BaseResponseCapabilitiesAgentResponse.java index 1bbe818d..e093e4b4 100644 --- a/src/main/java/ai/reveng/model/BaseResponseCapabilitiesAgentResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseCapabilitiesAgentResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.CapabilitiesAgentResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseCapabilitiesAgentResponse data(@javax.annotation.Nullable Cap } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseCapabilitiesAgentResponse message(@javax.annotation.Nullable } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseCapabilitiesAgentResponse addErrorsItem(ErrorModel errorsItem } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseCapabilitiesAgentResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseCapabilitiesAgentResponse is not found in the empty JSON string", BaseResponseCapabilitiesAgentResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseCapabilitiesAgentResponse is not found in the empty JSON string", BaseResponseCapabilitiesAgentResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti CapabilitiesAgentResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseChildBinariesResponse.java b/src/main/java/ai/reveng/model/BaseResponseChildBinariesResponse.java index 4b76a939..766b4a49 100644 --- a/src/main/java/ai/reveng/model/BaseResponseChildBinariesResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseChildBinariesResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ChildBinariesResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseChildBinariesResponse data(@javax.annotation.Nullable ChildBi } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseChildBinariesResponse message(@javax.annotation.Nullable Stri } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseChildBinariesResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseChildBinariesResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseChildBinariesResponse is not found in the empty JSON string", BaseResponseChildBinariesResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseChildBinariesResponse is not found in the empty JSON string", BaseResponseChildBinariesResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti ChildBinariesResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseCollectionBinariesUpdateResponse.java b/src/main/java/ai/reveng/model/BaseResponseCollectionBinariesUpdateResponse.java index 816130b0..7afc5b06 100644 --- a/src/main/java/ai/reveng/model/BaseResponseCollectionBinariesUpdateResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseCollectionBinariesUpdateResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.CollectionBinariesUpdateResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseCollectionBinariesUpdateResponse data(@javax.annotation.Nulla } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseCollectionBinariesUpdateResponse message(@javax.annotation.Nu } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseCollectionBinariesUpdateResponse addErrorsItem(ErrorModel err } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseCollectionBinariesUpdateResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseCollectionBinariesUpdateResponse is not found in the empty JSON string", BaseResponseCollectionBinariesUpdateResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseCollectionBinariesUpdateResponse is not found in the empty JSON string", BaseResponseCollectionBinariesUpdateResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti CollectionBinariesUpdateResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseCollectionResponse.java b/src/main/java/ai/reveng/model/BaseResponseCollectionResponse.java index b8f75caa..ba655d9e 100644 --- a/src/main/java/ai/reveng/model/BaseResponseCollectionResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseCollectionResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.CollectionResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseCollectionResponse data(@javax.annotation.Nullable Collection } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseCollectionResponse message(@javax.annotation.Nullable String } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseCollectionResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseCollectionResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseCollectionResponse is not found in the empty JSON string", BaseResponseCollectionResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseCollectionResponse is not found in the empty JSON string", BaseResponseCollectionResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti CollectionResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseCollectionSearchResponse.java b/src/main/java/ai/reveng/model/BaseResponseCollectionSearchResponse.java index 741a5413..cc76288d 100644 --- a/src/main/java/ai/reveng/model/BaseResponseCollectionSearchResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseCollectionSearchResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.CollectionSearchResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseCollectionSearchResponse data(@javax.annotation.Nullable Coll } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseCollectionSearchResponse message(@javax.annotation.Nullable S } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseCollectionSearchResponse addErrorsItem(ErrorModel errorsItem) } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseCollectionSearchResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseCollectionSearchResponse is not found in the empty JSON string", BaseResponseCollectionSearchResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseCollectionSearchResponse is not found in the empty JSON string", BaseResponseCollectionSearchResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti CollectionSearchResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseCollectionTagsUpdateResponse.java b/src/main/java/ai/reveng/model/BaseResponseCollectionTagsUpdateResponse.java index b36ba930..d743ee13 100644 --- a/src/main/java/ai/reveng/model/BaseResponseCollectionTagsUpdateResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseCollectionTagsUpdateResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.CollectionTagsUpdateResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseCollectionTagsUpdateResponse data(@javax.annotation.Nullable } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseCollectionTagsUpdateResponse message(@javax.annotation.Nullab } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseCollectionTagsUpdateResponse addErrorsItem(ErrorModel errorsI } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseCollectionTagsUpdateResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseCollectionTagsUpdateResponse is not found in the empty JSON string", BaseResponseCollectionTagsUpdateResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseCollectionTagsUpdateResponse is not found in the empty JSON string", BaseResponseCollectionTagsUpdateResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti CollectionTagsUpdateResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseCommentResponse.java b/src/main/java/ai/reveng/model/BaseResponseCommentResponse.java index 67805b5d..3a76a3bd 100644 --- a/src/main/java/ai/reveng/model/BaseResponseCommentResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseCommentResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.CommentResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseCommentResponse data(@javax.annotation.Nullable CommentRespon } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseCommentResponse message(@javax.annotation.Nullable String mes } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseCommentResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseCommentResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseCommentResponse is not found in the empty JSON string", BaseResponseCommentResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseCommentResponse is not found in the empty JSON string", BaseResponseCommentResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti CommentResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseConfigResponse.java b/src/main/java/ai/reveng/model/BaseResponseConfigResponse.java index 9f70fa02..c15120ad 100644 --- a/src/main/java/ai/reveng/model/BaseResponseConfigResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseConfigResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ConfigResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseConfigResponse data(@javax.annotation.Nullable ConfigResponse } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseConfigResponse message(@javax.annotation.Nullable String mess } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseConfigResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseConfigResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseConfigResponse is not found in the empty JSON string", BaseResponseConfigResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseConfigResponse is not found in the empty JSON string", BaseResponseConfigResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti ConfigResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseCreated.java b/src/main/java/ai/reveng/model/BaseResponseCreated.java index 2facb29f..ab01d74b 100644 --- a/src/main/java/ai/reveng/model/BaseResponseCreated.java +++ b/src/main/java/ai/reveng/model/BaseResponseCreated.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.Created; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseCreated data(@javax.annotation.Nullable Created data) { } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseCreated message(@javax.annotation.Nullable String message) { } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseCreated addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseCreated.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseCreated is not found in the empty JSON string", BaseResponseCreated.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseCreated is not found in the empty JSON string", BaseResponseCreated.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti Created.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseDict.java b/src/main/java/ai/reveng/model/BaseResponseDict.java index 08e3beea..7b1b3a0d 100644 --- a/src/main/java/ai/reveng/model/BaseResponseDict.java +++ b/src/main/java/ai/reveng/model/BaseResponseDict.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; import com.google.gson.TypeAdapter; @@ -49,7 +48,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -119,7 +117,7 @@ public BaseResponseDict putDataItem(String key, Object dataItem) { } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -138,7 +136,7 @@ public BaseResponseDict message(@javax.annotation.Nullable String message) { } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -165,7 +163,7 @@ public BaseResponseDict addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -294,10 +292,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -321,19 +316,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseDict.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseDict is not found in the empty JSON string", BaseResponseDict.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseDict is not found in the empty JSON string", BaseResponseDict.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -405,7 +400,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseExternalResponse.java b/src/main/java/ai/reveng/model/BaseResponseExternalResponse.java index dfdb2ce6..923da4ab 100644 --- a/src/main/java/ai/reveng/model/BaseResponseExternalResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseExternalResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.ExternalResponse; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseExternalResponse data(@javax.annotation.Nullable ExternalResp } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseExternalResponse message(@javax.annotation.Nullable String me } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseExternalResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseExternalResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseExternalResponse is not found in the empty JSON string", BaseResponseExternalResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseExternalResponse is not found in the empty JSON string", BaseResponseExternalResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti ExternalResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseFunctionBlocksResponse.java b/src/main/java/ai/reveng/model/BaseResponseFunctionBlocksResponse.java index f657ee79..d3a4d309 100644 --- a/src/main/java/ai/reveng/model/BaseResponseFunctionBlocksResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseFunctionBlocksResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.FunctionBlocksResponse; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseFunctionBlocksResponse data(@javax.annotation.Nullable Functi } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseFunctionBlocksResponse message(@javax.annotation.Nullable Str } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseFunctionBlocksResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseFunctionBlocksResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseFunctionBlocksResponse is not found in the empty JSON string", BaseResponseFunctionBlocksResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseFunctionBlocksResponse is not found in the empty JSON string", BaseResponseFunctionBlocksResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti FunctionBlocksResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseFunctionCapabilityResponse.java b/src/main/java/ai/reveng/model/BaseResponseFunctionCapabilityResponse.java index e577c453..42835de7 100644 --- a/src/main/java/ai/reveng/model/BaseResponseFunctionCapabilityResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseFunctionCapabilityResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.FunctionCapabilityResponse; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseFunctionCapabilityResponse data(@javax.annotation.Nullable Fu } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseFunctionCapabilityResponse message(@javax.annotation.Nullable } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseFunctionCapabilityResponse addErrorsItem(ErrorModel errorsIte } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseFunctionCapabilityResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseFunctionCapabilityResponse is not found in the empty JSON string", BaseResponseFunctionCapabilityResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseFunctionCapabilityResponse is not found in the empty JSON string", BaseResponseFunctionCapabilityResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti FunctionCapabilityResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseFunctionDataTypes.java b/src/main/java/ai/reveng/model/BaseResponseFunctionDataTypes.java index 62c66e73..c705204f 100644 --- a/src/main/java/ai/reveng/model/BaseResponseFunctionDataTypes.java +++ b/src/main/java/ai/reveng/model/BaseResponseFunctionDataTypes.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.FunctionDataTypes; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseFunctionDataTypes data(@javax.annotation.Nullable FunctionDat } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseFunctionDataTypes message(@javax.annotation.Nullable String m } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseFunctionDataTypes addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseFunctionDataTypes.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseFunctionDataTypes is not found in the empty JSON string", BaseResponseFunctionDataTypes.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseFunctionDataTypes is not found in the empty JSON string", BaseResponseFunctionDataTypes.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti FunctionDataTypes.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseFunctionDataTypesList.java b/src/main/java/ai/reveng/model/BaseResponseFunctionDataTypesList.java index f61948e4..3e610c26 100644 --- a/src/main/java/ai/reveng/model/BaseResponseFunctionDataTypesList.java +++ b/src/main/java/ai/reveng/model/BaseResponseFunctionDataTypesList.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.FunctionDataTypesList; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseFunctionDataTypesList data(@javax.annotation.Nullable Functio } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseFunctionDataTypesList message(@javax.annotation.Nullable Stri } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseFunctionDataTypesList addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseFunctionDataTypesList.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseFunctionDataTypesList is not found in the empty JSON string", BaseResponseFunctionDataTypesList.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseFunctionDataTypesList is not found in the empty JSON string", BaseResponseFunctionDataTypesList.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti FunctionDataTypesList.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseFunctionSearchResponse.java b/src/main/java/ai/reveng/model/BaseResponseFunctionSearchResponse.java index af80e196..c3efc4b4 100644 --- a/src/main/java/ai/reveng/model/BaseResponseFunctionSearchResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseFunctionSearchResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.FunctionSearchResponse; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseFunctionSearchResponse data(@javax.annotation.Nullable Functi } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseFunctionSearchResponse message(@javax.annotation.Nullable Str } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseFunctionSearchResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseFunctionSearchResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseFunctionSearchResponse is not found in the empty JSON string", BaseResponseFunctionSearchResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseFunctionSearchResponse is not found in the empty JSON string", BaseResponseFunctionSearchResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti FunctionSearchResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseFunctionStringsResponse.java b/src/main/java/ai/reveng/model/BaseResponseFunctionStringsResponse.java index 9b6c9771..d7229e46 100644 --- a/src/main/java/ai/reveng/model/BaseResponseFunctionStringsResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseFunctionStringsResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.FunctionStringsResponse; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseFunctionStringsResponse data(@javax.annotation.Nullable Funct } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseFunctionStringsResponse message(@javax.annotation.Nullable St } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseFunctionStringsResponse addErrorsItem(ErrorModel errorsItem) } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseFunctionStringsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseFunctionStringsResponse is not found in the empty JSON string", BaseResponseFunctionStringsResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseFunctionStringsResponse is not found in the empty JSON string", BaseResponseFunctionStringsResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti FunctionStringsResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseFunctionTaskResponse.java b/src/main/java/ai/reveng/model/BaseResponseFunctionTaskResponse.java index 8d2666cc..965466f7 100644 --- a/src/main/java/ai/reveng/model/BaseResponseFunctionTaskResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseFunctionTaskResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.FunctionTaskResponse; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseFunctionTaskResponse data(@javax.annotation.Nullable Function } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseFunctionTaskResponse message(@javax.annotation.Nullable Strin } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseFunctionTaskResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseFunctionTaskResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseFunctionTaskResponse is not found in the empty JSON string", BaseResponseFunctionTaskResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseFunctionTaskResponse is not found in the empty JSON string", BaseResponseFunctionTaskResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti FunctionTaskResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseFunctionsDetailResponse.java b/src/main/java/ai/reveng/model/BaseResponseFunctionsDetailResponse.java index 2d6b16c8..b073758a 100644 --- a/src/main/java/ai/reveng/model/BaseResponseFunctionsDetailResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseFunctionsDetailResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.FunctionsDetailResponse; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseFunctionsDetailResponse data(@javax.annotation.Nullable Funct } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseFunctionsDetailResponse message(@javax.annotation.Nullable St } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseFunctionsDetailResponse addErrorsItem(ErrorModel errorsItem) } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseFunctionsDetailResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseFunctionsDetailResponse is not found in the empty JSON string", BaseResponseFunctionsDetailResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseFunctionsDetailResponse is not found in the empty JSON string", BaseResponseFunctionsDetailResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti FunctionsDetailResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseGenerateFunctionDataTypes.java b/src/main/java/ai/reveng/model/BaseResponseGenerateFunctionDataTypes.java index 87d03b58..256b89e9 100644 --- a/src/main/java/ai/reveng/model/BaseResponseGenerateFunctionDataTypes.java +++ b/src/main/java/ai/reveng/model/BaseResponseGenerateFunctionDataTypes.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.GenerateFunctionDataTypes; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseGenerateFunctionDataTypes data(@javax.annotation.Nullable Gen } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseGenerateFunctionDataTypes message(@javax.annotation.Nullable } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseGenerateFunctionDataTypes addErrorsItem(ErrorModel errorsItem } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseGenerateFunctionDataTypes.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseGenerateFunctionDataTypes is not found in the empty JSON string", BaseResponseGenerateFunctionDataTypes.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseGenerateFunctionDataTypes is not found in the empty JSON string", BaseResponseGenerateFunctionDataTypes.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti GenerateFunctionDataTypes.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseGenerationStatusList.java b/src/main/java/ai/reveng/model/BaseResponseGenerationStatusList.java index 9575178b..20afcb53 100644 --- a/src/main/java/ai/reveng/model/BaseResponseGenerationStatusList.java +++ b/src/main/java/ai/reveng/model/BaseResponseGenerationStatusList.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.GenerationStatusList; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseGenerationStatusList data(@javax.annotation.Nullable Generati } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseGenerationStatusList message(@javax.annotation.Nullable Strin } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseGenerationStatusList addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseGenerationStatusList.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseGenerationStatusList is not found in the empty JSON string", BaseResponseGenerationStatusList.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseGenerationStatusList is not found in the empty JSON string", BaseResponseGenerationStatusList.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti GenerationStatusList.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseGetAiDecompilationTask.java b/src/main/java/ai/reveng/model/BaseResponseGetAiDecompilationTask.java index 290abb1d..0ebfde3d 100644 --- a/src/main/java/ai/reveng/model/BaseResponseGetAiDecompilationTask.java +++ b/src/main/java/ai/reveng/model/BaseResponseGetAiDecompilationTask.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.GetAiDecompilationTask; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseGetAiDecompilationTask data(@javax.annotation.Nullable GetAiD } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseGetAiDecompilationTask message(@javax.annotation.Nullable Str } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseGetAiDecompilationTask addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseGetAiDecompilationTask.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseGetAiDecompilationTask is not found in the empty JSON string", BaseResponseGetAiDecompilationTask.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseGetAiDecompilationTask is not found in the empty JSON string", BaseResponseGetAiDecompilationTask.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti GetAiDecompilationTask.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseGetPublicUserResponse.java b/src/main/java/ai/reveng/model/BaseResponseGetPublicUserResponse.java index 44f01e84..d05682cb 100644 --- a/src/main/java/ai/reveng/model/BaseResponseGetPublicUserResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseGetPublicUserResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.GetPublicUserResponse; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseGetPublicUserResponse data(@javax.annotation.Nullable GetPubl } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseGetPublicUserResponse message(@javax.annotation.Nullable Stri } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseGetPublicUserResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseGetPublicUserResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseGetPublicUserResponse is not found in the empty JSON string", BaseResponseGetPublicUserResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseGetPublicUserResponse is not found in the empty JSON string", BaseResponseGetPublicUserResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti GetPublicUserResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseListCalleesCallerFunctionsResponse.java b/src/main/java/ai/reveng/model/BaseResponseListCalleesCallerFunctionsResponse.java index b03b0344..73eb2048 100644 --- a/src/main/java/ai/reveng/model/BaseResponseListCalleesCallerFunctionsResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseListCalleesCallerFunctionsResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.CalleesCallerFunctionsResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -118,7 +116,7 @@ public BaseResponseListCalleesCallerFunctionsResponse addDataItem(CalleesCallerF } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -137,7 +135,7 @@ public BaseResponseListCalleesCallerFunctionsResponse message(@javax.annotation. } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -164,7 +162,7 @@ public BaseResponseListCalleesCallerFunctionsResponse addErrorsItem(ErrorModel e } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -293,10 +291,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -320,7 +315,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseListCalleesCallerFunctionsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseListCalleesCallerFunctionsResponse is not found in the empty JSON string", BaseResponseListCalleesCallerFunctionsResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseListCalleesCallerFunctionsResponse is not found in the empty JSON string", BaseResponseListCalleesCallerFunctionsResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -329,7 +324,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonArraydata != null) { // ensure the json data is an array if (!jsonObj.get("data").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); } // validate the optional field `data` (array) @@ -339,14 +334,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -418,7 +413,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseListCollectionResults.java b/src/main/java/ai/reveng/model/BaseResponseListCollectionResults.java index 03a969e8..575e8270 100644 --- a/src/main/java/ai/reveng/model/BaseResponseListCollectionResults.java +++ b/src/main/java/ai/reveng/model/BaseResponseListCollectionResults.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.ListCollectionResults; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseListCollectionResults data(@javax.annotation.Nullable ListCol } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseListCollectionResults message(@javax.annotation.Nullable Stri } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseListCollectionResults addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseListCollectionResults.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseListCollectionResults is not found in the empty JSON string", BaseResponseListCollectionResults.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseListCollectionResults is not found in the empty JSON string", BaseResponseListCollectionResults.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti ListCollectionResults.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseListCommentResponse.java b/src/main/java/ai/reveng/model/BaseResponseListCommentResponse.java index 0bf87a58..d129f22b 100644 --- a/src/main/java/ai/reveng/model/BaseResponseListCommentResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseListCommentResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.CommentResponse; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -118,7 +116,7 @@ public BaseResponseListCommentResponse addDataItem(CommentResponse dataItem) { } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -137,7 +135,7 @@ public BaseResponseListCommentResponse message(@javax.annotation.Nullable String } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -164,7 +162,7 @@ public BaseResponseListCommentResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -293,10 +291,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -320,7 +315,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseListCommentResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseListCommentResponse is not found in the empty JSON string", BaseResponseListCommentResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseListCommentResponse is not found in the empty JSON string", BaseResponseListCommentResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -329,7 +324,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonArraydata != null) { // ensure the json data is an array if (!jsonObj.get("data").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); } // validate the optional field `data` (array) @@ -339,14 +334,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -418,7 +413,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseListDieMatch.java b/src/main/java/ai/reveng/model/BaseResponseListDieMatch.java index 1d910970..1bc4e0c6 100644 --- a/src/main/java/ai/reveng/model/BaseResponseListDieMatch.java +++ b/src/main/java/ai/reveng/model/BaseResponseListDieMatch.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.DieMatch; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -118,7 +116,7 @@ public BaseResponseListDieMatch addDataItem(DieMatch dataItem) { } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -137,7 +135,7 @@ public BaseResponseListDieMatch message(@javax.annotation.Nullable String messag } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -164,7 +162,7 @@ public BaseResponseListDieMatch addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -293,10 +291,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -320,7 +315,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseListDieMatch.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseListDieMatch is not found in the empty JSON string", BaseResponseListDieMatch.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseListDieMatch is not found in the empty JSON string", BaseResponseListDieMatch.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -329,7 +324,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonArraydata != null) { // ensure the json data is an array if (!jsonObj.get("data").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); } // validate the optional field `data` (array) @@ -339,14 +334,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -418,7 +413,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseListFunctionNameHistory.java b/src/main/java/ai/reveng/model/BaseResponseListFunctionNameHistory.java index ceb9d7f0..7ebfbb5b 100644 --- a/src/main/java/ai/reveng/model/BaseResponseListFunctionNameHistory.java +++ b/src/main/java/ai/reveng/model/BaseResponseListFunctionNameHistory.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.FunctionNameHistory; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -118,7 +116,7 @@ public BaseResponseListFunctionNameHistory addDataItem(FunctionNameHistory dataI } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -137,7 +135,7 @@ public BaseResponseListFunctionNameHistory message(@javax.annotation.Nullable St } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -164,7 +162,7 @@ public BaseResponseListFunctionNameHistory addErrorsItem(ErrorModel errorsItem) } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -293,10 +291,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -320,7 +315,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseListFunctionNameHistory.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseListFunctionNameHistory is not found in the empty JSON string", BaseResponseListFunctionNameHistory.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseListFunctionNameHistory is not found in the empty JSON string", BaseResponseListFunctionNameHistory.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -329,7 +324,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonArraydata != null) { // ensure the json data is an array if (!jsonObj.get("data").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); } // validate the optional field `data` (array) @@ -339,14 +334,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -418,7 +413,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseListSBOM.java b/src/main/java/ai/reveng/model/BaseResponseListSBOM.java index 6ec59322..795074f2 100644 --- a/src/main/java/ai/reveng/model/BaseResponseListSBOM.java +++ b/src/main/java/ai/reveng/model/BaseResponseListSBOM.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; import ai.reveng.model.SBOM; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -118,7 +116,7 @@ public BaseResponseListSBOM addDataItem(SBOM dataItem) { } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -137,7 +135,7 @@ public BaseResponseListSBOM message(@javax.annotation.Nullable String message) { } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -164,7 +162,7 @@ public BaseResponseListSBOM addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -293,10 +291,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -320,7 +315,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseListSBOM.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseListSBOM is not found in the empty JSON string", BaseResponseListSBOM.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseListSBOM is not found in the empty JSON string", BaseResponseListSBOM.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -329,7 +324,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonArraydata != null) { // ensure the json data is an array if (!jsonObj.get("data").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); } // validate the optional field `data` (array) @@ -339,14 +334,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -418,7 +413,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseListUserActivityResponse.java b/src/main/java/ai/reveng/model/BaseResponseListUserActivityResponse.java index f8409a10..e426cbc5 100644 --- a/src/main/java/ai/reveng/model/BaseResponseListUserActivityResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseListUserActivityResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; import ai.reveng.model.UserActivityResponse; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -118,7 +116,7 @@ public BaseResponseListUserActivityResponse addDataItem(UserActivityResponse dat } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -137,7 +135,7 @@ public BaseResponseListUserActivityResponse message(@javax.annotation.Nullable S } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -164,7 +162,7 @@ public BaseResponseListUserActivityResponse addErrorsItem(ErrorModel errorsItem) } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -293,10 +291,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -320,7 +315,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseListUserActivityResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseListUserActivityResponse is not found in the empty JSON string", BaseResponseListUserActivityResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseListUserActivityResponse is not found in the empty JSON string", BaseResponseListUserActivityResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -329,7 +324,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonArraydata != null) { // ensure the json data is an array if (!jsonObj.get("data").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); } // validate the optional field `data` (array) @@ -339,14 +334,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -418,7 +413,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseLogs.java b/src/main/java/ai/reveng/model/BaseResponseLogs.java index f6621f20..97140c2b 100644 --- a/src/main/java/ai/reveng/model/BaseResponseLogs.java +++ b/src/main/java/ai/reveng/model/BaseResponseLogs.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.Logs; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseLogs data(@javax.annotation.Nullable Logs data) { } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseLogs message(@javax.annotation.Nullable String message) { } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseLogs addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseLogs.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseLogs is not found in the empty JSON string", BaseResponseLogs.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseLogs is not found in the empty JSON string", BaseResponseLogs.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti Logs.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseModelsResponse.java b/src/main/java/ai/reveng/model/BaseResponseModelsResponse.java index c7de16a6..4e11d27d 100644 --- a/src/main/java/ai/reveng/model/BaseResponseModelsResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseModelsResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; import ai.reveng.model.ModelsResponse; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseModelsResponse data(@javax.annotation.Nullable ModelsResponse } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseModelsResponse message(@javax.annotation.Nullable String mess } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseModelsResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseModelsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseModelsResponse is not found in the empty JSON string", BaseResponseModelsResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseModelsResponse is not found in the empty JSON string", BaseResponseModelsResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti ModelsResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseParams.java b/src/main/java/ai/reveng/model/BaseResponseParams.java index ab4fb98d..69be76d9 100644 --- a/src/main/java/ai/reveng/model/BaseResponseParams.java +++ b/src/main/java/ai/reveng/model/BaseResponseParams.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; import ai.reveng.model.Params; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseParams data(@javax.annotation.Nullable Params data) { } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseParams message(@javax.annotation.Nullable String message) { } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseParams addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseParams.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseParams is not found in the empty JSON string", BaseResponseParams.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseParams is not found in the empty JSON string", BaseResponseParams.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti Params.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseQueuedWorkflowTaskResponse.java b/src/main/java/ai/reveng/model/BaseResponseQueuedWorkflowTaskResponse.java index 39fe43c7..5a0764f6 100644 --- a/src/main/java/ai/reveng/model/BaseResponseQueuedWorkflowTaskResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseQueuedWorkflowTaskResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; import ai.reveng.model.QueuedWorkflowTaskResponse; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseQueuedWorkflowTaskResponse data(@javax.annotation.Nullable Qu } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseQueuedWorkflowTaskResponse message(@javax.annotation.Nullable } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseQueuedWorkflowTaskResponse addErrorsItem(ErrorModel errorsIte } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseQueuedWorkflowTaskResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseQueuedWorkflowTaskResponse is not found in the empty JSON string", BaseResponseQueuedWorkflowTaskResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseQueuedWorkflowTaskResponse is not found in the empty JSON string", BaseResponseQueuedWorkflowTaskResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti QueuedWorkflowTaskResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseRecent.java b/src/main/java/ai/reveng/model/BaseResponseRecent.java index e9cb6cfe..5d5270f9 100644 --- a/src/main/java/ai/reveng/model/BaseResponseRecent.java +++ b/src/main/java/ai/reveng/model/BaseResponseRecent.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; import ai.reveng.model.Recent; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseRecent data(@javax.annotation.Nullable Recent data) { } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseRecent message(@javax.annotation.Nullable String message) { } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseRecent addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseRecent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseRecent is not found in the empty JSON string", BaseResponseRecent.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseRecent is not found in the empty JSON string", BaseResponseRecent.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti Recent.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseReportAnalysisResponse.java b/src/main/java/ai/reveng/model/BaseResponseReportAnalysisResponse.java index f20f6a1d..9c8ee3d9 100644 --- a/src/main/java/ai/reveng/model/BaseResponseReportAnalysisResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseReportAnalysisResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; import ai.reveng.model.ReportAnalysisResponse; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseReportAnalysisResponse data(@javax.annotation.Nullable Report } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseReportAnalysisResponse message(@javax.annotation.Nullable Str } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseReportAnalysisResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseReportAnalysisResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseReportAnalysisResponse is not found in the empty JSON string", BaseResponseReportAnalysisResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseReportAnalysisResponse is not found in the empty JSON string", BaseResponseReportAnalysisResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti ReportAnalysisResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseStatus.java b/src/main/java/ai/reveng/model/BaseResponseStatus.java index 7cb6f866..fa22a4be 100644 --- a/src/main/java/ai/reveng/model/BaseResponseStatus.java +++ b/src/main/java/ai/reveng/model/BaseResponseStatus.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; import ai.reveng.model.StatusOutput; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseStatus data(@javax.annotation.Nullable StatusOutput data) { } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseStatus message(@javax.annotation.Nullable String message) { } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseStatus addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseStatus.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseStatus is not found in the empty JSON string", BaseResponseStatus.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseStatus is not found in the empty JSON string", BaseResponseStatus.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti StatusOutput.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseStr.java b/src/main/java/ai/reveng/model/BaseResponseStr.java index a0f9f09e..e708e56b 100644 --- a/src/main/java/ai/reveng/model/BaseResponseStr.java +++ b/src/main/java/ai/reveng/model/BaseResponseStr.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; import com.google.gson.TypeAdapter; @@ -47,7 +46,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -109,7 +107,7 @@ public BaseResponseStr data(@javax.annotation.Nullable String data) { } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -128,7 +126,7 @@ public BaseResponseStr message(@javax.annotation.Nullable String message) { } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -155,7 +153,7 @@ public BaseResponseStr addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -284,10 +282,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -311,22 +306,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseStr.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseStr is not found in the empty JSON string", BaseResponseStr.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseStr is not found in the empty JSON string", BaseResponseStr.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) && !jsonObj.get("data").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `data` to be a primitive type in the JSON string but got `%s`", jsonObj.get("data").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `data` to be a primitive type in the JSON string but got `%s`", jsonObj.get("data").toString())); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -398,7 +393,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseTagSearchResponse.java b/src/main/java/ai/reveng/model/BaseResponseTagSearchResponse.java index 9721d4f1..cd9ebbc5 100644 --- a/src/main/java/ai/reveng/model/BaseResponseTagSearchResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseTagSearchResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; import ai.reveng.model.TagSearchResponse; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseTagSearchResponse data(@javax.annotation.Nullable TagSearchRe } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseTagSearchResponse message(@javax.annotation.Nullable String m } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseTagSearchResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseTagSearchResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseTagSearchResponse is not found in the empty JSON string", BaseResponseTagSearchResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseTagSearchResponse is not found in the empty JSON string", BaseResponseTagSearchResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti TagSearchResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseTaskResponse.java b/src/main/java/ai/reveng/model/BaseResponseTaskResponse.java index 233993e1..5902e87d 100644 --- a/src/main/java/ai/reveng/model/BaseResponseTaskResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseTaskResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; import ai.reveng.model.TaskResponse; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseTaskResponse data(@javax.annotation.Nullable TaskResponse dat } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseTaskResponse message(@javax.annotation.Nullable String messag } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseTaskResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseTaskResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseTaskResponse is not found in the empty JSON string", BaseResponseTaskResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseTaskResponse is not found in the empty JSON string", BaseResponseTaskResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti TaskResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseTaskStatusResponse.java b/src/main/java/ai/reveng/model/BaseResponseTaskStatusResponse.java index db9c40d5..b27fead5 100644 --- a/src/main/java/ai/reveng/model/BaseResponseTaskStatusResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseTaskStatusResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; import ai.reveng.model.TaskStatusResponse; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseTaskStatusResponse data(@javax.annotation.Nullable TaskStatus } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseTaskStatusResponse message(@javax.annotation.Nullable String } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseTaskStatusResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseTaskStatusResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseTaskStatusResponse is not found in the empty JSON string", BaseResponseTaskStatusResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseTaskStatusResponse is not found in the empty JSON string", BaseResponseTaskStatusResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti TaskStatusResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseTriageReportResponse.java b/src/main/java/ai/reveng/model/BaseResponseTriageReportResponse.java index bfa894e1..06cbb3f2 100644 --- a/src/main/java/ai/reveng/model/BaseResponseTriageReportResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseTriageReportResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; import ai.reveng.model.TriageReportResponse; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseTriageReportResponse data(@javax.annotation.Nullable TriageRe } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseTriageReportResponse message(@javax.annotation.Nullable Strin } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseTriageReportResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseTriageReportResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseTriageReportResponse is not found in the empty JSON string", BaseResponseTriageReportResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseTriageReportResponse is not found in the empty JSON string", BaseResponseTriageReportResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti TriageReportResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseUnionGetAiDecompilationRatingResponseNoneType.java b/src/main/java/ai/reveng/model/BaseResponseUnionGetAiDecompilationRatingResponseNoneType.java index 21d02d2d..00240f56 100644 --- a/src/main/java/ai/reveng/model/BaseResponseUnionGetAiDecompilationRatingResponseNoneType.java +++ b/src/main/java/ai/reveng/model/BaseResponseUnionGetAiDecompilationRatingResponseNoneType.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.GetAiDecompilationRatingResponse; import ai.reveng.model.MetaModel; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseUnionGetAiDecompilationRatingResponseNoneType data(@javax.ann } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseUnionGetAiDecompilationRatingResponseNoneType message(@javax. } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseUnionGetAiDecompilationRatingResponseNoneType addErrorsItem(E } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseUnionGetAiDecompilationRatingResponseNoneType.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseUnionGetAiDecompilationRatingResponseNoneType is not found in the empty JSON string", BaseResponseUnionGetAiDecompilationRatingResponseNoneType.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseUnionGetAiDecompilationRatingResponseNoneType is not found in the empty JSON string", BaseResponseUnionGetAiDecompilationRatingResponseNoneType.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti GetAiDecompilationRatingResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseUploadResponse.java b/src/main/java/ai/reveng/model/BaseResponseUploadResponse.java index 4a0da469..c1c0ae92 100644 --- a/src/main/java/ai/reveng/model/BaseResponseUploadResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseUploadResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; import ai.reveng.model.UploadResponse; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseUploadResponse data(@javax.annotation.Nullable UploadResponse } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseUploadResponse message(@javax.annotation.Nullable String mess } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseUploadResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseUploadResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseUploadResponse is not found in the empty JSON string", BaseResponseUploadResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseUploadResponse is not found in the empty JSON string", BaseResponseUploadResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti UploadResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseVulnerabilities.java b/src/main/java/ai/reveng/model/BaseResponseVulnerabilities.java index f3030c49..9a55b1f4 100644 --- a/src/main/java/ai/reveng/model/BaseResponseVulnerabilities.java +++ b/src/main/java/ai/reveng/model/BaseResponseVulnerabilities.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; import ai.reveng.model.Vulnerabilities; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseVulnerabilities data(@javax.annotation.Nullable Vulnerabiliti } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseVulnerabilities message(@javax.annotation.Nullable String mes } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseVulnerabilities addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseVulnerabilities.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseVulnerabilities is not found in the empty JSON string", BaseResponseVulnerabilities.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseVulnerabilities is not found in the empty JSON string", BaseResponseVulnerabilities.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti Vulnerabilities.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BaseResponseXrefResponse.java b/src/main/java/ai/reveng/model/BaseResponseXrefResponse.java index 3ab0e7e5..1d77d616 100644 --- a/src/main/java/ai/reveng/model/BaseResponseXrefResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseXrefResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ErrorModel; import ai.reveng.model.MetaModel; import ai.reveng.model.XrefResponse; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -110,7 +108,7 @@ public BaseResponseXrefResponse data(@javax.annotation.Nullable XrefResponse dat } /** - * Get data + * Response data * @return data */ @javax.annotation.Nullable @@ -129,7 +127,7 @@ public BaseResponseXrefResponse message(@javax.annotation.Nullable String messag } /** - * Get message + * Response message * @return message */ @javax.annotation.Nullable @@ -156,7 +154,7 @@ public BaseResponseXrefResponse addErrorsItem(ErrorModel errorsItem) { } /** - * Get errors + * List of errors * @return errors */ @javax.annotation.Nullable @@ -285,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -312,7 +307,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BaseResponseXrefResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseXrefResponse is not found in the empty JSON string", BaseResponseXrefResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BaseResponseXrefResponse is not found in the empty JSON string", BaseResponseXrefResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -321,14 +316,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti XrefResponse.validateJsonElement(jsonObj.get("data")); } if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); if (jsonArrayerrors != null) { // ensure the json data is an array if (!jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } // validate the optional field `errors` (array) @@ -400,7 +395,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/Basic.java b/src/main/java/ai/reveng/model/Basic.java index e3749794..440ad698 100644 --- a/src/main/java/ai/reveng/model/Basic.java +++ b/src/main/java/ai/reveng/model/Basic.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -418,7 +416,7 @@ public Basic baseAddress(@javax.annotation.Nullable Integer baseAddress) { } /** - * Get baseAddress + * The base address of the binary * @return baseAddress */ @javax.annotation.Nullable @@ -437,7 +435,7 @@ public Basic binaryUuid(@javax.annotation.Nullable String binaryUuid) { } /** - * Get binaryUuid + * The UUID of the binary * @return binaryUuid */ @javax.annotation.Nullable @@ -456,7 +454,7 @@ public Basic sequencerVersion(@javax.annotation.Nullable String sequencerVersion } /** - * Get sequencerVersion + * The sequencer version used for analysis * @return sequencerVersion */ @javax.annotation.Nullable @@ -611,10 +609,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -638,37 +633,37 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Basic.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Basic is not found in the empty JSON string", Basic.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Basic is not found in the empty JSON string", Basic.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Basic.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("binary_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); } if (!jsonObj.get("sha_256_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); } if (!jsonObj.get("model_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); } if (!jsonObj.get("owner_username").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `owner_username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owner_username").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `owner_username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owner_username").toString())); } if (!jsonObj.get("analysis_scope").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `analysis_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("analysis_scope").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `analysis_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("analysis_scope").toString())); } if ((jsonObj.get("binary_uuid") != null && !jsonObj.get("binary_uuid").isJsonNull()) && !jsonObj.get("binary_uuid").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binary_uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_uuid").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binary_uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_uuid").toString())); } if ((jsonObj.get("sequencer_version") != null && !jsonObj.get("sequencer_version").isJsonNull()) && !jsonObj.get("sequencer_version").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sequencer_version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sequencer_version").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sequencer_version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sequencer_version").toString())); } } @@ -729,7 +724,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BatchRenameInputBody.java b/src/main/java/ai/reveng/model/BatchRenameInputBody.java index d6a5a9da..cb9213c6 100644 --- a/src/main/java/ai/reveng/model/BatchRenameInputBody.java +++ b/src/main/java/ai/reveng/model/BatchRenameInputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.BatchRenameItem; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -88,50 +86,6 @@ public void setFunctions(@javax.annotation.Nullable List functi this.functions = functions; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the BatchRenameInputBody instance itself - */ - public BatchRenameInputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -143,13 +97,12 @@ public boolean equals(Object o) { return false; } BatchRenameInputBody batchRenameInputBody = (BatchRenameInputBody) o; - return Objects.equals(this.functions, batchRenameInputBody.functions)&& - Objects.equals(this.additionalProperties, batchRenameInputBody.additionalProperties); + return Objects.equals(this.functions, batchRenameInputBody.functions); } @Override public int hashCode() { - return Objects.hash(functions, additionalProperties); + return Objects.hash(functions); } @Override @@ -157,7 +110,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class BatchRenameInputBody {\n"); sb.append(" functions: ").append(toIndentedString(functions)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,10 +119,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,22 +143,34 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BatchRenameInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BatchRenameInputBody is not found in the empty JSON string", BatchRenameInputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BatchRenameInputBody is not found in the empty JSON string", BatchRenameInputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!BatchRenameInputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BatchRenameInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BatchRenameInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the required json array is present - if (jsonObj.get("functions") == null) { - throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); - } else if (!jsonObj.get("functions").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); + if (jsonObj.get("functions") != null && !jsonObj.get("functions").isJsonNull()) { + if (!jsonObj.get("functions").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); + } + JsonArray jsonArrayfunctions = jsonObj.getAsJsonArray("functions"); + // validate the required field `functions` (array) + for (int i = 0; i < jsonArrayfunctions.size(); i++) { + BatchRenameItem.validateJsonElement(jsonArrayfunctions.get(i)); + } } } @@ -228,28 +189,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BatchRenameInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -257,28 +196,7 @@ else if (entry.getValue() instanceof Character) public BatchRenameInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - BatchRenameInputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/BatchRenameItem.java b/src/main/java/ai/reveng/model/BatchRenameItem.java index 2bb0924f..c19fb35e 100644 --- a/src/main/java/ai/reveng/model/BatchRenameItem.java +++ b/src/main/java/ai/reveng/model/BatchRenameItem.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -126,50 +124,6 @@ public void setNewName(@javax.annotation.Nonnull String newName) { this.newName = newName; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the BatchRenameItem instance itself - */ - public BatchRenameItem putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -183,13 +137,12 @@ public boolean equals(Object o) { BatchRenameItem batchRenameItem = (BatchRenameItem) o; return Objects.equals(this.functionId, batchRenameItem.functionId) && Objects.equals(this.newMangledName, batchRenameItem.newMangledName) && - Objects.equals(this.newName, batchRenameItem.newName)&& - Objects.equals(this.additionalProperties, batchRenameItem.additionalProperties); + Objects.equals(this.newName, batchRenameItem.newName); } @Override public int hashCode() { - return Objects.hash(functionId, newMangledName, newName, additionalProperties); + return Objects.hash(functionId, newMangledName, newName); } @Override @@ -199,7 +152,6 @@ public String toString() { sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); sb.append(" newMangledName: ").append(toIndentedString(newMangledName)).append("\n"); sb.append(" newName: ").append(toIndentedString(newName)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -209,10 +161,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -236,22 +185,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BatchRenameItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BatchRenameItem is not found in the empty JSON string", BatchRenameItem.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BatchRenameItem is not found in the empty JSON string", BatchRenameItem.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!BatchRenameItem.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BatchRenameItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BatchRenameItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("new_mangled_name") != null && !jsonObj.get("new_mangled_name").isJsonNull()) && !jsonObj.get("new_mangled_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `new_mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("new_mangled_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `new_mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("new_mangled_name").toString())); } if (!jsonObj.get("new_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `new_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("new_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `new_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("new_name").toString())); } } @@ -270,28 +227,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BatchRenameItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -299,28 +234,7 @@ else if (entry.getValue() instanceof Character) public BatchRenameItem read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - BatchRenameItem instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/BatchRenameOutputBody.java b/src/main/java/ai/reveng/model/BatchRenameOutputBody.java index b8f7cae9..b385d5a0 100644 --- a/src/main/java/ai/reveng/model/BatchRenameOutputBody.java +++ b/src/main/java/ai/reveng/model/BatchRenameOutputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -77,50 +75,6 @@ public void setRenamedCount(@javax.annotation.Nonnull Long renamedCount) { this.renamedCount = renamedCount; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the BatchRenameOutputBody instance itself - */ - public BatchRenameOutputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -132,13 +86,12 @@ public boolean equals(Object o) { return false; } BatchRenameOutputBody batchRenameOutputBody = (BatchRenameOutputBody) o; - return Objects.equals(this.renamedCount, batchRenameOutputBody.renamedCount)&& - Objects.equals(this.additionalProperties, batchRenameOutputBody.additionalProperties); + return Objects.equals(this.renamedCount, batchRenameOutputBody.renamedCount); } @Override public int hashCode() { - return Objects.hash(renamedCount, additionalProperties); + return Objects.hash(renamedCount); } @Override @@ -146,7 +99,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class BatchRenameOutputBody {\n"); sb.append(" renamedCount: ").append(toIndentedString(renamedCount)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -156,10 +108,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,14 +132,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BatchRenameOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BatchRenameOutputBody is not found in the empty JSON string", BatchRenameOutputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BatchRenameOutputBody is not found in the empty JSON string", BatchRenameOutputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!BatchRenameOutputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BatchRenameOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BatchRenameOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -211,28 +168,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BatchRenameOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -240,28 +175,7 @@ else if (entry.getValue() instanceof Character) public BatchRenameOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - BatchRenameOutputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/BinariesRelatedStatusResponse.java b/src/main/java/ai/reveng/model/BinariesRelatedStatusResponse.java index 7bb08652..f7be2fba 100644 --- a/src/main/java/ai/reveng/model/BinariesRelatedStatusResponse.java +++ b/src/main/java/ai/reveng/model/BinariesRelatedStatusResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -156,10 +154,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,19 +178,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BinariesRelatedStatusResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BinariesRelatedStatusResponse is not found in the empty JSON string", BinariesRelatedStatusResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BinariesRelatedStatusResponse is not found in the empty JSON string", BinariesRelatedStatusResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BinariesRelatedStatusResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); } } @@ -256,7 +251,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BinariesTaskStatus.java b/src/main/java/ai/reveng/model/BinariesTaskStatus.java index 0c23a85a..a988aaf8 100644 --- a/src/main/java/ai/reveng/model/BinariesTaskStatus.java +++ b/src/main/java/ai/reveng/model/BinariesTaskStatus.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/Binary.java b/src/main/java/ai/reveng/model/Binary.java index 9f53af9a..0af0b965 100644 --- a/src/main/java/ai/reveng/model/Binary.java +++ b/src/main/java/ai/reveng/model/Binary.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -222,50 +220,6 @@ public void setSha256Hash(@javax.annotation.Nonnull String sha256Hash) { this.sha256Hash = sha256Hash; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the Binary instance itself - */ - public Binary putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -283,13 +237,12 @@ public boolean equals(Object o) { Objects.equals(this.createdAt, binary.createdAt) && Objects.equals(this.isSystemAnalysis, binary.isSystemAnalysis) && Objects.equals(this.ownerId, binary.ownerId) && - Objects.equals(this.sha256Hash, binary.sha256Hash)&& - Objects.equals(this.additionalProperties, binary.additionalProperties); + Objects.equals(this.sha256Hash, binary.sha256Hash); } @Override public int hashCode() { - return Objects.hash(analysisId, binaryId, binaryName, createdAt, isSystemAnalysis, ownerId, sha256Hash, additionalProperties); + return Objects.hash(analysisId, binaryId, binaryName, createdAt, isSystemAnalysis, ownerId, sha256Hash); } @Override @@ -303,7 +256,6 @@ public String toString() { sb.append(" isSystemAnalysis: ").append(toIndentedString(isSystemAnalysis)).append("\n"); sb.append(" ownerId: ").append(toIndentedString(ownerId)).append("\n"); sb.append(" sha256Hash: ").append(toIndentedString(sha256Hash)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -313,10 +265,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -340,22 +289,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Binary.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Binary is not found in the empty JSON string", Binary.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Binary is not found in the empty JSON string", Binary.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!Binary.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Binary` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Binary.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("binary_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); } if (!jsonObj.get("sha_256_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); } } @@ -374,28 +331,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Binary value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -403,28 +338,7 @@ else if (entry.getValue() instanceof Character) public Binary read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - Binary instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/BinaryAdditionalDetailsDataResponse.java b/src/main/java/ai/reveng/model/BinaryAdditionalDetailsDataResponse.java index 3acb32a7..be4f7fd1 100644 --- a/src/main/java/ai/reveng/model/BinaryAdditionalDetailsDataResponse.java +++ b/src/main/java/ai/reveng/model/BinaryAdditionalDetailsDataResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ELFModel; import ai.reveng.model.FileMetadata; import ai.reveng.model.PEModel; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -223,10 +221,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -250,14 +245,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BinaryAdditionalDetailsDataResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BinaryAdditionalDetailsDataResponse is not found in the empty JSON string", BinaryAdditionalDetailsDataResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BinaryAdditionalDetailsDataResponse is not found in the empty JSON string", BinaryAdditionalDetailsDataResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BinaryAdditionalDetailsDataResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -330,7 +325,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BinaryAdditionalResponse.java b/src/main/java/ai/reveng/model/BinaryAdditionalResponse.java index 58fd1040..354eeed6 100644 --- a/src/main/java/ai/reveng/model/BinaryAdditionalResponse.java +++ b/src/main/java/ai/reveng/model/BinaryAdditionalResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.BinaryAdditionalDetailsDataResponse; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -222,10 +220,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -249,19 +244,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BinaryAdditionalResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BinaryAdditionalResponse is not found in the empty JSON string", BinaryAdditionalResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BinaryAdditionalResponse is not found in the empty JSON string", BinaryAdditionalResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BinaryAdditionalResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("details") != null && !jsonObj.get("details").isJsonNull()) { // validate the required field `details` BinaryAdditionalDetailsDataResponse.validateJsonElement(jsonObj.get("details")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -321,7 +318,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BinaryConfig.java b/src/main/java/ai/reveng/model/BinaryConfig.java index 50405c0a..34b6811e 100644 --- a/src/main/java/ai/reveng/model/BinaryConfig.java +++ b/src/main/java/ai/reveng/model/BinaryConfig.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FileFormat; import ai.reveng.model.ISA; import ai.reveng.model.Platform; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -79,7 +77,7 @@ public BinaryConfig isa(@javax.annotation.Nullable ISA isa) { } /** - * Get isa + * Instruction Set Architecture * @return isa */ @javax.annotation.Nullable @@ -223,10 +221,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -250,7 +245,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BinaryConfig.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BinaryConfig is not found in the empty JSON string", BinaryConfig.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BinaryConfig is not found in the empty JSON string", BinaryConfig.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -325,7 +320,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BinaryDetailsResponse.java b/src/main/java/ai/reveng/model/BinaryDetailsResponse.java index 52c68d77..8d2a2d3d 100644 --- a/src/main/java/ai/reveng/model/BinaryDetailsResponse.java +++ b/src/main/java/ai/reveng/model/BinaryDetailsResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -652,10 +650,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -679,55 +674,55 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BinaryDetailsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BinaryDetailsResponse is not found in the empty JSON string", BinaryDetailsResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BinaryDetailsResponse is not found in the empty JSON string", BinaryDetailsResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BinaryDetailsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("arch").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `arch` to be a primitive type in the JSON string but got `%s`", jsonObj.get("arch").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `arch` to be a primitive type in the JSON string but got `%s`", jsonObj.get("arch").toString())); } if (!jsonObj.get("crc32").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `crc32` to be a primitive type in the JSON string but got `%s`", jsonObj.get("crc32").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `crc32` to be a primitive type in the JSON string but got `%s`", jsonObj.get("crc32").toString())); } if (!jsonObj.get("Class").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `Class` to be a primitive type in the JSON string but got `%s`", jsonObj.get("Class").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `Class` to be a primitive type in the JSON string but got `%s`", jsonObj.get("Class").toString())); } if (!jsonObj.get("language").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `language` to be a primitive type in the JSON string but got `%s`", jsonObj.get("language").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `language` to be a primitive type in the JSON string but got `%s`", jsonObj.get("language").toString())); } if (!jsonObj.get("md5").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `md5` to be a primitive type in the JSON string but got `%s`", jsonObj.get("md5").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `md5` to be a primitive type in the JSON string but got `%s`", jsonObj.get("md5").toString())); } if (!jsonObj.get("machine").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `machine` to be a primitive type in the JSON string but got `%s`", jsonObj.get("machine").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `machine` to be a primitive type in the JSON string but got `%s`", jsonObj.get("machine").toString())); } if (!jsonObj.get("os").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `os` to be a primitive type in the JSON string but got `%s`", jsonObj.get("os").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `os` to be a primitive type in the JSON string but got `%s`", jsonObj.get("os").toString())); } if (!jsonObj.get("sha1").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha1` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha1").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha1` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha1").toString())); } if (!jsonObj.get("sha256").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha256` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha256").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha256` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha256").toString())); } if ((jsonObj.get("ssdeep") != null && !jsonObj.get("ssdeep").isJsonNull()) && !jsonObj.get("ssdeep").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `ssdeep` to be a primitive type in the JSON string but got `%s`", jsonObj.get("ssdeep").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `ssdeep` to be a primitive type in the JSON string but got `%s`", jsonObj.get("ssdeep").toString())); } if (!jsonObj.get("sub_sys").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sub_sys` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sub_sys").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sub_sys` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sub_sys").toString())); } if (!jsonObj.get("tlsh").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tlsh` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tlsh").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tlsh` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tlsh").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -788,7 +783,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BinaryExternalsResponse.java b/src/main/java/ai/reveng/model/BinaryExternalsResponse.java index af6c75ba..dfa3ede8 100644 --- a/src/main/java/ai/reveng/model/BinaryExternalsResponse.java +++ b/src/main/java/ai/reveng/model/BinaryExternalsResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -279,10 +277,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -306,19 +301,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BinaryExternalsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BinaryExternalsResponse is not found in the empty JSON string", BinaryExternalsResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BinaryExternalsResponse is not found in the empty JSON string", BinaryExternalsResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BinaryExternalsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("sha_256_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); } } @@ -379,7 +374,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BinarySearchResponse.java b/src/main/java/ai/reveng/model/BinarySearchResponse.java index cf99f9e9..2eb6adbe 100644 --- a/src/main/java/ai/reveng/model/BinarySearchResponse.java +++ b/src/main/java/ai/reveng/model/BinarySearchResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.BinarySearchResult; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -167,10 +165,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,27 +189,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BinarySearchResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BinarySearchResponse is not found in the empty JSON string", BinarySearchResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BinarySearchResponse is not found in the empty JSON string", BinarySearchResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BinarySearchResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("results").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); + if (jsonObj.get("results") != null) { + if (!jsonObj.get("results").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); + } + JsonArray jsonArrayresults = jsonObj.getAsJsonArray("results"); + // validate the required field `results` (array) + for (int i = 0; i < jsonArrayresults.size(); i++) { + BinarySearchResult.validateJsonElement(jsonArrayresults.get(i)); + } } - - JsonArray jsonArrayresults = jsonObj.getAsJsonArray("results"); - // validate the required field `results` (array) - for (int i = 0; i < jsonArrayresults.size(); i++) { - BinarySearchResult.validateJsonElement(jsonArrayresults.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -274,7 +269,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BinarySearchResult.java b/src/main/java/ai/reveng/model/BinarySearchResult.java index e678069d..610c3e24 100644 --- a/src/main/java/ai/reveng/model/BinarySearchResult.java +++ b/src/main/java/ai/reveng/model/BinarySearchResult.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -192,7 +190,7 @@ public BinarySearchResult addTagsItem(String tagsItem) { } /** - * Get tags + * The tags of the binary * @return tags */ @javax.annotation.Nullable @@ -375,10 +373,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -402,34 +397,34 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BinarySearchResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BinarySearchResult is not found in the empty JSON string", BinarySearchResult.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BinarySearchResult is not found in the empty JSON string", BinarySearchResult.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BinarySearchResult.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("binary_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); } if (!jsonObj.get("sha_256_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); } // ensure the required json array is present if (jsonObj.get("tags") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); - } else if (!jsonObj.get("tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + } else if (!jsonObj.get("tags").isJsonArray() && !jsonObj.get("tags").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); } if (!jsonObj.get("model_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); } if (!jsonObj.get("owned_by").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `owned_by` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owned_by").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `owned_by` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owned_by").toString())); } } @@ -490,7 +485,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/BinaryTaskStatus.java b/src/main/java/ai/reveng/model/BinaryTaskStatus.java index b8858b1c..d4fb4f57 100644 --- a/src/main/java/ai/reveng/model/BinaryTaskStatus.java +++ b/src/main/java/ai/reveng/model/BinaryTaskStatus.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/BulkDeleteAnalysesRequest.java b/src/main/java/ai/reveng/model/BulkDeleteAnalysesRequest.java index 578f3986..befbeedf 100644 --- a/src/main/java/ai/reveng/model/BulkDeleteAnalysesRequest.java +++ b/src/main/java/ai/reveng/model/BulkDeleteAnalysesRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -166,10 +164,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -193,14 +188,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BulkDeleteAnalysesRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BulkDeleteAnalysesRequest is not found in the empty JSON string", BulkDeleteAnalysesRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BulkDeleteAnalysesRequest is not found in the empty JSON string", BulkDeleteAnalysesRequest.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BulkDeleteAnalysesRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -208,7 +203,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("analysis_ids") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("analysis_ids").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `analysis_ids` to be an array in the JSON string but got `%s`", jsonObj.get("analysis_ids").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `analysis_ids` to be an array in the JSON string but got `%s`", jsonObj.get("analysis_ids").toString())); } } @@ -269,7 +264,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CalleeFunctionInfo.java b/src/main/java/ai/reveng/model/CalleeFunctionInfo.java index 88d351e6..c9ebc73a 100644 --- a/src/main/java/ai/reveng/model/CalleeFunctionInfo.java +++ b/src/main/java/ai/reveng/model/CalleeFunctionInfo.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -109,7 +107,7 @@ public CalleeFunctionInfo matchedFunctionId(@javax.annotation.Nullable Integer m } /** - * Get matchedFunctionId + * Unique identifier of the matched function * @return matchedFunctionId */ @javax.annotation.Nullable @@ -286,10 +284,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -313,25 +308,25 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CalleeFunctionInfo.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CalleeFunctionInfo is not found in the empty JSON string", CalleeFunctionInfo.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CalleeFunctionInfo is not found in the empty JSON string", CalleeFunctionInfo.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CalleeFunctionInfo.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("dashboard_url") != null && !jsonObj.get("dashboard_url").isJsonNull()) && !jsonObj.get("dashboard_url").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `dashboard_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("dashboard_url").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `dashboard_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("dashboard_url").toString())); } if (!jsonObj.get("callee_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `callee_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("callee_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `callee_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("callee_name").toString())); } if (!jsonObj.get("callee_vaddr").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `callee_vaddr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("callee_vaddr").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `callee_vaddr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("callee_vaddr").toString())); } } @@ -392,7 +387,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CalleesCallerFunctionsResponse.java b/src/main/java/ai/reveng/model/CalleesCallerFunctionsResponse.java index af2b1ce4..43f1aa58 100644 --- a/src/main/java/ai/reveng/model/CalleesCallerFunctionsResponse.java +++ b/src/main/java/ai/reveng/model/CalleesCallerFunctionsResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.CalleeFunctionInfo; import ai.reveng.model.CallerFunctionInfo; import com.google.gson.TypeAdapter; @@ -47,7 +46,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -229,10 +227,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -256,37 +251,37 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CalleesCallerFunctionsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CalleesCallerFunctionsResponse is not found in the empty JSON string", CalleesCallerFunctionsResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CalleesCallerFunctionsResponse is not found in the empty JSON string", CalleesCallerFunctionsResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CalleesCallerFunctionsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("callees").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `callees` to be an array in the JSON string but got `%s`", jsonObj.get("callees").toString())); + if (jsonObj.get("callees") != null) { + if (!jsonObj.get("callees").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `callees` to be an array in the JSON string but got `%s`", jsonObj.get("callees").toString())); + } + JsonArray jsonArraycallees = jsonObj.getAsJsonArray("callees"); + // validate the required field `callees` (array) + for (int i = 0; i < jsonArraycallees.size(); i++) { + CalleeFunctionInfo.validateJsonElement(jsonArraycallees.get(i)); + } } - - JsonArray jsonArraycallees = jsonObj.getAsJsonArray("callees"); - // validate the required field `callees` (array) - for (int i = 0; i < jsonArraycallees.size(); i++) { - CalleeFunctionInfo.validateJsonElement(jsonArraycallees.get(i)); - }; - // ensure the json data is an array - if (!jsonObj.get("callers").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `callers` to be an array in the JSON string but got `%s`", jsonObj.get("callers").toString())); + if (jsonObj.get("callers") != null) { + if (!jsonObj.get("callers").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `callers` to be an array in the JSON string but got `%s`", jsonObj.get("callers").toString())); + } + JsonArray jsonArraycallers = jsonObj.getAsJsonArray("callers"); + // validate the required field `callers` (array) + for (int i = 0; i < jsonArraycallers.size(); i++) { + CallerFunctionInfo.validateJsonElement(jsonArraycallers.get(i)); + } } - - JsonArray jsonArraycallers = jsonObj.getAsJsonArray("callers"); - // validate the required field `callers` (array) - for (int i = 0; i < jsonArraycallers.size(); i++) { - CallerFunctionInfo.validateJsonElement(jsonArraycallers.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -346,7 +341,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CallerFunctionInfo.java b/src/main/java/ai/reveng/model/CallerFunctionInfo.java index dc4e1cfe..61183111 100644 --- a/src/main/java/ai/reveng/model/CallerFunctionInfo.java +++ b/src/main/java/ai/reveng/model/CallerFunctionInfo.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -109,7 +107,7 @@ public CallerFunctionInfo matchedFunctionId(@javax.annotation.Nullable Integer m } /** - * Get matchedFunctionId + * Unique identifier of the matched function * @return matchedFunctionId */ @javax.annotation.Nullable @@ -286,10 +284,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -313,25 +308,25 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CallerFunctionInfo.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CallerFunctionInfo is not found in the empty JSON string", CallerFunctionInfo.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CallerFunctionInfo is not found in the empty JSON string", CallerFunctionInfo.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CallerFunctionInfo.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("dashboard_url") != null && !jsonObj.get("dashboard_url").isJsonNull()) && !jsonObj.get("dashboard_url").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `dashboard_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("dashboard_url").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `dashboard_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("dashboard_url").toString())); } if (!jsonObj.get("caller_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `caller_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("caller_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `caller_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("caller_name").toString())); } if (!jsonObj.get("caller_vaddr").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `caller_vaddr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("caller_vaddr").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `caller_vaddr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("caller_vaddr").toString())); } } @@ -392,7 +387,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/Capabilities.java b/src/main/java/ai/reveng/model/Capabilities.java index 4486d02f..762301e4 100644 --- a/src/main/java/ai/reveng/model/Capabilities.java +++ b/src/main/java/ai/reveng/model/Capabilities.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AppApiRestV2InfoTypesCapability; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -167,10 +165,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,27 +189,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Capabilities.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Capabilities is not found in the empty JSON string", Capabilities.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Capabilities is not found in the empty JSON string", Capabilities.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Capabilities.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("capabilities").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `capabilities` to be an array in the JSON string but got `%s`", jsonObj.get("capabilities").toString())); + if (jsonObj.get("capabilities") != null) { + if (!jsonObj.get("capabilities").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `capabilities` to be an array in the JSON string but got `%s`", jsonObj.get("capabilities").toString())); + } + JsonArray jsonArraycapabilities = jsonObj.getAsJsonArray("capabilities"); + // validate the required field `capabilities` (array) + for (int i = 0; i < jsonArraycapabilities.size(); i++) { + AppApiRestV2InfoTypesCapability.validateJsonElement(jsonArraycapabilities.get(i)); + } } - - JsonArray jsonArraycapabilities = jsonObj.getAsJsonArray("capabilities"); - // validate the required field `capabilities` (array) - for (int i = 0; i < jsonArraycapabilities.size(); i++) { - AppApiRestV2InfoTypesCapability.validateJsonElement(jsonArraycapabilities.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -274,7 +269,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CapabilitiesAgentResponse.java b/src/main/java/ai/reveng/model/CapabilitiesAgentResponse.java index 8ce15774..ba371855 100644 --- a/src/main/java/ai/reveng/model/CapabilitiesAgentResponse.java +++ b/src/main/java/ai/reveng/model/CapabilitiesAgentResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AppApiRestV2AgentSchemaCapability; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -167,10 +165,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,27 +189,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CapabilitiesAgentResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CapabilitiesAgentResponse is not found in the empty JSON string", CapabilitiesAgentResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CapabilitiesAgentResponse is not found in the empty JSON string", CapabilitiesAgentResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CapabilitiesAgentResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("capabilities").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `capabilities` to be an array in the JSON string but got `%s`", jsonObj.get("capabilities").toString())); + if (jsonObj.get("capabilities") != null) { + if (!jsonObj.get("capabilities").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `capabilities` to be an array in the JSON string but got `%s`", jsonObj.get("capabilities").toString())); + } + JsonArray jsonArraycapabilities = jsonObj.getAsJsonArray("capabilities"); + // validate the required field `capabilities` (array) + for (int i = 0; i < jsonArraycapabilities.size(); i++) { + AppApiRestV2AgentSchemaCapability.validateJsonElement(jsonArraycapabilities.get(i)); + } } - - JsonArray jsonArraycapabilities = jsonObj.getAsJsonArray("capabilities"); - // validate the required field `capabilities` (array) - for (int i = 0; i < jsonArraycapabilities.size(); i++) { - AppApiRestV2AgentSchemaCapability.validateJsonElement(jsonArraycapabilities.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -274,7 +269,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ChildBinariesResponse.java b/src/main/java/ai/reveng/model/ChildBinariesResponse.java index 53406563..1f40ed62 100644 --- a/src/main/java/ai/reveng/model/ChildBinariesResponse.java +++ b/src/main/java/ai/reveng/model/ChildBinariesResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.RelativeBinaryResponse; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -101,7 +99,7 @@ public ChildBinariesResponse parent(@javax.annotation.Nullable RelativeBinaryRes } /** - * Get parent + * Details of the parent binary if it exists * @return parent */ @javax.annotation.Nullable @@ -205,10 +203,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -232,27 +227,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ChildBinariesResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ChildBinariesResponse is not found in the empty JSON string", ChildBinariesResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ChildBinariesResponse is not found in the empty JSON string", ChildBinariesResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ChildBinariesResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("children").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `children` to be an array in the JSON string but got `%s`", jsonObj.get("children").toString())); + if (jsonObj.get("children") != null) { + if (!jsonObj.get("children").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `children` to be an array in the JSON string but got `%s`", jsonObj.get("children").toString())); + } + JsonArray jsonArraychildren = jsonObj.getAsJsonArray("children"); + // validate the required field `children` (array) + for (int i = 0; i < jsonArraychildren.size(); i++) { + RelativeBinaryResponse.validateJsonElement(jsonArraychildren.get(i)); + } } - - JsonArray jsonArraychildren = jsonObj.getAsJsonArray("children"); - // validate the required field `children` (array) - for (int i = 0; i < jsonArraychildren.size(); i++) { - RelativeBinaryResponse.validateJsonElement(jsonArraychildren.get(i)); - }; // validate the optional field `parent` if (jsonObj.get("parent") != null && !jsonObj.get("parent").isJsonNull()) { RelativeBinaryResponse.validateJsonElement(jsonObj.get("parent")); @@ -316,7 +311,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CodeSignatureModel.java b/src/main/java/ai/reveng/model/CodeSignatureModel.java index a5468a8f..77b984e3 100644 --- a/src/main/java/ai/reveng/model/CodeSignatureModel.java +++ b/src/main/java/ai/reveng/model/CodeSignatureModel.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SingleCodeSignatureModel; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -219,10 +217,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -246,27 +241,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CodeSignatureModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CodeSignatureModel is not found in the empty JSON string", CodeSignatureModel.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CodeSignatureModel is not found in the empty JSON string", CodeSignatureModel.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CodeSignatureModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("signatures").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `signatures` to be an array in the JSON string but got `%s`", jsonObj.get("signatures").toString())); + if (jsonObj.get("signatures") != null) { + if (!jsonObj.get("signatures").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `signatures` to be an array in the JSON string but got `%s`", jsonObj.get("signatures").toString())); + } + JsonArray jsonArraysignatures = jsonObj.getAsJsonArray("signatures"); + // validate the required field `signatures` (array) + for (int i = 0; i < jsonArraysignatures.size(); i++) { + SingleCodeSignatureModel.validateJsonElement(jsonArraysignatures.get(i)); + } } - - JsonArray jsonArraysignatures = jsonObj.getAsJsonArray("signatures"); - // validate the required field `signatures` (array) - for (int i = 0; i < jsonArraysignatures.size(); i++) { - SingleCodeSignatureModel.validateJsonElement(jsonArraysignatures.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -326,7 +321,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CollectionBinariesUpdateRequest.java b/src/main/java/ai/reveng/model/CollectionBinariesUpdateRequest.java index 3fcd6717..8c835af8 100644 --- a/src/main/java/ai/reveng/model/CollectionBinariesUpdateRequest.java +++ b/src/main/java/ai/reveng/model/CollectionBinariesUpdateRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -166,10 +164,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -193,14 +188,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CollectionBinariesUpdateRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CollectionBinariesUpdateRequest is not found in the empty JSON string", CollectionBinariesUpdateRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CollectionBinariesUpdateRequest is not found in the empty JSON string", CollectionBinariesUpdateRequest.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionBinariesUpdateRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -208,7 +203,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("binaries") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("binaries").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); } } @@ -269,7 +264,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CollectionBinariesUpdateResponse.java b/src/main/java/ai/reveng/model/CollectionBinariesUpdateResponse.java index f36530a4..94b6074c 100644 --- a/src/main/java/ai/reveng/model/CollectionBinariesUpdateResponse.java +++ b/src/main/java/ai/reveng/model/CollectionBinariesUpdateResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.CollectionBinaryResponse; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -167,10 +165,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,27 +189,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CollectionBinariesUpdateResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CollectionBinariesUpdateResponse is not found in the empty JSON string", CollectionBinariesUpdateResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CollectionBinariesUpdateResponse is not found in the empty JSON string", CollectionBinariesUpdateResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionBinariesUpdateResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("binaries").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); + if (jsonObj.get("binaries") != null) { + if (!jsonObj.get("binaries").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); + } + JsonArray jsonArraybinaries = jsonObj.getAsJsonArray("binaries"); + // validate the required field `binaries` (array) + for (int i = 0; i < jsonArraybinaries.size(); i++) { + CollectionBinaryResponse.validateJsonElement(jsonArraybinaries.get(i)); + } } - - JsonArray jsonArraybinaries = jsonObj.getAsJsonArray("binaries"); - // validate the required field `binaries` (array) - for (int i = 0; i < jsonArraybinaries.size(); i++) { - CollectionBinaryResponse.validateJsonElement(jsonArraybinaries.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -274,7 +269,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CollectionBinaryResponse.java b/src/main/java/ai/reveng/model/CollectionBinaryResponse.java index c05cc4df..4b98ba3a 100644 --- a/src/main/java/ai/reveng/model/CollectionBinaryResponse.java +++ b/src/main/java/ai/reveng/model/CollectionBinaryResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -313,10 +311,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -340,22 +335,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CollectionBinaryResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CollectionBinaryResponse is not found in the empty JSON string", CollectionBinaryResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CollectionBinaryResponse is not found in the empty JSON string", CollectionBinaryResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionBinaryResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("binary_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); } if (!jsonObj.get("sha_256_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); } } @@ -416,7 +411,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CollectionCreateRequest.java b/src/main/java/ai/reveng/model/CollectionCreateRequest.java index 4f5ea2ff..6d13104c 100644 --- a/src/main/java/ai/reveng/model/CollectionCreateRequest.java +++ b/src/main/java/ai/reveng/model/CollectionCreateRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.CollectionScope; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -68,7 +66,7 @@ public class CollectionCreateRequest { public static final String SERIALIZED_NAME_COLLECTION_SCOPE = "collection_scope"; @SerializedName(SERIALIZED_NAME_COLLECTION_SCOPE) @javax.annotation.Nullable - private CollectionScope collectionScope; + private CollectionScope collectionScope = CollectionScope.PRIVATE; public static final String SERIALIZED_NAME_TAGS = "tags"; @SerializedName(SERIALIZED_NAME_TAGS) @@ -317,10 +315,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -344,22 +339,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CollectionCreateRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CollectionCreateRequest is not found in the empty JSON string", CollectionCreateRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CollectionCreateRequest is not found in the empty JSON string", CollectionCreateRequest.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionCreateRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("collection_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); } if (!jsonObj.get("description").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); } // validate the optional field `collection_scope` if (jsonObj.get("collection_scope") != null && !jsonObj.get("collection_scope").isJsonNull()) { @@ -367,11 +362,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } // ensure the optional json data is an array if present if (jsonObj.get("tags") != null && !jsonObj.get("tags").isJsonNull() && !jsonObj.get("tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); } // ensure the optional json data is an array if present if (jsonObj.get("binaries") != null && !jsonObj.get("binaries").isJsonNull() && !jsonObj.get("binaries").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); } } @@ -432,7 +427,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CollectionListItem.java b/src/main/java/ai/reveng/model/CollectionListItem.java index c5e131fc..b320236a 100644 --- a/src/main/java/ai/reveng/model/CollectionListItem.java +++ b/src/main/java/ai/reveng/model/CollectionListItem.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -317,7 +315,7 @@ public CollectionListItem teamId(@javax.annotation.Nullable Integer teamId) { } /** - * Get teamId + * The team ID for the collection * @return teamId */ @javax.annotation.Nullable @@ -439,10 +437,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -466,35 +461,35 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CollectionListItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CollectionListItem is not found in the empty JSON string", CollectionListItem.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CollectionListItem is not found in the empty JSON string", CollectionListItem.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionListItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("collection_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); } if (!jsonObj.get("description").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); } if (!jsonObj.get("collection_scope").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_scope").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_scope").toString())); } if (!jsonObj.get("collection_owner").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_owner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_owner").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_owner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_owner").toString())); } // ensure the optional json data is an array if present if (jsonObj.get("collection_tags") != null && !jsonObj.get("collection_tags").isJsonNull() && !jsonObj.get("collection_tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_tags` to be an array in the JSON string but got `%s`", jsonObj.get("collection_tags").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_tags` to be an array in the JSON string but got `%s`", jsonObj.get("collection_tags").toString())); } if (!jsonObj.get("model_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); } } @@ -555,7 +550,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CollectionListItemBody.java b/src/main/java/ai/reveng/model/CollectionListItemBody.java index 3526c69a..a021e587 100644 --- a/src/main/java/ai/reveng/model/CollectionListItemBody.java +++ b/src/main/java/ai/reveng/model/CollectionListItemBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -328,50 +326,6 @@ public void setTeamId(@javax.annotation.Nonnull Long teamId) { this.teamId = teamId; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the CollectionListItemBody instance itself - */ - public CollectionListItemBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -393,13 +347,12 @@ public boolean equals(Object o) { Objects.equals(this.description, collectionListItemBody.description) && Objects.equals(this.modelName, collectionListItemBody.modelName) && Objects.equals(this.officialCollection, collectionListItemBody.officialCollection) && - Objects.equals(this.teamId, collectionListItemBody.teamId)&& - Objects.equals(this.additionalProperties, collectionListItemBody.additionalProperties); + Objects.equals(this.teamId, collectionListItemBody.teamId); } @Override public int hashCode() { - return Objects.hash(collectionId, collectionName, collectionOwner, collectionScope, collectionSize, collectionTags, creation, description, modelName, officialCollection, teamId, additionalProperties); + return Objects.hash(collectionId, collectionName, collectionOwner, collectionScope, collectionSize, collectionTags, creation, description, modelName, officialCollection, teamId); } @Override @@ -417,7 +370,6 @@ public String toString() { sb.append(" modelName: ").append(toIndentedString(modelName)).append("\n"); sb.append(" officialCollection: ").append(toIndentedString(officialCollection)).append("\n"); sb.append(" teamId: ").append(toIndentedString(teamId)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -427,10 +379,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -454,37 +403,45 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CollectionListItemBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CollectionListItemBody is not found in the empty JSON string", CollectionListItemBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CollectionListItemBody is not found in the empty JSON string", CollectionListItemBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CollectionListItemBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CollectionListItemBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionListItemBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("collection_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); } if (!jsonObj.get("collection_owner").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_owner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_owner").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_owner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_owner").toString())); } if (!jsonObj.get("collection_scope").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_scope").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_scope").toString())); } // ensure the required json array is present if (jsonObj.get("collection_tags") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); - } else if (!jsonObj.get("collection_tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_tags` to be an array in the JSON string but got `%s`", jsonObj.get("collection_tags").toString())); + } else if (!jsonObj.get("collection_tags").isJsonArray() && !jsonObj.get("collection_tags").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_tags` to be an array in the JSON string but got `%s`", jsonObj.get("collection_tags").toString())); } if (!jsonObj.get("description").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); } if (!jsonObj.get("model_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); } } @@ -503,28 +460,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CollectionListItemBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -532,28 +467,7 @@ else if (entry.getValue() instanceof Character) public CollectionListItemBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - CollectionListItemBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CollectionResponse.java b/src/main/java/ai/reveng/model/CollectionResponse.java index 06b89975..4dc6877f 100644 --- a/src/main/java/ai/reveng/model/CollectionResponse.java +++ b/src/main/java/ai/reveng/model/CollectionResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.CollectionResponseBinariesInner; import ai.reveng.model.CollectionScope; import com.google.gson.TypeAdapter; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -216,7 +214,7 @@ public CollectionResponse teamId(@javax.annotation.Nullable Integer teamId) { } /** - * Get teamId + * Collection team ID * @return teamId */ @javax.annotation.Nullable @@ -300,7 +298,7 @@ public CollectionResponse addTagsItem(String tagsItem) { } /** - * Get tags + * Collection tags * @return tags */ @javax.annotation.Nullable @@ -327,7 +325,7 @@ public CollectionResponse addBinariesItem(CollectionResponseBinariesInner binari } /** - * Get binaries + * Collection binaries * @return binaries */ @javax.annotation.Nullable @@ -449,10 +447,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -476,35 +471,35 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CollectionResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CollectionResponse is not found in the empty JSON string", CollectionResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CollectionResponse is not found in the empty JSON string", CollectionResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("collection_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); } if (!jsonObj.get("description").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); } // validate the required field `collection_scope` CollectionScope.validateJsonElement(jsonObj.get("collection_scope")); // ensure the optional json data is an array if present if (jsonObj.get("tags") != null && !jsonObj.get("tags").isJsonNull() && !jsonObj.get("tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); } if (jsonObj.get("binaries") != null && !jsonObj.get("binaries").isJsonNull()) { JsonArray jsonArraybinaries = jsonObj.getAsJsonArray("binaries"); if (jsonArraybinaries != null) { // ensure the json data is an array if (!jsonObj.get("binaries").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); } // validate the optional field `binaries` (array) @@ -572,7 +567,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CollectionResponseBinariesInner.java b/src/main/java/ai/reveng/model/CollectionResponseBinariesInner.java index 18396f91..14473f6d 100644 --- a/src/main/java/ai/reveng/model/CollectionResponseBinariesInner.java +++ b/src/main/java/ai/reveng/model/CollectionResponseBinariesInner.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.CollectionBinaryResponse; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -36,7 +35,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Locale; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -110,7 +108,7 @@ public CollectionResponseBinariesInner read(JsonReader in) throws IOException { try { // validate the JSON object to see if any exception is thrown if (!jsonElement.getAsJsonPrimitive().isNumber()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString())); } actualAdapter = adapterInteger; CollectionResponseBinariesInner ret = new CollectionResponseBinariesInner(); @@ -118,7 +116,7 @@ public CollectionResponseBinariesInner read(JsonReader in) throws IOException { return ret; } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for Integer failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for Integer failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'Integer'", e); } // deserialize CollectionBinaryResponse @@ -131,11 +129,11 @@ public CollectionResponseBinariesInner read(JsonReader in) throws IOException { return ret; } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for CollectionBinaryResponse failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for CollectionBinaryResponse failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'CollectionBinaryResponse'", e); } - throw new IOException(String.format(Locale.ROOT, "Failed deserialization for CollectionResponseBinariesInner: no class matches result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); + throw new IOException(String.format(java.util.Locale.ROOT, "Failed deserialization for CollectionResponseBinariesInner: no class matches result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); } }.nullSafe(); } @@ -231,11 +229,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the json string with Integer try { if (!jsonElement.getAsJsonPrimitive().isNumber()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString())); } return; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for Integer failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for Integer failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with CollectionBinaryResponse @@ -243,10 +241,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti CollectionBinaryResponse.validateJsonElement(jsonElement); return; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for CollectionBinaryResponse failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for CollectionBinaryResponse failed with `%s`.", e.getMessage())); // continue to the next one } - throw new IOException(String.format(Locale.ROOT, "The JSON string is invalid for CollectionResponseBinariesInner with anyOf schemas: CollectionBinaryResponse, Integer. no class match the result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); + throw new IOException(String.format(java.util.Locale.ROOT, "The JSON string is invalid for CollectionResponseBinariesInner with anyOf schemas: CollectionBinaryResponse, Integer. no class match the result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); } /** diff --git a/src/main/java/ai/reveng/model/CollectionScope.java b/src/main/java/ai/reveng/model/CollectionScope.java index a98f353b..34267cb6 100644 --- a/src/main/java/ai/reveng/model/CollectionScope.java +++ b/src/main/java/ai/reveng/model/CollectionScope.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/CollectionSearchResponse.java b/src/main/java/ai/reveng/model/CollectionSearchResponse.java index 1fcca2c5..15ab5b6e 100644 --- a/src/main/java/ai/reveng/model/CollectionSearchResponse.java +++ b/src/main/java/ai/reveng/model/CollectionSearchResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.CollectionSearchResult; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -167,10 +165,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,27 +189,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CollectionSearchResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CollectionSearchResponse is not found in the empty JSON string", CollectionSearchResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CollectionSearchResponse is not found in the empty JSON string", CollectionSearchResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionSearchResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("results").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); + if (jsonObj.get("results") != null) { + if (!jsonObj.get("results").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); + } + JsonArray jsonArrayresults = jsonObj.getAsJsonArray("results"); + // validate the required field `results` (array) + for (int i = 0; i < jsonArrayresults.size(); i++) { + CollectionSearchResult.validateJsonElement(jsonArrayresults.get(i)); + } } - - JsonArray jsonArrayresults = jsonObj.getAsJsonArray("results"); - // validate the required field `results` (array) - for (int i = 0; i < jsonArrayresults.size(); i++) { - CollectionSearchResult.validateJsonElement(jsonArrayresults.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -274,7 +269,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CollectionSearchResult.java b/src/main/java/ai/reveng/model/CollectionSearchResult.java index f6ab08ad..afd2170d 100644 --- a/src/main/java/ai/reveng/model/CollectionSearchResult.java +++ b/src/main/java/ai/reveng/model/CollectionSearchResult.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -284,7 +282,7 @@ public CollectionSearchResult addTagsItem(String tagsItem) { } /** - * Get tags + * The tags of the collection * @return tags */ @javax.annotation.Nullable @@ -303,7 +301,7 @@ public CollectionSearchResult size(@javax.annotation.Nullable Integer size) { } /** - * Get size + * The number of binaries in the collection * @return size */ @javax.annotation.Nullable @@ -341,7 +339,7 @@ public CollectionSearchResult teamId(@javax.annotation.Nullable Integer teamId) } /** - * Get teamId + * The team ID of the collection * @return teamId */ @javax.annotation.Nullable @@ -465,10 +463,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -492,35 +487,35 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CollectionSearchResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CollectionSearchResult is not found in the empty JSON string", CollectionSearchResult.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CollectionSearchResult is not found in the empty JSON string", CollectionSearchResult.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionSearchResult.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("collection_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); } if (!jsonObj.get("scope").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("scope").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("scope").toString())); } if (!jsonObj.get("model_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); } if (!jsonObj.get("owned_by").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `owned_by` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owned_by").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `owned_by` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owned_by").toString())); } // ensure the optional json data is an array if present if (jsonObj.get("tags") != null && !jsonObj.get("tags").isJsonNull() && !jsonObj.get("tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); } if (!jsonObj.get("description").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); } } @@ -581,7 +576,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CollectionTagsUpdateRequest.java b/src/main/java/ai/reveng/model/CollectionTagsUpdateRequest.java index 0ed15d02..445f4d19 100644 --- a/src/main/java/ai/reveng/model/CollectionTagsUpdateRequest.java +++ b/src/main/java/ai/reveng/model/CollectionTagsUpdateRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -166,10 +164,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -193,14 +188,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CollectionTagsUpdateRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CollectionTagsUpdateRequest is not found in the empty JSON string", CollectionTagsUpdateRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CollectionTagsUpdateRequest is not found in the empty JSON string", CollectionTagsUpdateRequest.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionTagsUpdateRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -208,7 +203,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("tags") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); } } @@ -269,7 +264,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CollectionTagsUpdateResponse.java b/src/main/java/ai/reveng/model/CollectionTagsUpdateResponse.java index cd56e847..c88441db 100644 --- a/src/main/java/ai/reveng/model/CollectionTagsUpdateResponse.java +++ b/src/main/java/ai/reveng/model/CollectionTagsUpdateResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -166,10 +164,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -193,14 +188,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CollectionTagsUpdateResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CollectionTagsUpdateResponse is not found in the empty JSON string", CollectionTagsUpdateResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CollectionTagsUpdateResponse is not found in the empty JSON string", CollectionTagsUpdateResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionTagsUpdateResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -208,7 +203,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("tags") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); } } @@ -269,7 +264,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CollectionUpdateRequest.java b/src/main/java/ai/reveng/model/CollectionUpdateRequest.java index a5a31945..0ab1907d 100644 --- a/src/main/java/ai/reveng/model/CollectionUpdateRequest.java +++ b/src/main/java/ai/reveng/model/CollectionUpdateRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.CollectionScope; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -221,10 +219,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -248,15 +243,15 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CollectionUpdateRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CollectionUpdateRequest is not found in the empty JSON string", CollectionUpdateRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CollectionUpdateRequest is not found in the empty JSON string", CollectionUpdateRequest.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("collection_name") != null && !jsonObj.get("collection_name").isJsonNull()) && !jsonObj.get("collection_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); } if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); } // validate the optional field `collection_scope` if (jsonObj.get("collection_scope") != null && !jsonObj.get("collection_scope").isJsonNull()) { @@ -321,7 +316,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CommentBase.java b/src/main/java/ai/reveng/model/CommentBase.java index 43259c60..a4b179d7 100644 --- a/src/main/java/ai/reveng/model/CommentBase.java +++ b/src/main/java/ai/reveng/model/CommentBase.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -156,10 +154,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,19 +178,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CommentBase.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CommentBase is not found in the empty JSON string", CommentBase.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CommentBase is not found in the empty JSON string", CommentBase.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentBase.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("content").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `content` to be a primitive type in the JSON string but got `%s`", jsonObj.get("content").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `content` to be a primitive type in the JSON string but got `%s`", jsonObj.get("content").toString())); } } @@ -256,7 +251,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CommentResponse.java b/src/main/java/ai/reveng/model/CommentResponse.java index b424003b..9aaee85c 100644 --- a/src/main/java/ai/reveng/model/CommentResponse.java +++ b/src/main/java/ai/reveng/model/CommentResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.Context; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -352,10 +350,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -379,25 +374,25 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CommentResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CommentResponse is not found in the empty JSON string", CommentResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CommentResponse is not found in the empty JSON string", CommentResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("content").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `content` to be a primitive type in the JSON string but got `%s`", jsonObj.get("content").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `content` to be a primitive type in the JSON string but got `%s`", jsonObj.get("content").toString())); } if (!jsonObj.get("resource_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `resource_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("resource_type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `resource_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("resource_type").toString())); } if (!jsonObj.get("resource_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `resource_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("resource_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `resource_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("resource_id").toString())); } // validate the optional field `context` if (jsonObj.get("context") != null && !jsonObj.get("context").isJsonNull()) { @@ -462,7 +457,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CommentUpdateRequest.java b/src/main/java/ai/reveng/model/CommentUpdateRequest.java index 35049396..50ad24dd 100644 --- a/src/main/java/ai/reveng/model/CommentUpdateRequest.java +++ b/src/main/java/ai/reveng/model/CommentUpdateRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -156,10 +154,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,19 +178,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CommentUpdateRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CommentUpdateRequest is not found in the empty JSON string", CommentUpdateRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CommentUpdateRequest is not found in the empty JSON string", CommentUpdateRequest.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentUpdateRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("content").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `content` to be a primitive type in the JSON string but got `%s`", jsonObj.get("content").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `content` to be a primitive type in the JSON string but got `%s`", jsonObj.get("content").toString())); } } @@ -256,7 +251,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CommentsData.java b/src/main/java/ai/reveng/model/CommentsData.java index fda10805..1bcfb1f1 100644 --- a/src/main/java/ai/reveng/model/CommentsData.java +++ b/src/main/java/ai/reveng/model/CommentsData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.InlineComment; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -168,50 +166,6 @@ public void setTaskStatus(@javax.annotation.Nonnull TaskStatusEnum taskStatus) { this.taskStatus = taskStatus; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the CommentsData instance itself - */ - public CommentsData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -224,13 +178,12 @@ public boolean equals(Object o) { } CommentsData commentsData = (CommentsData) o; return Objects.equals(this.inlineComments, commentsData.inlineComments) && - Objects.equals(this.taskStatus, commentsData.taskStatus)&& - Objects.equals(this.additionalProperties, commentsData.additionalProperties); + Objects.equals(this.taskStatus, commentsData.taskStatus); } @Override public int hashCode() { - return Objects.hash(inlineComments, taskStatus, additionalProperties); + return Objects.hash(inlineComments, taskStatus); } @Override @@ -239,7 +192,6 @@ public String toString() { sb.append("class CommentsData {\n"); sb.append(" inlineComments: ").append(toIndentedString(inlineComments)).append("\n"); sb.append(" taskStatus: ").append(toIndentedString(taskStatus)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -249,10 +201,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -276,25 +225,37 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CommentsData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CommentsData is not found in the empty JSON string", CommentsData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CommentsData is not found in the empty JSON string", CommentsData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CommentsData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentsData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentsData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the required json array is present - if (jsonObj.get("inline_comments") == null) { - throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); - } else if (!jsonObj.get("inline_comments").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `inline_comments` to be an array in the JSON string but got `%s`", jsonObj.get("inline_comments").toString())); + if (jsonObj.get("inline_comments") != null && !jsonObj.get("inline_comments").isJsonNull()) { + if (!jsonObj.get("inline_comments").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `inline_comments` to be an array in the JSON string but got `%s`", jsonObj.get("inline_comments").toString())); + } + JsonArray jsonArrayinlineComments = jsonObj.getAsJsonArray("inline_comments"); + // validate the required field `inline_comments` (array) + for (int i = 0; i < jsonArrayinlineComments.size(); i++) { + InlineComment.validateJsonElement(jsonArrayinlineComments.get(i)); + } } if (!jsonObj.get("task_status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `task_status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("task_status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `task_status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("task_status").toString())); } // validate the required field `task_status` TaskStatusEnum.validateJsonElement(jsonObj.get("task_status")); @@ -315,28 +276,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentsData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -344,28 +283,7 @@ else if (entry.getValue() instanceof Character) public CommentsData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - CommentsData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ConfigResponse.java b/src/main/java/ai/reveng/model/ConfigResponse.java index 0d59c416..7448c377 100644 --- a/src/main/java/ai/reveng/model/ConfigResponse.java +++ b/src/main/java/ai/reveng/model/ConfigResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -252,10 +250,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -279,31 +274,31 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ConfigResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ConfigResponse is not found in the empty JSON string", ConfigResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ConfigResponse is not found in the empty JSON string", ConfigResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ConfigResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("dashboard_url") != null && !jsonObj.get("dashboard_url").isJsonNull()) && !jsonObj.get("dashboard_url").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `dashboard_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("dashboard_url").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `dashboard_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("dashboard_url").toString())); } // ensure the required json array is present if (jsonObj.get("ai_decompiler_unsupported_languages") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("ai_decompiler_unsupported_languages").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `ai_decompiler_unsupported_languages` to be an array in the JSON string but got `%s`", jsonObj.get("ai_decompiler_unsupported_languages").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `ai_decompiler_unsupported_languages` to be an array in the JSON string but got `%s`", jsonObj.get("ai_decompiler_unsupported_languages").toString())); } // ensure the required json array is present if (jsonObj.get("ai_decompiler_supported_models") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("ai_decompiler_supported_models").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `ai_decompiler_supported_models` to be an array in the JSON string but got `%s`", jsonObj.get("ai_decompiler_supported_models").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `ai_decompiler_supported_models` to be an array in the JSON string but got `%s`", jsonObj.get("ai_decompiler_supported_models").toString())); } } @@ -364,7 +359,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ConfirmToolInputBody.java b/src/main/java/ai/reveng/model/ConfirmToolInputBody.java index 8dd5f91e..9f12cdb9 100644 --- a/src/main/java/ai/reveng/model/ConfirmToolInputBody.java +++ b/src/main/java/ai/reveng/model/ConfirmToolInputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -77,50 +75,6 @@ public void setApproved(@javax.annotation.Nonnull Boolean approved) { this.approved = approved; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ConfirmToolInputBody instance itself - */ - public ConfirmToolInputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -132,13 +86,12 @@ public boolean equals(Object o) { return false; } ConfirmToolInputBody confirmToolInputBody = (ConfirmToolInputBody) o; - return Objects.equals(this.approved, confirmToolInputBody.approved)&& - Objects.equals(this.additionalProperties, confirmToolInputBody.additionalProperties); + return Objects.equals(this.approved, confirmToolInputBody.approved); } @Override public int hashCode() { - return Objects.hash(approved, additionalProperties); + return Objects.hash(approved); } @Override @@ -146,7 +99,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ConfirmToolInputBody {\n"); sb.append(" approved: ").append(toIndentedString(approved)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -156,10 +108,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,14 +132,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ConfirmToolInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ConfirmToolInputBody is not found in the empty JSON string", ConfirmToolInputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ConfirmToolInputBody is not found in the empty JSON string", ConfirmToolInputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ConfirmToolInputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ConfirmToolInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ConfirmToolInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -211,28 +168,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ConfirmToolInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -240,28 +175,7 @@ else if (entry.getValue() instanceof Character) public ConfirmToolInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ConfirmToolInputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/Connection.java b/src/main/java/ai/reveng/model/Connection.java index 7e784660..db0e63bd 100644 --- a/src/main/java/ai/reveng/model/Connection.java +++ b/src/main/java/ai/reveng/model/Connection.java @@ -13,8 +13,8 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ReportEvent; +import ai.reveng.model.TcpCarvedFile; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -46,7 +46,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -55,14 +54,34 @@ */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Connection { + public static final String SERIALIZED_NAME_BYTES_RECEIVED = "bytes_received"; + @SerializedName(SERIALIZED_NAME_BYTES_RECEIVED) + @javax.annotation.Nullable + private Long bytesReceived; + + public static final String SERIALIZED_NAME_BYTES_SENT = "bytes_sent"; + @SerializedName(SERIALIZED_NAME_BYTES_SENT) + @javax.annotation.Nullable + private Long bytesSent; + public static final String SERIALIZED_NAME_EVENTS = "events"; @SerializedName(SERIALIZED_NAME_EVENTS) @javax.annotation.Nullable private List events; + public static final String SERIALIZED_NAME_JA3 = "ja3"; + @SerializedName(SERIALIZED_NAME_JA3) + @javax.annotation.Nullable + private String ja3; + + public static final String SERIALIZED_NAME_JA3S = "ja3s"; + @SerializedName(SERIALIZED_NAME_JA3S) + @javax.annotation.Nullable + private String ja3s; + public static final String SERIALIZED_NAME_LOCAL_IP = "local_ip"; @SerializedName(SERIALIZED_NAME_LOCAL_IP) - @javax.annotation.Nullable + @javax.annotation.Nonnull private String localIp; public static final String SERIALIZED_NAME_LOCAL_PORT = "local_port"; @@ -72,12 +91,12 @@ public class Connection { public static final String SERIALIZED_NAME_PROTOCOL = "protocol"; @SerializedName(SERIALIZED_NAME_PROTOCOL) - @javax.annotation.Nullable + @javax.annotation.Nonnull private String protocol; public static final String SERIALIZED_NAME_REMOTE_IP = "remote_ip"; @SerializedName(SERIALIZED_NAME_REMOTE_IP) - @javax.annotation.Nullable + @javax.annotation.Nonnull private String remoteIp; public static final String SERIALIZED_NAME_REMOTE_PORT = "remote_port"; @@ -85,9 +104,52 @@ public class Connection { @javax.annotation.Nullable private Object remotePort = null; + public static final String SERIALIZED_NAME_TCP_CARVED_FILES = "tcp_carved_files"; + @SerializedName(SERIALIZED_NAME_TCP_CARVED_FILES) + @javax.annotation.Nullable + private List tcpCarvedFiles; + public Connection() { } + public Connection bytesReceived(@javax.annotation.Nullable Long bytesReceived) { + this.bytesReceived = bytesReceived; + return this; + } + + /** + * Get bytesReceived + * @return bytesReceived + */ + @javax.annotation.Nullable + public Long getBytesReceived() { + return bytesReceived; + } + + public void setBytesReceived(@javax.annotation.Nullable Long bytesReceived) { + this.bytesReceived = bytesReceived; + } + + + public Connection bytesSent(@javax.annotation.Nullable Long bytesSent) { + this.bytesSent = bytesSent; + return this; + } + + /** + * Get bytesSent + * @return bytesSent + */ + @javax.annotation.Nullable + public Long getBytesSent() { + return bytesSent; + } + + public void setBytesSent(@javax.annotation.Nullable Long bytesSent) { + this.bytesSent = bytesSent; + } + + public Connection events(@javax.annotation.Nullable List events) { this.events = events; return this; @@ -115,7 +177,45 @@ public void setEvents(@javax.annotation.Nullable List events) { } - public Connection localIp(@javax.annotation.Nullable String localIp) { + public Connection ja3(@javax.annotation.Nullable String ja3) { + this.ja3 = ja3; + return this; + } + + /** + * Get ja3 + * @return ja3 + */ + @javax.annotation.Nullable + public String getJa3() { + return ja3; + } + + public void setJa3(@javax.annotation.Nullable String ja3) { + this.ja3 = ja3; + } + + + public Connection ja3s(@javax.annotation.Nullable String ja3s) { + this.ja3s = ja3s; + return this; + } + + /** + * Get ja3s + * @return ja3s + */ + @javax.annotation.Nullable + public String getJa3s() { + return ja3s; + } + + public void setJa3s(@javax.annotation.Nullable String ja3s) { + this.ja3s = ja3s; + } + + + public Connection localIp(@javax.annotation.Nonnull String localIp) { this.localIp = localIp; return this; } @@ -124,12 +224,12 @@ public Connection localIp(@javax.annotation.Nullable String localIp) { * Get localIp * @return localIp */ - @javax.annotation.Nullable + @javax.annotation.Nonnull public String getLocalIp() { return localIp; } - public void setLocalIp(@javax.annotation.Nullable String localIp) { + public void setLocalIp(@javax.annotation.Nonnull String localIp) { this.localIp = localIp; } @@ -153,7 +253,7 @@ public void setLocalPort(@javax.annotation.Nullable Object localPort) { } - public Connection protocol(@javax.annotation.Nullable String protocol) { + public Connection protocol(@javax.annotation.Nonnull String protocol) { this.protocol = protocol; return this; } @@ -162,17 +262,17 @@ public Connection protocol(@javax.annotation.Nullable String protocol) { * Get protocol * @return protocol */ - @javax.annotation.Nullable + @javax.annotation.Nonnull public String getProtocol() { return protocol; } - public void setProtocol(@javax.annotation.Nullable String protocol) { + public void setProtocol(@javax.annotation.Nonnull String protocol) { this.protocol = protocol; } - public Connection remoteIp(@javax.annotation.Nullable String remoteIp) { + public Connection remoteIp(@javax.annotation.Nonnull String remoteIp) { this.remoteIp = remoteIp; return this; } @@ -181,12 +281,12 @@ public Connection remoteIp(@javax.annotation.Nullable String remoteIp) { * Get remoteIp * @return remoteIp */ - @javax.annotation.Nullable + @javax.annotation.Nonnull public String getRemoteIp() { return remoteIp; } - public void setRemoteIp(@javax.annotation.Nullable String remoteIp) { + public void setRemoteIp(@javax.annotation.Nonnull String remoteIp) { this.remoteIp = remoteIp; } @@ -209,52 +309,35 @@ public void setRemotePort(@javax.annotation.Nullable Object remotePort) { this.remotePort = remotePort; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the Connection instance itself - */ - public Connection putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); + public Connection tcpCarvedFiles(@javax.annotation.Nullable List tcpCarvedFiles) { + this.tcpCarvedFiles = tcpCarvedFiles; + return this; + } + + public Connection addTcpCarvedFilesItem(TcpCarvedFile tcpCarvedFilesItem) { + if (this.tcpCarvedFiles == null) { + this.tcpCarvedFiles = new ArrayList<>(); } - this.additionalProperties.put(key, value); + this.tcpCarvedFiles.add(tcpCarvedFilesItem); return this; } /** - * Return the additional (undeclared) property. - * - * @return a map of objects + * Get tcpCarvedFiles + * @return tcpCarvedFiles */ - public Map getAdditionalProperties() { - return additionalProperties; + @javax.annotation.Nullable + public List getTcpCarvedFiles() { + return tcpCarvedFiles; } - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); + public void setTcpCarvedFiles(@javax.annotation.Nullable List tcpCarvedFiles) { + this.tcpCarvedFiles = tcpCarvedFiles; } + @Override public boolean equals(Object o) { if (this == o) { @@ -264,13 +347,17 @@ public boolean equals(Object o) { return false; } Connection connection = (Connection) o; - return Objects.equals(this.events, connection.events) && + return Objects.equals(this.bytesReceived, connection.bytesReceived) && + Objects.equals(this.bytesSent, connection.bytesSent) && + Objects.equals(this.events, connection.events) && + Objects.equals(this.ja3, connection.ja3) && + Objects.equals(this.ja3s, connection.ja3s) && Objects.equals(this.localIp, connection.localIp) && Objects.equals(this.localPort, connection.localPort) && Objects.equals(this.protocol, connection.protocol) && Objects.equals(this.remoteIp, connection.remoteIp) && - Objects.equals(this.remotePort, connection.remotePort)&& - Objects.equals(this.additionalProperties, connection.additionalProperties); + Objects.equals(this.remotePort, connection.remotePort) && + Objects.equals(this.tcpCarvedFiles, connection.tcpCarvedFiles); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -279,7 +366,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(events, localIp, localPort, protocol, remoteIp, remotePort, additionalProperties); + return Objects.hash(bytesReceived, bytesSent, events, ja3, ja3s, localIp, localPort, protocol, remoteIp, remotePort, tcpCarvedFiles); } private static int hashCodeNullable(JsonNullable a) { @@ -293,13 +380,17 @@ private static int hashCodeNullable(JsonNullable a) { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Connection {\n"); + sb.append(" bytesReceived: ").append(toIndentedString(bytesReceived)).append("\n"); + sb.append(" bytesSent: ").append(toIndentedString(bytesSent)).append("\n"); sb.append(" events: ").append(toIndentedString(events)).append("\n"); + sb.append(" ja3: ").append(toIndentedString(ja3)).append("\n"); + sb.append(" ja3s: ").append(toIndentedString(ja3s)).append("\n"); sb.append(" localIp: ").append(toIndentedString(localIp)).append("\n"); sb.append(" localPort: ").append(toIndentedString(localPort)).append("\n"); sb.append(" protocol: ").append(toIndentedString(protocol)).append("\n"); sb.append(" remoteIp: ").append(toIndentedString(remoteIp)).append("\n"); sb.append(" remotePort: ").append(toIndentedString(remotePort)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append(" tcpCarvedFiles: ").append(toIndentedString(tcpCarvedFiles)).append("\n"); sb.append("}"); return sb.toString(); } @@ -309,10 +400,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -321,7 +409,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("events", "local_ip", "local_port", "protocol", "remote_ip", "remote_port")); + openapiFields = new HashSet(Arrays.asList("bytes_received", "bytes_sent", "events", "ja3", "ja3s", "local_ip", "local_port", "protocol", "remote_ip", "remote_port", "tcp_carved_files")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("local_ip", "local_port", "protocol", "remote_ip", "remote_port")); @@ -336,29 +424,67 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Connection.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Connection is not found in the empty JSON string", Connection.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Connection is not found in the empty JSON string", Connection.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!Connection.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Connection` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Connection.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the optional json data is an array if present - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull() && !jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { + JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); + if (jsonArrayevents != null) { + // ensure the json data is an array + if (!jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + } + + // validate the optional field `events` (array) + for (int i = 0; i < jsonArrayevents.size(); i++) { + ReportEvent.validateJsonElement(jsonArrayevents.get(i)); + }; + } + } + if ((jsonObj.get("ja3") != null && !jsonObj.get("ja3").isJsonNull()) && !jsonObj.get("ja3").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `ja3` to be a primitive type in the JSON string but got `%s`", jsonObj.get("ja3").toString())); + } + if ((jsonObj.get("ja3s") != null && !jsonObj.get("ja3s").isJsonNull()) && !jsonObj.get("ja3s").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `ja3s` to be a primitive type in the JSON string but got `%s`", jsonObj.get("ja3s").toString())); } - if ((jsonObj.get("local_ip") != null && !jsonObj.get("local_ip").isJsonNull()) && !jsonObj.get("local_ip").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `local_ip` to be a primitive type in the JSON string but got `%s`", jsonObj.get("local_ip").toString())); + if (!jsonObj.get("local_ip").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `local_ip` to be a primitive type in the JSON string but got `%s`", jsonObj.get("local_ip").toString())); } - if ((jsonObj.get("protocol") != null && !jsonObj.get("protocol").isJsonNull()) && !jsonObj.get("protocol").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `protocol` to be a primitive type in the JSON string but got `%s`", jsonObj.get("protocol").toString())); + if (!jsonObj.get("protocol").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `protocol` to be a primitive type in the JSON string but got `%s`", jsonObj.get("protocol").toString())); } - if ((jsonObj.get("remote_ip") != null && !jsonObj.get("remote_ip").isJsonNull()) && !jsonObj.get("remote_ip").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `remote_ip` to be a primitive type in the JSON string but got `%s`", jsonObj.get("remote_ip").toString())); + if (!jsonObj.get("remote_ip").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `remote_ip` to be a primitive type in the JSON string but got `%s`", jsonObj.get("remote_ip").toString())); + } + if (jsonObj.get("tcp_carved_files") != null && !jsonObj.get("tcp_carved_files").isJsonNull()) { + JsonArray jsonArraytcpCarvedFiles = jsonObj.getAsJsonArray("tcp_carved_files"); + if (jsonArraytcpCarvedFiles != null) { + // ensure the json data is an array + if (!jsonObj.get("tcp_carved_files").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tcp_carved_files` to be an array in the JSON string but got `%s`", jsonObj.get("tcp_carved_files").toString())); + } + + // validate the optional field `tcp_carved_files` (array) + for (int i = 0; i < jsonArraytcpCarvedFiles.size(); i++) { + TcpCarvedFile.validateJsonElement(jsonArraytcpCarvedFiles.get(i)); + }; + } } } @@ -377,28 +503,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Connection value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -406,28 +510,7 @@ else if (entry.getValue() instanceof Character) public Connection read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - Connection instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ConsoleOutputEntry.java b/src/main/java/ai/reveng/model/ConsoleOutputEntry.java new file mode 100644 index 00000000..298df016 --- /dev/null +++ b/src/main/java/ai/reveng/model/ConsoleOutputEntry.java @@ -0,0 +1,234 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * ConsoleOutputEntry + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ConsoleOutputEntry { + public static final String SERIALIZED_NAME_OUTPUT = "output"; + @SerializedName(SERIALIZED_NAME_OUTPUT) + @javax.annotation.Nonnull + private String output; + + public static final String SERIALIZED_NAME_PROCESS_SEQID = "process_seqid"; + @SerializedName(SERIALIZED_NAME_PROCESS_SEQID) + @javax.annotation.Nonnull + private Long processSeqid; + + public ConsoleOutputEntry() { + } + + public ConsoleOutputEntry output(@javax.annotation.Nonnull String output) { + this.output = output; + return this; + } + + /** + * Get output + * @return output + */ + @javax.annotation.Nonnull + public String getOutput() { + return output; + } + + public void setOutput(@javax.annotation.Nonnull String output) { + this.output = output; + } + + + public ConsoleOutputEntry processSeqid(@javax.annotation.Nonnull Long processSeqid) { + this.processSeqid = processSeqid; + return this; + } + + /** + * Get processSeqid + * @return processSeqid + */ + @javax.annotation.Nonnull + public Long getProcessSeqid() { + return processSeqid; + } + + public void setProcessSeqid(@javax.annotation.Nonnull Long processSeqid) { + this.processSeqid = processSeqid; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ConsoleOutputEntry consoleOutputEntry = (ConsoleOutputEntry) o; + return Objects.equals(this.output, consoleOutputEntry.output) && + Objects.equals(this.processSeqid, consoleOutputEntry.processSeqid); + } + + @Override + public int hashCode() { + return Objects.hash(output, processSeqid); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ConsoleOutputEntry {\n"); + sb.append(" output: ").append(toIndentedString(output)).append("\n"); + sb.append(" processSeqid: ").append(toIndentedString(processSeqid)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("output", "process_seqid")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("output", "process_seqid")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ConsoleOutputEntry + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ConsoleOutputEntry.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ConsoleOutputEntry is not found in the empty JSON string", ConsoleOutputEntry.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ConsoleOutputEntry.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ConsoleOutputEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ConsoleOutputEntry.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("output").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `output` to be a primitive type in the JSON string but got `%s`", jsonObj.get("output").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ConsoleOutputEntry.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ConsoleOutputEntry' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ConsoleOutputEntry.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ConsoleOutputEntry value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ConsoleOutputEntry read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ConsoleOutputEntry given an JSON string + * + * @param jsonString JSON string + * @return An instance of ConsoleOutputEntry + * @throws IOException if the JSON string is invalid with respect to ConsoleOutputEntry + */ + public static ConsoleOutputEntry fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ConsoleOutputEntry.class); + } + + /** + * Convert an instance of ConsoleOutputEntry to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/Context.java b/src/main/java/ai/reveng/model/Context.java index a50e7e30..557b1ed7 100644 --- a/src/main/java/ai/reveng/model/Context.java +++ b/src/main/java/ai/reveng/model/Context.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.DecompilationCommentContext; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -35,7 +34,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Locale; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -115,14 +113,14 @@ public Context read(JsonReader in) throws IOException { return ret; } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for DecompilationCommentContext failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for DecompilationCommentContext failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'DecompilationCommentContext'", e); } // deserialize Object try { // validate the JSON object to see if any exception is thrown if (!jsonElement.getAsJsonPrimitive().isNumber()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString())); } actualAdapter = adapterObject; Context ret = new Context(); @@ -130,11 +128,11 @@ public Context read(JsonReader in) throws IOException { return ret; } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for Object failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for Object failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'Object'", e); } - throw new IOException(String.format(Locale.ROOT, "Failed deserialization for Context: no class matches result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); + throw new IOException(String.format(java.util.Locale.ROOT, "Failed deserialization for Context: no class matches result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); } }.nullSafe(); } @@ -237,20 +235,20 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti DecompilationCommentContext.validateJsonElement(jsonElement); return; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for DecompilationCommentContext failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for DecompilationCommentContext failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with Object try { if (!jsonElement.getAsJsonPrimitive().isNumber()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString())); } return; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for Object failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for Object failed with `%s`.", e.getMessage())); // continue to the next one } - throw new IOException(String.format(Locale.ROOT, "The JSON string is invalid for Context with anyOf schemas: DecompilationCommentContext, Object. no class match the result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); + throw new IOException(String.format(java.util.Locale.ROOT, "The JSON string is invalid for Context with anyOf schemas: DecompilationCommentContext, Object. no class match the result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); } /** diff --git a/src/main/java/ai/reveng/model/Conversation.java b/src/main/java/ai/reveng/model/Conversation.java index 5d7d57de..da8f58bb 100644 --- a/src/main/java/ai/reveng/model/Conversation.java +++ b/src/main/java/ai/reveng/model/Conversation.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -199,50 +197,6 @@ public void setUserId(@javax.annotation.Nonnull Long userId) { this.userId = userId; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the Conversation instance itself - */ - public Conversation putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -259,8 +213,7 @@ public boolean equals(Object o) { Objects.equals(this.createdAt, conversation.createdAt) && Objects.equals(this.title, conversation.title) && Objects.equals(this.updatedAt, conversation.updatedAt) && - Objects.equals(this.userId, conversation.userId)&& - Objects.equals(this.additionalProperties, conversation.additionalProperties); + Objects.equals(this.userId, conversation.userId); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -269,7 +222,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(context, conversationUuid, createdAt, title, updatedAt, userId, additionalProperties); + return Objects.hash(context, conversationUuid, createdAt, title, updatedAt, userId); } private static int hashCodeNullable(JsonNullable a) { @@ -289,7 +242,6 @@ public String toString() { sb.append(" title: ").append(toIndentedString(title)).append("\n"); sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -299,10 +251,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -326,22 +275,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Conversation.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Conversation is not found in the empty JSON string", Conversation.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Conversation is not found in the empty JSON string", Conversation.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!Conversation.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Conversation` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Conversation.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("conversation_uuid").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `conversation_uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("conversation_uuid").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `conversation_uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("conversation_uuid").toString())); } if (!jsonObj.get("title").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `title` to be a primitive type in the JSON string but got `%s`", jsonObj.get("title").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `title` to be a primitive type in the JSON string but got `%s`", jsonObj.get("title").toString())); } } @@ -360,28 +317,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Conversation value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -389,28 +324,7 @@ else if (entry.getValue() instanceof Character) public Conversation read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - Conversation instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ConversationContext.java b/src/main/java/ai/reveng/model/ConversationContext.java index 470e211b..a1edbed7 100644 --- a/src/main/java/ai/reveng/model/ConversationContext.java +++ b/src/main/java/ai/reveng/model/ConversationContext.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -101,50 +99,6 @@ public void setFunctionId(@javax.annotation.Nullable Long functionId) { this.functionId = functionId; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ConversationContext instance itself - */ - public ConversationContext putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -157,13 +111,12 @@ public boolean equals(Object o) { } ConversationContext conversationContext = (ConversationContext) o; return Objects.equals(this.analysisId, conversationContext.analysisId) && - Objects.equals(this.functionId, conversationContext.functionId)&& - Objects.equals(this.additionalProperties, conversationContext.additionalProperties); + Objects.equals(this.functionId, conversationContext.functionId); } @Override public int hashCode() { - return Objects.hash(analysisId, functionId, additionalProperties); + return Objects.hash(analysisId, functionId); } @Override @@ -172,7 +125,6 @@ public String toString() { sb.append("class ConversationContext {\n"); sb.append(" analysisId: ").append(toIndentedString(analysisId)).append("\n"); sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -182,10 +134,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -209,7 +158,15 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ConversationContext.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ConversationContext is not found in the empty JSON string", ConversationContext.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ConversationContext is not found in the empty JSON string", ConversationContext.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ConversationContext.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ConversationContext` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -230,28 +187,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ConversationContext value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -259,28 +194,7 @@ else if (entry.getValue() instanceof Character) public ConversationContext read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ConversationContext instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ConversationWithEvents.java b/src/main/java/ai/reveng/model/ConversationWithEvents.java index 39dc4bd2..6427402a 100644 --- a/src/main/java/ai/reveng/model/ConversationWithEvents.java +++ b/src/main/java/ai/reveng/model/ConversationWithEvents.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.Event; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -47,7 +46,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -234,50 +232,6 @@ public void setUserId(@javax.annotation.Nonnull Long userId) { this.userId = userId; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ConversationWithEvents instance itself - */ - public ConversationWithEvents putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -295,8 +249,7 @@ public boolean equals(Object o) { Objects.equals(this.events, conversationWithEvents.events) && Objects.equals(this.title, conversationWithEvents.title) && Objects.equals(this.updatedAt, conversationWithEvents.updatedAt) && - Objects.equals(this.userId, conversationWithEvents.userId)&& - Objects.equals(this.additionalProperties, conversationWithEvents.additionalProperties); + Objects.equals(this.userId, conversationWithEvents.userId); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -305,7 +258,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(context, conversationUuid, createdAt, events, title, updatedAt, userId, additionalProperties); + return Objects.hash(context, conversationUuid, createdAt, events, title, updatedAt, userId); } private static int hashCodeNullable(JsonNullable a) { @@ -326,7 +279,6 @@ public String toString() { sb.append(" title: ").append(toIndentedString(title)).append("\n"); sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -336,10 +288,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -363,28 +312,40 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ConversationWithEvents.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ConversationWithEvents is not found in the empty JSON string", ConversationWithEvents.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ConversationWithEvents is not found in the empty JSON string", ConversationWithEvents.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ConversationWithEvents.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ConversationWithEvents` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ConversationWithEvents.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("conversation_uuid").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `conversation_uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("conversation_uuid").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `conversation_uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("conversation_uuid").toString())); } - // ensure the required json array is present - if (jsonObj.get("events") == null) { - throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); - } else if (!jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { + if (!jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + } + JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); + // validate the required field `events` (array) + for (int i = 0; i < jsonArrayevents.size(); i++) { + Event.validateJsonElement(jsonArrayevents.get(i)); + } } if (!jsonObj.get("title").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `title` to be a primitive type in the JSON string but got `%s`", jsonObj.get("title").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `title` to be a primitive type in the JSON string but got `%s`", jsonObj.get("title").toString())); } } @@ -403,28 +364,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ConversationWithEvents value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -432,28 +371,7 @@ else if (entry.getValue() instanceof Character) public ConversationWithEvents read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ConversationWithEvents instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CreateAIDecompOutputBody.java b/src/main/java/ai/reveng/model/CreateAIDecompOutputBody.java index b809ae23..672d797a 100644 --- a/src/main/java/ai/reveng/model/CreateAIDecompOutputBody.java +++ b/src/main/java/ai/reveng/model/CreateAIDecompOutputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -77,50 +75,6 @@ public void setStatus(@javax.annotation.Nonnull Boolean status) { this.status = status; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the CreateAIDecompOutputBody instance itself - */ - public CreateAIDecompOutputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -132,13 +86,12 @@ public boolean equals(Object o) { return false; } CreateAIDecompOutputBody createAIDecompOutputBody = (CreateAIDecompOutputBody) o; - return Objects.equals(this.status, createAIDecompOutputBody.status)&& - Objects.equals(this.additionalProperties, createAIDecompOutputBody.additionalProperties); + return Objects.equals(this.status, createAIDecompOutputBody.status); } @Override public int hashCode() { - return Objects.hash(status, additionalProperties); + return Objects.hash(status); } @Override @@ -146,7 +99,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CreateAIDecompOutputBody {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -156,10 +108,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,14 +132,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CreateAIDecompOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CreateAIDecompOutputBody is not found in the empty JSON string", CreateAIDecompOutputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CreateAIDecompOutputBody is not found in the empty JSON string", CreateAIDecompOutputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CreateAIDecompOutputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateAIDecompOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateAIDecompOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -211,28 +168,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateAIDecompOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -240,28 +175,7 @@ else if (entry.getValue() instanceof Character) public CreateAIDecompOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - CreateAIDecompOutputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CreateCheckoutSessionInputBody.java b/src/main/java/ai/reveng/model/CreateCheckoutSessionInputBody.java index 68e19fef..b08810cf 100644 --- a/src/main/java/ai/reveng/model/CreateCheckoutSessionInputBody.java +++ b/src/main/java/ai/reveng/model/CreateCheckoutSessionInputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -208,10 +206,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -235,25 +230,25 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CreateCheckoutSessionInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CreateCheckoutSessionInputBody is not found in the empty JSON string", CreateCheckoutSessionInputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CreateCheckoutSessionInputBody is not found in the empty JSON string", CreateCheckoutSessionInputBody.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateCheckoutSessionInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("cancel_url").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `cancel_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cancel_url").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `cancel_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cancel_url").toString())); } if (!jsonObj.get("price_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `price_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("price_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `price_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("price_id").toString())); } if (!jsonObj.get("success_url").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `success_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("success_url").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `success_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("success_url").toString())); } } @@ -314,7 +309,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/CreateCollectionInputBody.java b/src/main/java/ai/reveng/model/CreateCollectionInputBody.java index ca3aee54..07743019 100644 --- a/src/main/java/ai/reveng/model/CreateCollectionInputBody.java +++ b/src/main/java/ai/reveng/model/CreateCollectionInputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -275,50 +273,6 @@ public void setTags(@javax.annotation.Nullable List tags) { this.tags = tags; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the CreateCollectionInputBody instance itself - */ - public CreateCollectionInputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -335,8 +289,7 @@ public boolean equals(Object o) { Objects.equals(this.collectionScope, createCollectionInputBody.collectionScope) && Objects.equals(this.description, createCollectionInputBody.description) && Objects.equals(this.modelId, createCollectionInputBody.modelId) && - Objects.equals(this.tags, createCollectionInputBody.tags)&& - Objects.equals(this.additionalProperties, createCollectionInputBody.additionalProperties); + Objects.equals(this.tags, createCollectionInputBody.tags); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -345,7 +298,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(binaries, collectionName, collectionScope, description, modelId, tags, additionalProperties); + return Objects.hash(binaries, collectionName, collectionScope, description, modelId, tags); } private static int hashCodeNullable(JsonNullable a) { @@ -365,7 +318,6 @@ public String toString() { sb.append(" description: ").append(toIndentedString(description)).append("\n"); sb.append(" modelId: ").append(toIndentedString(modelId)).append("\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -375,10 +327,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -402,35 +351,43 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CreateCollectionInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CreateCollectionInputBody is not found in the empty JSON string", CreateCollectionInputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CreateCollectionInputBody is not found in the empty JSON string", CreateCollectionInputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CreateCollectionInputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateCollectionInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateCollectionInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the optional json data is an array if present if (jsonObj.get("binaries") != null && !jsonObj.get("binaries").isJsonNull() && !jsonObj.get("binaries").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); } if (!jsonObj.get("collection_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); } if (!jsonObj.get("collection_scope").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_scope").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_scope").toString())); } // validate the required field `collection_scope` CollectionScopeEnum.validateJsonElement(jsonObj.get("collection_scope")); if (!jsonObj.get("description").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); } // ensure the optional json data is an array if present if (jsonObj.get("tags") != null && !jsonObj.get("tags").isJsonNull() && !jsonObj.get("tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); } } @@ -449,28 +406,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateCollectionInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -478,28 +413,7 @@ else if (entry.getValue() instanceof Character) public CreateCollectionInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - CreateCollectionInputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CreateCollectionOutputBody.java b/src/main/java/ai/reveng/model/CreateCollectionOutputBody.java index 1ab32a24..a9f343ef 100644 --- a/src/main/java/ai/reveng/model/CreateCollectionOutputBody.java +++ b/src/main/java/ai/reveng/model/CreateCollectionOutputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.Binary; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -47,7 +46,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -338,50 +336,6 @@ public void setUserId(@javax.annotation.Nonnull Long userId) { this.userId = userId; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the CreateCollectionOutputBody instance itself - */ - public CreateCollectionOutputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -403,8 +357,7 @@ public boolean equals(Object o) { Objects.equals(this.tags, createCollectionOutputBody.tags) && Objects.equals(this.teamId, createCollectionOutputBody.teamId) && Objects.equals(this.updatedAt, createCollectionOutputBody.updatedAt) && - Objects.equals(this.userId, createCollectionOutputBody.userId)&& - Objects.equals(this.additionalProperties, createCollectionOutputBody.additionalProperties); + Objects.equals(this.userId, createCollectionOutputBody.userId); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -413,7 +366,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(binaries, collectionId, collectionName, collectionScope, createdAt, description, modelId, tags, teamId, updatedAt, userId, additionalProperties); + return Objects.hash(binaries, collectionId, collectionName, collectionScope, createdAt, description, modelId, tags, teamId, updatedAt, userId); } private static int hashCodeNullable(JsonNullable a) { @@ -438,7 +391,6 @@ public String toString() { sb.append(" teamId: ").append(toIndentedString(teamId)).append("\n"); sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -448,10 +400,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -475,33 +424,51 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CreateCollectionOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CreateCollectionOutputBody is not found in the empty JSON string", CreateCollectionOutputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CreateCollectionOutputBody is not found in the empty JSON string", CreateCollectionOutputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CreateCollectionOutputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateCollectionOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateCollectionOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the optional json data is an array if present - if (jsonObj.get("binaries") != null && !jsonObj.get("binaries").isJsonNull() && !jsonObj.get("binaries").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); + if (jsonObj.get("binaries") != null && !jsonObj.get("binaries").isJsonNull()) { + JsonArray jsonArraybinaries = jsonObj.getAsJsonArray("binaries"); + if (jsonArraybinaries != null) { + // ensure the json data is an array + if (!jsonObj.get("binaries").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); + } + + // validate the optional field `binaries` (array) + for (int i = 0; i < jsonArraybinaries.size(); i++) { + Binary.validateJsonElement(jsonArraybinaries.get(i)); + }; + } } if (!jsonObj.get("collection_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); } if (!jsonObj.get("collection_scope").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_scope").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_scope").toString())); } if (!jsonObj.get("description").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); } // ensure the optional json data is an array if present if (jsonObj.get("tags") != null && !jsonObj.get("tags").isJsonNull() && !jsonObj.get("tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); } } @@ -520,28 +487,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateCollectionOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -549,28 +494,7 @@ else if (entry.getValue() instanceof Character) public CreateCollectionOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - CreateCollectionOutputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CreateConversationRequest.java b/src/main/java/ai/reveng/model/CreateConversationRequest.java index 29d0a762..f40b019a 100644 --- a/src/main/java/ai/reveng/model/CreateConversationRequest.java +++ b/src/main/java/ai/reveng/model/CreateConversationRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ConversationContext; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -102,50 +100,6 @@ public void setTitle(@javax.annotation.Nullable String title) { this.title = title; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the CreateConversationRequest instance itself - */ - public CreateConversationRequest putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -158,13 +112,12 @@ public boolean equals(Object o) { } CreateConversationRequest createConversationRequest = (CreateConversationRequest) o; return Objects.equals(this.context, createConversationRequest.context) && - Objects.equals(this.title, createConversationRequest.title)&& - Objects.equals(this.additionalProperties, createConversationRequest.additionalProperties); + Objects.equals(this.title, createConversationRequest.title); } @Override public int hashCode() { - return Objects.hash(context, title, additionalProperties); + return Objects.hash(context, title); } @Override @@ -173,7 +126,6 @@ public String toString() { sb.append("class CreateConversationRequest {\n"); sb.append(" context: ").append(toIndentedString(context)).append("\n"); sb.append(" title: ").append(toIndentedString(title)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -183,10 +135,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -210,12 +159,24 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CreateConversationRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CreateConversationRequest is not found in the empty JSON string", CreateConversationRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CreateConversationRequest is not found in the empty JSON string", CreateConversationRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CreateConversationRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateConversationRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `context` + if (jsonObj.get("context") != null && !jsonObj.get("context").isJsonNull()) { + ConversationContext.validateJsonElement(jsonObj.get("context")); + } if ((jsonObj.get("title") != null && !jsonObj.get("title").isJsonNull()) && !jsonObj.get("title").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `title` to be a primitive type in the JSON string but got `%s`", jsonObj.get("title").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `title` to be a primitive type in the JSON string but got `%s`", jsonObj.get("title").toString())); } } @@ -234,28 +195,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateConversationRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -263,28 +202,7 @@ else if (entry.getValue() instanceof Character) public CreateConversationRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - CreateConversationRequest instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/CreatePortalSessionInputBody.java b/src/main/java/ai/reveng/model/CreatePortalSessionInputBody.java index 8e511e9b..37ca0f5f 100644 --- a/src/main/java/ai/reveng/model/CreatePortalSessionInputBody.java +++ b/src/main/java/ai/reveng/model/CreatePortalSessionInputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -156,10 +154,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,19 +178,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CreatePortalSessionInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CreatePortalSessionInputBody is not found in the empty JSON string", CreatePortalSessionInputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CreatePortalSessionInputBody is not found in the empty JSON string", CreatePortalSessionInputBody.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreatePortalSessionInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("return_url").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `return_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("return_url").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `return_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("return_url").toString())); } } @@ -256,7 +251,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/Created.java b/src/main/java/ai/reveng/model/Created.java index 91247b6b..5417e2a1 100644 --- a/src/main/java/ai/reveng/model/Created.java +++ b/src/main/java/ai/reveng/model/Created.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -213,10 +211,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -240,19 +235,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Created.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Created is not found in the empty JSON string", Created.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Created is not found in the empty JSON string", Created.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Created.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("reference").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `reference` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reference").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `reference` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reference").toString())); } } @@ -313,7 +308,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/DecompFailedEvent.java b/src/main/java/ai/reveng/model/DecompFailedEvent.java index 4faf7d6c..0f64b250 100644 --- a/src/main/java/ai/reveng/model/DecompFailedEvent.java +++ b/src/main/java/ai/reveng/model/DecompFailedEvent.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -173,50 +171,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the DecompFailedEvent instance itself - */ - public DecompFailedEvent putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -232,13 +186,12 @@ public boolean equals(Object o) { Objects.equals(this.error, decompFailedEvent.error) && Objects.equals(this.errorCode, decompFailedEvent.errorCode) && Objects.equals(this.seq, decompFailedEvent.seq) && - Objects.equals(this.type, decompFailedEvent.type)&& - Objects.equals(this.additionalProperties, decompFailedEvent.additionalProperties); + Objects.equals(this.type, decompFailedEvent.type); } @Override public int hashCode() { - return Objects.hash(attempt, error, errorCode, seq, type, additionalProperties); + return Objects.hash(attempt, error, errorCode, seq, type); } @Override @@ -250,7 +203,6 @@ public String toString() { sb.append(" errorCode: ").append(toIndentedString(errorCode)).append("\n"); sb.append(" seq: ").append(toIndentedString(seq)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -260,10 +212,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -287,25 +236,33 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!DecompFailedEvent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in DecompFailedEvent is not found in the empty JSON string", DecompFailedEvent.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in DecompFailedEvent is not found in the empty JSON string", DecompFailedEvent.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!DecompFailedEvent.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `DecompFailedEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DecompFailedEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("error").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `error` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `error` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error").toString())); } if ((jsonObj.get("error_code") != null && !jsonObj.get("error_code").isJsonNull()) && !jsonObj.get("error_code").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `error_code` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error_code").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `error_code` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error_code").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -324,28 +281,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DecompFailedEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -353,28 +288,7 @@ else if (entry.getValue() instanceof Character) public DecompFailedEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - DecompFailedEvent instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/DecompFinishedEvent.java b/src/main/java/ai/reveng/model/DecompFinishedEvent.java index a9568cfb..358767a1 100644 --- a/src/main/java/ai/reveng/model/DecompFinishedEvent.java +++ b/src/main/java/ai/reveng/model/DecompFinishedEvent.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -125,50 +123,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the DecompFinishedEvent instance itself - */ - public DecompFinishedEvent putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -182,13 +136,12 @@ public boolean equals(Object o) { DecompFinishedEvent decompFinishedEvent = (DecompFinishedEvent) o; return Objects.equals(this.attempt, decompFinishedEvent.attempt) && Objects.equals(this.seq, decompFinishedEvent.seq) && - Objects.equals(this.type, decompFinishedEvent.type)&& - Objects.equals(this.additionalProperties, decompFinishedEvent.additionalProperties); + Objects.equals(this.type, decompFinishedEvent.type); } @Override public int hashCode() { - return Objects.hash(attempt, seq, type, additionalProperties); + return Objects.hash(attempt, seq, type); } @Override @@ -198,7 +151,6 @@ public String toString() { sb.append(" attempt: ").append(toIndentedString(attempt)).append("\n"); sb.append(" seq: ").append(toIndentedString(seq)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -208,10 +160,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -235,19 +184,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!DecompFinishedEvent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in DecompFinishedEvent is not found in the empty JSON string", DecompFinishedEvent.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in DecompFinishedEvent is not found in the empty JSON string", DecompFinishedEvent.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!DecompFinishedEvent.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `DecompFinishedEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DecompFinishedEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -266,28 +223,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DecompFinishedEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -295,28 +230,7 @@ else if (entry.getValue() instanceof Character) public DecompFinishedEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - DecompFinishedEvent instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/DecompilationCommentContext.java b/src/main/java/ai/reveng/model/DecompilationCommentContext.java index 0f3473f6..2f90c81d 100644 --- a/src/main/java/ai/reveng/model/DecompilationCommentContext.java +++ b/src/main/java/ai/reveng/model/DecompilationCommentContext.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -182,10 +180,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -209,14 +204,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!DecompilationCommentContext.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in DecompilationCommentContext is not found in the empty JSON string", DecompilationCommentContext.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in DecompilationCommentContext is not found in the empty JSON string", DecompilationCommentContext.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DecompilationCommentContext.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -279,7 +274,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/DecompilationData.java b/src/main/java/ai/reveng/model/DecompilationData.java index c40a30fc..affe0e56 100644 --- a/src/main/java/ai/reveng/model/DecompilationData.java +++ b/src/main/java/ai/reveng/model/DecompilationData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -161,50 +159,6 @@ public void setStatus(@javax.annotation.Nonnull StatusEnum status) { this.status = status; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the DecompilationData instance itself - */ - public DecompilationData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -217,13 +171,12 @@ public boolean equals(Object o) { } DecompilationData decompilationData = (DecompilationData) o; return Objects.equals(this.decompilation, decompilationData.decompilation) && - Objects.equals(this.status, decompilationData.status)&& - Objects.equals(this.additionalProperties, decompilationData.additionalProperties); + Objects.equals(this.status, decompilationData.status); } @Override public int hashCode() { - return Objects.hash(decompilation, status, additionalProperties); + return Objects.hash(decompilation, status); } @Override @@ -232,7 +185,6 @@ public String toString() { sb.append("class DecompilationData {\n"); sb.append(" decompilation: ").append(toIndentedString(decompilation)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -242,10 +194,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -269,22 +218,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!DecompilationData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in DecompilationData is not found in the empty JSON string", DecompilationData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in DecompilationData is not found in the empty JSON string", DecompilationData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!DecompilationData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `DecompilationData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DecompilationData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("decompilation") != null && !jsonObj.get("decompilation").isJsonNull()) && !jsonObj.get("decompilation").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `decompilation` to be a primitive type in the JSON string but got `%s`", jsonObj.get("decompilation").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `decompilation` to be a primitive type in the JSON string but got `%s`", jsonObj.get("decompilation").toString())); } if (!jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); } // validate the required field `status` StatusEnum.validateJsonElement(jsonObj.get("status")); @@ -305,28 +262,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DecompilationData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -334,28 +269,7 @@ else if (entry.getValue() instanceof Character) public DecompilationData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - DecompilationData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/DieMatch.java b/src/main/java/ai/reveng/model/DieMatch.java index f34097d2..66777bc3 100644 --- a/src/main/java/ai/reveng/model/DieMatch.java +++ b/src/main/java/ai/reveng/model/DieMatch.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -234,10 +232,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,28 +256,28 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!DieMatch.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in DieMatch is not found in the empty JSON string", DieMatch.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in DieMatch is not found in the empty JSON string", DieMatch.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DieMatch.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } if (!jsonObj.get("display").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `display` to be a primitive type in the JSON string but got `%s`", jsonObj.get("display").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `display` to be a primitive type in the JSON string but got `%s`", jsonObj.get("display").toString())); } if (!jsonObj.get("version").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("version").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("version").toString())); } } @@ -343,7 +338,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/DnsQuery.java b/src/main/java/ai/reveng/model/DnsQuery.java index 06646fce..3d541630 100644 --- a/src/main/java/ai/reveng/model/DnsQuery.java +++ b/src/main/java/ai/reveng/model/DnsQuery.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ReportEvent; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -55,9 +53,14 @@ */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class DnsQuery { + public static final String SERIALIZED_NAME_CNAME_CHAIN = "cname_chain"; + @SerializedName(SERIALIZED_NAME_CNAME_CHAIN) + @javax.annotation.Nullable + private List cnameChain; + public static final String SERIALIZED_NAME_DOMAIN = "domain"; @SerializedName(SERIALIZED_NAME_DOMAIN) - @javax.annotation.Nullable + @javax.annotation.Nonnull private String domain; public static final String SERIALIZED_NAME_EVENTS = "events"; @@ -65,10 +68,47 @@ public class DnsQuery { @javax.annotation.Nullable private List events; + public static final String SERIALIZED_NAME_MIN_TTL = "min_ttl"; + @SerializedName(SERIALIZED_NAME_MIN_TTL) + @javax.annotation.Nullable + private Long minTtl; + + public static final String SERIALIZED_NAME_RESOLVED_IPS = "resolved_ips"; + @SerializedName(SERIALIZED_NAME_RESOLVED_IPS) + @javax.annotation.Nullable + private List resolvedIps; + public DnsQuery() { } - public DnsQuery domain(@javax.annotation.Nullable String domain) { + public DnsQuery cnameChain(@javax.annotation.Nullable List cnameChain) { + this.cnameChain = cnameChain; + return this; + } + + public DnsQuery addCnameChainItem(String cnameChainItem) { + if (this.cnameChain == null) { + this.cnameChain = new ArrayList<>(); + } + this.cnameChain.add(cnameChainItem); + return this; + } + + /** + * Get cnameChain + * @return cnameChain + */ + @javax.annotation.Nullable + public List getCnameChain() { + return cnameChain; + } + + public void setCnameChain(@javax.annotation.Nullable List cnameChain) { + this.cnameChain = cnameChain; + } + + + public DnsQuery domain(@javax.annotation.Nonnull String domain) { this.domain = domain; return this; } @@ -77,12 +117,12 @@ public DnsQuery domain(@javax.annotation.Nullable String domain) { * Get domain * @return domain */ - @javax.annotation.Nullable + @javax.annotation.Nonnull public String getDomain() { return domain; } - public void setDomain(@javax.annotation.Nullable String domain) { + public void setDomain(@javax.annotation.Nonnull String domain) { this.domain = domain; } @@ -113,52 +153,54 @@ public void setEvents(@javax.annotation.Nullable List events) { this.events = events; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; + + public DnsQuery minTtl(@javax.annotation.Nullable Long minTtl) { + this.minTtl = minTtl; + return this; + } /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the DnsQuery instance itself + * Get minTtl + * @return minTtl */ - public DnsQuery putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); + @javax.annotation.Nullable + public Long getMinTtl() { + return minTtl; + } + + public void setMinTtl(@javax.annotation.Nullable Long minTtl) { + this.minTtl = minTtl; + } + + + public DnsQuery resolvedIps(@javax.annotation.Nullable List resolvedIps) { + this.resolvedIps = resolvedIps; + return this; + } + + public DnsQuery addResolvedIpsItem(String resolvedIpsItem) { + if (this.resolvedIps == null) { + this.resolvedIps = new ArrayList<>(); } - this.additionalProperties.put(key, value); + this.resolvedIps.add(resolvedIpsItem); return this; } /** - * Return the additional (undeclared) property. - * - * @return a map of objects + * Get resolvedIps + * @return resolvedIps */ - public Map getAdditionalProperties() { - return additionalProperties; + @javax.annotation.Nullable + public List getResolvedIps() { + return resolvedIps; } - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); + public void setResolvedIps(@javax.annotation.Nullable List resolvedIps) { + this.resolvedIps = resolvedIps; } + @Override public boolean equals(Object o) { if (this == o) { @@ -168,9 +210,11 @@ public boolean equals(Object o) { return false; } DnsQuery dnsQuery = (DnsQuery) o; - return Objects.equals(this.domain, dnsQuery.domain) && - Objects.equals(this.events, dnsQuery.events)&& - Objects.equals(this.additionalProperties, dnsQuery.additionalProperties); + return Objects.equals(this.cnameChain, dnsQuery.cnameChain) && + Objects.equals(this.domain, dnsQuery.domain) && + Objects.equals(this.events, dnsQuery.events) && + Objects.equals(this.minTtl, dnsQuery.minTtl) && + Objects.equals(this.resolvedIps, dnsQuery.resolvedIps); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -179,7 +223,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(domain, events, additionalProperties); + return Objects.hash(cnameChain, domain, events, minTtl, resolvedIps); } private static int hashCodeNullable(JsonNullable a) { @@ -193,9 +237,11 @@ private static int hashCodeNullable(JsonNullable a) { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class DnsQuery {\n"); + sb.append(" cnameChain: ").append(toIndentedString(cnameChain)).append("\n"); sb.append(" domain: ").append(toIndentedString(domain)).append("\n"); sb.append(" events: ").append(toIndentedString(events)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append(" minTtl: ").append(toIndentedString(minTtl)).append("\n"); + sb.append(" resolvedIps: ").append(toIndentedString(resolvedIps)).append("\n"); sb.append("}"); return sb.toString(); } @@ -205,10 +251,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -217,7 +260,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("domain", "events")); + openapiFields = new HashSet(Arrays.asList("cname_chain", "domain", "events", "min_ttl", "resolved_ips")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("domain")); @@ -232,23 +275,49 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!DnsQuery.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in DnsQuery is not found in the empty JSON string", DnsQuery.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in DnsQuery is not found in the empty JSON string", DnsQuery.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!DnsQuery.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `DnsQuery` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DnsQuery.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("domain") != null && !jsonObj.get("domain").isJsonNull()) && !jsonObj.get("domain").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `domain` to be a primitive type in the JSON string but got `%s`", jsonObj.get("domain").toString())); + // ensure the optional json data is an array if present + if (jsonObj.get("cname_chain") != null && !jsonObj.get("cname_chain").isJsonNull() && !jsonObj.get("cname_chain").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `cname_chain` to be an array in the JSON string but got `%s`", jsonObj.get("cname_chain").toString())); + } + if (!jsonObj.get("domain").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `domain` to be a primitive type in the JSON string but got `%s`", jsonObj.get("domain").toString())); + } + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { + JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); + if (jsonArrayevents != null) { + // ensure the json data is an array + if (!jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + } + + // validate the optional field `events` (array) + for (int i = 0; i < jsonArrayevents.size(); i++) { + ReportEvent.validateJsonElement(jsonArrayevents.get(i)); + }; + } } // ensure the optional json data is an array if present - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull() && !jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + if (jsonObj.get("resolved_ips") != null && !jsonObj.get("resolved_ips").isJsonNull() && !jsonObj.get("resolved_ips").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `resolved_ips` to be an array in the JSON string but got `%s`", jsonObj.get("resolved_ips").toString())); } } @@ -267,28 +336,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DnsQuery value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -296,28 +343,7 @@ else if (entry.getValue() instanceof Character) public DnsQuery read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - DnsQuery instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/DrakvufFileMetadata.java b/src/main/java/ai/reveng/model/DrakvufFileMetadata.java index 69f9ec91..47a85067 100644 --- a/src/main/java/ai/reveng/model/DrakvufFileMetadata.java +++ b/src/main/java/ai/reveng/model/DrakvufFileMetadata.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -21,7 +20,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; -import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -43,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -59,12 +56,12 @@ public class DrakvufFileMetadata { public static final String SERIALIZED_NAME_NAME = "name"; @SerializedName(SERIALIZED_NAME_NAME) - @javax.annotation.Nullable + @javax.annotation.Nonnull private String name; public static final String SERIALIZED_NAME_SHA256 = "sha256"; @SerializedName(SERIALIZED_NAME_SHA256) - @javax.annotation.Nullable + @javax.annotation.Nonnull private String sha256; public static final String SERIALIZED_NAME_TYPE = "type"; @@ -99,7 +96,7 @@ public void setMimeType(@javax.annotation.Nullable String mimeType) { } - public DrakvufFileMetadata name(@javax.annotation.Nullable String name) { + public DrakvufFileMetadata name(@javax.annotation.Nonnull String name) { this.name = name; return this; } @@ -108,17 +105,17 @@ public DrakvufFileMetadata name(@javax.annotation.Nullable String name) { * Get name * @return name */ - @javax.annotation.Nullable + @javax.annotation.Nonnull public String getName() { return name; } - public void setName(@javax.annotation.Nullable String name) { + public void setName(@javax.annotation.Nonnull String name) { this.name = name; } - public DrakvufFileMetadata sha256(@javax.annotation.Nullable String sha256) { + public DrakvufFileMetadata sha256(@javax.annotation.Nonnull String sha256) { this.sha256 = sha256; return this; } @@ -127,12 +124,12 @@ public DrakvufFileMetadata sha256(@javax.annotation.Nullable String sha256) { * Get sha256 * @return sha256 */ - @javax.annotation.Nullable + @javax.annotation.Nonnull public String getSha256() { return sha256; } - public void setSha256(@javax.annotation.Nullable String sha256) { + public void setSha256(@javax.annotation.Nonnull String sha256) { this.sha256 = sha256; } @@ -174,50 +171,6 @@ public void setTypeId(@javax.annotation.Nullable String typeId) { this.typeId = typeId; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the DrakvufFileMetadata instance itself - */ - public DrakvufFileMetadata putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -233,24 +186,12 @@ public boolean equals(Object o) { Objects.equals(this.name, drakvufFileMetadata.name) && Objects.equals(this.sha256, drakvufFileMetadata.sha256) && Objects.equals(this.type, drakvufFileMetadata.type) && - Objects.equals(this.typeId, drakvufFileMetadata.typeId)&& - Objects.equals(this.additionalProperties, drakvufFileMetadata.additionalProperties); - } - - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + Objects.equals(this.typeId, drakvufFileMetadata.typeId); } @Override public int hashCode() { - return Objects.hash(mimeType, name, sha256, type, typeId, additionalProperties); - } - - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + return Objects.hash(mimeType, name, sha256, type, typeId); } @Override @@ -262,7 +203,6 @@ public String toString() { sb.append(" sha256: ").append(toIndentedString(sha256)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" typeId: ").append(toIndentedString(typeId)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -272,10 +212,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -299,31 +236,39 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!DrakvufFileMetadata.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in DrakvufFileMetadata is not found in the empty JSON string", DrakvufFileMetadata.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in DrakvufFileMetadata is not found in the empty JSON string", DrakvufFileMetadata.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!DrakvufFileMetadata.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `DrakvufFileMetadata` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DrakvufFileMetadata.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("mime_type") != null && !jsonObj.get("mime_type").isJsonNull()) && !jsonObj.get("mime_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `mime_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mime_type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `mime_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mime_type").toString())); } - if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } - if ((jsonObj.get("sha256") != null && !jsonObj.get("sha256").isJsonNull()) && !jsonObj.get("sha256").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha256` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha256").toString())); + if (!jsonObj.get("sha256").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha256` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha256").toString())); } if ((jsonObj.get("type") != null && !jsonObj.get("type").isJsonNull()) && !jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } if ((jsonObj.get("type_id") != null && !jsonObj.get("type_id").isJsonNull()) && !jsonObj.get("type_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type_id").toString())); } } @@ -342,28 +287,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DrakvufFileMetadata value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -371,28 +294,7 @@ else if (entry.getValue() instanceof Character) public DrakvufFileMetadata read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - DrakvufFileMetadata instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/DynamicExecutionStatus.java b/src/main/java/ai/reveng/model/DynamicExecutionStatus.java index 7307917d..919c59fa 100644 --- a/src/main/java/ai/reveng/model/DynamicExecutionStatus.java +++ b/src/main/java/ai/reveng/model/DynamicExecutionStatus.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/DynamicExecutionStatusResponse.java b/src/main/java/ai/reveng/model/DynamicExecutionStatusResponse.java index 801662d5..bbcdc580 100644 --- a/src/main/java/ai/reveng/model/DynamicExecutionStatusResponse.java +++ b/src/main/java/ai/reveng/model/DynamicExecutionStatusResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AnalysisLogs; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -209,10 +207,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -236,22 +231,24 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!DynamicExecutionStatusResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in DynamicExecutionStatusResponse is not found in the empty JSON string", DynamicExecutionStatusResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in DynamicExecutionStatusResponse is not found in the empty JSON string", DynamicExecutionStatusResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DynamicExecutionStatusResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("error_message") != null && !jsonObj.get("error_message").isJsonNull()) && !jsonObj.get("error_message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `error_message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error_message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `error_message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error_message").toString())); } + // validate the required field `logs` + AnalysisLogs.validateJsonElement(jsonObj.get("logs")); if (!jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); } } @@ -312,7 +309,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ELFImportModel.java b/src/main/java/ai/reveng/model/ELFImportModel.java index 89f535ab..ee5bd3e9 100644 --- a/src/main/java/ai/reveng/model/ELFImportModel.java +++ b/src/main/java/ai/reveng/model/ELFImportModel.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -192,10 +190,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -219,14 +214,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ELFImportModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ELFImportModel is not found in the empty JSON string", ELFImportModel.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ELFImportModel is not found in the empty JSON string", ELFImportModel.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ELFImportModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -234,7 +229,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("imports") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("imports").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `imports` to be an array in the JSON string but got `%s`", jsonObj.get("imports").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `imports` to be an array in the JSON string but got `%s`", jsonObj.get("imports").toString())); } } @@ -295,7 +290,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ELFModel.java b/src/main/java/ai/reveng/model/ELFModel.java index 227a27ab..14c15202 100644 --- a/src/main/java/ai/reveng/model/ELFModel.java +++ b/src/main/java/ai/reveng/model/ELFModel.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ELFImportModel; import ai.reveng.model.ELFRelocation; import ai.reveng.model.ELFSection; @@ -53,7 +52,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -741,10 +739,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -768,113 +763,113 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ELFModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ELFModel is not found in the empty JSON string", ELFModel.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ELFModel is not found in the empty JSON string", ELFModel.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ELFModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("file_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `file_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("file_type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `file_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("file_type").toString())); } if (!jsonObj.get("architecture").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `architecture` to be a primitive type in the JSON string but got `%s`", jsonObj.get("architecture").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `architecture` to be a primitive type in the JSON string but got `%s`", jsonObj.get("architecture").toString())); } if (!jsonObj.get("endianness").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `endianness` to be a primitive type in the JSON string but got `%s`", jsonObj.get("endianness").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `endianness` to be a primitive type in the JSON string but got `%s`", jsonObj.get("endianness").toString())); } if (!jsonObj.get("entry_point_bytes").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `entry_point_bytes` to be a primitive type in the JSON string but got `%s`", jsonObj.get("entry_point_bytes").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `entry_point_bytes` to be a primitive type in the JSON string but got `%s`", jsonObj.get("entry_point_bytes").toString())); } if (!jsonObj.get("import_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `import_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("import_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `import_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("import_hash").toString())); } if (!jsonObj.get("export_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `export_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("export_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `export_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("export_hash").toString())); } if (!jsonObj.get("build_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `build_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("build_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `build_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("build_id").toString())); } // validate the required field `security` ELFSecurity.validateJsonElement(jsonObj.get("security")); - // ensure the json data is an array - if (!jsonObj.get("sections").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sections` to be an array in the JSON string but got `%s`", jsonObj.get("sections").toString())); + if (jsonObj.get("sections") != null) { + if (!jsonObj.get("sections").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sections` to be an array in the JSON string but got `%s`", jsonObj.get("sections").toString())); + } + JsonArray jsonArraysections = jsonObj.getAsJsonArray("sections"); + // validate the required field `sections` (array) + for (int i = 0; i < jsonArraysections.size(); i++) { + ELFSection.validateJsonElement(jsonArraysections.get(i)); + } } - - JsonArray jsonArraysections = jsonObj.getAsJsonArray("sections"); - // validate the required field `sections` (array) - for (int i = 0; i < jsonArraysections.size(); i++) { - ELFSection.validateJsonElement(jsonArraysections.get(i)); - }; - // ensure the json data is an array - if (!jsonObj.get("segments").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `segments` to be an array in the JSON string but got `%s`", jsonObj.get("segments").toString())); + if (jsonObj.get("segments") != null) { + if (!jsonObj.get("segments").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `segments` to be an array in the JSON string but got `%s`", jsonObj.get("segments").toString())); + } + JsonArray jsonArraysegments = jsonObj.getAsJsonArray("segments"); + // validate the required field `segments` (array) + for (int i = 0; i < jsonArraysegments.size(); i++) { + ELFSegment.validateJsonElement(jsonArraysegments.get(i)); + } } - - JsonArray jsonArraysegments = jsonObj.getAsJsonArray("segments"); - // validate the required field `segments` (array) - for (int i = 0; i < jsonArraysegments.size(); i++) { - ELFSegment.validateJsonElement(jsonArraysegments.get(i)); - }; - // ensure the json data is an array - if (!jsonObj.get("symbols").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `symbols` to be an array in the JSON string but got `%s`", jsonObj.get("symbols").toString())); + if (jsonObj.get("symbols") != null) { + if (!jsonObj.get("symbols").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `symbols` to be an array in the JSON string but got `%s`", jsonObj.get("symbols").toString())); + } + JsonArray jsonArraysymbols = jsonObj.getAsJsonArray("symbols"); + // validate the required field `symbols` (array) + for (int i = 0; i < jsonArraysymbols.size(); i++) { + ELFSymbol.validateJsonElement(jsonArraysymbols.get(i)); + } } - - JsonArray jsonArraysymbols = jsonObj.getAsJsonArray("symbols"); - // validate the required field `symbols` (array) - for (int i = 0; i < jsonArraysymbols.size(); i++) { - ELFSymbol.validateJsonElement(jsonArraysymbols.get(i)); - }; - // ensure the json data is an array - if (!jsonObj.get("dynamic_symbols").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `dynamic_symbols` to be an array in the JSON string but got `%s`", jsonObj.get("dynamic_symbols").toString())); + if (jsonObj.get("dynamic_symbols") != null) { + if (!jsonObj.get("dynamic_symbols").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `dynamic_symbols` to be an array in the JSON string but got `%s`", jsonObj.get("dynamic_symbols").toString())); + } + JsonArray jsonArraydynamicSymbols = jsonObj.getAsJsonArray("dynamic_symbols"); + // validate the required field `dynamic_symbols` (array) + for (int i = 0; i < jsonArraydynamicSymbols.size(); i++) { + ELFSymbol.validateJsonElement(jsonArraydynamicSymbols.get(i)); + } } - - JsonArray jsonArraydynamicSymbols = jsonObj.getAsJsonArray("dynamic_symbols"); - // validate the required field `dynamic_symbols` (array) - for (int i = 0; i < jsonArraydynamicSymbols.size(); i++) { - ELFSymbol.validateJsonElement(jsonArraydynamicSymbols.get(i)); - }; - // ensure the json data is an array - if (!jsonObj.get("relocations").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `relocations` to be an array in the JSON string but got `%s`", jsonObj.get("relocations").toString())); + if (jsonObj.get("relocations") != null) { + if (!jsonObj.get("relocations").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `relocations` to be an array in the JSON string but got `%s`", jsonObj.get("relocations").toString())); + } + JsonArray jsonArrayrelocations = jsonObj.getAsJsonArray("relocations"); + // validate the required field `relocations` (array) + for (int i = 0; i < jsonArrayrelocations.size(); i++) { + ELFRelocation.validateJsonElement(jsonArrayrelocations.get(i)); + } } - - JsonArray jsonArrayrelocations = jsonObj.getAsJsonArray("relocations"); - // validate the required field `relocations` (array) - for (int i = 0; i < jsonArrayrelocations.size(); i++) { - ELFRelocation.validateJsonElement(jsonArrayrelocations.get(i)); - }; // validate the required field `imports` ELFImportModel.validateJsonElement(jsonObj.get("imports")); // ensure the required json array is present if (jsonObj.get("exported_functions") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("exported_functions").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `exported_functions` to be an array in the JSON string but got `%s`", jsonObj.get("exported_functions").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `exported_functions` to be an array in the JSON string but got `%s`", jsonObj.get("exported_functions").toString())); } - // ensure the json data is an array - if (!jsonObj.get("dynamic_entries").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `dynamic_entries` to be an array in the JSON string but got `%s`", jsonObj.get("dynamic_entries").toString())); + if (jsonObj.get("dynamic_entries") != null) { + if (!jsonObj.get("dynamic_entries").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `dynamic_entries` to be an array in the JSON string but got `%s`", jsonObj.get("dynamic_entries").toString())); + } + JsonArray jsonArraydynamicEntries = jsonObj.getAsJsonArray("dynamic_entries"); + // validate the required field `dynamic_entries` (array) + for (int i = 0; i < jsonArraydynamicEntries.size(); i++) { + ElfDynamicEntry.validateJsonElement(jsonArraydynamicEntries.get(i)); + } } - - JsonArray jsonArraydynamicEntries = jsonObj.getAsJsonArray("dynamic_entries"); - // validate the required field `dynamic_entries` (array) - for (int i = 0; i < jsonArraydynamicEntries.size(); i++) { - ElfDynamicEntry.validateJsonElement(jsonArraydynamicEntries.get(i)); - }; // ensure the required json array is present if (jsonObj.get("notes") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("notes").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `notes` to be an array in the JSON string but got `%s`", jsonObj.get("notes").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `notes` to be an array in the JSON string but got `%s`", jsonObj.get("notes").toString())); } } @@ -935,7 +930,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ELFRelocation.java b/src/main/java/ai/reveng/model/ELFRelocation.java index 11e20594..97589a4e 100644 --- a/src/main/java/ai/reveng/model/ELFRelocation.java +++ b/src/main/java/ai/reveng/model/ELFRelocation.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -338,10 +336,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -365,22 +360,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ELFRelocation.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ELFRelocation is not found in the empty JSON string", ELFRelocation.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ELFRelocation is not found in the empty JSON string", ELFRelocation.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ELFRelocation.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } if (!jsonObj.get("symbol_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `symbol_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("symbol_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `symbol_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("symbol_name").toString())); } } @@ -441,7 +436,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ELFSection.java b/src/main/java/ai/reveng/model/ELFSection.java index cfde1bb8..270ea672 100644 --- a/src/main/java/ai/reveng/model/ELFSection.java +++ b/src/main/java/ai/reveng/model/ELFSection.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -391,10 +389,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -418,25 +413,25 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ELFSection.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ELFSection is not found in the empty JSON string", ELFSection.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ELFSection is not found in the empty JSON string", ELFSection.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ELFSection.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } if (!jsonObj.get("flags").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `flags` to be a primitive type in the JSON string but got `%s`", jsonObj.get("flags").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `flags` to be a primitive type in the JSON string but got `%s`", jsonObj.get("flags").toString())); } } @@ -497,7 +492,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ELFSecurity.java b/src/main/java/ai/reveng/model/ELFSecurity.java index 90c279e4..16549027 100644 --- a/src/main/java/ai/reveng/model/ELFSecurity.java +++ b/src/main/java/ai/reveng/model/ELFSecurity.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -260,10 +258,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -287,14 +282,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ELFSecurity.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ELFSecurity is not found in the empty JSON string", ELFSecurity.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ELFSecurity is not found in the empty JSON string", ELFSecurity.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ELFSecurity.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -357,7 +352,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ELFSegment.java b/src/main/java/ai/reveng/model/ELFSegment.java index 8ff78d76..67d3cde3 100644 --- a/src/main/java/ai/reveng/model/ELFSegment.java +++ b/src/main/java/ai/reveng/model/ELFSegment.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -364,10 +362,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -391,22 +386,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ELFSegment.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ELFSegment is not found in the empty JSON string", ELFSegment.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ELFSegment is not found in the empty JSON string", ELFSegment.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ELFSegment.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } if (!jsonObj.get("flags").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `flags` to be a primitive type in the JSON string but got `%s`", jsonObj.get("flags").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `flags` to be a primitive type in the JSON string but got `%s`", jsonObj.get("flags").toString())); } } @@ -467,7 +462,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ELFSymbol.java b/src/main/java/ai/reveng/model/ELFSymbol.java index 793e123d..46ae4519 100644 --- a/src/main/java/ai/reveng/model/ELFSymbol.java +++ b/src/main/java/ai/reveng/model/ELFSymbol.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -338,10 +336,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -365,28 +360,28 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ELFSymbol.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ELFSymbol is not found in the empty JSON string", ELFSymbol.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ELFSymbol is not found in the empty JSON string", ELFSymbol.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ELFSymbol.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } if (!jsonObj.get("binding").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binding` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binding").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binding` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binding").toString())); } if (!jsonObj.get("visibility").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `visibility` to be a primitive type in the JSON string but got `%s`", jsonObj.get("visibility").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `visibility` to be a primitive type in the JSON string but got `%s`", jsonObj.get("visibility").toString())); } } @@ -447,7 +442,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ElfDynamicEntry.java b/src/main/java/ai/reveng/model/ElfDynamicEntry.java index 230f1a56..0c1b8496 100644 --- a/src/main/java/ai/reveng/model/ElfDynamicEntry.java +++ b/src/main/java/ai/reveng/model/ElfDynamicEntry.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -182,10 +180,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -209,19 +204,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ElfDynamicEntry.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ElfDynamicEntry is not found in the empty JSON string", ElfDynamicEntry.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ElfDynamicEntry is not found in the empty JSON string", ElfDynamicEntry.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ElfDynamicEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("tag").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tag` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tag").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tag` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tag").toString())); } } @@ -282,7 +277,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EntrypointModel.java b/src/main/java/ai/reveng/model/EntrypointModel.java index 58eb3890..443eac91 100644 --- a/src/main/java/ai/reveng/model/EntrypointModel.java +++ b/src/main/java/ai/reveng/model/EntrypointModel.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -182,10 +180,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -209,19 +204,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EntrypointModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EntrypointModel is not found in the empty JSON string", EntrypointModel.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EntrypointModel is not found in the empty JSON string", EntrypointModel.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EntrypointModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("first_bytes").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `first_bytes` to be a primitive type in the JSON string but got `%s`", jsonObj.get("first_bytes").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `first_bytes` to be a primitive type in the JSON string but got `%s`", jsonObj.get("first_bytes").toString())); } } @@ -282,7 +277,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/Enumeration.java b/src/main/java/ai/reveng/model/Enumeration.java index 576fd747..ee910d7f 100644 --- a/src/main/java/ai/reveng/model/Enumeration.java +++ b/src/main/java/ai/reveng/model/Enumeration.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -83,7 +81,7 @@ public Enumeration lastChange(@javax.annotation.Nullable String lastChange) { } /** - * Get lastChange + * Timestamp of the last change to this enumeration * @return lastChange */ @javax.annotation.Nullable @@ -256,10 +254,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -283,25 +278,25 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Enumeration.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Enumeration is not found in the empty JSON string", Enumeration.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Enumeration is not found in the empty JSON string", Enumeration.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Enumeration.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("last_change") != null && !jsonObj.get("last_change").isJsonNull()) && !jsonObj.get("last_change").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `last_change` to be a primitive type in the JSON string but got `%s`", jsonObj.get("last_change").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `last_change` to be a primitive type in the JSON string but got `%s`", jsonObj.get("last_change").toString())); } if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if ((jsonObj.get("artifact_type") != null && !jsonObj.get("artifact_type").isJsonNull()) && !jsonObj.get("artifact_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `artifact_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("artifact_type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `artifact_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("artifact_type").toString())); } } @@ -362,7 +357,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ErrorBody.java b/src/main/java/ai/reveng/model/ErrorBody.java index 7d5741c4..0c8ae8ba 100644 --- a/src/main/java/ai/reveng/model/ErrorBody.java +++ b/src/main/java/ai/reveng/model/ErrorBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -327,50 +325,6 @@ public void setTraceId(@javax.annotation.Nonnull String traceId) { this.traceId = traceId; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ErrorBody instance itself - */ - public ErrorBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -386,13 +340,12 @@ public boolean equals(Object o) { Objects.equals(this.detail, errorBody.detail) && Objects.equals(this.docUrl, errorBody.docUrl) && Objects.equals(this.message, errorBody.message) && - Objects.equals(this.traceId, errorBody.traceId)&& - Objects.equals(this.additionalProperties, errorBody.additionalProperties); + Objects.equals(this.traceId, errorBody.traceId); } @Override public int hashCode() { - return Objects.hash(code, detail, docUrl, message, traceId, additionalProperties); + return Objects.hash(code, detail, docUrl, message, traceId); } @Override @@ -404,7 +357,6 @@ public String toString() { sb.append(" docUrl: ").append(toIndentedString(docUrl)).append("\n"); sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" traceId: ").append(toIndentedString(traceId)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -414,10 +366,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -441,33 +390,41 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ErrorBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ErrorBody is not found in the empty JSON string", ErrorBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ErrorBody is not found in the empty JSON string", ErrorBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ErrorBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ErrorBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ErrorBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("code").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `code` to be a primitive type in the JSON string but got `%s`", jsonObj.get("code").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `code` to be a primitive type in the JSON string but got `%s`", jsonObj.get("code").toString())); } // validate the required field `code` CodeEnum.validateJsonElement(jsonObj.get("code")); if ((jsonObj.get("detail") != null && !jsonObj.get("detail").isJsonNull()) && !jsonObj.get("detail").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `detail` to be a primitive type in the JSON string but got `%s`", jsonObj.get("detail").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `detail` to be a primitive type in the JSON string but got `%s`", jsonObj.get("detail").toString())); } if ((jsonObj.get("doc_url") != null && !jsonObj.get("doc_url").isJsonNull()) && !jsonObj.get("doc_url").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `doc_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("doc_url").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `doc_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("doc_url").toString())); } if (!jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (!jsonObj.get("trace_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `trace_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("trace_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `trace_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("trace_id").toString())); } } @@ -486,28 +443,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ErrorBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -515,28 +450,7 @@ else if (entry.getValue() instanceof Character) public ErrorBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ErrorBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ErrorModel.java b/src/main/java/ai/reveng/model/ErrorModel.java index 96074e8c..a4eb9e3d 100644 --- a/src/main/java/ai/reveng/model/ErrorModel.java +++ b/src/main/java/ai/reveng/model/ErrorModel.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -182,10 +180,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -209,22 +204,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ErrorModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ErrorModel is not found in the empty JSON string", ErrorModel.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ErrorModel is not found in the empty JSON string", ErrorModel.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ErrorModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("code").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `code` to be a primitive type in the JSON string but got `%s`", jsonObj.get("code").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `code` to be a primitive type in the JSON string but got `%s`", jsonObj.get("code").toString())); } if (!jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } } @@ -285,7 +280,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/Event.java b/src/main/java/ai/reveng/model/Event.java index d0dc60dc..b0deed47 100644 --- a/src/main/java/ai/reveng/model/Event.java +++ b/src/main/java/ai/reveng/model/Event.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -222,50 +220,6 @@ public void setType(@javax.annotation.Nonnull Integer type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the Event instance itself - */ - public Event putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -283,13 +237,12 @@ public boolean equals(Object o) { Objects.equals(this.eventId, event.eventId) && Objects.equals(this.role, event.role) && Objects.equals(this.tokensUsed, event.tokensUsed) && - Objects.equals(this.type, event.type)&& - Objects.equals(this.additionalProperties, event.additionalProperties); + Objects.equals(this.type, event.type); } @Override public int hashCode() { - return Objects.hash(conversationUuid, createdAt, data, eventId, role, tokensUsed, type, additionalProperties); + return Objects.hash(conversationUuid, createdAt, data, eventId, role, tokensUsed, type); } @Override @@ -303,7 +256,6 @@ public String toString() { sb.append(" role: ").append(toIndentedString(role)).append("\n"); sb.append(" tokensUsed: ").append(toIndentedString(tokensUsed)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -313,10 +265,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -340,19 +289,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Event.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Event is not found in the empty JSON string", Event.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Event is not found in the empty JSON string", Event.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!Event.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Event` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Event.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("conversation_uuid").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `conversation_uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("conversation_uuid").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `conversation_uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("conversation_uuid").toString())); } } @@ -371,28 +328,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Event value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -400,28 +335,7 @@ else if (entry.getValue() instanceof Character) public Event read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - Event instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/EventAttemptFailed.java b/src/main/java/ai/reveng/model/EventAttemptFailed.java index fbdbb49f..196155d7 100644 --- a/src/main/java/ai/reveng/model/EventAttemptFailed.java +++ b/src/main/java/ai/reveng/model/EventAttemptFailed.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AttemptFailedEvent; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventAttemptFailed.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventAttemptFailed is not found in the empty JSON string", EventAttemptFailed.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventAttemptFailed is not found in the empty JSON string", EventAttemptFailed.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventAttemptFailed.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + AttemptFailedEvent.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventAttemptStarted.java b/src/main/java/ai/reveng/model/EventAttemptStarted.java index afe141d1..f6a7e614 100644 --- a/src/main/java/ai/reveng/model/EventAttemptStarted.java +++ b/src/main/java/ai/reveng/model/EventAttemptStarted.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AttemptStartedEvent; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventAttemptStarted.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventAttemptStarted is not found in the empty JSON string", EventAttemptStarted.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventAttemptStarted is not found in the empty JSON string", EventAttemptStarted.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventAttemptStarted.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + AttemptStartedEvent.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventCONTEXTCOMPACTED.java b/src/main/java/ai/reveng/model/EventCONTEXTCOMPACTED.java index 605a30ce..3c034a33 100644 --- a/src/main/java/ai/reveng/model/EventCONTEXTCOMPACTED.java +++ b/src/main/java/ai/reveng/model/EventCONTEXTCOMPACTED.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SseEventContextCompactedData; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventCONTEXTCOMPACTED.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventCONTEXTCOMPACTED is not found in the empty JSON string", EventCONTEXTCOMPACTED.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventCONTEXTCOMPACTED is not found in the empty JSON string", EventCONTEXTCOMPACTED.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventCONTEXTCOMPACTED.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + SseEventContextCompactedData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventDecompFailed.java b/src/main/java/ai/reveng/model/EventDecompFailed.java index 34ad2085..8117857f 100644 --- a/src/main/java/ai/reveng/model/EventDecompFailed.java +++ b/src/main/java/ai/reveng/model/EventDecompFailed.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.DecompFailedEvent; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventDecompFailed.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventDecompFailed is not found in the empty JSON string", EventDecompFailed.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventDecompFailed is not found in the empty JSON string", EventDecompFailed.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventDecompFailed.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + DecompFailedEvent.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventDecompFinished.java b/src/main/java/ai/reveng/model/EventDecompFinished.java index a77d7309..a5ea568e 100644 --- a/src/main/java/ai/reveng/model/EventDecompFinished.java +++ b/src/main/java/ai/reveng/model/EventDecompFinished.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.DecompFinishedEvent; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventDecompFinished.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventDecompFinished is not found in the empty JSON string", EventDecompFinished.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventDecompFinished is not found in the empty JSON string", EventDecompFinished.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventDecompFinished.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + DecompFinishedEvent.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventProse.java b/src/main/java/ai/reveng/model/EventProse.java index 96e5fe57..e03e01f7 100644 --- a/src/main/java/ai/reveng/model/EventProse.java +++ b/src/main/java/ai/reveng/model/EventProse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ProseEvent; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventProse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventProse is not found in the empty JSON string", EventProse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventProse is not found in the empty JSON string", EventProse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventProse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + ProseEvent.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventRUNCANCELLED.java b/src/main/java/ai/reveng/model/EventRUNCANCELLED.java index b1924b95..2993907c 100644 --- a/src/main/java/ai/reveng/model/EventRUNCANCELLED.java +++ b/src/main/java/ai/reveng/model/EventRUNCANCELLED.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SseEventRunCancelledData; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventRUNCANCELLED.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventRUNCANCELLED is not found in the empty JSON string", EventRUNCANCELLED.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventRUNCANCELLED is not found in the empty JSON string", EventRUNCANCELLED.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventRUNCANCELLED.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + SseEventRunCancelledData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventRUNERROR.java b/src/main/java/ai/reveng/model/EventRUNERROR.java index cdb3fb86..b3521a8c 100644 --- a/src/main/java/ai/reveng/model/EventRUNERROR.java +++ b/src/main/java/ai/reveng/model/EventRUNERROR.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SseEventRunErrorData; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventRUNERROR.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventRUNERROR is not found in the empty JSON string", EventRUNERROR.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventRUNERROR is not found in the empty JSON string", EventRUNERROR.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventRUNERROR.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + SseEventRunErrorData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventRUNFINISHED.java b/src/main/java/ai/reveng/model/EventRUNFINISHED.java index 65b0ad5d..ea2f36a4 100644 --- a/src/main/java/ai/reveng/model/EventRUNFINISHED.java +++ b/src/main/java/ai/reveng/model/EventRUNFINISHED.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SseEventRunFinishedData; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventRUNFINISHED.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventRUNFINISHED is not found in the empty JSON string", EventRUNFINISHED.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventRUNFINISHED is not found in the empty JSON string", EventRUNFINISHED.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventRUNFINISHED.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + SseEventRunFinishedData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventRUNSTARTED.java b/src/main/java/ai/reveng/model/EventRUNSTARTED.java index fde173b5..95611ee3 100644 --- a/src/main/java/ai/reveng/model/EventRUNSTARTED.java +++ b/src/main/java/ai/reveng/model/EventRUNSTARTED.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SseEventRunStartedData; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventRUNSTARTED.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventRUNSTARTED is not found in the empty JSON string", EventRUNSTARTED.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventRUNSTARTED is not found in the empty JSON string", EventRUNSTARTED.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventRUNSTARTED.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + SseEventRunStartedData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventRenameApplied.java b/src/main/java/ai/reveng/model/EventRenameApplied.java index 6f6280eb..7cc8b82f 100644 --- a/src/main/java/ai/reveng/model/EventRenameApplied.java +++ b/src/main/java/ai/reveng/model/EventRenameApplied.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.RenameAppliedEvent; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventRenameApplied.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventRenameApplied is not found in the empty JSON string", EventRenameApplied.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventRenameApplied is not found in the empty JSON string", EventRenameApplied.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventRenameApplied.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + RenameAppliedEvent.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventSTEPFINISHED.java b/src/main/java/ai/reveng/model/EventSTEPFINISHED.java index 6db1e56e..9ff46464 100644 --- a/src/main/java/ai/reveng/model/EventSTEPFINISHED.java +++ b/src/main/java/ai/reveng/model/EventSTEPFINISHED.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SseEventStepFinishedData; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventSTEPFINISHED.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventSTEPFINISHED is not found in the empty JSON string", EventSTEPFINISHED.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventSTEPFINISHED is not found in the empty JSON string", EventSTEPFINISHED.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventSTEPFINISHED.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + SseEventStepFinishedData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventSTEPSTARTED.java b/src/main/java/ai/reveng/model/EventSTEPSTARTED.java index 6390a058..7d7302fd 100644 --- a/src/main/java/ai/reveng/model/EventSTEPSTARTED.java +++ b/src/main/java/ai/reveng/model/EventSTEPSTARTED.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SseEventStepStartedData; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventSTEPSTARTED.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventSTEPSTARTED is not found in the empty JSON string", EventSTEPSTARTED.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventSTEPSTARTED is not found in the empty JSON string", EventSTEPSTARTED.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventSTEPSTARTED.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + SseEventStepStartedData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventSourceDelta.java b/src/main/java/ai/reveng/model/EventSourceDelta.java index 97233dcd..eab33def 100644 --- a/src/main/java/ai/reveng/model/EventSourceDelta.java +++ b/src/main/java/ai/reveng/model/EventSourceDelta.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SourceDeltaEvent; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventSourceDelta.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventSourceDelta is not found in the empty JSON string", EventSourceDelta.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventSourceDelta is not found in the empty JSON string", EventSourceDelta.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventSourceDelta.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + SourceDeltaEvent.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventSourceReset.java b/src/main/java/ai/reveng/model/EventSourceReset.java index 7747c238..76fb69ae 100644 --- a/src/main/java/ai/reveng/model/EventSourceReset.java +++ b/src/main/java/ai/reveng/model/EventSourceReset.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SourceResetEvent; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventSourceReset.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventSourceReset is not found in the empty JSON string", EventSourceReset.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventSourceReset is not found in the empty JSON string", EventSourceReset.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventSourceReset.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + SourceResetEvent.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventTEXTMESSAGECONTENT.java b/src/main/java/ai/reveng/model/EventTEXTMESSAGECONTENT.java index 2cfe79fb..f804e8b4 100644 --- a/src/main/java/ai/reveng/model/EventTEXTMESSAGECONTENT.java +++ b/src/main/java/ai/reveng/model/EventTEXTMESSAGECONTENT.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SseEventTextMessageContentData; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventTEXTMESSAGECONTENT.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventTEXTMESSAGECONTENT is not found in the empty JSON string", EventTEXTMESSAGECONTENT.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventTEXTMESSAGECONTENT is not found in the empty JSON string", EventTEXTMESSAGECONTENT.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventTEXTMESSAGECONTENT.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + SseEventTextMessageContentData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventTEXTMESSAGEEND.java b/src/main/java/ai/reveng/model/EventTEXTMESSAGEEND.java index 95668874..85c89ffb 100644 --- a/src/main/java/ai/reveng/model/EventTEXTMESSAGEEND.java +++ b/src/main/java/ai/reveng/model/EventTEXTMESSAGEEND.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SseEventTextMessageEndData; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventTEXTMESSAGEEND.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventTEXTMESSAGEEND is not found in the empty JSON string", EventTEXTMESSAGEEND.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventTEXTMESSAGEEND is not found in the empty JSON string", EventTEXTMESSAGEEND.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventTEXTMESSAGEEND.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + SseEventTextMessageEndData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventTEXTMESSAGESTART.java b/src/main/java/ai/reveng/model/EventTEXTMESSAGESTART.java index 7b32de4b..9fa7812e 100644 --- a/src/main/java/ai/reveng/model/EventTEXTMESSAGESTART.java +++ b/src/main/java/ai/reveng/model/EventTEXTMESSAGESTART.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SseEventTextMessageStartData; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventTEXTMESSAGESTART.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventTEXTMESSAGESTART is not found in the empty JSON string", EventTEXTMESSAGESTART.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventTEXTMESSAGESTART is not found in the empty JSON string", EventTEXTMESSAGESTART.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventTEXTMESSAGESTART.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + SseEventTextMessageStartData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventTITLEUPDATED.java b/src/main/java/ai/reveng/model/EventTITLEUPDATED.java index 15b4c89c..daeb3fb8 100644 --- a/src/main/java/ai/reveng/model/EventTITLEUPDATED.java +++ b/src/main/java/ai/reveng/model/EventTITLEUPDATED.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SseEventTitleUpdatedData; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventTITLEUPDATED.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventTITLEUPDATED is not found in the empty JSON string", EventTITLEUPDATED.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventTITLEUPDATED is not found in the empty JSON string", EventTITLEUPDATED.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventTITLEUPDATED.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + SseEventTitleUpdatedData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventTOOLCALLARGSDELTA.java b/src/main/java/ai/reveng/model/EventTOOLCALLARGSDELTA.java index a7adf0d5..266310cb 100644 --- a/src/main/java/ai/reveng/model/EventTOOLCALLARGSDELTA.java +++ b/src/main/java/ai/reveng/model/EventTOOLCALLARGSDELTA.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SseEventToolCallArgsDeltaData; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventTOOLCALLARGSDELTA.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventTOOLCALLARGSDELTA is not found in the empty JSON string", EventTOOLCALLARGSDELTA.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventTOOLCALLARGSDELTA is not found in the empty JSON string", EventTOOLCALLARGSDELTA.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventTOOLCALLARGSDELTA.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + SseEventToolCallArgsDeltaData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventTOOLCALLEND.java b/src/main/java/ai/reveng/model/EventTOOLCALLEND.java index 8003a7f3..2d2a42f1 100644 --- a/src/main/java/ai/reveng/model/EventTOOLCALLEND.java +++ b/src/main/java/ai/reveng/model/EventTOOLCALLEND.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SseEventToolCallEndData; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventTOOLCALLEND.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventTOOLCALLEND is not found in the empty JSON string", EventTOOLCALLEND.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventTOOLCALLEND is not found in the empty JSON string", EventTOOLCALLEND.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventTOOLCALLEND.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + SseEventToolCallEndData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventTOOLCALLRESULT.java b/src/main/java/ai/reveng/model/EventTOOLCALLRESULT.java index 37c55629..69edf358 100644 --- a/src/main/java/ai/reveng/model/EventTOOLCALLRESULT.java +++ b/src/main/java/ai/reveng/model/EventTOOLCALLRESULT.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SseEventToolCallResultData; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventTOOLCALLRESULT.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventTOOLCALLRESULT is not found in the empty JSON string", EventTOOLCALLRESULT.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventTOOLCALLRESULT is not found in the empty JSON string", EventTOOLCALLRESULT.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventTOOLCALLRESULT.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + SseEventToolCallResultData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventTOOLCALLSTART.java b/src/main/java/ai/reveng/model/EventTOOLCALLSTART.java index 48ffd237..04605332 100644 --- a/src/main/java/ai/reveng/model/EventTOOLCALLSTART.java +++ b/src/main/java/ai/reveng/model/EventTOOLCALLSTART.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SseEventToolCallStartData; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventTOOLCALLSTART.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventTOOLCALLSTART is not found in the empty JSON string", EventTOOLCALLSTART.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventTOOLCALLSTART is not found in the empty JSON string", EventTOOLCALLSTART.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventTOOLCALLSTART.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + SseEventToolCallStartData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventTOOLCONFIRMATIONREQUIRED.java b/src/main/java/ai/reveng/model/EventTOOLCONFIRMATIONREQUIRED.java index 6204b064..1f6328f0 100644 --- a/src/main/java/ai/reveng/model/EventTOOLCONFIRMATIONREQUIRED.java +++ b/src/main/java/ai/reveng/model/EventTOOLCONFIRMATIONREQUIRED.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SseEventToolConfirmationRequiredData; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventTOOLCONFIRMATIONREQUIRED.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventTOOLCONFIRMATIONREQUIRED is not found in the empty JSON string", EventTOOLCONFIRMATIONREQUIRED.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventTOOLCONFIRMATIONREQUIRED is not found in the empty JSON string", EventTOOLCONFIRMATIONREQUIRED.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventTOOLCONFIRMATIONREQUIRED.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + SseEventToolConfirmationRequiredData.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/EventWarning.java b/src/main/java/ai/reveng/model/EventWarning.java index d2f5a8e1..9290ca71 100644 --- a/src/main/java/ai/reveng/model/EventWarning.java +++ b/src/main/java/ai/reveng/model/EventWarning.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.WarningEvent; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,19 +309,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EventWarning.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EventWarning is not found in the empty JSON string", EventWarning.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in EventWarning is not found in the empty JSON string", EventWarning.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventWarning.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `data` + WarningEvent.validateJsonElement(jsonObj.get("data")); if (!jsonObj.get("event").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `event` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event").toString())); } // validate the required field `event` EventEnum.validateJsonElement(jsonObj.get("event")); @@ -389,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ExportModel.java b/src/main/java/ai/reveng/model/ExportModel.java index d69af3fb..4e304810 100644 --- a/src/main/java/ai/reveng/model/ExportModel.java +++ b/src/main/java/ai/reveng/model/ExportModel.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -193,10 +191,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -220,14 +215,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ExportModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ExportModel is not found in the empty JSON string", ExportModel.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ExportModel is not found in the empty JSON string", ExportModel.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ExportModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -235,7 +230,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("exports") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("exports").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `exports` to be an array in the JSON string but got `%s`", jsonObj.get("exports").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `exports` to be an array in the JSON string but got `%s`", jsonObj.get("exports").toString())); } } @@ -296,7 +291,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ExternalResponse.java b/src/main/java/ai/reveng/model/ExternalResponse.java index 7917d54c..2f94c4e2 100644 --- a/src/main/java/ai/reveng/model/ExternalResponse.java +++ b/src/main/java/ai/reveng/model/ExternalResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -219,10 +217,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -246,19 +241,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ExternalResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ExternalResponse is not found in the empty JSON string", ExternalResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ExternalResponse is not found in the empty JSON string", ExternalResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ExternalResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("sha_256_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); } } @@ -319,7 +314,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ExtractedFileEntry.java b/src/main/java/ai/reveng/model/ExtractedFileEntry.java deleted file mode 100644 index 302e7f28..00000000 --- a/src/main/java/ai/reveng/model/ExtractedFileEntry.java +++ /dev/null @@ -1,558 +0,0 @@ -/* - * RevEng.AI API - * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. - * - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package ai.reveng.model; - -import java.util.Objects; -import java.util.Locale; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; -import org.openapitools.jackson.nullable.JsonNullable; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Locale; - -import ai.reveng.invoker.JSON; - -/** - * ExtractedFileEntry - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class ExtractedFileEntry { - public static final String SERIALIZED_NAME_FILE_HASH = "file_hash"; - @SerializedName(SERIALIZED_NAME_FILE_HASH) - @javax.annotation.Nullable - private String fileHash; - - public static final String SERIALIZED_NAME_FILE_SIZE = "file_size"; - @SerializedName(SERIALIZED_NAME_FILE_SIZE) - @javax.annotation.Nonnull - private Long fileSize; - - public static final String SERIALIZED_NAME_FILE_TYPE = "file_type"; - @SerializedName(SERIALIZED_NAME_FILE_TYPE) - @javax.annotation.Nullable - private String fileType; - - public static final String SERIALIZED_NAME_FILENAME = "filename"; - @SerializedName(SERIALIZED_NAME_FILENAME) - @javax.annotation.Nullable - private String filename; - - public static final String SERIALIZED_NAME_IS_PE = "is_pe"; - @SerializedName(SERIALIZED_NAME_IS_PE) - @javax.annotation.Nullable - private Boolean isPe; - - public static final String SERIALIZED_NAME_MIME_TYPE = "mime_type"; - @SerializedName(SERIALIZED_NAME_MIME_TYPE) - @javax.annotation.Nullable - private String mimeType; - - public static final String SERIALIZED_NAME_REASON = "reason"; - @SerializedName(SERIALIZED_NAME_REASON) - @javax.annotation.Nullable - private String reason; - - public static final String SERIALIZED_NAME_SEQ_NUM = "seq_num"; - @SerializedName(SERIALIZED_NAME_SEQ_NUM) - @javax.annotation.Nonnull - private Long seqNum; - - public static final String SERIALIZED_NAME_SHA256 = "sha256"; - @SerializedName(SERIALIZED_NAME_SHA256) - @javax.annotation.Nullable - private String sha256; - - public static final String SERIALIZED_NAME_ZIP_FILENAME = "zip_filename"; - @SerializedName(SERIALIZED_NAME_ZIP_FILENAME) - @javax.annotation.Nullable - private String zipFilename; - - public ExtractedFileEntry() { - } - - public ExtractedFileEntry fileHash(@javax.annotation.Nullable String fileHash) { - this.fileHash = fileHash; - return this; - } - - /** - * Get fileHash - * @return fileHash - */ - @javax.annotation.Nullable - public String getFileHash() { - return fileHash; - } - - public void setFileHash(@javax.annotation.Nullable String fileHash) { - this.fileHash = fileHash; - } - - - public ExtractedFileEntry fileSize(@javax.annotation.Nonnull Long fileSize) { - this.fileSize = fileSize; - return this; - } - - /** - * Get fileSize - * @return fileSize - */ - @javax.annotation.Nonnull - public Long getFileSize() { - return fileSize; - } - - public void setFileSize(@javax.annotation.Nonnull Long fileSize) { - this.fileSize = fileSize; - } - - - public ExtractedFileEntry fileType(@javax.annotation.Nullable String fileType) { - this.fileType = fileType; - return this; - } - - /** - * Get fileType - * @return fileType - */ - @javax.annotation.Nullable - public String getFileType() { - return fileType; - } - - public void setFileType(@javax.annotation.Nullable String fileType) { - this.fileType = fileType; - } - - - public ExtractedFileEntry filename(@javax.annotation.Nullable String filename) { - this.filename = filename; - return this; - } - - /** - * Get filename - * @return filename - */ - @javax.annotation.Nullable - public String getFilename() { - return filename; - } - - public void setFilename(@javax.annotation.Nullable String filename) { - this.filename = filename; - } - - - public ExtractedFileEntry isPe(@javax.annotation.Nullable Boolean isPe) { - this.isPe = isPe; - return this; - } - - /** - * Get isPe - * @return isPe - */ - @javax.annotation.Nullable - public Boolean getIsPe() { - return isPe; - } - - public void setIsPe(@javax.annotation.Nullable Boolean isPe) { - this.isPe = isPe; - } - - - public ExtractedFileEntry mimeType(@javax.annotation.Nullable String mimeType) { - this.mimeType = mimeType; - return this; - } - - /** - * Get mimeType - * @return mimeType - */ - @javax.annotation.Nullable - public String getMimeType() { - return mimeType; - } - - public void setMimeType(@javax.annotation.Nullable String mimeType) { - this.mimeType = mimeType; - } - - - public ExtractedFileEntry reason(@javax.annotation.Nullable String reason) { - this.reason = reason; - return this; - } - - /** - * Get reason - * @return reason - */ - @javax.annotation.Nullable - public String getReason() { - return reason; - } - - public void setReason(@javax.annotation.Nullable String reason) { - this.reason = reason; - } - - - public ExtractedFileEntry seqNum(@javax.annotation.Nonnull Long seqNum) { - this.seqNum = seqNum; - return this; - } - - /** - * Get seqNum - * @return seqNum - */ - @javax.annotation.Nonnull - public Long getSeqNum() { - return seqNum; - } - - public void setSeqNum(@javax.annotation.Nonnull Long seqNum) { - this.seqNum = seqNum; - } - - - public ExtractedFileEntry sha256(@javax.annotation.Nullable String sha256) { - this.sha256 = sha256; - return this; - } - - /** - * Get sha256 - * @return sha256 - */ - @javax.annotation.Nullable - public String getSha256() { - return sha256; - } - - public void setSha256(@javax.annotation.Nullable String sha256) { - this.sha256 = sha256; - } - - - public ExtractedFileEntry zipFilename(@javax.annotation.Nullable String zipFilename) { - this.zipFilename = zipFilename; - return this; - } - - /** - * Get zipFilename - * @return zipFilename - */ - @javax.annotation.Nullable - public String getZipFilename() { - return zipFilename; - } - - public void setZipFilename(@javax.annotation.Nullable String zipFilename) { - this.zipFilename = zipFilename; - } - - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ExtractedFileEntry instance itself - */ - public ExtractedFileEntry putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ExtractedFileEntry extractedFileEntry = (ExtractedFileEntry) o; - return Objects.equals(this.fileHash, extractedFileEntry.fileHash) && - Objects.equals(this.fileSize, extractedFileEntry.fileSize) && - Objects.equals(this.fileType, extractedFileEntry.fileType) && - Objects.equals(this.filename, extractedFileEntry.filename) && - Objects.equals(this.isPe, extractedFileEntry.isPe) && - Objects.equals(this.mimeType, extractedFileEntry.mimeType) && - Objects.equals(this.reason, extractedFileEntry.reason) && - Objects.equals(this.seqNum, extractedFileEntry.seqNum) && - Objects.equals(this.sha256, extractedFileEntry.sha256) && - Objects.equals(this.zipFilename, extractedFileEntry.zipFilename)&& - Objects.equals(this.additionalProperties, extractedFileEntry.additionalProperties); - } - - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); - } - - @Override - public int hashCode() { - return Objects.hash(fileHash, fileSize, fileType, filename, isPe, mimeType, reason, seqNum, sha256, zipFilename, additionalProperties); - } - - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ExtractedFileEntry {\n"); - sb.append(" fileHash: ").append(toIndentedString(fileHash)).append("\n"); - sb.append(" fileSize: ").append(toIndentedString(fileSize)).append("\n"); - sb.append(" fileType: ").append(toIndentedString(fileType)).append("\n"); - sb.append(" filename: ").append(toIndentedString(filename)).append("\n"); - sb.append(" isPe: ").append(toIndentedString(isPe)).append("\n"); - sb.append(" mimeType: ").append(toIndentedString(mimeType)).append("\n"); - sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); - sb.append(" seqNum: ").append(toIndentedString(seqNum)).append("\n"); - sb.append(" sha256: ").append(toIndentedString(sha256)).append("\n"); - sb.append(" zipFilename: ").append(toIndentedString(zipFilename)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("file_hash", "file_size", "file_type", "filename", "is_pe", "mime_type", "reason", "seq_num", "sha256", "zip_filename")); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(Arrays.asList("file_size", "filename", "seq_num", "zip_filename")); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to ExtractedFileEntry - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!ExtractedFileEntry.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ExtractedFileEntry is not found in the empty JSON string", ExtractedFileEntry.openapiRequiredFields.toString())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : ExtractedFileEntry.openapiRequiredFields) { - if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("file_hash") != null && !jsonObj.get("file_hash").isJsonNull()) && !jsonObj.get("file_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `file_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("file_hash").toString())); - } - if ((jsonObj.get("file_type") != null && !jsonObj.get("file_type").isJsonNull()) && !jsonObj.get("file_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `file_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("file_type").toString())); - } - if ((jsonObj.get("filename") != null && !jsonObj.get("filename").isJsonNull()) && !jsonObj.get("filename").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `filename` to be a primitive type in the JSON string but got `%s`", jsonObj.get("filename").toString())); - } - if ((jsonObj.get("mime_type") != null && !jsonObj.get("mime_type").isJsonNull()) && !jsonObj.get("mime_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `mime_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mime_type").toString())); - } - if ((jsonObj.get("reason") != null && !jsonObj.get("reason").isJsonNull()) && !jsonObj.get("reason").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); - } - if ((jsonObj.get("sha256") != null && !jsonObj.get("sha256").isJsonNull()) && !jsonObj.get("sha256").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha256` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha256").toString())); - } - if ((jsonObj.get("zip_filename") != null && !jsonObj.get("zip_filename").isJsonNull()) && !jsonObj.get("zip_filename").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `zip_filename` to be a primitive type in the JSON string but got `%s`", jsonObj.get("zip_filename").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!ExtractedFileEntry.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'ExtractedFileEntry' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(ExtractedFileEntry.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, ExtractedFileEntry value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } - elementAdapter.write(out, obj); - } - - @Override - public ExtractedFileEntry read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ExtractedFileEntry instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; - } - - }.nullSafe(); - } - } - - /** - * Create an instance of ExtractedFileEntry given an JSON string - * - * @param jsonString JSON string - * @return An instance of ExtractedFileEntry - * @throws IOException if the JSON string is invalid with respect to ExtractedFileEntry - */ - public static ExtractedFileEntry fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, ExtractedFileEntry.class); - } - - /** - * Convert an instance of ExtractedFileEntry to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/ai/reveng/model/ExtractedURL.java b/src/main/java/ai/reveng/model/ExtractedURL.java index d9b5fe63..ddf6935f 100644 --- a/src/main/java/ai/reveng/model/ExtractedURL.java +++ b/src/main/java/ai/reveng/model/ExtractedURL.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ReportEvent; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -62,7 +60,7 @@ public class ExtractedURL { public static final String SERIALIZED_NAME_URL = "url"; @SerializedName(SERIALIZED_NAME_URL) - @javax.annotation.Nullable + @javax.annotation.Nonnull private String url; public ExtractedURL() { @@ -95,7 +93,7 @@ public void setEvents(@javax.annotation.Nullable List events) { } - public ExtractedURL url(@javax.annotation.Nullable String url) { + public ExtractedURL url(@javax.annotation.Nonnull String url) { this.url = url; return this; } @@ -104,59 +102,15 @@ public ExtractedURL url(@javax.annotation.Nullable String url) { * Get url * @return url */ - @javax.annotation.Nullable + @javax.annotation.Nonnull public String getUrl() { return url; } - public void setUrl(@javax.annotation.Nullable String url) { + public void setUrl(@javax.annotation.Nonnull String url) { this.url = url; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ExtractedURL instance itself - */ - public ExtractedURL putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -169,8 +123,7 @@ public boolean equals(Object o) { } ExtractedURL extractedURL = (ExtractedURL) o; return Objects.equals(this.events, extractedURL.events) && - Objects.equals(this.url, extractedURL.url)&& - Objects.equals(this.additionalProperties, extractedURL.additionalProperties); + Objects.equals(this.url, extractedURL.url); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -179,7 +132,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(events, url, additionalProperties); + return Objects.hash(events, url); } private static int hashCodeNullable(JsonNullable a) { @@ -195,7 +148,6 @@ public String toString() { sb.append("class ExtractedURL {\n"); sb.append(" events: ").append(toIndentedString(events)).append("\n"); sb.append(" url: ").append(toIndentedString(url)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -205,10 +157,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -232,23 +181,41 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ExtractedURL.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ExtractedURL is not found in the empty JSON string", ExtractedURL.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ExtractedURL is not found in the empty JSON string", ExtractedURL.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ExtractedURL.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ExtractedURL` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ExtractedURL.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the optional json data is an array if present - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull() && !jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { + JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); + if (jsonArrayevents != null) { + // ensure the json data is an array + if (!jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + } + + // validate the optional field `events` (array) + for (int i = 0; i < jsonArrayevents.size(); i++) { + ReportEvent.validateJsonElement(jsonArrayevents.get(i)); + }; + } } - if ((jsonObj.get("url") != null && !jsonObj.get("url").isJsonNull()) && !jsonObj.get("url").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("url").toString())); + if (!jsonObj.get("url").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("url").toString())); } } @@ -267,28 +234,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ExtractedURL value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -296,28 +241,7 @@ else if (entry.getValue() instanceof Character) public ExtractedURL read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ExtractedURL instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/FileActivityEntry.java b/src/main/java/ai/reveng/model/FileActivityEntry.java index d3d4702b..c4058e5a 100644 --- a/src/main/java/ai/reveng/model/FileActivityEntry.java +++ b/src/main/java/ai/reveng/model/FileActivityEntry.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ReportEvent; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -62,7 +60,7 @@ public class FileActivityEntry { public static final String SERIALIZED_NAME_PATH = "path"; @SerializedName(SERIALIZED_NAME_PATH) - @javax.annotation.Nullable + @javax.annotation.Nonnull private String path; public FileActivityEntry() { @@ -95,7 +93,7 @@ public void setEvents(@javax.annotation.Nullable List events) { } - public FileActivityEntry path(@javax.annotation.Nullable String path) { + public FileActivityEntry path(@javax.annotation.Nonnull String path) { this.path = path; return this; } @@ -104,59 +102,15 @@ public FileActivityEntry path(@javax.annotation.Nullable String path) { * Get path * @return path */ - @javax.annotation.Nullable + @javax.annotation.Nonnull public String getPath() { return path; } - public void setPath(@javax.annotation.Nullable String path) { + public void setPath(@javax.annotation.Nonnull String path) { this.path = path; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the FileActivityEntry instance itself - */ - public FileActivityEntry putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -169,8 +123,7 @@ public boolean equals(Object o) { } FileActivityEntry fileActivityEntry = (FileActivityEntry) o; return Objects.equals(this.events, fileActivityEntry.events) && - Objects.equals(this.path, fileActivityEntry.path)&& - Objects.equals(this.additionalProperties, fileActivityEntry.additionalProperties); + Objects.equals(this.path, fileActivityEntry.path); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -179,7 +132,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(events, path, additionalProperties); + return Objects.hash(events, path); } private static int hashCodeNullable(JsonNullable a) { @@ -195,7 +148,6 @@ public String toString() { sb.append("class FileActivityEntry {\n"); sb.append(" events: ").append(toIndentedString(events)).append("\n"); sb.append(" path: ").append(toIndentedString(path)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -205,10 +157,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -232,23 +181,41 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FileActivityEntry.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FileActivityEntry is not found in the empty JSON string", FileActivityEntry.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FileActivityEntry is not found in the empty JSON string", FileActivityEntry.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!FileActivityEntry.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FileActivityEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FileActivityEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the optional json data is an array if present - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull() && !jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { + JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); + if (jsonArrayevents != null) { + // ensure the json data is an array + if (!jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + } + + // validate the optional field `events` (array) + for (int i = 0; i < jsonArrayevents.size(); i++) { + ReportEvent.validateJsonElement(jsonArrayevents.get(i)); + }; + } } - if ((jsonObj.get("path") != null && !jsonObj.get("path").isJsonNull()) && !jsonObj.get("path").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `path` to be a primitive type in the JSON string but got `%s`", jsonObj.get("path").toString())); + if (!jsonObj.get("path").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `path` to be a primitive type in the JSON string but got `%s`", jsonObj.get("path").toString())); } } @@ -267,28 +234,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FileActivityEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -296,28 +241,7 @@ else if (entry.getValue() instanceof Character) public FileActivityEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - FileActivityEntry instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/FileFormat.java b/src/main/java/ai/reveng/model/FileFormat.java index ee723940..b4f81581 100644 --- a/src/main/java/ai/reveng/model/FileFormat.java +++ b/src/main/java/ai/reveng/model/FileFormat.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/FileHashes.java b/src/main/java/ai/reveng/model/FileHashes.java index d42d3eda..64a0b40e 100644 --- a/src/main/java/ai/reveng/model/FileHashes.java +++ b/src/main/java/ai/reveng/model/FileHashes.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -338,10 +336,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -365,40 +360,40 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FileHashes.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FileHashes is not found in the empty JSON string", FileHashes.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FileHashes is not found in the empty JSON string", FileHashes.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FileHashes.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("md5") != null && !jsonObj.get("md5").isJsonNull()) && !jsonObj.get("md5").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `md5` to be a primitive type in the JSON string but got `%s`", jsonObj.get("md5").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `md5` to be a primitive type in the JSON string but got `%s`", jsonObj.get("md5").toString())); } if ((jsonObj.get("sha1") != null && !jsonObj.get("sha1").isJsonNull()) && !jsonObj.get("sha1").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha1` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha1").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha1` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha1").toString())); } if ((jsonObj.get("sha256") != null && !jsonObj.get("sha256").isJsonNull()) && !jsonObj.get("sha256").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha256` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha256").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha256` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha256").toString())); } if ((jsonObj.get("sha512") != null && !jsonObj.get("sha512").isJsonNull()) && !jsonObj.get("sha512").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha512` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha512").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha512` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha512").toString())); } if ((jsonObj.get("sha3_224") != null && !jsonObj.get("sha3_224").isJsonNull()) && !jsonObj.get("sha3_224").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha3_224` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha3_224").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha3_224` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha3_224").toString())); } if ((jsonObj.get("sha3_256") != null && !jsonObj.get("sha3_256").isJsonNull()) && !jsonObj.get("sha3_256").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha3_256` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha3_256").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha3_256` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha3_256").toString())); } if ((jsonObj.get("sha3_384") != null && !jsonObj.get("sha3_384").isJsonNull()) && !jsonObj.get("sha3_384").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha3_384` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha3_384").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha3_384` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha3_384").toString())); } if ((jsonObj.get("sha3_512") != null && !jsonObj.get("sha3_512").isJsonNull()) && !jsonObj.get("sha3_512").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha3_512` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha3_512").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha3_512` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha3_512").toString())); } } @@ -459,7 +454,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FileMetadata.java b/src/main/java/ai/reveng/model/FileMetadata.java index 692b79d7..236f910f 100644 --- a/src/main/java/ai/reveng/model/FileMetadata.java +++ b/src/main/java/ai/reveng/model/FileMetadata.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FileHashes; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -236,10 +234,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -263,19 +258,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FileMetadata.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FileMetadata is not found in the empty JSON string", FileMetadata.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FileMetadata is not found in the empty JSON string", FileMetadata.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FileMetadata.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("friendly_size").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `friendly_size` to be a primitive type in the JSON string but got `%s`", jsonObj.get("friendly_size").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `friendly_size` to be a primitive type in the JSON string but got `%s`", jsonObj.get("friendly_size").toString())); } // validate the required field `hashes` FileHashes.validateJsonElement(jsonObj.get("hashes")); @@ -338,7 +333,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/Filters.java b/src/main/java/ai/reveng/model/Filters.java index 5f907b42..72636932 100644 --- a/src/main/java/ai/reveng/model/Filters.java +++ b/src/main/java/ai/reveng/model/Filters.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/FunctionInfoInputFuncDepsInner.java b/src/main/java/ai/reveng/model/FuncDepsInner.java similarity index 79% rename from src/main/java/ai/reveng/model/FunctionInfoInputFuncDepsInner.java rename to src/main/java/ai/reveng/model/FuncDepsInner.java index 0b9416ef..3bd67734 100644 --- a/src/main/java/ai/reveng/model/FunctionInfoInputFuncDepsInner.java +++ b/src/main/java/ai/reveng/model/FuncDepsInner.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.Enumeration; import ai.reveng.model.GlobalVariable; import ai.reveng.model.Structure; @@ -40,7 +39,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Locale; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -65,15 +63,15 @@ import ai.reveng.invoker.JSON; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class FunctionInfoInputFuncDepsInner extends AbstractOpenApiSchema { - private static final Logger log = Logger.getLogger(FunctionInfoInputFuncDepsInner.class.getName()); +public class FuncDepsInner extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(FuncDepsInner.class.getName()); public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!FunctionInfoInputFuncDepsInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'FunctionInfoInputFuncDepsInner' and its subtypes + if (!FuncDepsInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FuncDepsInner' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); final TypeAdapter adapterStructure = gson.getDelegateAdapter(this, TypeToken.get(Structure.class)); @@ -81,9 +79,9 @@ public TypeAdapter create(Gson gson, TypeToken type) { final TypeAdapter adapterTypeDefinition = gson.getDelegateAdapter(this, TypeToken.get(TypeDefinition.class)); final TypeAdapter adapterGlobalVariable = gson.getDelegateAdapter(this, TypeToken.get(GlobalVariable.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, FunctionInfoInputFuncDepsInner value) throws IOException { + public void write(JsonWriter out, FuncDepsInner value) throws IOException { if (value == null || value.getActualInstance() == null) { elementAdapter.write(out, null); return; @@ -117,7 +115,7 @@ public void write(JsonWriter out, FunctionInfoInputFuncDepsInner value) throws I } @Override - public FunctionInfoInputFuncDepsInner read(JsonReader in) throws IOException { + public FuncDepsInner read(JsonReader in) throws IOException { Object deserialized = null; JsonElement jsonElement = elementAdapter.read(in); @@ -129,12 +127,12 @@ public FunctionInfoInputFuncDepsInner read(JsonReader in) throws IOException { // validate the JSON object to see if any exception is thrown Structure.validateJsonElement(jsonElement); actualAdapter = adapterStructure; - FunctionInfoInputFuncDepsInner ret = new FunctionInfoInputFuncDepsInner(); + FuncDepsInner ret = new FuncDepsInner(); ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); return ret; } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for Structure failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for Structure failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'Structure'", e); } // deserialize Enumeration @@ -142,12 +140,12 @@ public FunctionInfoInputFuncDepsInner read(JsonReader in) throws IOException { // validate the JSON object to see if any exception is thrown Enumeration.validateJsonElement(jsonElement); actualAdapter = adapterEnumeration; - FunctionInfoInputFuncDepsInner ret = new FunctionInfoInputFuncDepsInner(); + FuncDepsInner ret = new FuncDepsInner(); ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); return ret; } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for Enumeration failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for Enumeration failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'Enumeration'", e); } // deserialize TypeDefinition @@ -155,12 +153,12 @@ public FunctionInfoInputFuncDepsInner read(JsonReader in) throws IOException { // validate the JSON object to see if any exception is thrown TypeDefinition.validateJsonElement(jsonElement); actualAdapter = adapterTypeDefinition; - FunctionInfoInputFuncDepsInner ret = new FunctionInfoInputFuncDepsInner(); + FuncDepsInner ret = new FuncDepsInner(); ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); return ret; } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for TypeDefinition failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for TypeDefinition failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'TypeDefinition'", e); } // deserialize GlobalVariable @@ -168,16 +166,16 @@ public FunctionInfoInputFuncDepsInner read(JsonReader in) throws IOException { // validate the JSON object to see if any exception is thrown GlobalVariable.validateJsonElement(jsonElement); actualAdapter = adapterGlobalVariable; - FunctionInfoInputFuncDepsInner ret = new FunctionInfoInputFuncDepsInner(); + FuncDepsInner ret = new FuncDepsInner(); ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); return ret; } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for GlobalVariable failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for GlobalVariable failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'GlobalVariable'", e); } - throw new IOException(String.format(Locale.ROOT, "Failed deserialization for FunctionInfoInputFuncDepsInner: no class matches result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); + throw new IOException(String.format(java.util.Locale.ROOT, "Failed deserialization for FuncDepsInner: no class matches result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); } }.nullSafe(); } @@ -186,11 +184,11 @@ public FunctionInfoInputFuncDepsInner read(JsonReader in) throws IOException { // store a list of schema names defined in anyOf public static final Map> schemas = new HashMap>(); - public FunctionInfoInputFuncDepsInner() { + public FuncDepsInner() { super("anyOf", Boolean.FALSE); } - public FunctionInfoInputFuncDepsInner(Object o) { + public FuncDepsInner(Object o) { super("anyOf", Boolean.FALSE); setActualInstance(o); } @@ -204,7 +202,7 @@ public FunctionInfoInputFuncDepsInner(Object o) { @Override public Map> getSchemas() { - return FunctionInfoInputFuncDepsInner.schemas; + return FuncDepsInner.schemas; } /** @@ -299,7 +297,7 @@ public GlobalVariable getGlobalVariable() throws ClassCastException { * Validates the JSON Element and throws an exception if issues found * * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to FunctionInfoInputFuncDepsInner + * @throws IOException if the JSON Element is invalid with respect to FuncDepsInner */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { // validate anyOf schemas one by one @@ -309,7 +307,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti Structure.validateJsonElement(jsonElement); return; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for Structure failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for Structure failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with Enumeration @@ -317,7 +315,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti Enumeration.validateJsonElement(jsonElement); return; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for Enumeration failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for Enumeration failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with TypeDefinition @@ -325,7 +323,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti TypeDefinition.validateJsonElement(jsonElement); return; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for TypeDefinition failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for TypeDefinition failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with GlobalVariable @@ -333,25 +331,25 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti GlobalVariable.validateJsonElement(jsonElement); return; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for GlobalVariable failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for GlobalVariable failed with `%s`.", e.getMessage())); // continue to the next one } - throw new IOException(String.format(Locale.ROOT, "The JSON string is invalid for FunctionInfoInputFuncDepsInner with anyOf schemas: Enumeration, GlobalVariable, Structure, TypeDefinition. no class match the result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); + throw new IOException(String.format(java.util.Locale.ROOT, "The JSON string is invalid for FuncDepsInner with anyOf schemas: Enumeration, GlobalVariable, Structure, TypeDefinition. no class match the result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); } /** - * Create an instance of FunctionInfoInputFuncDepsInner given an JSON string + * Create an instance of FuncDepsInner given an JSON string * * @param jsonString JSON string - * @return An instance of FunctionInfoInputFuncDepsInner - * @throws IOException if the JSON string is invalid with respect to FunctionInfoInputFuncDepsInner + * @return An instance of FuncDepsInner + * @throws IOException if the JSON string is invalid with respect to FuncDepsInner */ - public static FunctionInfoInputFuncDepsInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, FunctionInfoInputFuncDepsInner.class); + public static FuncDepsInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FuncDepsInner.class); } /** - * Convert an instance of FunctionInfoInputFuncDepsInner to an JSON string + * Convert an instance of FuncDepsInner to an JSON string * * @return JSON string */ diff --git a/src/main/java/ai/reveng/model/FunctionBlockDestinationResponse.java b/src/main/java/ai/reveng/model/FunctionBlockDestinationResponse.java index 236ad69d..6d5f1cfe 100644 --- a/src/main/java/ai/reveng/model/FunctionBlockDestinationResponse.java +++ b/src/main/java/ai/reveng/model/FunctionBlockDestinationResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -75,7 +73,7 @@ public FunctionBlockDestinationResponse destinationBlockId(@javax.annotation.Nul } /** - * Get destinationBlockId + * The block where execution can flow to from the current block * @return destinationBlockId */ @javax.annotation.Nullable @@ -208,10 +206,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -235,22 +230,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionBlockDestinationResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionBlockDestinationResponse is not found in the empty JSON string", FunctionBlockDestinationResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionBlockDestinationResponse is not found in the empty JSON string", FunctionBlockDestinationResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionBlockDestinationResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("flowtype").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `flowtype` to be a primitive type in the JSON string but got `%s`", jsonObj.get("flowtype").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `flowtype` to be a primitive type in the JSON string but got `%s`", jsonObj.get("flowtype").toString())); } if (!jsonObj.get("vaddr").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `vaddr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("vaddr").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `vaddr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("vaddr").toString())); } } @@ -311,7 +306,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionBlockResponse.java b/src/main/java/ai/reveng/model/FunctionBlockResponse.java index 4f966db0..90ad78db 100644 --- a/src/main/java/ai/reveng/model/FunctionBlockResponse.java +++ b/src/main/java/ai/reveng/model/FunctionBlockResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FunctionBlockDestinationResponse; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -205,7 +203,7 @@ public FunctionBlockResponse comment(@javax.annotation.Nullable String comment) } /** - * Get comment + * An optional comment associated with this block, if any * @return comment */ @javax.annotation.Nullable @@ -317,10 +315,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -344,14 +339,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionBlockResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionBlockResponse is not found in the empty JSON string", FunctionBlockResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionBlockResponse is not found in the empty JSON string", FunctionBlockResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionBlockResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -359,20 +354,20 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("asm") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("asm").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `asm` to be an array in the JSON string but got `%s`", jsonObj.get("asm").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `asm` to be an array in the JSON string but got `%s`", jsonObj.get("asm").toString())); } - // ensure the json data is an array - if (!jsonObj.get("destinations").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `destinations` to be an array in the JSON string but got `%s`", jsonObj.get("destinations").toString())); + if (jsonObj.get("destinations") != null) { + if (!jsonObj.get("destinations").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `destinations` to be an array in the JSON string but got `%s`", jsonObj.get("destinations").toString())); + } + JsonArray jsonArraydestinations = jsonObj.getAsJsonArray("destinations"); + // validate the required field `destinations` (array) + for (int i = 0; i < jsonArraydestinations.size(); i++) { + FunctionBlockDestinationResponse.validateJsonElement(jsonArraydestinations.get(i)); + } } - - JsonArray jsonArraydestinations = jsonObj.getAsJsonArray("destinations"); - // validate the required field `destinations` (array) - for (int i = 0; i < jsonArraydestinations.size(); i++) { - FunctionBlockDestinationResponse.validateJsonElement(jsonArraydestinations.get(i)); - }; if ((jsonObj.get("comment") != null && !jsonObj.get("comment").isJsonNull()) && !jsonObj.get("comment").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `comment` to be a primitive type in the JSON string but got `%s`", jsonObj.get("comment").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `comment` to be a primitive type in the JSON string but got `%s`", jsonObj.get("comment").toString())); } } @@ -433,7 +428,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionBlocksResponse.java b/src/main/java/ai/reveng/model/FunctionBlocksResponse.java index 22538426..630a1236 100644 --- a/src/main/java/ai/reveng/model/FunctionBlocksResponse.java +++ b/src/main/java/ai/reveng/model/FunctionBlocksResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FunctionBlockResponse; import ai.reveng.model.FunctionLocalVariableResponse; import ai.reveng.model.FunctionParamResponse; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -167,7 +165,7 @@ public FunctionBlocksResponse overviewComment(@javax.annotation.Nullable String } /** - * Get overviewComment + * An overview comment for the whole function * @return overviewComment */ @javax.annotation.Nullable @@ -275,10 +273,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -302,49 +297,49 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionBlocksResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionBlocksResponse is not found in the empty JSON string", FunctionBlocksResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionBlocksResponse is not found in the empty JSON string", FunctionBlocksResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionBlocksResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("blocks").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `blocks` to be an array in the JSON string but got `%s`", jsonObj.get("blocks").toString())); + if (jsonObj.get("blocks") != null) { + if (!jsonObj.get("blocks").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `blocks` to be an array in the JSON string but got `%s`", jsonObj.get("blocks").toString())); + } + JsonArray jsonArrayblocks = jsonObj.getAsJsonArray("blocks"); + // validate the required field `blocks` (array) + for (int i = 0; i < jsonArrayblocks.size(); i++) { + FunctionBlockResponse.validateJsonElement(jsonArrayblocks.get(i)); + } } - - JsonArray jsonArrayblocks = jsonObj.getAsJsonArray("blocks"); - // validate the required field `blocks` (array) - for (int i = 0; i < jsonArrayblocks.size(); i++) { - FunctionBlockResponse.validateJsonElement(jsonArrayblocks.get(i)); - }; - // ensure the json data is an array - if (!jsonObj.get("local_variables").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `local_variables` to be an array in the JSON string but got `%s`", jsonObj.get("local_variables").toString())); + if (jsonObj.get("local_variables") != null) { + if (!jsonObj.get("local_variables").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `local_variables` to be an array in the JSON string but got `%s`", jsonObj.get("local_variables").toString())); + } + JsonArray jsonArraylocalVariables = jsonObj.getAsJsonArray("local_variables"); + // validate the required field `local_variables` (array) + for (int i = 0; i < jsonArraylocalVariables.size(); i++) { + FunctionLocalVariableResponse.validateJsonElement(jsonArraylocalVariables.get(i)); + } } - - JsonArray jsonArraylocalVariables = jsonObj.getAsJsonArray("local_variables"); - // validate the required field `local_variables` (array) - for (int i = 0; i < jsonArraylocalVariables.size(); i++) { - FunctionLocalVariableResponse.validateJsonElement(jsonArraylocalVariables.get(i)); - }; - // ensure the json data is an array - if (!jsonObj.get("params").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `params` to be an array in the JSON string but got `%s`", jsonObj.get("params").toString())); + if (jsonObj.get("params") != null) { + if (!jsonObj.get("params").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `params` to be an array in the JSON string but got `%s`", jsonObj.get("params").toString())); + } + JsonArray jsonArrayparams = jsonObj.getAsJsonArray("params"); + // validate the required field `params` (array) + for (int i = 0; i < jsonArrayparams.size(); i++) { + FunctionParamResponse.validateJsonElement(jsonArrayparams.get(i)); + } } - - JsonArray jsonArrayparams = jsonObj.getAsJsonArray("params"); - // validate the required field `params` (array) - for (int i = 0; i < jsonArrayparams.size(); i++) { - FunctionParamResponse.validateJsonElement(jsonArrayparams.get(i)); - }; if ((jsonObj.get("overview_comment") != null && !jsonObj.get("overview_comment").isJsonNull()) && !jsonObj.get("overview_comment").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `overview_comment` to be a primitive type in the JSON string but got `%s`", jsonObj.get("overview_comment").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `overview_comment` to be a primitive type in the JSON string but got `%s`", jsonObj.get("overview_comment").toString())); } } @@ -405,7 +400,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionBoundary.java b/src/main/java/ai/reveng/model/FunctionBoundary.java index 36a67fb3..5e3d2f94 100644 --- a/src/main/java/ai/reveng/model/FunctionBoundary.java +++ b/src/main/java/ai/reveng/model/FunctionBoundary.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -138,7 +136,7 @@ public FunctionBoundary includeInAnalysis(@javax.annotation.Nullable Boolean inc } /** - * Get includeInAnalysis + * Indicates whether the function should be included in the analysis * @return includeInAnalysis */ @javax.annotation.Nullable @@ -246,10 +244,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -273,19 +268,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionBoundary.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionBoundary is not found in the empty JSON string", FunctionBoundary.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionBoundary is not found in the empty JSON string", FunctionBoundary.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionBoundary.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("mangled_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mangled_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mangled_name").toString())); } } @@ -346,7 +341,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionCapabilityResponse.java b/src/main/java/ai/reveng/model/FunctionCapabilityResponse.java index 12eb66d8..73a77cad 100644 --- a/src/main/java/ai/reveng/model/FunctionCapabilityResponse.java +++ b/src/main/java/ai/reveng/model/FunctionCapabilityResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -166,10 +164,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -193,14 +188,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionCapabilityResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionCapabilityResponse is not found in the empty JSON string", FunctionCapabilityResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionCapabilityResponse is not found in the empty JSON string", FunctionCapabilityResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionCapabilityResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -208,7 +203,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("capabilities") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("capabilities").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `capabilities` to be an array in the JSON string but got `%s`", jsonObj.get("capabilities").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `capabilities` to be an array in the JSON string but got `%s`", jsonObj.get("capabilities").toString())); } } @@ -269,7 +264,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionCommentCreateRequest.java b/src/main/java/ai/reveng/model/FunctionCommentCreateRequest.java index 69b72e04..a52f7783 100644 --- a/src/main/java/ai/reveng/model/FunctionCommentCreateRequest.java +++ b/src/main/java/ai/reveng/model/FunctionCommentCreateRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.DecompilationCommentContext; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -183,10 +181,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -210,19 +205,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionCommentCreateRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionCommentCreateRequest is not found in the empty JSON string", FunctionCommentCreateRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionCommentCreateRequest is not found in the empty JSON string", FunctionCommentCreateRequest.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionCommentCreateRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("content").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `content` to be a primitive type in the JSON string but got `%s`", jsonObj.get("content").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `content` to be a primitive type in the JSON string but got `%s`", jsonObj.get("content").toString())); } // validate the optional field `context` if (jsonObj.get("context") != null && !jsonObj.get("context").isJsonNull()) { @@ -287,7 +282,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionDataTypes.java b/src/main/java/ai/reveng/model/FunctionDataTypes.java index ca20feaa..f348aefb 100644 --- a/src/main/java/ai/reveng/model/FunctionDataTypes.java +++ b/src/main/java/ai/reveng/model/FunctionDataTypes.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FunctionInfoOutput; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -120,7 +118,7 @@ public FunctionDataTypes dataTypes(@javax.annotation.Nullable FunctionInfoOutput } /** - * Get dataTypes + * Function data types information if available * @return dataTypes */ @javax.annotation.Nullable @@ -139,7 +137,7 @@ public FunctionDataTypes dataTypesVersion(@javax.annotation.Nullable Integer dat } /** - * Get dataTypesVersion + * If the data types information has been updated by the user, this field will be populated * @return dataTypesVersion */ @javax.annotation.Nullable @@ -247,10 +245,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -274,19 +269,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionDataTypes.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionDataTypes is not found in the empty JSON string", FunctionDataTypes.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionDataTypes is not found in the empty JSON string", FunctionDataTypes.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionDataTypes.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); } // validate the optional field `data_types` if (jsonObj.get("data_types") != null && !jsonObj.get("data_types").isJsonNull()) { @@ -351,7 +346,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionDataTypesList.java b/src/main/java/ai/reveng/model/FunctionDataTypesList.java index d23ffcca..db96206e 100644 --- a/src/main/java/ai/reveng/model/FunctionDataTypesList.java +++ b/src/main/java/ai/reveng/model/FunctionDataTypesList.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FunctionDataTypesListItem; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -219,10 +217,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -246,27 +241,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionDataTypesList.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionDataTypesList is not found in the empty JSON string", FunctionDataTypesList.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionDataTypesList is not found in the empty JSON string", FunctionDataTypesList.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionDataTypesList.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("items").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `items` to be an array in the JSON string but got `%s`", jsonObj.get("items").toString())); + if (jsonObj.get("items") != null) { + if (!jsonObj.get("items").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `items` to be an array in the JSON string but got `%s`", jsonObj.get("items").toString())); + } + JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); + // validate the required field `items` (array) + for (int i = 0; i < jsonArrayitems.size(); i++) { + FunctionDataTypesListItem.validateJsonElement(jsonArrayitems.get(i)); + } } - - JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); - // validate the required field `items` (array) - for (int i = 0; i < jsonArrayitems.size(); i++) { - FunctionDataTypesListItem.validateJsonElement(jsonArrayitems.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -326,7 +321,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionDataTypesListItem.java b/src/main/java/ai/reveng/model/FunctionDataTypesListItem.java index b247bae9..39a491d9 100644 --- a/src/main/java/ai/reveng/model/FunctionDataTypesListItem.java +++ b/src/main/java/ai/reveng/model/FunctionDataTypesListItem.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FunctionInfoOutput; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -125,7 +123,7 @@ public FunctionDataTypesListItem dataTypes(@javax.annotation.Nullable FunctionIn } /** - * Get dataTypes + * Function data types information if available * @return dataTypes */ @javax.annotation.Nullable @@ -144,7 +142,7 @@ public FunctionDataTypesListItem dataTypesVersion(@javax.annotation.Nullable Int } /** - * Get dataTypesVersion + * If the data types information has been updated by the user, this field will be populated * @return dataTypesVersion */ @javax.annotation.Nullable @@ -273,10 +271,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -300,19 +295,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionDataTypesListItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionDataTypesListItem is not found in the empty JSON string", FunctionDataTypesListItem.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionDataTypesListItem is not found in the empty JSON string", FunctionDataTypesListItem.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionDataTypesListItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); } // validate the optional field `data_types` if (jsonObj.get("data_types") != null && !jsonObj.get("data_types").isJsonNull()) { @@ -377,7 +372,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionDataTypesParams.java b/src/main/java/ai/reveng/model/FunctionDataTypesParams.java index 5ef2bf7b..af99b78a 100644 --- a/src/main/java/ai/reveng/model/FunctionDataTypesParams.java +++ b/src/main/java/ai/reveng/model/FunctionDataTypesParams.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -166,10 +164,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -193,14 +188,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionDataTypesParams.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionDataTypesParams is not found in the empty JSON string", FunctionDataTypesParams.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionDataTypesParams is not found in the empty JSON string", FunctionDataTypesParams.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionDataTypesParams.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -208,7 +203,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("function_ids") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("function_ids").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `function_ids` to be an array in the JSON string but got `%s`", jsonObj.get("function_ids").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_ids` to be an array in the JSON string but got `%s`", jsonObj.get("function_ids").toString())); } } @@ -269,7 +264,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionDataTypesStatus.java b/src/main/java/ai/reveng/model/FunctionDataTypesStatus.java index 2d4799fd..12e8d9c5 100644 --- a/src/main/java/ai/reveng/model/FunctionDataTypesStatus.java +++ b/src/main/java/ai/reveng/model/FunctionDataTypesStatus.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -208,10 +206,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -235,19 +230,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionDataTypesStatus.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionDataTypesStatus is not found in the empty JSON string", FunctionDataTypesStatus.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionDataTypesStatus is not found in the empty JSON string", FunctionDataTypesStatus.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionDataTypesStatus.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); } } @@ -308,7 +303,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionHeader.java b/src/main/java/ai/reveng/model/FunctionHeader.java index 44ef6099..e3f90124 100644 --- a/src/main/java/ai/reveng/model/FunctionHeader.java +++ b/src/main/java/ai/reveng/model/FunctionHeader.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.Argument; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -89,7 +87,7 @@ public FunctionHeader lastChange(@javax.annotation.Nullable String lastChange) { } /** - * Get lastChange + * Timestamp of the last change to this function header * @return lastChange */ @javax.annotation.Nullable @@ -283,10 +281,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -310,25 +305,25 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionHeader.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionHeader is not found in the empty JSON string", FunctionHeader.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionHeader is not found in the empty JSON string", FunctionHeader.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionHeader.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("last_change") != null && !jsonObj.get("last_change").isJsonNull()) && !jsonObj.get("last_change").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `last_change` to be a primitive type in the JSON string but got `%s`", jsonObj.get("last_change").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `last_change` to be a primitive type in the JSON string but got `%s`", jsonObj.get("last_change").toString())); } if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -389,7 +384,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionInfoInput.java b/src/main/java/ai/reveng/model/FunctionInfoInput.java index e8b15bd7..736c53e7 100644 --- a/src/main/java/ai/reveng/model/FunctionInfoInput.java +++ b/src/main/java/ai/reveng/model/FunctionInfoInput.java @@ -13,8 +13,7 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; -import ai.reveng.model.FunctionInfoInputFuncDepsInner; +import ai.reveng.model.FuncDepsInner; import ai.reveng.model.FunctionTypeInput; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -47,7 +46,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -64,7 +62,7 @@ public class FunctionInfoInput { public static final String SERIALIZED_NAME_FUNC_DEPS = "func_deps"; @SerializedName(SERIALIZED_NAME_FUNC_DEPS) @javax.annotation.Nonnull - private List funcDeps = new ArrayList<>(); + private List funcDeps = new ArrayList<>(); public FunctionInfoInput() { } @@ -75,7 +73,7 @@ public FunctionInfoInput funcTypes(@javax.annotation.Nullable FunctionTypeInput } /** - * Get funcTypes + * Function type information * @return funcTypes */ @javax.annotation.Nullable @@ -88,12 +86,12 @@ public void setFuncTypes(@javax.annotation.Nullable FunctionTypeInput funcTypes) } - public FunctionInfoInput funcDeps(@javax.annotation.Nonnull List funcDeps) { + public FunctionInfoInput funcDeps(@javax.annotation.Nonnull List funcDeps) { this.funcDeps = funcDeps; return this; } - public FunctionInfoInput addFuncDepsItem(FunctionInfoInputFuncDepsInner funcDepsItem) { + public FunctionInfoInput addFuncDepsItem(FuncDepsInner funcDepsItem) { if (this.funcDeps == null) { this.funcDeps = new ArrayList<>(); } @@ -106,11 +104,11 @@ public FunctionInfoInput addFuncDepsItem(FunctionInfoInputFuncDepsInner funcDeps * @return funcDeps */ @javax.annotation.Nonnull - public List getFuncDeps() { + public List getFuncDeps() { return funcDeps; } - public void setFuncDeps(@javax.annotation.Nonnull List funcDeps) { + public void setFuncDeps(@javax.annotation.Nonnull List funcDeps) { this.funcDeps = funcDeps; } @@ -206,10 +204,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -233,14 +228,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionInfoInput.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionInfoInput is not found in the empty JSON string", FunctionInfoInput.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionInfoInput is not found in the empty JSON string", FunctionInfoInput.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionInfoInput.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -248,16 +243,16 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("func_types") != null && !jsonObj.get("func_types").isJsonNull()) { FunctionTypeInput.validateJsonElement(jsonObj.get("func_types")); } - // ensure the json data is an array - if (!jsonObj.get("func_deps").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `func_deps` to be an array in the JSON string but got `%s`", jsonObj.get("func_deps").toString())); + if (jsonObj.get("func_deps") != null) { + if (!jsonObj.get("func_deps").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `func_deps` to be an array in the JSON string but got `%s`", jsonObj.get("func_deps").toString())); + } + JsonArray jsonArrayfuncDeps = jsonObj.getAsJsonArray("func_deps"); + // validate the required field `func_deps` (array) + for (int i = 0; i < jsonArrayfuncDeps.size(); i++) { + FuncDepsInner.validateJsonElement(jsonArrayfuncDeps.get(i)); + } } - - JsonArray jsonArrayfuncDeps = jsonObj.getAsJsonArray("func_deps"); - // validate the required field `func_deps` (array) - for (int i = 0; i < jsonArrayfuncDeps.size(); i++) { - FunctionInfoInputFuncDepsInner.validateJsonElement(jsonArrayfuncDeps.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -317,7 +312,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionInfoOutput.java b/src/main/java/ai/reveng/model/FunctionInfoOutput.java index 95782151..e1cf9d0f 100644 --- a/src/main/java/ai/reveng/model/FunctionInfoOutput.java +++ b/src/main/java/ai/reveng/model/FunctionInfoOutput.java @@ -13,9 +13,8 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; -import ai.reveng.model.FunctionInfoInputFuncDepsInner; -import ai.reveng.model.FunctionTypeOutput; +import ai.reveng.model.FuncDepsInner; +import ai.reveng.model.FunctionTypeInput; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -47,7 +46,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -59,41 +57,41 @@ public class FunctionInfoOutput { public static final String SERIALIZED_NAME_FUNC_TYPES = "func_types"; @SerializedName(SERIALIZED_NAME_FUNC_TYPES) @javax.annotation.Nullable - private FunctionTypeOutput funcTypes; + private FunctionTypeInput funcTypes; public static final String SERIALIZED_NAME_FUNC_DEPS = "func_deps"; @SerializedName(SERIALIZED_NAME_FUNC_DEPS) @javax.annotation.Nonnull - private List funcDeps = new ArrayList<>(); + private List funcDeps = new ArrayList<>(); public FunctionInfoOutput() { } - public FunctionInfoOutput funcTypes(@javax.annotation.Nullable FunctionTypeOutput funcTypes) { + public FunctionInfoOutput funcTypes(@javax.annotation.Nullable FunctionTypeInput funcTypes) { this.funcTypes = funcTypes; return this; } /** - * Get funcTypes + * Function type information * @return funcTypes */ @javax.annotation.Nullable - public FunctionTypeOutput getFuncTypes() { + public FunctionTypeInput getFuncTypes() { return funcTypes; } - public void setFuncTypes(@javax.annotation.Nullable FunctionTypeOutput funcTypes) { + public void setFuncTypes(@javax.annotation.Nullable FunctionTypeInput funcTypes) { this.funcTypes = funcTypes; } - public FunctionInfoOutput funcDeps(@javax.annotation.Nonnull List funcDeps) { + public FunctionInfoOutput funcDeps(@javax.annotation.Nonnull List funcDeps) { this.funcDeps = funcDeps; return this; } - public FunctionInfoOutput addFuncDepsItem(FunctionInfoInputFuncDepsInner funcDepsItem) { + public FunctionInfoOutput addFuncDepsItem(FuncDepsInner funcDepsItem) { if (this.funcDeps == null) { this.funcDeps = new ArrayList<>(); } @@ -106,11 +104,11 @@ public FunctionInfoOutput addFuncDepsItem(FunctionInfoInputFuncDepsInner funcDep * @return funcDeps */ @javax.annotation.Nonnull - public List getFuncDeps() { + public List getFuncDeps() { return funcDeps; } - public void setFuncDeps(@javax.annotation.Nonnull List funcDeps) { + public void setFuncDeps(@javax.annotation.Nonnull List funcDeps) { this.funcDeps = funcDeps; } @@ -206,10 +204,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -233,31 +228,31 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionInfoOutput.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionInfoOutput is not found in the empty JSON string", FunctionInfoOutput.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionInfoOutput is not found in the empty JSON string", FunctionInfoOutput.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionInfoOutput.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `func_types` if (jsonObj.get("func_types") != null && !jsonObj.get("func_types").isJsonNull()) { - FunctionTypeOutput.validateJsonElement(jsonObj.get("func_types")); + FunctionTypeInput.validateJsonElement(jsonObj.get("func_types")); } - // ensure the json data is an array - if (!jsonObj.get("func_deps").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `func_deps` to be an array in the JSON string but got `%s`", jsonObj.get("func_deps").toString())); + if (jsonObj.get("func_deps") != null) { + if (!jsonObj.get("func_deps").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `func_deps` to be an array in the JSON string but got `%s`", jsonObj.get("func_deps").toString())); + } + JsonArray jsonArrayfuncDeps = jsonObj.getAsJsonArray("func_deps"); + // validate the required field `func_deps` (array) + for (int i = 0; i < jsonArrayfuncDeps.size(); i++) { + FuncDepsInner.validateJsonElement(jsonArrayfuncDeps.get(i)); + } } - - JsonArray jsonArrayfuncDeps = jsonObj.getAsJsonArray("func_deps"); - // validate the required field `func_deps` (array) - for (int i = 0; i < jsonArrayfuncDeps.size(); i++) { - FunctionInfoInputFuncDepsInner.validateJsonElement(jsonArrayfuncDeps.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -317,7 +312,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionListItem.java b/src/main/java/ai/reveng/model/FunctionListItem.java index e8c5aad7..95c2df69 100644 --- a/src/main/java/ai/reveng/model/FunctionListItem.java +++ b/src/main/java/ai/reveng/model/FunctionListItem.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.NameSourceType; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -401,10 +399,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -428,29 +423,29 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionListItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionListItem is not found in the empty JSON string", FunctionListItem.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionListItem is not found in the empty JSON string", FunctionListItem.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionListItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if (!jsonObj.get("name_source_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name_source_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name_source_type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name_source_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name_source_type").toString())); } // validate the required field `name_source_type` NameSourceTypeEnum.validateJsonElement(jsonObj.get("name_source_type")); // validate the required field `name_source` NameSourceType.validateJsonElement(jsonObj.get("name_source")); if (!jsonObj.get("mangled_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mangled_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mangled_name").toString())); } } @@ -511,7 +506,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionLocalVariableResponse.java b/src/main/java/ai/reveng/model/FunctionLocalVariableResponse.java index 073bdfe6..db6c2f6d 100644 --- a/src/main/java/ai/reveng/model/FunctionLocalVariableResponse.java +++ b/src/main/java/ai/reveng/model/FunctionLocalVariableResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -260,10 +258,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -287,28 +282,28 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionLocalVariableResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionLocalVariableResponse is not found in the empty JSON string", FunctionLocalVariableResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionLocalVariableResponse is not found in the empty JSON string", FunctionLocalVariableResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionLocalVariableResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("address").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `address` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `address` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address").toString())); } if (!jsonObj.get("d_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `d_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("d_type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `d_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("d_type").toString())); } if (!jsonObj.get("loc").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `loc` to be a primitive type in the JSON string but got `%s`", jsonObj.get("loc").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `loc` to be a primitive type in the JSON string but got `%s`", jsonObj.get("loc").toString())); } if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } } @@ -369,7 +364,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionMapping.java b/src/main/java/ai/reveng/model/FunctionMapping.java index a401d95e..512afc3a 100644 --- a/src/main/java/ai/reveng/model/FunctionMapping.java +++ b/src/main/java/ai/reveng/model/FunctionMapping.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -234,10 +232,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,14 +256,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionMapping.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionMapping is not found in the empty JSON string", FunctionMapping.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionMapping is not found in the empty JSON string", FunctionMapping.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionMapping.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -331,7 +326,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionMappingFull.java b/src/main/java/ai/reveng/model/FunctionMappingFull.java index ae2ad153..9274fb7f 100644 --- a/src/main/java/ai/reveng/model/FunctionMappingFull.java +++ b/src/main/java/ai/reveng/model/FunctionMappingFull.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.InverseFunctionMapItem; import ai.reveng.model.InverseStringMapItem; import ai.reveng.model.InverseValue; @@ -47,7 +46,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -616,10 +614,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -643,14 +638,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionMappingFull.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionMappingFull is not found in the empty JSON string", FunctionMappingFull.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionMappingFull is not found in the empty JSON string", FunctionMappingFull.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionMappingFull.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -713,7 +708,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionMatch.java b/src/main/java/ai/reveng/model/FunctionMatch.java index 37d6533b..7c36dff1 100644 --- a/src/main/java/ai/reveng/model/FunctionMatch.java +++ b/src/main/java/ai/reveng/model/FunctionMatch.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.MatchedFunction; import ai.reveng.model.NameConfidence; import com.google.gson.TypeAdapter; @@ -47,7 +46,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -240,10 +238,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -267,33 +262,33 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionMatch.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionMatch is not found in the empty JSON string", FunctionMatch.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionMatch is not found in the empty JSON string", FunctionMatch.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionMatch.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("matched_functions").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `matched_functions` to be an array in the JSON string but got `%s`", jsonObj.get("matched_functions").toString())); + if (jsonObj.get("matched_functions") != null) { + if (!jsonObj.get("matched_functions").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `matched_functions` to be an array in the JSON string but got `%s`", jsonObj.get("matched_functions").toString())); + } + JsonArray jsonArraymatchedFunctions = jsonObj.getAsJsonArray("matched_functions"); + // validate the required field `matched_functions` (array) + for (int i = 0; i < jsonArraymatchedFunctions.size(); i++) { + MatchedFunction.validateJsonElement(jsonArraymatchedFunctions.get(i)); + } } - - JsonArray jsonArraymatchedFunctions = jsonObj.getAsJsonArray("matched_functions"); - // validate the required field `matched_functions` (array) - for (int i = 0; i < jsonArraymatchedFunctions.size(); i++) { - MatchedFunction.validateJsonElement(jsonArraymatchedFunctions.get(i)); - }; if (jsonObj.get("confidences") != null && !jsonObj.get("confidences").isJsonNull()) { JsonArray jsonArrayconfidences = jsonObj.getAsJsonArray("confidences"); if (jsonArrayconfidences != null) { // ensure the json data is an array if (!jsonObj.get("confidences").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `confidences` to be an array in the JSON string but got `%s`", jsonObj.get("confidences").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `confidences` to be an array in the JSON string but got `%s`", jsonObj.get("confidences").toString())); } // validate the optional field `confidences` (array) @@ -361,7 +356,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionMatchingFilters.java b/src/main/java/ai/reveng/model/FunctionMatchingFilters.java index 76a8c227..899bac71 100644 --- a/src/main/java/ai/reveng/model/FunctionMatchingFilters.java +++ b/src/main/java/ai/reveng/model/FunctionMatchingFilters.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -358,10 +356,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -385,29 +380,29 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionMatchingFilters.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionMatchingFilters is not found in the empty JSON string", FunctionMatchingFilters.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionMatchingFilters is not found in the empty JSON string", FunctionMatchingFilters.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the optional json data is an array if present if (jsonObj.get("binary_ids") != null && !jsonObj.get("binary_ids").isJsonNull() && !jsonObj.get("binary_ids").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binary_ids` to be an array in the JSON string but got `%s`", jsonObj.get("binary_ids").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binary_ids` to be an array in the JSON string but got `%s`", jsonObj.get("binary_ids").toString())); } // ensure the optional json data is an array if present if (jsonObj.get("collection_ids") != null && !jsonObj.get("collection_ids").isJsonNull() && !jsonObj.get("collection_ids").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_ids` to be an array in the JSON string but got `%s`", jsonObj.get("collection_ids").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_ids` to be an array in the JSON string but got `%s`", jsonObj.get("collection_ids").toString())); } // ensure the optional json data is an array if present if (jsonObj.get("function_ids") != null && !jsonObj.get("function_ids").isJsonNull() && !jsonObj.get("function_ids").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `function_ids` to be an array in the JSON string but got `%s`", jsonObj.get("function_ids").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_ids` to be an array in the JSON string but got `%s`", jsonObj.get("function_ids").toString())); } // ensure the optional json data is an array if present if (jsonObj.get("user_ids") != null && !jsonObj.get("user_ids").isJsonNull() && !jsonObj.get("user_ids").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `user_ids` to be an array in the JSON string but got `%s`", jsonObj.get("user_ids").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `user_ids` to be an array in the JSON string but got `%s`", jsonObj.get("user_ids").toString())); } // ensure the optional json data is an array if present if (jsonObj.get("debug_types") != null && !jsonObj.get("debug_types").isJsonNull() && !jsonObj.get("debug_types").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `debug_types` to be an array in the JSON string but got `%s`", jsonObj.get("debug_types").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `debug_types` to be an array in the JSON string but got `%s`", jsonObj.get("debug_types").toString())); } } @@ -468,7 +463,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionMatchingRequest.java b/src/main/java/ai/reveng/model/FunctionMatchingRequest.java index cf77eb02..31b10c77 100644 --- a/src/main/java/ai/reveng/model/FunctionMatchingRequest.java +++ b/src/main/java/ai/reveng/model/FunctionMatchingRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FunctionMatchingFilters; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -47,7 +46,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -185,7 +183,7 @@ public FunctionMatchingRequest filters(@javax.annotation.Nullable FunctionMatchi } /** - * Get filters + * Used to limit the search to specific binaries, collections, and functions * @return filters */ @javax.annotation.Nullable @@ -436,10 +434,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -463,14 +458,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionMatchingRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionMatchingRequest is not found in the empty JSON string", FunctionMatchingRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionMatchingRequest is not found in the empty JSON string", FunctionMatchingRequest.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionMatchingRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -478,7 +473,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("function_ids") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("function_ids").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `function_ids` to be an array in the JSON string but got `%s`", jsonObj.get("function_ids").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_ids` to be an array in the JSON string but got `%s`", jsonObj.get("function_ids").toString())); } // validate the optional field `filters` if (jsonObj.get("filters") != null && !jsonObj.get("filters").isJsonNull()) { @@ -543,7 +538,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionMatchingResponse.java b/src/main/java/ai/reveng/model/FunctionMatchingResponse.java index 6b830116..e83da28c 100644 --- a/src/main/java/ai/reveng/model/FunctionMatchingResponse.java +++ b/src/main/java/ai/reveng/model/FunctionMatchingResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FunctionMatch; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -133,7 +131,7 @@ public FunctionMatchingResponse status(@javax.annotation.Nullable String status) } /** - * Get status + * Status of the function matching operation * @return status */ @javax.annotation.Nullable @@ -152,7 +150,7 @@ public FunctionMatchingResponse totalTime(@javax.annotation.Nullable Integer tot } /** - * Get totalTime + * Total time taken for the matching operation in seconds * @return totalTime */ @javax.annotation.Nullable @@ -171,7 +169,7 @@ public FunctionMatchingResponse errorMessage(@javax.annotation.Nullable String e } /** - * Get errorMessage + * Optional message providing additional information about the operation * @return errorMessage */ @javax.annotation.Nullable @@ -190,7 +188,7 @@ public FunctionMatchingResponse currentPage(@javax.annotation.Nullable Integer c } /** - * Get currentPage + * Current page number of the results, if pagination is used * @return currentPage */ @javax.annotation.Nullable @@ -209,7 +207,7 @@ public FunctionMatchingResponse totalPages(@javax.annotation.Nullable Integer to } /** - * Get totalPages + * Total number of pages available, if pagination is used * @return totalPages */ @javax.annotation.Nullable @@ -236,7 +234,7 @@ public FunctionMatchingResponse addMatchesItem(FunctionMatch matchesItem) { } /** - * Get matches + * List of function matching results with best match information * @return matches */ @javax.annotation.Nullable @@ -255,7 +253,7 @@ public FunctionMatchingResponse numMatches(@javax.annotation.Nullable Integer nu } /** - * Get numMatches + * Total number of function matches found * @return numMatches */ @javax.annotation.Nullable @@ -274,7 +272,7 @@ public FunctionMatchingResponse numDebugMatches(@javax.annotation.Nullable Integ } /** - * Get numDebugMatches + * Total number of debug function matches found * @return numDebugMatches */ @javax.annotation.Nullable @@ -293,7 +291,7 @@ public FunctionMatchingResponse updatedAt(@javax.annotation.Nullable String upda } /** - * Get updatedAt + * Timestamp of the last time function matching with the same request parameters was performed * @return updatedAt */ @javax.annotation.Nullable @@ -413,10 +411,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -440,22 +435,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionMatchingResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionMatchingResponse is not found in the empty JSON string", FunctionMatchingResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionMatchingResponse is not found in the empty JSON string", FunctionMatchingResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); } if ((jsonObj.get("error_message") != null && !jsonObj.get("error_message").isJsonNull()) && !jsonObj.get("error_message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `error_message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error_message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `error_message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error_message").toString())); } if (jsonObj.get("matches") != null && !jsonObj.get("matches").isJsonNull()) { JsonArray jsonArraymatches = jsonObj.getAsJsonArray("matches"); if (jsonArraymatches != null) { // ensure the json data is an array if (!jsonObj.get("matches").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `matches` to be an array in the JSON string but got `%s`", jsonObj.get("matches").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `matches` to be an array in the JSON string but got `%s`", jsonObj.get("matches").toString())); } // validate the optional field `matches` (array) @@ -465,7 +460,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } if ((jsonObj.get("updated_at") != null && !jsonObj.get("updated_at").isJsonNull()) && !jsonObj.get("updated_at").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `updated_at` to be a primitive type in the JSON string but got `%s`", jsonObj.get("updated_at").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `updated_at` to be a primitive type in the JSON string but got `%s`", jsonObj.get("updated_at").toString())); } } @@ -526,7 +521,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionNameHistory.java b/src/main/java/ai/reveng/model/FunctionNameHistory.java index 3deb7d7a..a75c22c1 100644 --- a/src/main/java/ai/reveng/model/FunctionNameHistory.java +++ b/src/main/java/ai/reveng/model/FunctionNameHistory.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FunctionSourceType; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -313,10 +311,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -340,30 +335,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionNameHistory.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionNameHistory is not found in the empty JSON string", FunctionNameHistory.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionNameHistory is not found in the empty JSON string", FunctionNameHistory.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionNameHistory.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("change_made_by").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `change_made_by` to be a primitive type in the JSON string but got `%s`", jsonObj.get("change_made_by").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `change_made_by` to be a primitive type in the JSON string but got `%s`", jsonObj.get("change_made_by").toString())); } if (!jsonObj.get("function_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); } if (!jsonObj.get("mangled_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mangled_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mangled_name").toString())); } // validate the required field `source_type` FunctionSourceType.validateJsonElement(jsonObj.get("source_type")); if (!jsonObj.get("created_at").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `created_at` to be a primitive type in the JSON string but got `%s`", jsonObj.get("created_at").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `created_at` to be a primitive type in the JSON string but got `%s`", jsonObj.get("created_at").toString())); } } @@ -424,7 +419,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionParamResponse.java b/src/main/java/ai/reveng/model/FunctionParamResponse.java index 36b4a93d..aa598610 100644 --- a/src/main/java/ai/reveng/model/FunctionParamResponse.java +++ b/src/main/java/ai/reveng/model/FunctionParamResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -260,10 +258,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -287,28 +282,28 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionParamResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionParamResponse is not found in the empty JSON string", FunctionParamResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionParamResponse is not found in the empty JSON string", FunctionParamResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionParamResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("d_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `d_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("d_type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `d_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("d_type").toString())); } if (!jsonObj.get("loc").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `loc` to be a primitive type in the JSON string but got `%s`", jsonObj.get("loc").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `loc` to be a primitive type in the JSON string but got `%s`", jsonObj.get("loc").toString())); } if (!jsonObj.get("addr").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `addr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("addr").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `addr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("addr").toString())); } if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } } @@ -369,7 +364,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionRename.java b/src/main/java/ai/reveng/model/FunctionRename.java index 6e6b816d..91470007 100644 --- a/src/main/java/ai/reveng/model/FunctionRename.java +++ b/src/main/java/ai/reveng/model/FunctionRename.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -182,10 +180,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -209,22 +204,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionRename.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionRename is not found in the empty JSON string", FunctionRename.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionRename is not found in the empty JSON string", FunctionRename.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionRename.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("new_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `new_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("new_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `new_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("new_name").toString())); } if (!jsonObj.get("new_mangled_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `new_mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("new_mangled_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `new_mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("new_mangled_name").toString())); } } @@ -285,7 +280,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionRenameMap.java b/src/main/java/ai/reveng/model/FunctionRenameMap.java index d9da97c1..3d9fed16 100644 --- a/src/main/java/ai/reveng/model/FunctionRenameMap.java +++ b/src/main/java/ai/reveng/model/FunctionRenameMap.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -208,10 +206,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -235,22 +230,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionRenameMap.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionRenameMap is not found in the empty JSON string", FunctionRenameMap.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionRenameMap is not found in the empty JSON string", FunctionRenameMap.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionRenameMap.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("new_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `new_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("new_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `new_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("new_name").toString())); } if (!jsonObj.get("new_mangled_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `new_mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("new_mangled_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `new_mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("new_mangled_name").toString())); } } @@ -311,7 +306,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionSearchResponse.java b/src/main/java/ai/reveng/model/FunctionSearchResponse.java index 318cd05f..ad4dccd9 100644 --- a/src/main/java/ai/reveng/model/FunctionSearchResponse.java +++ b/src/main/java/ai/reveng/model/FunctionSearchResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FunctionSearchResult; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -167,10 +165,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,27 +189,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionSearchResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionSearchResponse is not found in the empty JSON string", FunctionSearchResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionSearchResponse is not found in the empty JSON string", FunctionSearchResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionSearchResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("results").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); + if (jsonObj.get("results") != null) { + if (!jsonObj.get("results").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); + } + JsonArray jsonArrayresults = jsonObj.getAsJsonArray("results"); + // validate the required field `results` (array) + for (int i = 0; i < jsonArrayresults.size(); i++) { + FunctionSearchResult.validateJsonElement(jsonArrayresults.get(i)); + } } - - JsonArray jsonArrayresults = jsonObj.getAsJsonArray("results"); - // validate the required field `results` (array) - for (int i = 0; i < jsonArrayresults.size(); i++) { - FunctionSearchResult.validateJsonElement(jsonArrayresults.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -274,7 +269,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionSearchResult.java b/src/main/java/ai/reveng/model/FunctionSearchResult.java index 4f210760..fb31baff 100644 --- a/src/main/java/ai/reveng/model/FunctionSearchResult.java +++ b/src/main/java/ai/reveng/model/FunctionSearchResult.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -313,10 +311,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -340,28 +335,28 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionSearchResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionSearchResult is not found in the empty JSON string", FunctionSearchResult.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionSearchResult is not found in the empty JSON string", FunctionSearchResult.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionSearchResult.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("function_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); } if (!jsonObj.get("binary_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); } if (!jsonObj.get("model_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); } if (!jsonObj.get("owned_by").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `owned_by` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owned_by").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `owned_by` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owned_by").toString())); } } @@ -422,7 +417,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionSourceType.java b/src/main/java/ai/reveng/model/FunctionSourceType.java index 9b35b373..2c3f34b2 100644 --- a/src/main/java/ai/reveng/model/FunctionSourceType.java +++ b/src/main/java/ai/reveng/model/FunctionSourceType.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/FunctionString.java b/src/main/java/ai/reveng/model/FunctionString.java index 34af80ab..fadcd761 100644 --- a/src/main/java/ai/reveng/model/FunctionString.java +++ b/src/main/java/ai/reveng/model/FunctionString.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.StringSource; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -65,7 +63,7 @@ public class FunctionString { public static final String SERIALIZED_NAME_SOURCE = "source"; @SerializedName(SERIALIZED_NAME_SOURCE) @javax.annotation.Nullable - private StringSource source; + private StringSource source = StringSource.SYSTEM; public FunctionString() { } @@ -209,10 +207,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -236,19 +231,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionString.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionString is not found in the empty JSON string", FunctionString.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionString is not found in the empty JSON string", FunctionString.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionString.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("value").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); } // validate the optional field `source` if (jsonObj.get("source") != null && !jsonObj.get("source").isJsonNull()) { @@ -313,7 +308,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionStringItem.java b/src/main/java/ai/reveng/model/FunctionStringItem.java index b38bef41..f0a6d445 100644 --- a/src/main/java/ai/reveng/model/FunctionStringItem.java +++ b/src/main/java/ai/reveng/model/FunctionStringItem.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -125,50 +123,6 @@ public void setValue(@javax.annotation.Nonnull String value) { this.value = value; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the FunctionStringItem instance itself - */ - public FunctionStringItem putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -182,13 +136,12 @@ public boolean equals(Object o) { FunctionStringItem functionStringItem = (FunctionStringItem) o; return Objects.equals(this.source, functionStringItem.source) && Objects.equals(this.vaddr, functionStringItem.vaddr) && - Objects.equals(this.value, functionStringItem.value)&& - Objects.equals(this.additionalProperties, functionStringItem.additionalProperties); + Objects.equals(this.value, functionStringItem.value); } @Override public int hashCode() { - return Objects.hash(source, vaddr, value, additionalProperties); + return Objects.hash(source, vaddr, value); } @Override @@ -198,7 +151,6 @@ public String toString() { sb.append(" source: ").append(toIndentedString(source)).append("\n"); sb.append(" vaddr: ").append(toIndentedString(vaddr)).append("\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -208,10 +160,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -235,22 +184,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionStringItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionStringItem is not found in the empty JSON string", FunctionStringItem.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionStringItem is not found in the empty JSON string", FunctionStringItem.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!FunctionStringItem.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionStringItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionStringItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("source").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source").toString())); } if (!jsonObj.get("value").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); } } @@ -269,28 +226,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionStringItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -298,28 +233,7 @@ else if (entry.getValue() instanceof Character) public FunctionStringItem read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - FunctionStringItem instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/FunctionStringsResponse.java b/src/main/java/ai/reveng/model/FunctionStringsResponse.java index 002eae5f..05f678ff 100644 --- a/src/main/java/ai/reveng/model/FunctionStringsResponse.java +++ b/src/main/java/ai/reveng/model/FunctionStringsResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FunctionString; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -193,10 +191,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -220,27 +215,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionStringsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionStringsResponse is not found in the empty JSON string", FunctionStringsResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionStringsResponse is not found in the empty JSON string", FunctionStringsResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionStringsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("strings").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `strings` to be an array in the JSON string but got `%s`", jsonObj.get("strings").toString())); + if (jsonObj.get("strings") != null) { + if (!jsonObj.get("strings").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `strings` to be an array in the JSON string but got `%s`", jsonObj.get("strings").toString())); + } + JsonArray jsonArraystrings = jsonObj.getAsJsonArray("strings"); + // validate the required field `strings` (array) + for (int i = 0; i < jsonArraystrings.size(); i++) { + FunctionString.validateJsonElement(jsonArraystrings.get(i)); + } } - - JsonArray jsonArraystrings = jsonObj.getAsJsonArray("strings"); - // validate the required field `strings` (array) - for (int i = 0; i < jsonArraystrings.size(); i++) { - FunctionString.validateJsonElement(jsonArraystrings.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -300,7 +295,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionTaskResponse.java b/src/main/java/ai/reveng/model/FunctionTaskResponse.java index 24a68eb1..c8fbbff2 100644 --- a/src/main/java/ai/reveng/model/FunctionTaskResponse.java +++ b/src/main/java/ai/reveng/model/FunctionTaskResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FunctionTaskStatus; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -56,7 +54,7 @@ public class FunctionTaskResponse { public static final String SERIALIZED_NAME_STATUS = "status"; @SerializedName(SERIALIZED_NAME_STATUS) @javax.annotation.Nullable - private FunctionTaskStatus status; + private FunctionTaskStatus status = FunctionTaskStatus.UNINITIALISED; public static final String SERIALIZED_NAME_ERROR_MESSAGE = "error_message"; @SerializedName(SERIALIZED_NAME_ERROR_MESSAGE) @@ -195,10 +193,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -222,7 +217,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionTaskResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionTaskResponse is not found in the empty JSON string", FunctionTaskResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionTaskResponse is not found in the empty JSON string", FunctionTaskResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -231,7 +226,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti FunctionTaskStatus.validateJsonElement(jsonObj.get("status")); } if ((jsonObj.get("error_message") != null && !jsonObj.get("error_message").isJsonNull()) && !jsonObj.get("error_message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `error_message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error_message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `error_message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error_message").toString())); } } @@ -292,7 +287,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionTaskStatus.java b/src/main/java/ai/reveng/model/FunctionTaskStatus.java index ff1e4857..2ef73f12 100644 --- a/src/main/java/ai/reveng/model/FunctionTaskStatus.java +++ b/src/main/java/ai/reveng/model/FunctionTaskStatus.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/FunctionTypeInput.java b/src/main/java/ai/reveng/model/FunctionTypeInput.java index 5452ea3b..d32ed24b 100644 --- a/src/main/java/ai/reveng/model/FunctionTypeInput.java +++ b/src/main/java/ai/reveng/model/FunctionTypeInput.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FunctionHeader; import ai.reveng.model.StackVariable; import com.google.gson.TypeAdapter; @@ -47,7 +46,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -105,7 +103,7 @@ public FunctionTypeInput lastChange(@javax.annotation.Nullable String lastChange } /** - * Get lastChange + * Timestamp of the last change to this function type * @return lastChange */ @javax.annotation.Nullable @@ -189,7 +187,7 @@ public FunctionTypeInput putStackVarsItem(String key, StackVariable stackVarsIte } /** - * Get stackVars + * Dictionary of stack variables * @return stackVars */ @javax.annotation.Nullable @@ -362,10 +360,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -389,30 +384,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionTypeInput.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionTypeInput is not found in the empty JSON string", FunctionTypeInput.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionTypeInput is not found in the empty JSON string", FunctionTypeInput.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionTypeInput.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("last_change") != null && !jsonObj.get("last_change").isJsonNull()) && !jsonObj.get("last_change").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `last_change` to be a primitive type in the JSON string but got `%s`", jsonObj.get("last_change").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `last_change` to be a primitive type in the JSON string but got `%s`", jsonObj.get("last_change").toString())); } // validate the required field `header` FunctionHeader.validateJsonElement(jsonObj.get("header")); if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } if ((jsonObj.get("artifact_type") != null && !jsonObj.get("artifact_type").isJsonNull()) && !jsonObj.get("artifact_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `artifact_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("artifact_type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `artifact_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("artifact_type").toString())); } } @@ -473,7 +468,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionTypeOutput.java b/src/main/java/ai/reveng/model/FunctionTypeOutput.java deleted file mode 100644 index cdc7b5b0..00000000 --- a/src/main/java/ai/reveng/model/FunctionTypeOutput.java +++ /dev/null @@ -1,511 +0,0 @@ -/* - * RevEng.AI API - * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. - * - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package ai.reveng.model; - -import java.util.Objects; -import java.util.Locale; -import ai.reveng.model.FunctionHeader; -import ai.reveng.model.StackVariable; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import org.openapitools.jackson.nullable.JsonNullable; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Locale; - -import ai.reveng.invoker.JSON; - -/** - * FunctionTypeOutput - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class FunctionTypeOutput { - public static final String SERIALIZED_NAME_LAST_CHANGE = "last_change"; - @SerializedName(SERIALIZED_NAME_LAST_CHANGE) - @javax.annotation.Nullable - private String lastChange; - - public static final String SERIALIZED_NAME_ADDR = "addr"; - @SerializedName(SERIALIZED_NAME_ADDR) - @javax.annotation.Nonnull - private Integer addr; - - public static final String SERIALIZED_NAME_SIZE = "size"; - @SerializedName(SERIALIZED_NAME_SIZE) - @javax.annotation.Nonnull - private Integer size; - - public static final String SERIALIZED_NAME_HEADER = "header"; - @SerializedName(SERIALIZED_NAME_HEADER) - @javax.annotation.Nonnull - private FunctionHeader header; - - public static final String SERIALIZED_NAME_STACK_VARS = "stack_vars"; - @SerializedName(SERIALIZED_NAME_STACK_VARS) - @javax.annotation.Nullable - private Map stackVars; - - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) - @javax.annotation.Nonnull - private String name; - - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) - @javax.annotation.Nonnull - private String type; - - public static final String SERIALIZED_NAME_ARTIFACT_TYPE = "artifact_type"; - @SerializedName(SERIALIZED_NAME_ARTIFACT_TYPE) - @javax.annotation.Nullable - private String artifactType = "Function"; - - public FunctionTypeOutput() { - } - - public FunctionTypeOutput lastChange(@javax.annotation.Nullable String lastChange) { - this.lastChange = lastChange; - return this; - } - - /** - * Get lastChange - * @return lastChange - */ - @javax.annotation.Nullable - public String getLastChange() { - return lastChange; - } - - public void setLastChange(@javax.annotation.Nullable String lastChange) { - this.lastChange = lastChange; - } - - - public FunctionTypeOutput addr(@javax.annotation.Nonnull Integer addr) { - this.addr = addr; - return this; - } - - /** - * Memory address of the function - * @return addr - */ - @javax.annotation.Nonnull - public Integer getAddr() { - return addr; - } - - public void setAddr(@javax.annotation.Nonnull Integer addr) { - this.addr = addr; - } - - - public FunctionTypeOutput size(@javax.annotation.Nonnull Integer size) { - this.size = size; - return this; - } - - /** - * Size of the function in bytes - * @return size - */ - @javax.annotation.Nonnull - public Integer getSize() { - return size; - } - - public void setSize(@javax.annotation.Nonnull Integer size) { - this.size = size; - } - - - public FunctionTypeOutput header(@javax.annotation.Nonnull FunctionHeader header) { - this.header = header; - return this; - } - - /** - * Function header information - * @return header - */ - @javax.annotation.Nonnull - public FunctionHeader getHeader() { - return header; - } - - public void setHeader(@javax.annotation.Nonnull FunctionHeader header) { - this.header = header; - } - - - public FunctionTypeOutput stackVars(@javax.annotation.Nullable Map stackVars) { - this.stackVars = stackVars; - return this; - } - - public FunctionTypeOutput putStackVarsItem(String key, StackVariable stackVarsItem) { - if (this.stackVars == null) { - this.stackVars = new HashMap<>(); - } - this.stackVars.put(key, stackVarsItem); - return this; - } - - /** - * Get stackVars - * @return stackVars - */ - @javax.annotation.Nullable - public Map getStackVars() { - return stackVars; - } - - public void setStackVars(@javax.annotation.Nullable Map stackVars) { - this.stackVars = stackVars; - } - - - public FunctionTypeOutput name(@javax.annotation.Nonnull String name) { - this.name = name; - return this; - } - - /** - * Name of the function - * @return name - */ - @javax.annotation.Nonnull - public String getName() { - return name; - } - - public void setName(@javax.annotation.Nonnull String name) { - this.name = name; - } - - - public FunctionTypeOutput type(@javax.annotation.Nonnull String type) { - this.type = type; - return this; - } - - /** - * Return type of the function - * @return type - */ - @javax.annotation.Nonnull - public String getType() { - return type; - } - - public void setType(@javax.annotation.Nonnull String type) { - this.type = type; - } - - - public FunctionTypeOutput artifactType(@javax.annotation.Nullable String artifactType) { - this.artifactType = artifactType; - return this; - } - - /** - * Type of artifact that the structure is associated with - * @return artifactType - */ - @javax.annotation.Nullable - public String getArtifactType() { - return artifactType; - } - - public void setArtifactType(@javax.annotation.Nullable String artifactType) { - this.artifactType = artifactType; - } - - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the FunctionTypeOutput instance itself - */ - public FunctionTypeOutput putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - FunctionTypeOutput functionTypeOutput = (FunctionTypeOutput) o; - return Objects.equals(this.lastChange, functionTypeOutput.lastChange) && - Objects.equals(this.addr, functionTypeOutput.addr) && - Objects.equals(this.size, functionTypeOutput.size) && - Objects.equals(this.header, functionTypeOutput.header) && - Objects.equals(this.stackVars, functionTypeOutput.stackVars) && - Objects.equals(this.name, functionTypeOutput.name) && - Objects.equals(this.type, functionTypeOutput.type) && - Objects.equals(this.artifactType, functionTypeOutput.artifactType)&& - Objects.equals(this.additionalProperties, functionTypeOutput.additionalProperties); - } - - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); - } - - @Override - public int hashCode() { - return Objects.hash(lastChange, addr, size, header, stackVars, name, type, artifactType, additionalProperties); - } - - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class FunctionTypeOutput {\n"); - sb.append(" lastChange: ").append(toIndentedString(lastChange)).append("\n"); - sb.append(" addr: ").append(toIndentedString(addr)).append("\n"); - sb.append(" size: ").append(toIndentedString(size)).append("\n"); - sb.append(" header: ").append(toIndentedString(header)).append("\n"); - sb.append(" stackVars: ").append(toIndentedString(stackVars)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" artifactType: ").append(toIndentedString(artifactType)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("last_change", "addr", "size", "header", "stack_vars", "name", "type", "artifact_type")); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(Arrays.asList("addr", "size", "header", "name", "type")); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to FunctionTypeOutput - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!FunctionTypeOutput.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionTypeOutput is not found in the empty JSON string", FunctionTypeOutput.openapiRequiredFields.toString())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : FunctionTypeOutput.openapiRequiredFields) { - if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("last_change") != null && !jsonObj.get("last_change").isJsonNull()) && !jsonObj.get("last_change").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `last_change` to be a primitive type in the JSON string but got `%s`", jsonObj.get("last_change").toString())); - } - // validate the required field `header` - FunctionHeader.validateJsonElement(jsonObj.get("header")); - if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); - } - if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - if ((jsonObj.get("artifact_type") != null && !jsonObj.get("artifact_type").isJsonNull()) && !jsonObj.get("artifact_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `artifact_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("artifact_type").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!FunctionTypeOutput.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'FunctionTypeOutput' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(FunctionTypeOutput.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, FunctionTypeOutput value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } - elementAdapter.write(out, obj); - } - - @Override - public FunctionTypeOutput read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - FunctionTypeOutput instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; - } - - }.nullSafe(); - } - } - - /** - * Create an instance of FunctionTypeOutput given an JSON string - * - * @param jsonString JSON string - * @return An instance of FunctionTypeOutput - * @throws IOException if the JSON string is invalid with respect to FunctionTypeOutput - */ - public static FunctionTypeOutput fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, FunctionTypeOutput.class); - } - - /** - * Convert an instance of FunctionTypeOutput to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/ai/reveng/model/FunctionsDetailResponse.java b/src/main/java/ai/reveng/model/FunctionsDetailResponse.java index 3b0a38b4..2f6a3ab5 100644 --- a/src/main/java/ai/reveng/model/FunctionsDetailResponse.java +++ b/src/main/java/ai/reveng/model/FunctionsDetailResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -416,10 +414,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -443,31 +438,31 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionsDetailResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionsDetailResponse is not found in the empty JSON string", FunctionsDetailResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionsDetailResponse is not found in the empty JSON string", FunctionsDetailResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionsDetailResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("function_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); } if (!jsonObj.get("function_name_mangled").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `function_name_mangled` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name_mangled").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name_mangled` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name_mangled").toString())); } if (!jsonObj.get("binary_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); } if (!jsonObj.get("sha_256_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); } if ((jsonObj.get("debug_hash") != null && !jsonObj.get("debug_hash").isJsonNull()) && !jsonObj.get("debug_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `debug_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("debug_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `debug_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("debug_hash").toString())); } } @@ -528,7 +523,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/FunctionsListRename.java b/src/main/java/ai/reveng/model/FunctionsListRename.java index 6e17812f..1e402a22 100644 --- a/src/main/java/ai/reveng/model/FunctionsListRename.java +++ b/src/main/java/ai/reveng/model/FunctionsListRename.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FunctionRenameMap; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -167,10 +165,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,27 +189,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!FunctionsListRename.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionsListRename is not found in the empty JSON string", FunctionsListRename.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FunctionsListRename is not found in the empty JSON string", FunctionsListRename.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionsListRename.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("functions").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); + if (jsonObj.get("functions") != null) { + if (!jsonObj.get("functions").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); + } + JsonArray jsonArrayfunctions = jsonObj.getAsJsonArray("functions"); + // validate the required field `functions` (array) + for (int i = 0; i < jsonArrayfunctions.size(); i++) { + FunctionRenameMap.validateJsonElement(jsonArrayfunctions.get(i)); + } } - - JsonArray jsonArrayfunctions = jsonObj.getAsJsonArray("functions"); - // validate the required field `functions` (array) - for (int i = 0; i < jsonArrayfunctions.size(); i++) { - FunctionRenameMap.validateJsonElement(jsonArrayfunctions.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -274,7 +269,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/GenerateFunctionDataTypes.java b/src/main/java/ai/reveng/model/GenerateFunctionDataTypes.java index 8f292f46..6958b7c6 100644 --- a/src/main/java/ai/reveng/model/GenerateFunctionDataTypes.java +++ b/src/main/java/ai/reveng/model/GenerateFunctionDataTypes.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.GenerationStatusList; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -219,10 +217,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -246,19 +241,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GenerateFunctionDataTypes.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in GenerateFunctionDataTypes is not found in the empty JSON string", GenerateFunctionDataTypes.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in GenerateFunctionDataTypes is not found in the empty JSON string", GenerateFunctionDataTypes.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GenerateFunctionDataTypes.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("reference").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `reference` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reference").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `reference` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reference").toString())); } // validate the required field `data_types_list` GenerationStatusList.validateJsonElement(jsonObj.get("data_types_list")); @@ -321,7 +316,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/GeneratePDFOutputBody.java b/src/main/java/ai/reveng/model/GeneratePDFOutputBody.java index 8725b9d7..3ee859c1 100644 --- a/src/main/java/ai/reveng/model/GeneratePDFOutputBody.java +++ b/src/main/java/ai/reveng/model/GeneratePDFOutputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -77,50 +75,6 @@ public void setAlreadyRunning(@javax.annotation.Nullable Boolean alreadyRunning) this.alreadyRunning = alreadyRunning; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the GeneratePDFOutputBody instance itself - */ - public GeneratePDFOutputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -132,13 +86,12 @@ public boolean equals(Object o) { return false; } GeneratePDFOutputBody generatePDFOutputBody = (GeneratePDFOutputBody) o; - return Objects.equals(this.alreadyRunning, generatePDFOutputBody.alreadyRunning)&& - Objects.equals(this.additionalProperties, generatePDFOutputBody.additionalProperties); + return Objects.equals(this.alreadyRunning, generatePDFOutputBody.alreadyRunning); } @Override public int hashCode() { - return Objects.hash(alreadyRunning, additionalProperties); + return Objects.hash(alreadyRunning); } @Override @@ -146,7 +99,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class GeneratePDFOutputBody {\n"); sb.append(" alreadyRunning: ").append(toIndentedString(alreadyRunning)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -156,10 +108,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,7 +132,15 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GeneratePDFOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in GeneratePDFOutputBody is not found in the empty JSON string", GeneratePDFOutputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in GeneratePDFOutputBody is not found in the empty JSON string", GeneratePDFOutputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!GeneratePDFOutputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GeneratePDFOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -204,28 +161,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GeneratePDFOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -233,28 +168,7 @@ else if (entry.getValue() instanceof Character) public GeneratePDFOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - GeneratePDFOutputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/GenerationStatusList.java b/src/main/java/ai/reveng/model/GenerationStatusList.java index bc066bdd..ced7c044 100644 --- a/src/main/java/ai/reveng/model/GenerationStatusList.java +++ b/src/main/java/ai/reveng/model/GenerationStatusList.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FunctionDataTypesStatus; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -219,10 +217,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -246,27 +241,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GenerationStatusList.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in GenerationStatusList is not found in the empty JSON string", GenerationStatusList.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in GenerationStatusList is not found in the empty JSON string", GenerationStatusList.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GenerationStatusList.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("items").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `items` to be an array in the JSON string but got `%s`", jsonObj.get("items").toString())); + if (jsonObj.get("items") != null) { + if (!jsonObj.get("items").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `items` to be an array in the JSON string but got `%s`", jsonObj.get("items").toString())); + } + JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); + // validate the required field `items` (array) + for (int i = 0; i < jsonArrayitems.size(); i++) { + FunctionDataTypesStatus.validateJsonElement(jsonArrayitems.get(i)); + } } - - JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); - // validate the required field `items` (array) - for (int i = 0; i < jsonArrayitems.size(); i++) { - FunctionDataTypesStatus.validateJsonElement(jsonArrayitems.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -326,7 +321,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/GetAdditionalDetailsOutputBody.java b/src/main/java/ai/reveng/model/GetAdditionalDetailsOutputBody.java index 32431dfe..72661b14 100644 --- a/src/main/java/ai/reveng/model/GetAdditionalDetailsOutputBody.java +++ b/src/main/java/ai/reveng/model/GetAdditionalDetailsOutputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -101,50 +99,6 @@ public void setDetails(@javax.annotation.Nullable Object details) { this.details = details; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the GetAdditionalDetailsOutputBody instance itself - */ - public GetAdditionalDetailsOutputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -157,13 +111,12 @@ public boolean equals(Object o) { } GetAdditionalDetailsOutputBody getAdditionalDetailsOutputBody = (GetAdditionalDetailsOutputBody) o; return Objects.equals(this.binaryId, getAdditionalDetailsOutputBody.binaryId) && - Objects.equals(this.details, getAdditionalDetailsOutputBody.details)&& - Objects.equals(this.additionalProperties, getAdditionalDetailsOutputBody.additionalProperties); + Objects.equals(this.details, getAdditionalDetailsOutputBody.details); } @Override public int hashCode() { - return Objects.hash(binaryId, details, additionalProperties); + return Objects.hash(binaryId, details); } @Override @@ -172,7 +125,6 @@ public String toString() { sb.append("class GetAdditionalDetailsOutputBody {\n"); sb.append(" binaryId: ").append(toIndentedString(binaryId)).append("\n"); sb.append(" details: ").append(toIndentedString(details)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -182,10 +134,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -209,14 +158,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GetAdditionalDetailsOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in GetAdditionalDetailsOutputBody is not found in the empty JSON string", GetAdditionalDetailsOutputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in GetAdditionalDetailsOutputBody is not found in the empty JSON string", GetAdditionalDetailsOutputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!GetAdditionalDetailsOutputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetAdditionalDetailsOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetAdditionalDetailsOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -237,28 +194,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetAdditionalDetailsOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -266,28 +201,7 @@ else if (entry.getValue() instanceof Character) public GetAdditionalDetailsOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - GetAdditionalDetailsOutputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/GetAdditionalDetailsStatusOutputBody.java b/src/main/java/ai/reveng/model/GetAdditionalDetailsStatusOutputBody.java index 358b5560..23255e9c 100644 --- a/src/main/java/ai/reveng/model/GetAdditionalDetailsStatusOutputBody.java +++ b/src/main/java/ai/reveng/model/GetAdditionalDetailsStatusOutputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -77,50 +75,6 @@ public void setStatus(@javax.annotation.Nonnull String status) { this.status = status; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the GetAdditionalDetailsStatusOutputBody instance itself - */ - public GetAdditionalDetailsStatusOutputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -132,13 +86,12 @@ public boolean equals(Object o) { return false; } GetAdditionalDetailsStatusOutputBody getAdditionalDetailsStatusOutputBody = (GetAdditionalDetailsStatusOutputBody) o; - return Objects.equals(this.status, getAdditionalDetailsStatusOutputBody.status)&& - Objects.equals(this.additionalProperties, getAdditionalDetailsStatusOutputBody.additionalProperties); + return Objects.equals(this.status, getAdditionalDetailsStatusOutputBody.status); } @Override public int hashCode() { - return Objects.hash(status, additionalProperties); + return Objects.hash(status); } @Override @@ -146,7 +99,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class GetAdditionalDetailsStatusOutputBody {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -156,10 +108,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,19 +132,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GetAdditionalDetailsStatusOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in GetAdditionalDetailsStatusOutputBody is not found in the empty JSON string", GetAdditionalDetailsStatusOutputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in GetAdditionalDetailsStatusOutputBody is not found in the empty JSON string", GetAdditionalDetailsStatusOutputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!GetAdditionalDetailsStatusOutputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetAdditionalDetailsStatusOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetAdditionalDetailsStatusOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); } } @@ -214,28 +171,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetAdditionalDetailsStatusOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -243,28 +178,7 @@ else if (entry.getValue() instanceof Character) public GetAdditionalDetailsStatusOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - GetAdditionalDetailsStatusOutputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/GetAiDecompilationRatingResponse.java b/src/main/java/ai/reveng/model/GetAiDecompilationRatingResponse.java index 37e1e338..5b802aec 100644 --- a/src/main/java/ai/reveng/model/GetAiDecompilationRatingResponse.java +++ b/src/main/java/ai/reveng/model/GetAiDecompilationRatingResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AiDecompilationRating; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -90,7 +88,7 @@ public GetAiDecompilationRatingResponse reason(@javax.annotation.Nullable String } /** - * Get reason + * The optional reason the user has given for the rating * @return reason */ @javax.annotation.Nullable @@ -183,10 +181,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -210,21 +205,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GetAiDecompilationRatingResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in GetAiDecompilationRatingResponse is not found in the empty JSON string", GetAiDecompilationRatingResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in GetAiDecompilationRatingResponse is not found in the empty JSON string", GetAiDecompilationRatingResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetAiDecompilationRatingResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the required field `rating` AiDecompilationRating.validateJsonElement(jsonObj.get("rating")); if ((jsonObj.get("reason") != null && !jsonObj.get("reason").isJsonNull()) && !jsonObj.get("reason").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); } } @@ -285,7 +280,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/GetAiDecompilationTask.java b/src/main/java/ai/reveng/model/GetAiDecompilationTask.java index a9823af0..3b617ca2 100644 --- a/src/main/java/ai/reveng/model/GetAiDecompilationTask.java +++ b/src/main/java/ai/reveng/model/GetAiDecompilationTask.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AiDecompilationTaskStatus; import ai.reveng.model.FunctionMappingFull; import ai.reveng.model.InverseFunctionMapItem; @@ -48,7 +47,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -130,7 +128,7 @@ public GetAiDecompilationTask decompilation(@javax.annotation.Nullable String de } /** - * Get decompilation + * The AI decompilation string with values from function mappings already replaced * @return decompilation */ @javax.annotation.Nullable @@ -149,7 +147,7 @@ public GetAiDecompilationTask rawDecompilation(@javax.annotation.Nullable String } /** - * Get rawDecompilation + * The unedited AI Decompilation string * @return rawDecompilation */ @javax.annotation.Nullable @@ -176,7 +174,7 @@ public GetAiDecompilationTask putFunctionMappingItem(String key, InverseFunction } /** - * Get functionMapping + * Deprecated structure * @return functionMapping */ @javax.annotation.Nullable @@ -195,7 +193,7 @@ public GetAiDecompilationTask functionMappingFull(@javax.annotation.Nullable Fun } /** - * Get functionMappingFull + * The full mapping, useful for swapping out values within raw_decompilation * @return functionMappingFull */ @javax.annotation.Nullable @@ -214,7 +212,7 @@ public GetAiDecompilationTask summary(@javax.annotation.Nullable String summary) } /** - * Get summary + * The summary comment for the decompilation (deprecated, please use raw_ai_summary instead) * @return summary */ @javax.annotation.Nullable @@ -233,7 +231,7 @@ public GetAiDecompilationTask aiSummary(@javax.annotation.Nullable String aiSumm } /** - * Get aiSummary + * The summary comment for the decompilation with values from function mappings already replaced * @return aiSummary */ @javax.annotation.Nullable @@ -252,7 +250,7 @@ public GetAiDecompilationTask rawAiSummary(@javax.annotation.Nullable String raw } /** - * Get rawAiSummary + * The summary comment for the decompilation with no replacements * @return rawAiSummary */ @javax.annotation.Nullable @@ -271,7 +269,7 @@ public GetAiDecompilationTask predictedFunctionName(@javax.annotation.Nullable S } /** - * Get predictedFunctionName + * The predicted function name from the AI model * @return predictedFunctionName */ @javax.annotation.Nullable @@ -389,10 +387,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -416,38 +411,40 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GetAiDecompilationTask.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in GetAiDecompilationTask is not found in the empty JSON string", GetAiDecompilationTask.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in GetAiDecompilationTask is not found in the empty JSON string", GetAiDecompilationTask.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetAiDecompilationTask.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the required field `status` AiDecompilationTaskStatus.validateJsonElement(jsonObj.get("status")); if ((jsonObj.get("decompilation") != null && !jsonObj.get("decompilation").isJsonNull()) && !jsonObj.get("decompilation").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `decompilation` to be a primitive type in the JSON string but got `%s`", jsonObj.get("decompilation").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `decompilation` to be a primitive type in the JSON string but got `%s`", jsonObj.get("decompilation").toString())); } if ((jsonObj.get("raw_decompilation") != null && !jsonObj.get("raw_decompilation").isJsonNull()) && !jsonObj.get("raw_decompilation").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `raw_decompilation` to be a primitive type in the JSON string but got `%s`", jsonObj.get("raw_decompilation").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `raw_decompilation` to be a primitive type in the JSON string but got `%s`", jsonObj.get("raw_decompilation").toString())); } + if (jsonObj.get("function_mapping_full") != null && !jsonObj.get("function_mapping_full").isJsonNull()) { // validate the required field `function_mapping_full` FunctionMappingFull.validateJsonElement(jsonObj.get("function_mapping_full")); + } if ((jsonObj.get("summary") != null && !jsonObj.get("summary").isJsonNull()) && !jsonObj.get("summary").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("summary").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("summary").toString())); } if ((jsonObj.get("ai_summary") != null && !jsonObj.get("ai_summary").isJsonNull()) && !jsonObj.get("ai_summary").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `ai_summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("ai_summary").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `ai_summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("ai_summary").toString())); } if ((jsonObj.get("raw_ai_summary") != null && !jsonObj.get("raw_ai_summary").isJsonNull()) && !jsonObj.get("raw_ai_summary").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `raw_ai_summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("raw_ai_summary").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `raw_ai_summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("raw_ai_summary").toString())); } if ((jsonObj.get("predicted_function_name") != null && !jsonObj.get("predicted_function_name").isJsonNull()) && !jsonObj.get("predicted_function_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `predicted_function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("predicted_function_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `predicted_function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("predicted_function_name").toString())); } } @@ -508,7 +505,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/GetAnalysisStringsStatusOutputBody.java b/src/main/java/ai/reveng/model/GetAnalysisStringsStatusOutputBody.java index f0525e58..36db3310 100644 --- a/src/main/java/ai/reveng/model/GetAnalysisStringsStatusOutputBody.java +++ b/src/main/java/ai/reveng/model/GetAnalysisStringsStatusOutputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -77,50 +75,6 @@ public void setStatus(@javax.annotation.Nonnull String status) { this.status = status; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the GetAnalysisStringsStatusOutputBody instance itself - */ - public GetAnalysisStringsStatusOutputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -132,13 +86,12 @@ public boolean equals(Object o) { return false; } GetAnalysisStringsStatusOutputBody getAnalysisStringsStatusOutputBody = (GetAnalysisStringsStatusOutputBody) o; - return Objects.equals(this.status, getAnalysisStringsStatusOutputBody.status)&& - Objects.equals(this.additionalProperties, getAnalysisStringsStatusOutputBody.additionalProperties); + return Objects.equals(this.status, getAnalysisStringsStatusOutputBody.status); } @Override public int hashCode() { - return Objects.hash(status, additionalProperties); + return Objects.hash(status); } @Override @@ -146,7 +99,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class GetAnalysisStringsStatusOutputBody {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -156,10 +108,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,19 +132,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GetAnalysisStringsStatusOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in GetAnalysisStringsStatusOutputBody is not found in the empty JSON string", GetAnalysisStringsStatusOutputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in GetAnalysisStringsStatusOutputBody is not found in the empty JSON string", GetAnalysisStringsStatusOutputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!GetAnalysisStringsStatusOutputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetAnalysisStringsStatusOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetAnalysisStringsStatusOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); } } @@ -214,28 +171,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetAnalysisStringsStatusOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -243,28 +178,7 @@ else if (entry.getValue() instanceof Character) public GetAnalysisStringsStatusOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - GetAnalysisStringsStatusOutputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/GetCollectionOutputBody.java b/src/main/java/ai/reveng/model/GetCollectionOutputBody.java index 75f086fb..c450c16e 100644 --- a/src/main/java/ai/reveng/model/GetCollectionOutputBody.java +++ b/src/main/java/ai/reveng/model/GetCollectionOutputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.Binary; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -47,7 +46,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -410,50 +408,6 @@ public void setUserId(@javax.annotation.Nonnull Long userId) { this.userId = userId; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the GetCollectionOutputBody instance itself - */ - public GetCollectionOutputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -478,8 +432,7 @@ public boolean equals(Object o) { Objects.equals(this.tags, getCollectionOutputBody.tags) && Objects.equals(this.teamId, getCollectionOutputBody.teamId) && Objects.equals(this.updatedAt, getCollectionOutputBody.updatedAt) && - Objects.equals(this.userId, getCollectionOutputBody.userId)&& - Objects.equals(this.additionalProperties, getCollectionOutputBody.additionalProperties); + Objects.equals(this.userId, getCollectionOutputBody.userId); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -488,7 +441,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(binaries, collectionId, collectionName, collectionScope, createdAt, description, hasNextPage, modelId, pageNumber, pageSize, tags, teamId, updatedAt, userId, additionalProperties); + return Objects.hash(binaries, collectionId, collectionName, collectionScope, createdAt, description, hasNextPage, modelId, pageNumber, pageSize, tags, teamId, updatedAt, userId); } private static int hashCodeNullable(JsonNullable a) { @@ -516,7 +469,6 @@ public String toString() { sb.append(" teamId: ").append(toIndentedString(teamId)).append("\n"); sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -526,10 +478,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -553,33 +502,51 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GetCollectionOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in GetCollectionOutputBody is not found in the empty JSON string", GetCollectionOutputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in GetCollectionOutputBody is not found in the empty JSON string", GetCollectionOutputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!GetCollectionOutputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetCollectionOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetCollectionOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the optional json data is an array if present - if (jsonObj.get("binaries") != null && !jsonObj.get("binaries").isJsonNull() && !jsonObj.get("binaries").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); + if (jsonObj.get("binaries") != null && !jsonObj.get("binaries").isJsonNull()) { + JsonArray jsonArraybinaries = jsonObj.getAsJsonArray("binaries"); + if (jsonArraybinaries != null) { + // ensure the json data is an array + if (!jsonObj.get("binaries").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); + } + + // validate the optional field `binaries` (array) + for (int i = 0; i < jsonArraybinaries.size(); i++) { + Binary.validateJsonElement(jsonArraybinaries.get(i)); + }; + } } if (!jsonObj.get("collection_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); } if (!jsonObj.get("collection_scope").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_scope").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_scope").toString())); } if (!jsonObj.get("description").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); } // ensure the optional json data is an array if present if (jsonObj.get("tags") != null && !jsonObj.get("tags").isJsonNull() && !jsonObj.get("tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); } } @@ -598,28 +565,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetCollectionOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -627,28 +572,7 @@ else if (entry.getValue() instanceof Character) public GetCollectionOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - GetCollectionOutputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/GetProductsOutputBody.java b/src/main/java/ai/reveng/model/GetProductsOutputBody.java index a52812de..7e32cda7 100644 --- a/src/main/java/ai/reveng/model/GetProductsOutputBody.java +++ b/src/main/java/ai/reveng/model/GetProductsOutputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ProductOutput; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -167,10 +165,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,22 +189,26 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GetProductsOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in GetProductsOutputBody is not found in the empty JSON string", GetProductsOutputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in GetProductsOutputBody is not found in the empty JSON string", GetProductsOutputBody.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetProductsOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the required json array is present - if (jsonObj.get("products") == null) { - throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); - } else if (!jsonObj.get("products").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `products` to be an array in the JSON string but got `%s`", jsonObj.get("products").toString())); + if (jsonObj.get("products") != null && !jsonObj.get("products").isJsonNull()) { + if (!jsonObj.get("products").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `products` to be an array in the JSON string but got `%s`", jsonObj.get("products").toString())); + } + JsonArray jsonArrayproducts = jsonObj.getAsJsonArray("products"); + // validate the required field `products` (array) + for (int i = 0; i < jsonArrayproducts.size(); i++) { + ProductOutput.validateJsonElement(jsonArrayproducts.get(i)); + } } } @@ -270,7 +269,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/GetPublicUserResponse.java b/src/main/java/ai/reveng/model/GetPublicUserResponse.java index c75dd610..cd947441 100644 --- a/src/main/java/ai/reveng/model/GetPublicUserResponse.java +++ b/src/main/java/ai/reveng/model/GetPublicUserResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -182,10 +180,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -209,19 +204,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GetPublicUserResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in GetPublicUserResponse is not found in the empty JSON string", GetPublicUserResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in GetPublicUserResponse is not found in the empty JSON string", GetPublicUserResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetPublicUserResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("username").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); } } @@ -282,7 +277,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/GetSubscriptionOutputBody.java b/src/main/java/ai/reveng/model/GetSubscriptionOutputBody.java index ebea35d2..d72cf249 100644 --- a/src/main/java/ai/reveng/model/GetSubscriptionOutputBody.java +++ b/src/main/java/ai/reveng/model/GetSubscriptionOutputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.PriceSummary; import ai.reveng.model.ProductSummary; import com.google.gson.TypeAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -407,10 +405,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -434,24 +429,32 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GetSubscriptionOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in GetSubscriptionOutputBody is not found in the empty JSON string", GetSubscriptionOutputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in GetSubscriptionOutputBody is not found in the empty JSON string", GetSubscriptionOutputBody.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetSubscriptionOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `price` + if (jsonObj.get("price") != null && !jsonObj.get("price").isJsonNull()) { + PriceSummary.validateJsonElement(jsonObj.get("price")); + } + // validate the optional field `product` + if (jsonObj.get("product") != null && !jsonObj.get("product").isJsonNull()) { + ProductSummary.validateJsonElement(jsonObj.get("product")); + } if (!jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); } // validate the required field `status` StatusEnum.validateJsonElement(jsonObj.get("status")); if (!jsonObj.get("tier").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tier` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tier").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tier` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tier").toString())); } // validate the required field `tier` TierEnum.validateJsonElement(jsonObj.get("tier")); @@ -514,7 +517,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/GlobalVariable.java b/src/main/java/ai/reveng/model/GlobalVariable.java index 88b040b8..6b4624c3 100644 --- a/src/main/java/ai/reveng/model/GlobalVariable.java +++ b/src/main/java/ai/reveng/model/GlobalVariable.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -91,7 +89,7 @@ public GlobalVariable lastChange(@javax.annotation.Nullable String lastChange) { } /** - * Get lastChange + * Timestamp of the last change to this global variable * @return lastChange */ @javax.annotation.Nullable @@ -298,10 +296,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -325,28 +320,28 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GlobalVariable.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in GlobalVariable is not found in the empty JSON string", GlobalVariable.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in GlobalVariable is not found in the empty JSON string", GlobalVariable.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GlobalVariable.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("last_change") != null && !jsonObj.get("last_change").isJsonNull()) && !jsonObj.get("last_change").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `last_change` to be a primitive type in the JSON string but got `%s`", jsonObj.get("last_change").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `last_change` to be a primitive type in the JSON string but got `%s`", jsonObj.get("last_change").toString())); } if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } if ((jsonObj.get("artifact_type") != null && !jsonObj.get("artifact_type").isJsonNull()) && !jsonObj.get("artifact_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `artifact_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("artifact_type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `artifact_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("artifact_type").toString())); } } @@ -407,7 +402,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/HistoryEntry.java b/src/main/java/ai/reveng/model/HistoryEntry.java index 76ce4ea3..5de5fcdb 100644 --- a/src/main/java/ai/reveng/model/HistoryEntry.java +++ b/src/main/java/ai/reveng/model/HistoryEntry.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -222,50 +220,6 @@ public void setSourceType(@javax.annotation.Nonnull String sourceType) { this.sourceType = sourceType; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the HistoryEntry instance itself - */ - public HistoryEntry putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -283,13 +237,12 @@ public boolean equals(Object o) { Objects.equals(this.historyId, historyEntry.historyId) && Objects.equals(this.isDebug, historyEntry.isDebug) && Objects.equals(this.mangledName, historyEntry.mangledName) && - Objects.equals(this.sourceType, historyEntry.sourceType)&& - Objects.equals(this.additionalProperties, historyEntry.additionalProperties); + Objects.equals(this.sourceType, historyEntry.sourceType); } @Override public int hashCode() { - return Objects.hash(changeMadeBy, createdAt, functionName, historyId, isDebug, mangledName, sourceType, additionalProperties); + return Objects.hash(changeMadeBy, createdAt, functionName, historyId, isDebug, mangledName, sourceType); } @Override @@ -303,7 +256,6 @@ public String toString() { sb.append(" isDebug: ").append(toIndentedString(isDebug)).append("\n"); sb.append(" mangledName: ").append(toIndentedString(mangledName)).append("\n"); sb.append(" sourceType: ").append(toIndentedString(sourceType)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -313,10 +265,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -340,28 +289,36 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!HistoryEntry.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in HistoryEntry is not found in the empty JSON string", HistoryEntry.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in HistoryEntry is not found in the empty JSON string", HistoryEntry.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!HistoryEntry.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `HistoryEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : HistoryEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("change_made_by").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `change_made_by` to be a primitive type in the JSON string but got `%s`", jsonObj.get("change_made_by").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `change_made_by` to be a primitive type in the JSON string but got `%s`", jsonObj.get("change_made_by").toString())); } if (!jsonObj.get("function_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); } if ((jsonObj.get("mangled_name") != null && !jsonObj.get("mangled_name").isJsonNull()) && !jsonObj.get("mangled_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mangled_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mangled_name").toString())); } if (!jsonObj.get("source_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_type").toString())); } } @@ -380,28 +337,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, HistoryEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -409,28 +344,7 @@ else if (entry.getValue() instanceof Character) public HistoryEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - HistoryEntry instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/HttpRequest.java b/src/main/java/ai/reveng/model/HttpRequest.java index 0318b6ba..d9e27c1b 100644 --- a/src/main/java/ai/reveng/model/HttpRequest.java +++ b/src/main/java/ai/reveng/model/HttpRequest.java @@ -13,7 +13,7 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; +import ai.reveng.model.PcapBodyInfo; import ai.reveng.model.ReportEvent; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +46,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -55,6 +54,16 @@ */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class HttpRequest { + public static final String SERIALIZED_NAME_BYTES_RECEIVED = "bytes_received"; + @SerializedName(SERIALIZED_NAME_BYTES_RECEIVED) + @javax.annotation.Nullable + private Long bytesReceived; + + public static final String SERIALIZED_NAME_BYTES_SENT = "bytes_sent"; + @SerializedName(SERIALIZED_NAME_BYTES_SENT) + @javax.annotation.Nullable + private Long bytesSent; + public static final String SERIALIZED_NAME_EVENTS = "events"; @SerializedName(SERIALIZED_NAME_EVENTS) @javax.annotation.Nullable @@ -80,6 +89,11 @@ public class HttpRequest { @javax.annotation.Nullable private String path; + public static final String SERIALIZED_NAME_PCAP_STREAM_ID = "pcap_stream_id"; + @SerializedName(SERIALIZED_NAME_PCAP_STREAM_ID) + @javax.annotation.Nullable + private Long pcapStreamId; + public static final String SERIALIZED_NAME_POST_DATA = "post_data"; @SerializedName(SERIALIZED_NAME_POST_DATA) @javax.annotation.Nullable @@ -100,6 +114,26 @@ public class HttpRequest { @javax.annotation.Nullable private String referer; + public static final String SERIALIZED_NAME_REQUEST_BODY = "request_body"; + @SerializedName(SERIALIZED_NAME_REQUEST_BODY) + @javax.annotation.Nullable + private PcapBodyInfo requestBody; + + public static final String SERIALIZED_NAME_RESPONSE_BODY = "response_body"; + @SerializedName(SERIALIZED_NAME_RESPONSE_BODY) + @javax.annotation.Nullable + private PcapBodyInfo responseBody; + + public static final String SERIALIZED_NAME_RESPONSE_STATUS = "response_status"; + @SerializedName(SERIALIZED_NAME_RESPONSE_STATUS) + @javax.annotation.Nullable + private Long responseStatus; + + public static final String SERIALIZED_NAME_SERVER_IP = "server_ip"; + @SerializedName(SERIALIZED_NAME_SERVER_IP) + @javax.annotation.Nullable + private String serverIp; + public static final String SERIALIZED_NAME_SERVER_NAME = "server_name"; @SerializedName(SERIALIZED_NAME_SERVER_NAME) @javax.annotation.Nullable @@ -138,6 +172,44 @@ public class HttpRequest { public HttpRequest() { } + public HttpRequest bytesReceived(@javax.annotation.Nullable Long bytesReceived) { + this.bytesReceived = bytesReceived; + return this; + } + + /** + * Get bytesReceived + * @return bytesReceived + */ + @javax.annotation.Nullable + public Long getBytesReceived() { + return bytesReceived; + } + + public void setBytesReceived(@javax.annotation.Nullable Long bytesReceived) { + this.bytesReceived = bytesReceived; + } + + + public HttpRequest bytesSent(@javax.annotation.Nullable Long bytesSent) { + this.bytesSent = bytesSent; + return this; + } + + /** + * Get bytesSent + * @return bytesSent + */ + @javax.annotation.Nullable + public Long getBytesSent() { + return bytesSent; + } + + public void setBytesSent(@javax.annotation.Nullable Long bytesSent) { + this.bytesSent = bytesSent; + } + + public HttpRequest events(@javax.annotation.Nullable List events) { this.events = events; return this; @@ -249,6 +321,25 @@ public void setPath(@javax.annotation.Nullable String path) { } + public HttpRequest pcapStreamId(@javax.annotation.Nullable Long pcapStreamId) { + this.pcapStreamId = pcapStreamId; + return this; + } + + /** + * Get pcapStreamId + * @return pcapStreamId + */ + @javax.annotation.Nullable + public Long getPcapStreamId() { + return pcapStreamId; + } + + public void setPcapStreamId(@javax.annotation.Nullable Long pcapStreamId) { + this.pcapStreamId = pcapStreamId; + } + + public HttpRequest postData(@javax.annotation.Nullable String postData) { this.postData = postData; return this; @@ -325,6 +416,82 @@ public void setReferer(@javax.annotation.Nullable String referer) { } + public HttpRequest requestBody(@javax.annotation.Nullable PcapBodyInfo requestBody) { + this.requestBody = requestBody; + return this; + } + + /** + * Get requestBody + * @return requestBody + */ + @javax.annotation.Nullable + public PcapBodyInfo getRequestBody() { + return requestBody; + } + + public void setRequestBody(@javax.annotation.Nullable PcapBodyInfo requestBody) { + this.requestBody = requestBody; + } + + + public HttpRequest responseBody(@javax.annotation.Nullable PcapBodyInfo responseBody) { + this.responseBody = responseBody; + return this; + } + + /** + * Get responseBody + * @return responseBody + */ + @javax.annotation.Nullable + public PcapBodyInfo getResponseBody() { + return responseBody; + } + + public void setResponseBody(@javax.annotation.Nullable PcapBodyInfo responseBody) { + this.responseBody = responseBody; + } + + + public HttpRequest responseStatus(@javax.annotation.Nullable Long responseStatus) { + this.responseStatus = responseStatus; + return this; + } + + /** + * Get responseStatus + * @return responseStatus + */ + @javax.annotation.Nullable + public Long getResponseStatus() { + return responseStatus; + } + + public void setResponseStatus(@javax.annotation.Nullable Long responseStatus) { + this.responseStatus = responseStatus; + } + + + public HttpRequest serverIp(@javax.annotation.Nullable String serverIp) { + this.serverIp = serverIp; + return this; + } + + /** + * Get serverIp + * @return serverIp + */ + @javax.annotation.Nullable + public String getServerIp() { + return serverIp; + } + + public void setServerIp(@javax.annotation.Nullable String serverIp) { + this.serverIp = serverIp; + } + + public HttpRequest serverName(@javax.annotation.Nullable String serverName) { this.serverName = serverName; return this; @@ -457,50 +624,6 @@ public void setVersion(@javax.annotation.Nullable String version) { this.version = version; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the HttpRequest instance itself - */ - public HttpRequest putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -512,23 +635,29 @@ public boolean equals(Object o) { return false; } HttpRequest httpRequest = (HttpRequest) o; - return Objects.equals(this.events, httpRequest.events) && + return Objects.equals(this.bytesReceived, httpRequest.bytesReceived) && + Objects.equals(this.bytesSent, httpRequest.bytesSent) && + Objects.equals(this.events, httpRequest.events) && Objects.equals(this.extraHeaders, httpRequest.extraHeaders) && Objects.equals(this.flags, httpRequest.flags) && Objects.equals(this.password, httpRequest.password) && Objects.equals(this.path, httpRequest.path) && + Objects.equals(this.pcapStreamId, httpRequest.pcapStreamId) && Objects.equals(this.postData, httpRequest.postData) && Objects.equals(this.proxy, httpRequest.proxy) && Objects.equals(this.proxyBypass, httpRequest.proxyBypass) && Objects.equals(this.referer, httpRequest.referer) && + Objects.equals(this.requestBody, httpRequest.requestBody) && + Objects.equals(this.responseBody, httpRequest.responseBody) && + Objects.equals(this.responseStatus, httpRequest.responseStatus) && + Objects.equals(this.serverIp, httpRequest.serverIp) && Objects.equals(this.serverName, httpRequest.serverName) && Objects.equals(this.serverPort, httpRequest.serverPort) && Objects.equals(this.service, httpRequest.service) && Objects.equals(this.userAgent, httpRequest.userAgent) && Objects.equals(this.username, httpRequest.username) && Objects.equals(this.verb, httpRequest.verb) && - Objects.equals(this.version, httpRequest.version)&& - Objects.equals(this.additionalProperties, httpRequest.additionalProperties); + Objects.equals(this.version, httpRequest.version); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -537,7 +666,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(events, extraHeaders, flags, password, path, postData, proxy, proxyBypass, referer, serverName, serverPort, service, userAgent, username, verb, version, additionalProperties); + return Objects.hash(bytesReceived, bytesSent, events, extraHeaders, flags, password, path, pcapStreamId, postData, proxy, proxyBypass, referer, requestBody, responseBody, responseStatus, serverIp, serverName, serverPort, service, userAgent, username, verb, version); } private static int hashCodeNullable(JsonNullable a) { @@ -551,15 +680,22 @@ private static int hashCodeNullable(JsonNullable a) { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class HttpRequest {\n"); + sb.append(" bytesReceived: ").append(toIndentedString(bytesReceived)).append("\n"); + sb.append(" bytesSent: ").append(toIndentedString(bytesSent)).append("\n"); sb.append(" events: ").append(toIndentedString(events)).append("\n"); sb.append(" extraHeaders: ").append(toIndentedString(extraHeaders)).append("\n"); sb.append(" flags: ").append(toIndentedString(flags)).append("\n"); sb.append(" password: ").append(toIndentedString(password)).append("\n"); sb.append(" path: ").append(toIndentedString(path)).append("\n"); + sb.append(" pcapStreamId: ").append(toIndentedString(pcapStreamId)).append("\n"); sb.append(" postData: ").append(toIndentedString(postData)).append("\n"); sb.append(" proxy: ").append(toIndentedString(proxy)).append("\n"); sb.append(" proxyBypass: ").append(toIndentedString(proxyBypass)).append("\n"); sb.append(" referer: ").append(toIndentedString(referer)).append("\n"); + sb.append(" requestBody: ").append(toIndentedString(requestBody)).append("\n"); + sb.append(" responseBody: ").append(toIndentedString(responseBody)).append("\n"); + sb.append(" responseStatus: ").append(toIndentedString(responseStatus)).append("\n"); + sb.append(" serverIp: ").append(toIndentedString(serverIp)).append("\n"); sb.append(" serverName: ").append(toIndentedString(serverName)).append("\n"); sb.append(" serverPort: ").append(toIndentedString(serverPort)).append("\n"); sb.append(" service: ").append(toIndentedString(service)).append("\n"); @@ -567,7 +703,6 @@ public String toString() { sb.append(" username: ").append(toIndentedString(username)).append("\n"); sb.append(" verb: ").append(toIndentedString(verb)).append("\n"); sb.append(" version: ").append(toIndentedString(version)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -577,10 +712,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -589,7 +721,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("events", "extra_headers", "flags", "password", "path", "post_data", "proxy", "proxy_bypass", "referer", "server_name", "server_port", "service", "user_agent", "username", "verb", "version")); + openapiFields = new HashSet(Arrays.asList("bytes_received", "bytes_sent", "events", "extra_headers", "flags", "password", "path", "pcap_stream_id", "post_data", "proxy", "proxy_bypass", "referer", "request_body", "response_body", "response_status", "server_ip", "server_name", "server_port", "service", "user_agent", "username", "verb", "version")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(0); @@ -604,50 +736,79 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!HttpRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in HttpRequest is not found in the empty JSON string", HttpRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in HttpRequest is not found in the empty JSON string", HttpRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!HttpRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `HttpRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the optional json data is an array if present - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull() && !jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { + JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); + if (jsonArrayevents != null) { + // ensure the json data is an array + if (!jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + } + + // validate the optional field `events` (array) + for (int i = 0; i < jsonArrayevents.size(); i++) { + ReportEvent.validateJsonElement(jsonArrayevents.get(i)); + }; + } } // ensure the optional json data is an array if present if (jsonObj.get("extra_headers") != null && !jsonObj.get("extra_headers").isJsonNull() && !jsonObj.get("extra_headers").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `extra_headers` to be an array in the JSON string but got `%s`", jsonObj.get("extra_headers").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `extra_headers` to be an array in the JSON string but got `%s`", jsonObj.get("extra_headers").toString())); } if ((jsonObj.get("password") != null && !jsonObj.get("password").isJsonNull()) && !jsonObj.get("password").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `password` to be a primitive type in the JSON string but got `%s`", jsonObj.get("password").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `password` to be a primitive type in the JSON string but got `%s`", jsonObj.get("password").toString())); } if ((jsonObj.get("path") != null && !jsonObj.get("path").isJsonNull()) && !jsonObj.get("path").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `path` to be a primitive type in the JSON string but got `%s`", jsonObj.get("path").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `path` to be a primitive type in the JSON string but got `%s`", jsonObj.get("path").toString())); } if ((jsonObj.get("post_data") != null && !jsonObj.get("post_data").isJsonNull()) && !jsonObj.get("post_data").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `post_data` to be a primitive type in the JSON string but got `%s`", jsonObj.get("post_data").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `post_data` to be a primitive type in the JSON string but got `%s`", jsonObj.get("post_data").toString())); } if ((jsonObj.get("proxy") != null && !jsonObj.get("proxy").isJsonNull()) && !jsonObj.get("proxy").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `proxy` to be a primitive type in the JSON string but got `%s`", jsonObj.get("proxy").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `proxy` to be a primitive type in the JSON string but got `%s`", jsonObj.get("proxy").toString())); } if ((jsonObj.get("proxy_bypass") != null && !jsonObj.get("proxy_bypass").isJsonNull()) && !jsonObj.get("proxy_bypass").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `proxy_bypass` to be a primitive type in the JSON string but got `%s`", jsonObj.get("proxy_bypass").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `proxy_bypass` to be a primitive type in the JSON string but got `%s`", jsonObj.get("proxy_bypass").toString())); } if ((jsonObj.get("referer") != null && !jsonObj.get("referer").isJsonNull()) && !jsonObj.get("referer").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `referer` to be a primitive type in the JSON string but got `%s`", jsonObj.get("referer").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `referer` to be a primitive type in the JSON string but got `%s`", jsonObj.get("referer").toString())); + } + // validate the optional field `request_body` + if (jsonObj.get("request_body") != null && !jsonObj.get("request_body").isJsonNull()) { + PcapBodyInfo.validateJsonElement(jsonObj.get("request_body")); + } + // validate the optional field `response_body` + if (jsonObj.get("response_body") != null && !jsonObj.get("response_body").isJsonNull()) { + PcapBodyInfo.validateJsonElement(jsonObj.get("response_body")); + } + if ((jsonObj.get("server_ip") != null && !jsonObj.get("server_ip").isJsonNull()) && !jsonObj.get("server_ip").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `server_ip` to be a primitive type in the JSON string but got `%s`", jsonObj.get("server_ip").toString())); } if ((jsonObj.get("server_name") != null && !jsonObj.get("server_name").isJsonNull()) && !jsonObj.get("server_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `server_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("server_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `server_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("server_name").toString())); } if ((jsonObj.get("user_agent") != null && !jsonObj.get("user_agent").isJsonNull()) && !jsonObj.get("user_agent").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `user_agent` to be a primitive type in the JSON string but got `%s`", jsonObj.get("user_agent").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `user_agent` to be a primitive type in the JSON string but got `%s`", jsonObj.get("user_agent").toString())); } if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) && !jsonObj.get("username").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); } if ((jsonObj.get("verb") != null && !jsonObj.get("verb").isJsonNull()) && !jsonObj.get("verb").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `verb` to be a primitive type in the JSON string but got `%s`", jsonObj.get("verb").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `verb` to be a primitive type in the JSON string but got `%s`", jsonObj.get("verb").toString())); } if ((jsonObj.get("version") != null && !jsonObj.get("version").isJsonNull()) && !jsonObj.get("version").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("version").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("version").toString())); } } @@ -666,28 +827,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, HttpRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -695,28 +834,7 @@ else if (entry.getValue() instanceof Character) public HttpRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - HttpRequest instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/IOC.java b/src/main/java/ai/reveng/model/IOC.java index fdbda4f7..57da4b10 100644 --- a/src/main/java/ai/reveng/model/IOC.java +++ b/src/main/java/ai/reveng/model/IOC.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -244,7 +242,7 @@ public IOC source(@javax.annotation.Nullable String source) { } /** - * Get source + * The source address where the IOC can be found in the binary if possible. * @return source */ @javax.annotation.Nullable @@ -263,7 +261,7 @@ public IOC functionId(@javax.annotation.Nullable Integer functionId) { } /** - * Get functionId + * Unique identifier of the function containing the IOC * @return functionId */ @javax.annotation.Nullable @@ -282,7 +280,7 @@ public IOC functionName(@javax.annotation.Nullable String functionName) { } /** - * Get functionName + * Name of the function containing the IOC * @return functionName */ @javax.annotation.Nullable @@ -394,10 +392,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -421,33 +416,33 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!IOC.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in IOC is not found in the empty JSON string", IOC.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in IOC is not found in the empty JSON string", IOC.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : IOC.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } // validate the required field `type` TypeEnum.validateJsonElement(jsonObj.get("type")); if (!jsonObj.get("value").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); } if (!jsonObj.get("description").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); } if ((jsonObj.get("source") != null && !jsonObj.get("source").isJsonNull()) && !jsonObj.get("source").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source").toString())); } if ((jsonObj.get("function_name") != null && !jsonObj.get("function_name").isJsonNull()) && !jsonObj.get("function_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); } } @@ -508,7 +503,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ISA.java b/src/main/java/ai/reveng/model/ISA.java index 8ca3b398..50f95e9e 100644 --- a/src/main/java/ai/reveng/model/ISA.java +++ b/src/main/java/ai/reveng/model/ISA.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/IconModel.java b/src/main/java/ai/reveng/model/IconModel.java index 9fd19597..b47698b0 100644 --- a/src/main/java/ai/reveng/model/IconModel.java +++ b/src/main/java/ai/reveng/model/IconModel.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -156,10 +154,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,19 +178,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!IconModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in IconModel is not found in the empty JSON string", IconModel.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in IconModel is not found in the empty JSON string", IconModel.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : IconModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("content") != null && !jsonObj.get("content").isJsonNull()) && !jsonObj.get("content").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `content` to be a primitive type in the JSON string but got `%s`", jsonObj.get("content").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `content` to be a primitive type in the JSON string but got `%s`", jsonObj.get("content").toString())); } } @@ -256,7 +251,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ImportModel.java b/src/main/java/ai/reveng/model/ImportModel.java index 9f93cfd7..c5dd847a 100644 --- a/src/main/java/ai/reveng/model/ImportModel.java +++ b/src/main/java/ai/reveng/model/ImportModel.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -193,10 +191,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -220,14 +215,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ImportModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ImportModel is not found in the empty JSON string", ImportModel.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ImportModel is not found in the empty JSON string", ImportModel.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ImportModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -235,7 +230,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("imports") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("imports").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `imports` to be an array in the JSON string but got `%s`", jsonObj.get("imports").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `imports` to be an array in the JSON string but got `%s`", jsonObj.get("imports").toString())); } } @@ -296,7 +291,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/InlineComment.java b/src/main/java/ai/reveng/model/InlineComment.java index 05b9daa9..2413f44c 100644 --- a/src/main/java/ai/reveng/model/InlineComment.java +++ b/src/main/java/ai/reveng/model/InlineComment.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -101,50 +99,6 @@ public void setLine(@javax.annotation.Nonnull Long line) { this.line = line; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the InlineComment instance itself - */ - public InlineComment putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -157,13 +111,12 @@ public boolean equals(Object o) { } InlineComment inlineComment = (InlineComment) o; return Objects.equals(this.comment, inlineComment.comment) && - Objects.equals(this.line, inlineComment.line)&& - Objects.equals(this.additionalProperties, inlineComment.additionalProperties); + Objects.equals(this.line, inlineComment.line); } @Override public int hashCode() { - return Objects.hash(comment, line, additionalProperties); + return Objects.hash(comment, line); } @Override @@ -172,7 +125,6 @@ public String toString() { sb.append("class InlineComment {\n"); sb.append(" comment: ").append(toIndentedString(comment)).append("\n"); sb.append(" line: ").append(toIndentedString(line)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -182,10 +134,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -209,19 +158,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!InlineComment.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in InlineComment is not found in the empty JSON string", InlineComment.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in InlineComment is not found in the empty JSON string", InlineComment.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!InlineComment.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `InlineComment` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : InlineComment.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("comment").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `comment` to be a primitive type in the JSON string but got `%s`", jsonObj.get("comment").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `comment` to be a primitive type in the JSON string but got `%s`", jsonObj.get("comment").toString())); } } @@ -240,28 +197,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, InlineComment value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -269,28 +204,7 @@ else if (entry.getValue() instanceof Character) public InlineComment read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - InlineComment instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/InsertAnalysisLogRequest.java b/src/main/java/ai/reveng/model/InsertAnalysisLogRequest.java index 3b2711ad..dfbb35e1 100644 --- a/src/main/java/ai/reveng/model/InsertAnalysisLogRequest.java +++ b/src/main/java/ai/reveng/model/InsertAnalysisLogRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -156,10 +154,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,19 +178,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!InsertAnalysisLogRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in InsertAnalysisLogRequest is not found in the empty JSON string", InsertAnalysisLogRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in InsertAnalysisLogRequest is not found in the empty JSON string", InsertAnalysisLogRequest.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : InsertAnalysisLogRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("log").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `log` to be a primitive type in the JSON string but got `%s`", jsonObj.get("log").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `log` to be a primitive type in the JSON string but got `%s`", jsonObj.get("log").toString())); } } @@ -256,7 +251,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/InverseFunctionMapItem.java b/src/main/java/ai/reveng/model/InverseFunctionMapItem.java index 037016e4..bb01df30 100644 --- a/src/main/java/ai/reveng/model/InverseFunctionMapItem.java +++ b/src/main/java/ai/reveng/model/InverseFunctionMapItem.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.Addr; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -209,10 +207,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -236,22 +231,24 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!InverseFunctionMapItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in InverseFunctionMapItem is not found in the empty JSON string", InverseFunctionMapItem.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in InverseFunctionMapItem is not found in the empty JSON string", InverseFunctionMapItem.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : InverseFunctionMapItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } + if (jsonObj.get("addr") != null && !jsonObj.get("addr").isJsonNull()) { // validate the required field `addr` Addr.validateJsonElement(jsonObj.get("addr")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -311,7 +308,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/InverseStringMapItem.java b/src/main/java/ai/reveng/model/InverseStringMapItem.java index d54a5e9f..36c8460f 100644 --- a/src/main/java/ai/reveng/model/InverseStringMapItem.java +++ b/src/main/java/ai/reveng/model/InverseStringMapItem.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -182,10 +180,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -209,19 +204,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!InverseStringMapItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in InverseStringMapItem is not found in the empty JSON string", InverseStringMapItem.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in InverseStringMapItem is not found in the empty JSON string", InverseStringMapItem.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : InverseStringMapItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("string").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `string` to be a primitive type in the JSON string but got `%s`", jsonObj.get("string").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `string` to be a primitive type in the JSON string but got `%s`", jsonObj.get("string").toString())); } } @@ -282,7 +277,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/InverseValue.java b/src/main/java/ai/reveng/model/InverseValue.java index 3881da95..fb3607a7 100644 --- a/src/main/java/ai/reveng/model/InverseValue.java +++ b/src/main/java/ai/reveng/model/InverseValue.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -156,10 +154,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,19 +178,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!InverseValue.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in InverseValue is not found in the empty JSON string", InverseValue.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in InverseValue is not found in the empty JSON string", InverseValue.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : InverseValue.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("value").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); } } @@ -256,7 +251,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ListAnalysisStringsOutputBody.java b/src/main/java/ai/reveng/model/ListAnalysisStringsOutputBody.java index aa803adb..189cbcf7 100644 --- a/src/main/java/ai/reveng/model/ListAnalysisStringsOutputBody.java +++ b/src/main/java/ai/reveng/model/ListAnalysisStringsOutputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AnalysisStringItem; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -112,50 +110,6 @@ public void setTotalStrings(@javax.annotation.Nonnull Long totalStrings) { this.totalStrings = totalStrings; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ListAnalysisStringsOutputBody instance itself - */ - public ListAnalysisStringsOutputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -168,13 +122,12 @@ public boolean equals(Object o) { } ListAnalysisStringsOutputBody listAnalysisStringsOutputBody = (ListAnalysisStringsOutputBody) o; return Objects.equals(this.strings, listAnalysisStringsOutputBody.strings) && - Objects.equals(this.totalStrings, listAnalysisStringsOutputBody.totalStrings)&& - Objects.equals(this.additionalProperties, listAnalysisStringsOutputBody.additionalProperties); + Objects.equals(this.totalStrings, listAnalysisStringsOutputBody.totalStrings); } @Override public int hashCode() { - return Objects.hash(strings, totalStrings, additionalProperties); + return Objects.hash(strings, totalStrings); } @Override @@ -183,7 +136,6 @@ public String toString() { sb.append("class ListAnalysisStringsOutputBody {\n"); sb.append(" strings: ").append(toIndentedString(strings)).append("\n"); sb.append(" totalStrings: ").append(toIndentedString(totalStrings)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -193,10 +145,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -220,22 +169,34 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ListAnalysisStringsOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ListAnalysisStringsOutputBody is not found in the empty JSON string", ListAnalysisStringsOutputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ListAnalysisStringsOutputBody is not found in the empty JSON string", ListAnalysisStringsOutputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ListAnalysisStringsOutputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ListAnalysisStringsOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ListAnalysisStringsOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the required json array is present - if (jsonObj.get("strings") == null) { - throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); - } else if (!jsonObj.get("strings").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `strings` to be an array in the JSON string but got `%s`", jsonObj.get("strings").toString())); + if (jsonObj.get("strings") != null && !jsonObj.get("strings").isJsonNull()) { + if (!jsonObj.get("strings").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `strings` to be an array in the JSON string but got `%s`", jsonObj.get("strings").toString())); + } + JsonArray jsonArraystrings = jsonObj.getAsJsonArray("strings"); + // validate the required field `strings` (array) + for (int i = 0; i < jsonArraystrings.size(); i++) { + AnalysisStringItem.validateJsonElement(jsonArraystrings.get(i)); + } } } @@ -254,28 +215,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ListAnalysisStringsOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -283,28 +222,7 @@ else if (entry.getValue() instanceof Character) public ListAnalysisStringsOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ListAnalysisStringsOutputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ListCollectionResults.java b/src/main/java/ai/reveng/model/ListCollectionResults.java index a8f0e832..a3d76e35 100644 --- a/src/main/java/ai/reveng/model/ListCollectionResults.java +++ b/src/main/java/ai/reveng/model/ListCollectionResults.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.CollectionListItem; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -167,10 +165,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,27 +189,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ListCollectionResults.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ListCollectionResults is not found in the empty JSON string", ListCollectionResults.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ListCollectionResults is not found in the empty JSON string", ListCollectionResults.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ListCollectionResults.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("results").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); + if (jsonObj.get("results") != null) { + if (!jsonObj.get("results").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); + } + JsonArray jsonArrayresults = jsonObj.getAsJsonArray("results"); + // validate the required field `results` (array) + for (int i = 0; i < jsonArrayresults.size(); i++) { + CollectionListItem.validateJsonElement(jsonArrayresults.get(i)); + } } - - JsonArray jsonArrayresults = jsonObj.getAsJsonArray("results"); - // validate the required field `results` (array) - for (int i = 0; i < jsonArrayresults.size(); i++) { - CollectionListItem.validateJsonElement(jsonArrayresults.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -274,7 +269,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ListCollectionsOutputBody.java b/src/main/java/ai/reveng/model/ListCollectionsOutputBody.java index 98ff1c93..9be38307 100644 --- a/src/main/java/ai/reveng/model/ListCollectionsOutputBody.java +++ b/src/main/java/ai/reveng/model/ListCollectionsOutputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.CollectionListItemBody; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -160,50 +158,6 @@ public void setResults(@javax.annotation.Nullable List r this.results = results; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ListCollectionsOutputBody instance itself - */ - public ListCollectionsOutputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -218,13 +172,12 @@ public boolean equals(Object o) { return Objects.equals(this.hasNextPage, listCollectionsOutputBody.hasNextPage) && Objects.equals(this.pageNumber, listCollectionsOutputBody.pageNumber) && Objects.equals(this.pageSize, listCollectionsOutputBody.pageSize) && - Objects.equals(this.results, listCollectionsOutputBody.results)&& - Objects.equals(this.additionalProperties, listCollectionsOutputBody.additionalProperties); + Objects.equals(this.results, listCollectionsOutputBody.results); } @Override public int hashCode() { - return Objects.hash(hasNextPage, pageNumber, pageSize, results, additionalProperties); + return Objects.hash(hasNextPage, pageNumber, pageSize, results); } @Override @@ -235,7 +188,6 @@ public String toString() { sb.append(" pageNumber: ").append(toIndentedString(pageNumber)).append("\n"); sb.append(" pageSize: ").append(toIndentedString(pageSize)).append("\n"); sb.append(" results: ").append(toIndentedString(results)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -245,10 +197,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -272,22 +221,34 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ListCollectionsOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ListCollectionsOutputBody is not found in the empty JSON string", ListCollectionsOutputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ListCollectionsOutputBody is not found in the empty JSON string", ListCollectionsOutputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ListCollectionsOutputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ListCollectionsOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ListCollectionsOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the required json array is present - if (jsonObj.get("results") == null) { - throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); - } else if (!jsonObj.get("results").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); + if (jsonObj.get("results") != null && !jsonObj.get("results").isJsonNull()) { + if (!jsonObj.get("results").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); + } + JsonArray jsonArrayresults = jsonObj.getAsJsonArray("results"); + // validate the required field `results` (array) + for (int i = 0; i < jsonArrayresults.size(); i++) { + CollectionListItemBody.validateJsonElement(jsonArrayresults.get(i)); + } } } @@ -306,28 +267,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ListCollectionsOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -335,28 +274,7 @@ else if (entry.getValue() instanceof Character) public ListCollectionsOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ListCollectionsOutputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ListFunctionStringsOutputBody.java b/src/main/java/ai/reveng/model/ListFunctionStringsOutputBody.java index 2a120ada..103cff0f 100644 --- a/src/main/java/ai/reveng/model/ListFunctionStringsOutputBody.java +++ b/src/main/java/ai/reveng/model/ListFunctionStringsOutputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FunctionStringItem; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -112,50 +110,6 @@ public void setTotalStrings(@javax.annotation.Nonnull Long totalStrings) { this.totalStrings = totalStrings; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ListFunctionStringsOutputBody instance itself - */ - public ListFunctionStringsOutputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -168,13 +122,12 @@ public boolean equals(Object o) { } ListFunctionStringsOutputBody listFunctionStringsOutputBody = (ListFunctionStringsOutputBody) o; return Objects.equals(this.strings, listFunctionStringsOutputBody.strings) && - Objects.equals(this.totalStrings, listFunctionStringsOutputBody.totalStrings)&& - Objects.equals(this.additionalProperties, listFunctionStringsOutputBody.additionalProperties); + Objects.equals(this.totalStrings, listFunctionStringsOutputBody.totalStrings); } @Override public int hashCode() { - return Objects.hash(strings, totalStrings, additionalProperties); + return Objects.hash(strings, totalStrings); } @Override @@ -183,7 +136,6 @@ public String toString() { sb.append("class ListFunctionStringsOutputBody {\n"); sb.append(" strings: ").append(toIndentedString(strings)).append("\n"); sb.append(" totalStrings: ").append(toIndentedString(totalStrings)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -193,10 +145,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -220,22 +169,34 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ListFunctionStringsOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ListFunctionStringsOutputBody is not found in the empty JSON string", ListFunctionStringsOutputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ListFunctionStringsOutputBody is not found in the empty JSON string", ListFunctionStringsOutputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ListFunctionStringsOutputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ListFunctionStringsOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ListFunctionStringsOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the required json array is present - if (jsonObj.get("strings") == null) { - throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); - } else if (!jsonObj.get("strings").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `strings` to be an array in the JSON string but got `%s`", jsonObj.get("strings").toString())); + if (jsonObj.get("strings") != null && !jsonObj.get("strings").isJsonNull()) { + if (!jsonObj.get("strings").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `strings` to be an array in the JSON string but got `%s`", jsonObj.get("strings").toString())); + } + JsonArray jsonArraystrings = jsonObj.getAsJsonArray("strings"); + // validate the required field `strings` (array) + for (int i = 0; i < jsonArraystrings.size(); i++) { + FunctionStringItem.validateJsonElement(jsonArraystrings.get(i)); + } } } @@ -254,28 +215,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ListFunctionStringsOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -283,28 +222,7 @@ else if (entry.getValue() instanceof Character) public ListFunctionStringsOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ListFunctionStringsOutputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/Logs.java b/src/main/java/ai/reveng/model/Logs.java index 858757b2..7bd56f4c 100644 --- a/src/main/java/ai/reveng/model/Logs.java +++ b/src/main/java/ai/reveng/model/Logs.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -156,10 +154,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,19 +178,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Logs.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Logs is not found in the empty JSON string", Logs.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Logs is not found in the empty JSON string", Logs.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Logs.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("logs").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `logs` to be a primitive type in the JSON string but got `%s`", jsonObj.get("logs").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `logs` to be a primitive type in the JSON string but got `%s`", jsonObj.get("logs").toString())); } } @@ -256,7 +251,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/MITRETechnique.java b/src/main/java/ai/reveng/model/MITRETechnique.java index 8bb7fc7e..0fe39117 100644 --- a/src/main/java/ai/reveng/model/MITRETechnique.java +++ b/src/main/java/ai/reveng/model/MITRETechnique.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -390,10 +388,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -417,43 +412,43 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!MITRETechnique.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in MITRETechnique is not found in the empty JSON string", MITRETechnique.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in MITRETechnique is not found in the empty JSON string", MITRETechnique.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : MITRETechnique.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("start_addr").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `start_addr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("start_addr").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `start_addr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("start_addr").toString())); } if (!jsonObj.get("end_addr").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `end_addr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("end_addr").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `end_addr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("end_addr").toString())); } if (!jsonObj.get("function_addr").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `function_addr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_addr").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_addr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_addr").toString())); } if (!jsonObj.get("technique_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `technique_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("technique_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `technique_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("technique_id").toString())); } if (!jsonObj.get("technique_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `technique_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("technique_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `technique_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("technique_name").toString())); } if (!jsonObj.get("description").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); } if (!jsonObj.get("function_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); } if (!jsonObj.get("technique_url").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `technique_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("technique_url").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `technique_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("technique_url").toString())); } if (!jsonObj.get("technique_description").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `technique_description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("technique_description").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `technique_description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("technique_description").toString())); } } @@ -514,7 +509,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/MatchedFunction.java b/src/main/java/ai/reveng/model/MatchedFunction.java index f965c09b..2fabc40d 100644 --- a/src/main/java/ai/reveng/model/MatchedFunction.java +++ b/src/main/java/ai/reveng/model/MatchedFunction.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -429,10 +427,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -456,28 +451,28 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!MatchedFunction.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in MatchedFunction is not found in the empty JSON string", MatchedFunction.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in MatchedFunction is not found in the empty JSON string", MatchedFunction.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : MatchedFunction.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("function_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_name").toString())); } if (!jsonObj.get("mangled_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mangled_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mangled_name").toString())); } if (!jsonObj.get("binary_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); } if (!jsonObj.get("sha_256_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); } } @@ -538,7 +533,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/MatchedFunctionSuggestion.java b/src/main/java/ai/reveng/model/MatchedFunctionSuggestion.java index 3934b979..719c9547 100644 --- a/src/main/java/ai/reveng/model/MatchedFunctionSuggestion.java +++ b/src/main/java/ai/reveng/model/MatchedFunctionSuggestion.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -119,7 +117,7 @@ public MatchedFunctionSuggestion suggestedName(@javax.annotation.Nullable String } /** - * Get suggestedName + * Mangled name of the function group that contains the matched functions * @return suggestedName */ @javax.annotation.Nullable @@ -246,10 +244,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -273,22 +268,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!MatchedFunctionSuggestion.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in MatchedFunctionSuggestion is not found in the empty JSON string", MatchedFunctionSuggestion.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in MatchedFunctionSuggestion is not found in the empty JSON string", MatchedFunctionSuggestion.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : MatchedFunctionSuggestion.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("suggested_name") != null && !jsonObj.get("suggested_name").isJsonNull()) && !jsonObj.get("suggested_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `suggested_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suggested_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `suggested_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suggested_name").toString())); } if (!jsonObj.get("suggested_demangled_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `suggested_demangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suggested_demangled_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `suggested_demangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suggested_demangled_name").toString())); } } @@ -349,7 +344,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/MemdumpEntry.java b/src/main/java/ai/reveng/model/MemdumpEntry.java index 6db754dc..b19d0390 100644 --- a/src/main/java/ai/reveng/model/MemdumpEntry.java +++ b/src/main/java/ai/reveng/model/MemdumpEntry.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -21,7 +20,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; -import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -43,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -54,12 +51,12 @@ public class MemdumpEntry { public static final String SERIALIZED_NAME_ADDRESS = "address"; @SerializedName(SERIALIZED_NAME_ADDRESS) - @javax.annotation.Nullable + @javax.annotation.Nonnull private String address; public static final String SERIALIZED_NAME_DUMP_REASON = "dump_reason"; @SerializedName(SERIALIZED_NAME_DUMP_REASON) - @javax.annotation.Nullable + @javax.annotation.Nonnull private String dumpReason; public static final String SERIALIZED_NAME_FILE_TYPE = "file_type"; @@ -69,7 +66,7 @@ public class MemdumpEntry { public static final String SERIALIZED_NAME_FILENAME = "filename"; @SerializedName(SERIALIZED_NAME_FILENAME) - @javax.annotation.Nullable + @javax.annotation.Nonnull private String filename; public static final String SERIALIZED_NAME_INDEX = "index"; @@ -84,7 +81,7 @@ public class MemdumpEntry { public static final String SERIALIZED_NAME_METHOD = "method"; @SerializedName(SERIALIZED_NAME_METHOD) - @javax.annotation.Nullable + @javax.annotation.Nonnull private String method; public static final String SERIALIZED_NAME_MIME_TYPE = "mime_type"; @@ -115,7 +112,7 @@ public class MemdumpEntry { public MemdumpEntry() { } - public MemdumpEntry address(@javax.annotation.Nullable String address) { + public MemdumpEntry address(@javax.annotation.Nonnull String address) { this.address = address; return this; } @@ -124,17 +121,17 @@ public MemdumpEntry address(@javax.annotation.Nullable String address) { * Get address * @return address */ - @javax.annotation.Nullable + @javax.annotation.Nonnull public String getAddress() { return address; } - public void setAddress(@javax.annotation.Nullable String address) { + public void setAddress(@javax.annotation.Nonnull String address) { this.address = address; } - public MemdumpEntry dumpReason(@javax.annotation.Nullable String dumpReason) { + public MemdumpEntry dumpReason(@javax.annotation.Nonnull String dumpReason) { this.dumpReason = dumpReason; return this; } @@ -143,12 +140,12 @@ public MemdumpEntry dumpReason(@javax.annotation.Nullable String dumpReason) { * Get dumpReason * @return dumpReason */ - @javax.annotation.Nullable + @javax.annotation.Nonnull public String getDumpReason() { return dumpReason; } - public void setDumpReason(@javax.annotation.Nullable String dumpReason) { + public void setDumpReason(@javax.annotation.Nonnull String dumpReason) { this.dumpReason = dumpReason; } @@ -172,7 +169,7 @@ public void setFileType(@javax.annotation.Nullable String fileType) { } - public MemdumpEntry filename(@javax.annotation.Nullable String filename) { + public MemdumpEntry filename(@javax.annotation.Nonnull String filename) { this.filename = filename; return this; } @@ -181,12 +178,12 @@ public MemdumpEntry filename(@javax.annotation.Nullable String filename) { * Get filename * @return filename */ - @javax.annotation.Nullable + @javax.annotation.Nonnull public String getFilename() { return filename; } - public void setFilename(@javax.annotation.Nullable String filename) { + public void setFilename(@javax.annotation.Nonnull String filename) { this.filename = filename; } @@ -229,7 +226,7 @@ public void setIsPe(@javax.annotation.Nullable Boolean isPe) { } - public MemdumpEntry method(@javax.annotation.Nullable String method) { + public MemdumpEntry method(@javax.annotation.Nonnull String method) { this.method = method; return this; } @@ -238,12 +235,12 @@ public MemdumpEntry method(@javax.annotation.Nullable String method) { * Get method * @return method */ - @javax.annotation.Nullable + @javax.annotation.Nonnull public String getMethod() { return method; } - public void setMethod(@javax.annotation.Nullable String method) { + public void setMethod(@javax.annotation.Nonnull String method) { this.method = method; } @@ -342,50 +339,6 @@ public void setTargetProcess(@javax.annotation.Nullable Long targetProcess) { this.targetProcess = targetProcess; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the MemdumpEntry instance itself - */ - public MemdumpEntry putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -408,24 +361,12 @@ public boolean equals(Object o) { Objects.equals(this.sha256, memdumpEntry.sha256) && Objects.equals(this.size, memdumpEntry.size) && Objects.equals(this.targetAddr, memdumpEntry.targetAddr) && - Objects.equals(this.targetProcess, memdumpEntry.targetProcess)&& - Objects.equals(this.additionalProperties, memdumpEntry.additionalProperties); - } - - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + Objects.equals(this.targetProcess, memdumpEntry.targetProcess); } @Override public int hashCode() { - return Objects.hash(address, dumpReason, fileType, filename, index, isPe, method, mimeType, sha256, size, targetAddr, targetProcess, additionalProperties); - } - - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + return Objects.hash(address, dumpReason, fileType, filename, index, isPe, method, mimeType, sha256, size, targetAddr, targetProcess); } @Override @@ -444,7 +385,6 @@ public String toString() { sb.append(" size: ").append(toIndentedString(size)).append("\n"); sb.append(" targetAddr: ").append(toIndentedString(targetAddr)).append("\n"); sb.append(" targetProcess: ").append(toIndentedString(targetProcess)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -454,10 +394,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -481,40 +418,48 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!MemdumpEntry.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in MemdumpEntry is not found in the empty JSON string", MemdumpEntry.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in MemdumpEntry is not found in the empty JSON string", MemdumpEntry.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!MemdumpEntry.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `MemdumpEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : MemdumpEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("address") != null && !jsonObj.get("address").isJsonNull()) && !jsonObj.get("address").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `address` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address").toString())); + if (!jsonObj.get("address").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `address` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address").toString())); } - if ((jsonObj.get("dump_reason") != null && !jsonObj.get("dump_reason").isJsonNull()) && !jsonObj.get("dump_reason").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `dump_reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("dump_reason").toString())); + if (!jsonObj.get("dump_reason").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `dump_reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("dump_reason").toString())); } if ((jsonObj.get("file_type") != null && !jsonObj.get("file_type").isJsonNull()) && !jsonObj.get("file_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `file_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("file_type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `file_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("file_type").toString())); } - if ((jsonObj.get("filename") != null && !jsonObj.get("filename").isJsonNull()) && !jsonObj.get("filename").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `filename` to be a primitive type in the JSON string but got `%s`", jsonObj.get("filename").toString())); + if (!jsonObj.get("filename").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `filename` to be a primitive type in the JSON string but got `%s`", jsonObj.get("filename").toString())); } - if ((jsonObj.get("method") != null && !jsonObj.get("method").isJsonNull()) && !jsonObj.get("method").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `method` to be a primitive type in the JSON string but got `%s`", jsonObj.get("method").toString())); + if (!jsonObj.get("method").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `method` to be a primitive type in the JSON string but got `%s`", jsonObj.get("method").toString())); } if ((jsonObj.get("mime_type") != null && !jsonObj.get("mime_type").isJsonNull()) && !jsonObj.get("mime_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `mime_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mime_type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `mime_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mime_type").toString())); } if ((jsonObj.get("sha256") != null && !jsonObj.get("sha256").isJsonNull()) && !jsonObj.get("sha256").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha256` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha256").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha256` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha256").toString())); } if ((jsonObj.get("target_addr") != null && !jsonObj.get("target_addr").isJsonNull()) && !jsonObj.get("target_addr").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `target_addr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("target_addr").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `target_addr` to be a primitive type in the JSON string but got `%s`", jsonObj.get("target_addr").toString())); } } @@ -533,28 +478,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, MemdumpEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -562,28 +485,7 @@ else if (entry.getValue() instanceof Character) public MemdumpEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - MemdumpEntry instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/MetaModel.java b/src/main/java/ai/reveng/model/MetaModel.java index 9ea8ca60..926e8630 100644 --- a/src/main/java/ai/reveng/model/MetaModel.java +++ b/src/main/java/ai/reveng/model/MetaModel.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.PaginationModel; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -169,10 +167,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -196,7 +191,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!MetaModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in MetaModel is not found in the empty JSON string", MetaModel.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in MetaModel is not found in the empty JSON string", MetaModel.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -263,7 +258,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ModelName.java b/src/main/java/ai/reveng/model/ModelName.java index d4f957c6..d6015e47 100644 --- a/src/main/java/ai/reveng/model/ModelName.java +++ b/src/main/java/ai/reveng/model/ModelName.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/ModelsResponse.java b/src/main/java/ai/reveng/model/ModelsResponse.java index 4f92c862..cd8e97c4 100644 --- a/src/main/java/ai/reveng/model/ModelsResponse.java +++ b/src/main/java/ai/reveng/model/ModelsResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -166,10 +164,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -193,14 +188,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ModelsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ModelsResponse is not found in the empty JSON string", ModelsResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ModelsResponse is not found in the empty JSON string", ModelsResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ModelsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -208,7 +203,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("models") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("models").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `models` to be an array in the JSON string but got `%s`", jsonObj.get("models").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `models` to be an array in the JSON string but got `%s`", jsonObj.get("models").toString())); } } @@ -269,7 +264,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ModuleLoadEntry.java b/src/main/java/ai/reveng/model/ModuleLoadEntry.java index 91d7bc8d..5efd941d 100644 --- a/src/main/java/ai/reveng/model/ModuleLoadEntry.java +++ b/src/main/java/ai/reveng/model/ModuleLoadEntry.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -23,7 +22,6 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -45,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -160,50 +157,6 @@ public void setProcessSeqid(@javax.annotation.Nullable Long processSeqid) { this.processSeqid = processSeqid; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ModuleLoadEntry instance itself - */ - public ModuleLoadEntry putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -218,24 +171,12 @@ public boolean equals(Object o) { return Objects.equals(this.modules, moduleLoadEntry.modules) && Objects.equals(this.pid, moduleLoadEntry.pid) && Objects.equals(this.processName, moduleLoadEntry.processName) && - Objects.equals(this.processSeqid, moduleLoadEntry.processSeqid)&& - Objects.equals(this.additionalProperties, moduleLoadEntry.additionalProperties); - } - - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + Objects.equals(this.processSeqid, moduleLoadEntry.processSeqid); } @Override public int hashCode() { - return Objects.hash(modules, pid, processName, processSeqid, additionalProperties); - } - - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + return Objects.hash(modules, pid, processName, processSeqid); } @Override @@ -246,7 +187,6 @@ public String toString() { sb.append(" pid: ").append(toIndentedString(pid)).append("\n"); sb.append(" processName: ").append(toIndentedString(processName)).append("\n"); sb.append(" processSeqid: ").append(toIndentedString(processSeqid)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -256,10 +196,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -283,19 +220,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ModuleLoadEntry.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ModuleLoadEntry is not found in the empty JSON string", ModuleLoadEntry.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ModuleLoadEntry is not found in the empty JSON string", ModuleLoadEntry.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ModuleLoadEntry.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ModuleLoadEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ModuleLoadEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("process_name") != null && !jsonObj.get("process_name").isJsonNull()) && !jsonObj.get("process_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `process_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("process_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `process_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("process_name").toString())); } } @@ -314,28 +259,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ModuleLoadEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -343,28 +266,7 @@ else if (entry.getValue() instanceof Character) public ModuleLoadEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ModuleLoadEntry instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/MutexEntry.java b/src/main/java/ai/reveng/model/MutexEntry.java index 31b30c79..5bac596f 100644 --- a/src/main/java/ai/reveng/model/MutexEntry.java +++ b/src/main/java/ai/reveng/model/MutexEntry.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ReportEvent; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -62,7 +60,7 @@ public class MutexEntry { public static final String SERIALIZED_NAME_NAME = "name"; @SerializedName(SERIALIZED_NAME_NAME) - @javax.annotation.Nullable + @javax.annotation.Nonnull private String name; public MutexEntry() { @@ -95,7 +93,7 @@ public void setEvents(@javax.annotation.Nullable List events) { } - public MutexEntry name(@javax.annotation.Nullable String name) { + public MutexEntry name(@javax.annotation.Nonnull String name) { this.name = name; return this; } @@ -104,59 +102,15 @@ public MutexEntry name(@javax.annotation.Nullable String name) { * Get name * @return name */ - @javax.annotation.Nullable + @javax.annotation.Nonnull public String getName() { return name; } - public void setName(@javax.annotation.Nullable String name) { + public void setName(@javax.annotation.Nonnull String name) { this.name = name; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the MutexEntry instance itself - */ - public MutexEntry putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -169,8 +123,7 @@ public boolean equals(Object o) { } MutexEntry mutexEntry = (MutexEntry) o; return Objects.equals(this.events, mutexEntry.events) && - Objects.equals(this.name, mutexEntry.name)&& - Objects.equals(this.additionalProperties, mutexEntry.additionalProperties); + Objects.equals(this.name, mutexEntry.name); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -179,7 +132,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(events, name, additionalProperties); + return Objects.hash(events, name); } private static int hashCodeNullable(JsonNullable a) { @@ -195,7 +148,6 @@ public String toString() { sb.append("class MutexEntry {\n"); sb.append(" events: ").append(toIndentedString(events)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -205,10 +157,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -232,23 +181,41 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!MutexEntry.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in MutexEntry is not found in the empty JSON string", MutexEntry.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in MutexEntry is not found in the empty JSON string", MutexEntry.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!MutexEntry.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `MutexEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : MutexEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the optional json data is an array if present - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull() && !jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { + JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); + if (jsonArrayevents != null) { + // ensure the json data is an array + if (!jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + } + + // validate the optional field `events` (array) + for (int i = 0; i < jsonArrayevents.size(); i++) { + ReportEvent.validateJsonElement(jsonArrayevents.get(i)); + }; + } } - if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } } @@ -267,28 +234,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, MutexEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -296,28 +241,7 @@ else if (entry.getValue() instanceof Character) public MutexEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - MutexEntry instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/NameConfidence.java b/src/main/java/ai/reveng/model/NameConfidence.java index 860db1e7..7a7c5cf2 100644 --- a/src/main/java/ai/reveng/model/NameConfidence.java +++ b/src/main/java/ai/reveng/model/NameConfidence.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -185,10 +183,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -212,19 +207,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!NameConfidence.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in NameConfidence is not found in the empty JSON string", NameConfidence.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in NameConfidence is not found in the empty JSON string", NameConfidence.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : NameConfidence.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } } @@ -285,7 +280,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/NameSourceType.java b/src/main/java/ai/reveng/model/NameSourceType.java index 5d71eb63..dd2cee74 100644 --- a/src/main/java/ai/reveng/model/NameSourceType.java +++ b/src/main/java/ai/reveng/model/NameSourceType.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -162,7 +160,7 @@ public NameSourceType functionId(@javax.annotation.Nullable Integer functionId) } /** - * Get functionId + * The function id of the function the function name was copied from. * @return functionId */ @javax.annotation.Nullable @@ -181,7 +179,7 @@ public NameSourceType binaryId(@javax.annotation.Nullable Integer binaryId) { } /** - * Get binaryId + * The binary id of the function that the function name was copied from. * @return binaryId */ @javax.annotation.Nullable @@ -200,7 +198,7 @@ public NameSourceType analysisId(@javax.annotation.Nullable Integer analysisId) } /** - * Get analysisId + * The analysis id of the function that the function name was copied from. * @return analysisId */ @javax.annotation.Nullable @@ -308,10 +306,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -335,19 +330,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!NameSourceType.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in NameSourceType is not found in the empty JSON string", NameSourceType.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in NameSourceType is not found in the empty JSON string", NameSourceType.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : NameSourceType.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } // validate the required field `type` TypeEnum.validateJsonElement(jsonObj.get("type")); @@ -410,7 +405,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/NetworkActivity.java b/src/main/java/ai/reveng/model/NetworkActivity.java index 332675b1..f872388e 100644 --- a/src/main/java/ai/reveng/model/NetworkActivity.java +++ b/src/main/java/ai/reveng/model/NetworkActivity.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.Connection; import ai.reveng.model.DnsQuery; import ai.reveng.model.ExtractedURL; @@ -49,7 +48,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -188,50 +186,6 @@ public void setHttpRequests(@javax.annotation.Nullable List httpReq this.httpRequests = httpRequests; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the NetworkActivity instance itself - */ - public NetworkActivity putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -246,8 +200,7 @@ public boolean equals(Object o) { return Objects.equals(this.connections, networkActivity.connections) && Objects.equals(this.dnsQueries, networkActivity.dnsQueries) && Objects.equals(this.extractedUrls, networkActivity.extractedUrls) && - Objects.equals(this.httpRequests, networkActivity.httpRequests)&& - Objects.equals(this.additionalProperties, networkActivity.additionalProperties); + Objects.equals(this.httpRequests, networkActivity.httpRequests); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -256,7 +209,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(connections, dnsQueries, extractedUrls, httpRequests, additionalProperties); + return Objects.hash(connections, dnsQueries, extractedUrls, httpRequests); } private static int hashCodeNullable(JsonNullable a) { @@ -274,7 +227,6 @@ public String toString() { sb.append(" dnsQueries: ").append(toIndentedString(dnsQueries)).append("\n"); sb.append(" extractedUrls: ").append(toIndentedString(extractedUrls)).append("\n"); sb.append(" httpRequests: ").append(toIndentedString(httpRequests)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -284,10 +236,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -311,25 +260,73 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!NetworkActivity.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in NetworkActivity is not found in the empty JSON string", NetworkActivity.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in NetworkActivity is not found in the empty JSON string", NetworkActivity.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!NetworkActivity.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `NetworkActivity` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the optional json data is an array if present - if (jsonObj.get("connections") != null && !jsonObj.get("connections").isJsonNull() && !jsonObj.get("connections").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `connections` to be an array in the JSON string but got `%s`", jsonObj.get("connections").toString())); + if (jsonObj.get("connections") != null && !jsonObj.get("connections").isJsonNull()) { + JsonArray jsonArrayconnections = jsonObj.getAsJsonArray("connections"); + if (jsonArrayconnections != null) { + // ensure the json data is an array + if (!jsonObj.get("connections").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `connections` to be an array in the JSON string but got `%s`", jsonObj.get("connections").toString())); + } + + // validate the optional field `connections` (array) + for (int i = 0; i < jsonArrayconnections.size(); i++) { + Connection.validateJsonElement(jsonArrayconnections.get(i)); + }; + } } - // ensure the optional json data is an array if present - if (jsonObj.get("dns_queries") != null && !jsonObj.get("dns_queries").isJsonNull() && !jsonObj.get("dns_queries").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `dns_queries` to be an array in the JSON string but got `%s`", jsonObj.get("dns_queries").toString())); + if (jsonObj.get("dns_queries") != null && !jsonObj.get("dns_queries").isJsonNull()) { + JsonArray jsonArraydnsQueries = jsonObj.getAsJsonArray("dns_queries"); + if (jsonArraydnsQueries != null) { + // ensure the json data is an array + if (!jsonObj.get("dns_queries").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `dns_queries` to be an array in the JSON string but got `%s`", jsonObj.get("dns_queries").toString())); + } + + // validate the optional field `dns_queries` (array) + for (int i = 0; i < jsonArraydnsQueries.size(); i++) { + DnsQuery.validateJsonElement(jsonArraydnsQueries.get(i)); + }; + } } - // ensure the optional json data is an array if present - if (jsonObj.get("extracted_urls") != null && !jsonObj.get("extracted_urls").isJsonNull() && !jsonObj.get("extracted_urls").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `extracted_urls` to be an array in the JSON string but got `%s`", jsonObj.get("extracted_urls").toString())); + if (jsonObj.get("extracted_urls") != null && !jsonObj.get("extracted_urls").isJsonNull()) { + JsonArray jsonArrayextractedUrls = jsonObj.getAsJsonArray("extracted_urls"); + if (jsonArrayextractedUrls != null) { + // ensure the json data is an array + if (!jsonObj.get("extracted_urls").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `extracted_urls` to be an array in the JSON string but got `%s`", jsonObj.get("extracted_urls").toString())); + } + + // validate the optional field `extracted_urls` (array) + for (int i = 0; i < jsonArrayextractedUrls.size(); i++) { + ExtractedURL.validateJsonElement(jsonArrayextractedUrls.get(i)); + }; + } } - // ensure the optional json data is an array if present - if (jsonObj.get("http_requests") != null && !jsonObj.get("http_requests").isJsonNull() && !jsonObj.get("http_requests").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `http_requests` to be an array in the JSON string but got `%s`", jsonObj.get("http_requests").toString())); + if (jsonObj.get("http_requests") != null && !jsonObj.get("http_requests").isJsonNull()) { + JsonArray jsonArrayhttpRequests = jsonObj.getAsJsonArray("http_requests"); + if (jsonArrayhttpRequests != null) { + // ensure the json data is an array + if (!jsonObj.get("http_requests").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `http_requests` to be an array in the JSON string but got `%s`", jsonObj.get("http_requests").toString())); + } + + // validate the optional field `http_requests` (array) + for (int i = 0; i < jsonArrayhttpRequests.size(); i++) { + HttpRequest.validateJsonElement(jsonArrayhttpRequests.get(i)); + }; + } } } @@ -348,28 +345,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, NetworkActivity value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -377,28 +352,7 @@ else if (entry.getValue() instanceof Character) public NetworkActivity read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - NetworkActivity instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/Order.java b/src/main/java/ai/reveng/model/Order.java index 6aa098ad..1a7a0851 100644 --- a/src/main/java/ai/reveng/model/Order.java +++ b/src/main/java/ai/reveng/model/Order.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/PDBDebugModel.java b/src/main/java/ai/reveng/model/PDBDebugModel.java index 6d901dbe..72d8dc03 100644 --- a/src/main/java/ai/reveng/model/PDBDebugModel.java +++ b/src/main/java/ai/reveng/model/PDBDebugModel.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SinglePDBEntryModel; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -167,10 +165,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,27 +189,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!PDBDebugModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in PDBDebugModel is not found in the empty JSON string", PDBDebugModel.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in PDBDebugModel is not found in the empty JSON string", PDBDebugModel.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PDBDebugModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("debug_entries").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `debug_entries` to be an array in the JSON string but got `%s`", jsonObj.get("debug_entries").toString())); + if (jsonObj.get("debug_entries") != null) { + if (!jsonObj.get("debug_entries").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `debug_entries` to be an array in the JSON string but got `%s`", jsonObj.get("debug_entries").toString())); + } + JsonArray jsonArraydebugEntries = jsonObj.getAsJsonArray("debug_entries"); + // validate the required field `debug_entries` (array) + for (int i = 0; i < jsonArraydebugEntries.size(); i++) { + SinglePDBEntryModel.validateJsonElement(jsonArraydebugEntries.get(i)); + } } - - JsonArray jsonArraydebugEntries = jsonObj.getAsJsonArray("debug_entries"); - // validate the required field `debug_entries` (array) - for (int i = 0; i < jsonArraydebugEntries.size(); i++) { - SinglePDBEntryModel.validateJsonElement(jsonArraydebugEntries.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -274,7 +269,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/PEModel.java b/src/main/java/ai/reveng/model/PEModel.java index e9a67af7..6c068c41 100644 --- a/src/main/java/ai/reveng/model/PEModel.java +++ b/src/main/java/ai/reveng/model/PEModel.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.CodeSignatureModel; import ai.reveng.model.EntrypointModel; import ai.reveng.model.ExportModel; @@ -53,7 +52,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -669,10 +667,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -696,50 +691,68 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!PEModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in PEModel is not found in the empty JSON string", PEModel.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in PEModel is not found in the empty JSON string", PEModel.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PEModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } + if (jsonObj.get("timestamps") != null && !jsonObj.get("timestamps").isJsonNull()) { // validate the required field `timestamps` TimestampModel.validateJsonElement(jsonObj.get("timestamps")); + } if (!jsonObj.get("architecture").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `architecture` to be a primitive type in the JSON string but got `%s`", jsonObj.get("architecture").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `architecture` to be a primitive type in the JSON string but got `%s`", jsonObj.get("architecture").toString())); } + if (jsonObj.get("security") != null && !jsonObj.get("security").isJsonNull()) { // validate the required field `security` SecurityModel.validateJsonElement(jsonObj.get("security")); + } + if (jsonObj.get("debug_info") != null && !jsonObj.get("debug_info").isJsonNull()) { // validate the required field `debug_info` PDBDebugModel.validateJsonElement(jsonObj.get("debug_info")); + } + if (jsonObj.get("entry_point") != null && !jsonObj.get("entry_point").isJsonNull()) { // validate the required field `entry_point` EntrypointModel.validateJsonElement(jsonObj.get("entry_point")); + } + if (jsonObj.get("signature") != null && !jsonObj.get("signature").isJsonNull()) { // validate the required field `signature` CodeSignatureModel.validateJsonElement(jsonObj.get("signature")); + } if (!jsonObj.get("import_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `import_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("import_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `import_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("import_hash").toString())); } if (!jsonObj.get("export_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `export_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("export_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `export_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("export_hash").toString())); } if (!jsonObj.get("rich_header_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `rich_header_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("rich_header_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `rich_header_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("rich_header_hash").toString())); } + if (jsonObj.get("sections") != null && !jsonObj.get("sections").isJsonNull()) { // validate the required field `sections` SectionModel.validateJsonElement(jsonObj.get("sections")); + } + if (jsonObj.get("imports") != null && !jsonObj.get("imports").isJsonNull()) { // validate the required field `imports` ImportModel.validateJsonElement(jsonObj.get("imports")); + } + if (jsonObj.get("exports") != null && !jsonObj.get("exports").isJsonNull()) { // validate the required field `exports` ExportModel.validateJsonElement(jsonObj.get("exports")); + } + if (jsonObj.get("icon_data") != null && !jsonObj.get("icon_data").isJsonNull()) { // validate the required field `icon_data` IconModel.validateJsonElement(jsonObj.get("icon_data")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -799,7 +812,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/PaginationModel.java b/src/main/java/ai/reveng/model/PaginationModel.java index 14faf0ea..7b8cd181 100644 --- a/src/main/java/ai/reveng/model/PaginationModel.java +++ b/src/main/java/ai/reveng/model/PaginationModel.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -208,10 +206,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -235,14 +230,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!PaginationModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in PaginationModel is not found in the empty JSON string", PaginationModel.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in PaginationModel is not found in the empty JSON string", PaginationModel.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PaginationModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -305,7 +300,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/Params.java b/src/main/java/ai/reveng/model/Params.java index 9d658367..349234b2 100644 --- a/src/main/java/ai/reveng/model/Params.java +++ b/src/main/java/ai/reveng/model/Params.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -95,7 +93,7 @@ public Params debugHash(@javax.annotation.Nullable String debugHash) { } /** - * Get debugHash + * The debug hash, if one was supplied * @return debugHash */ @javax.annotation.Nullable @@ -312,10 +310,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -339,31 +334,31 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Params.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Params is not found in the empty JSON string", Params.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Params is not found in the empty JSON string", Params.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Params.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("debug_hash") != null && !jsonObj.get("debug_hash").isJsonNull()) && !jsonObj.get("debug_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `debug_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("debug_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `debug_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("debug_hash").toString())); } if (!jsonObj.get("architecture").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `architecture` to be a primitive type in the JSON string but got `%s`", jsonObj.get("architecture").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `architecture` to be a primitive type in the JSON string but got `%s`", jsonObj.get("architecture").toString())); } if (!jsonObj.get("binary_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binary_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binary_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_type").toString())); } if (!jsonObj.get("binary_format").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binary_format` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_format").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binary_format` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_format").toString())); } if (!jsonObj.get("model_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); } } @@ -424,7 +419,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/PatchCollectionBinariesInputBody.java b/src/main/java/ai/reveng/model/PatchCollectionBinariesInputBody.java index 116228bb..bdf4f850 100644 --- a/src/main/java/ai/reveng/model/PatchCollectionBinariesInputBody.java +++ b/src/main/java/ai/reveng/model/PatchCollectionBinariesInputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -87,50 +85,6 @@ public void setBinaries(@javax.annotation.Nullable List binaries) { this.binaries = binaries; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the PatchCollectionBinariesInputBody instance itself - */ - public PatchCollectionBinariesInputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -142,13 +96,12 @@ public boolean equals(Object o) { return false; } PatchCollectionBinariesInputBody patchCollectionBinariesInputBody = (PatchCollectionBinariesInputBody) o; - return Objects.equals(this.binaries, patchCollectionBinariesInputBody.binaries)&& - Objects.equals(this.additionalProperties, patchCollectionBinariesInputBody.additionalProperties); + return Objects.equals(this.binaries, patchCollectionBinariesInputBody.binaries); } @Override public int hashCode() { - return Objects.hash(binaries, additionalProperties); + return Objects.hash(binaries); } @Override @@ -156,7 +109,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class PatchCollectionBinariesInputBody {\n"); sb.append(" binaries: ").append(toIndentedString(binaries)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -166,10 +118,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -193,22 +142,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!PatchCollectionBinariesInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in PatchCollectionBinariesInputBody is not found in the empty JSON string", PatchCollectionBinariesInputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in PatchCollectionBinariesInputBody is not found in the empty JSON string", PatchCollectionBinariesInputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PatchCollectionBinariesInputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PatchCollectionBinariesInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PatchCollectionBinariesInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the required json array is present if (jsonObj.get("binaries") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); - } else if (!jsonObj.get("binaries").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); + } else if (!jsonObj.get("binaries").isJsonArray() && !jsonObj.get("binaries").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); } } @@ -227,28 +184,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PatchCollectionBinariesInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -256,28 +191,7 @@ else if (entry.getValue() instanceof Character) public PatchCollectionBinariesInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - PatchCollectionBinariesInputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/PatchCollectionBinariesOutputBody.java b/src/main/java/ai/reveng/model/PatchCollectionBinariesOutputBody.java index b7259f89..fc119fff 100644 --- a/src/main/java/ai/reveng/model/PatchCollectionBinariesOutputBody.java +++ b/src/main/java/ai/reveng/model/PatchCollectionBinariesOutputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.Binary; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -88,50 +86,6 @@ public void setBinaries(@javax.annotation.Nullable List binaries) { this.binaries = binaries; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the PatchCollectionBinariesOutputBody instance itself - */ - public PatchCollectionBinariesOutputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -143,13 +97,12 @@ public boolean equals(Object o) { return false; } PatchCollectionBinariesOutputBody patchCollectionBinariesOutputBody = (PatchCollectionBinariesOutputBody) o; - return Objects.equals(this.binaries, patchCollectionBinariesOutputBody.binaries)&& - Objects.equals(this.additionalProperties, patchCollectionBinariesOutputBody.additionalProperties); + return Objects.equals(this.binaries, patchCollectionBinariesOutputBody.binaries); } @Override public int hashCode() { - return Objects.hash(binaries, additionalProperties); + return Objects.hash(binaries); } @Override @@ -157,7 +110,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class PatchCollectionBinariesOutputBody {\n"); sb.append(" binaries: ").append(toIndentedString(binaries)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,10 +119,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,22 +143,34 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!PatchCollectionBinariesOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in PatchCollectionBinariesOutputBody is not found in the empty JSON string", PatchCollectionBinariesOutputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in PatchCollectionBinariesOutputBody is not found in the empty JSON string", PatchCollectionBinariesOutputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PatchCollectionBinariesOutputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PatchCollectionBinariesOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PatchCollectionBinariesOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the required json array is present - if (jsonObj.get("binaries") == null) { - throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); - } else if (!jsonObj.get("binaries").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); + if (jsonObj.get("binaries") != null && !jsonObj.get("binaries").isJsonNull()) { + if (!jsonObj.get("binaries").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binaries` to be an array in the JSON string but got `%s`", jsonObj.get("binaries").toString())); + } + JsonArray jsonArraybinaries = jsonObj.getAsJsonArray("binaries"); + // validate the required field `binaries` (array) + for (int i = 0; i < jsonArraybinaries.size(); i++) { + Binary.validateJsonElement(jsonArraybinaries.get(i)); + } } } @@ -228,28 +189,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PatchCollectionBinariesOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -257,28 +196,7 @@ else if (entry.getValue() instanceof Character) public PatchCollectionBinariesOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - PatchCollectionBinariesOutputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/PatchCollectionInputBody.java b/src/main/java/ai/reveng/model/PatchCollectionInputBody.java index 8eafb5d5..d5c65cbf 100644 --- a/src/main/java/ai/reveng/model/PatchCollectionInputBody.java +++ b/src/main/java/ai/reveng/model/PatchCollectionInputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -125,50 +123,6 @@ public void setDescription(@javax.annotation.Nullable String description) { this.description = description; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the PatchCollectionInputBody instance itself - */ - public PatchCollectionInputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -182,13 +136,12 @@ public boolean equals(Object o) { PatchCollectionInputBody patchCollectionInputBody = (PatchCollectionInputBody) o; return Objects.equals(this.collectionName, patchCollectionInputBody.collectionName) && Objects.equals(this.collectionScope, patchCollectionInputBody.collectionScope) && - Objects.equals(this.description, patchCollectionInputBody.description)&& - Objects.equals(this.additionalProperties, patchCollectionInputBody.additionalProperties); + Objects.equals(this.description, patchCollectionInputBody.description); } @Override public int hashCode() { - return Objects.hash(collectionName, collectionScope, description, additionalProperties); + return Objects.hash(collectionName, collectionScope, description); } @Override @@ -198,7 +151,6 @@ public String toString() { sb.append(" collectionName: ").append(toIndentedString(collectionName)).append("\n"); sb.append(" collectionScope: ").append(toIndentedString(collectionScope)).append("\n"); sb.append(" description: ").append(toIndentedString(description)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -208,10 +160,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -235,18 +184,26 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!PatchCollectionInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in PatchCollectionInputBody is not found in the empty JSON string", PatchCollectionInputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in PatchCollectionInputBody is not found in the empty JSON string", PatchCollectionInputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PatchCollectionInputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PatchCollectionInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("collection_name") != null && !jsonObj.get("collection_name").isJsonNull()) && !jsonObj.get("collection_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); } if ((jsonObj.get("collection_scope") != null && !jsonObj.get("collection_scope").isJsonNull()) && !jsonObj.get("collection_scope").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_scope").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_scope").toString())); } if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); } } @@ -265,28 +222,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PatchCollectionInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -294,28 +229,7 @@ else if (entry.getValue() instanceof Character) public PatchCollectionInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - PatchCollectionInputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/PatchCollectionOutputBody.java b/src/main/java/ai/reveng/model/PatchCollectionOutputBody.java index 1a66bb4e..fa87e21c 100644 --- a/src/main/java/ai/reveng/model/PatchCollectionOutputBody.java +++ b/src/main/java/ai/reveng/model/PatchCollectionOutputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -294,50 +292,6 @@ public void setUserId(@javax.annotation.Nonnull Long userId) { this.userId = userId; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the PatchCollectionOutputBody instance itself - */ - public PatchCollectionOutputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -358,13 +312,12 @@ public boolean equals(Object o) { Objects.equals(this.modelId, patchCollectionOutputBody.modelId) && Objects.equals(this.teamId, patchCollectionOutputBody.teamId) && Objects.equals(this.updatedAt, patchCollectionOutputBody.updatedAt) && - Objects.equals(this.userId, patchCollectionOutputBody.userId)&& - Objects.equals(this.additionalProperties, patchCollectionOutputBody.additionalProperties); + Objects.equals(this.userId, patchCollectionOutputBody.userId); } @Override public int hashCode() { - return Objects.hash(binaryCount, collectionId, collectionName, collectionScope, createdAt, description, modelId, teamId, updatedAt, userId, additionalProperties); + return Objects.hash(binaryCount, collectionId, collectionName, collectionScope, createdAt, description, modelId, teamId, updatedAt, userId); } @Override @@ -381,7 +334,6 @@ public String toString() { sb.append(" teamId: ").append(toIndentedString(teamId)).append("\n"); sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -391,10 +343,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -418,25 +367,33 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!PatchCollectionOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in PatchCollectionOutputBody is not found in the empty JSON string", PatchCollectionOutputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in PatchCollectionOutputBody is not found in the empty JSON string", PatchCollectionOutputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PatchCollectionOutputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PatchCollectionOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PatchCollectionOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("collection_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); } if (!jsonObj.get("collection_scope").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_scope").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `collection_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_scope").toString())); } if (!jsonObj.get("description").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); } } @@ -455,28 +412,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PatchCollectionOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -484,28 +419,7 @@ else if (entry.getValue() instanceof Character) public PatchCollectionOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - PatchCollectionOutputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/PatchCollectionTagsInputBody.java b/src/main/java/ai/reveng/model/PatchCollectionTagsInputBody.java index c797371a..f2872675 100644 --- a/src/main/java/ai/reveng/model/PatchCollectionTagsInputBody.java +++ b/src/main/java/ai/reveng/model/PatchCollectionTagsInputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -87,50 +85,6 @@ public void setTags(@javax.annotation.Nullable List tags) { this.tags = tags; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the PatchCollectionTagsInputBody instance itself - */ - public PatchCollectionTagsInputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -142,13 +96,12 @@ public boolean equals(Object o) { return false; } PatchCollectionTagsInputBody patchCollectionTagsInputBody = (PatchCollectionTagsInputBody) o; - return Objects.equals(this.tags, patchCollectionTagsInputBody.tags)&& - Objects.equals(this.additionalProperties, patchCollectionTagsInputBody.additionalProperties); + return Objects.equals(this.tags, patchCollectionTagsInputBody.tags); } @Override public int hashCode() { - return Objects.hash(tags, additionalProperties); + return Objects.hash(tags); } @Override @@ -156,7 +109,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class PatchCollectionTagsInputBody {\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -166,10 +118,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -193,22 +142,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!PatchCollectionTagsInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in PatchCollectionTagsInputBody is not found in the empty JSON string", PatchCollectionTagsInputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in PatchCollectionTagsInputBody is not found in the empty JSON string", PatchCollectionTagsInputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PatchCollectionTagsInputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PatchCollectionTagsInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PatchCollectionTagsInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the required json array is present if (jsonObj.get("tags") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); - } else if (!jsonObj.get("tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + } else if (!jsonObj.get("tags").isJsonArray() && !jsonObj.get("tags").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); } } @@ -227,28 +184,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PatchCollectionTagsInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -256,28 +191,7 @@ else if (entry.getValue() instanceof Character) public PatchCollectionTagsInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - PatchCollectionTagsInputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/PatchCollectionTagsOutputBody.java b/src/main/java/ai/reveng/model/PatchCollectionTagsOutputBody.java index 34ca49b6..805ccf56 100644 --- a/src/main/java/ai/reveng/model/PatchCollectionTagsOutputBody.java +++ b/src/main/java/ai/reveng/model/PatchCollectionTagsOutputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -87,50 +85,6 @@ public void setTags(@javax.annotation.Nullable List tags) { this.tags = tags; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the PatchCollectionTagsOutputBody instance itself - */ - public PatchCollectionTagsOutputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -142,13 +96,12 @@ public boolean equals(Object o) { return false; } PatchCollectionTagsOutputBody patchCollectionTagsOutputBody = (PatchCollectionTagsOutputBody) o; - return Objects.equals(this.tags, patchCollectionTagsOutputBody.tags)&& - Objects.equals(this.additionalProperties, patchCollectionTagsOutputBody.additionalProperties); + return Objects.equals(this.tags, patchCollectionTagsOutputBody.tags); } @Override public int hashCode() { - return Objects.hash(tags, additionalProperties); + return Objects.hash(tags); } @Override @@ -156,7 +109,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class PatchCollectionTagsOutputBody {\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -166,10 +118,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -193,22 +142,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!PatchCollectionTagsOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in PatchCollectionTagsOutputBody is not found in the empty JSON string", PatchCollectionTagsOutputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in PatchCollectionTagsOutputBody is not found in the empty JSON string", PatchCollectionTagsOutputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PatchCollectionTagsOutputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PatchCollectionTagsOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PatchCollectionTagsOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the required json array is present if (jsonObj.get("tags") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); - } else if (!jsonObj.get("tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + } else if (!jsonObj.get("tags").isJsonArray() && !jsonObj.get("tags").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); } } @@ -227,28 +184,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PatchCollectionTagsOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -256,28 +191,7 @@ else if (entry.getValue() instanceof Character) public PatchCollectionTagsOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - PatchCollectionTagsOutputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/PatchCommentBody.java b/src/main/java/ai/reveng/model/PatchCommentBody.java index 4d1ea476..3d3f1fcf 100644 --- a/src/main/java/ai/reveng/model/PatchCommentBody.java +++ b/src/main/java/ai/reveng/model/PatchCommentBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -102,50 +100,6 @@ public void setLine(@javax.annotation.Nonnull Long line) { this.line = line; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the PatchCommentBody instance itself - */ - public PatchCommentBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -158,13 +112,12 @@ public boolean equals(Object o) { } PatchCommentBody patchCommentBody = (PatchCommentBody) o; return Objects.equals(this.comment, patchCommentBody.comment) && - Objects.equals(this.line, patchCommentBody.line)&& - Objects.equals(this.additionalProperties, patchCommentBody.additionalProperties); + Objects.equals(this.line, patchCommentBody.line); } @Override public int hashCode() { - return Objects.hash(comment, line, additionalProperties); + return Objects.hash(comment, line); } @Override @@ -173,7 +126,6 @@ public String toString() { sb.append("class PatchCommentBody {\n"); sb.append(" comment: ").append(toIndentedString(comment)).append("\n"); sb.append(" line: ").append(toIndentedString(line)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -183,10 +135,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -210,19 +159,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!PatchCommentBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in PatchCommentBody is not found in the empty JSON string", PatchCommentBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in PatchCommentBody is not found in the empty JSON string", PatchCommentBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PatchCommentBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PatchCommentBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PatchCommentBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("comment").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `comment` to be a primitive type in the JSON string but got `%s`", jsonObj.get("comment").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `comment` to be a primitive type in the JSON string but got `%s`", jsonObj.get("comment").toString())); } } @@ -241,28 +198,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PatchCommentBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -270,28 +205,7 @@ else if (entry.getValue() instanceof Character) public PatchCommentBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - PatchCommentBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/PcapBodyInfo.java b/src/main/java/ai/reveng/model/PcapBodyInfo.java new file mode 100644 index 00000000..0b452ab6 --- /dev/null +++ b/src/main/java/ai/reveng/model/PcapBodyInfo.java @@ -0,0 +1,399 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * PcapBodyInfo + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class PcapBodyInfo { + public static final String SERIALIZED_NAME_FILENAME = "filename"; + @SerializedName(SERIALIZED_NAME_FILENAME) + @javax.annotation.Nullable + private String filename; + + public static final String SERIALIZED_NAME_IS_PE = "is_pe"; + @SerializedName(SERIALIZED_NAME_IS_PE) + @javax.annotation.Nonnull + private Boolean isPe; + + public static final String SERIALIZED_NAME_MIME_TYPE = "mime_type"; + @SerializedName(SERIALIZED_NAME_MIME_TYPE) + @javax.annotation.Nullable + private String mimeType; + + public static final String SERIALIZED_NAME_PREVIEW = "preview"; + @SerializedName(SERIALIZED_NAME_PREVIEW) + @javax.annotation.Nullable + private String preview; + + public static final String SERIALIZED_NAME_SHA256 = "sha256"; + @SerializedName(SERIALIZED_NAME_SHA256) + @javax.annotation.Nullable + private String sha256; + + public static final String SERIALIZED_NAME_SIZE = "size"; + @SerializedName(SERIALIZED_NAME_SIZE) + @javax.annotation.Nonnull + private Long size; + + public static final String SERIALIZED_NAME_YARA_HITS = "yara_hits"; + @SerializedName(SERIALIZED_NAME_YARA_HITS) + @javax.annotation.Nullable + private List yaraHits; + + public PcapBodyInfo() { + } + + public PcapBodyInfo filename(@javax.annotation.Nullable String filename) { + this.filename = filename; + return this; + } + + /** + * Get filename + * @return filename + */ + @javax.annotation.Nullable + public String getFilename() { + return filename; + } + + public void setFilename(@javax.annotation.Nullable String filename) { + this.filename = filename; + } + + + public PcapBodyInfo isPe(@javax.annotation.Nonnull Boolean isPe) { + this.isPe = isPe; + return this; + } + + /** + * Get isPe + * @return isPe + */ + @javax.annotation.Nonnull + public Boolean getIsPe() { + return isPe; + } + + public void setIsPe(@javax.annotation.Nonnull Boolean isPe) { + this.isPe = isPe; + } + + + public PcapBodyInfo mimeType(@javax.annotation.Nullable String mimeType) { + this.mimeType = mimeType; + return this; + } + + /** + * Get mimeType + * @return mimeType + */ + @javax.annotation.Nullable + public String getMimeType() { + return mimeType; + } + + public void setMimeType(@javax.annotation.Nullable String mimeType) { + this.mimeType = mimeType; + } + + + public PcapBodyInfo preview(@javax.annotation.Nullable String preview) { + this.preview = preview; + return this; + } + + /** + * Get preview + * @return preview + */ + @javax.annotation.Nullable + public String getPreview() { + return preview; + } + + public void setPreview(@javax.annotation.Nullable String preview) { + this.preview = preview; + } + + + public PcapBodyInfo sha256(@javax.annotation.Nullable String sha256) { + this.sha256 = sha256; + return this; + } + + /** + * Get sha256 + * @return sha256 + */ + @javax.annotation.Nullable + public String getSha256() { + return sha256; + } + + public void setSha256(@javax.annotation.Nullable String sha256) { + this.sha256 = sha256; + } + + + public PcapBodyInfo size(@javax.annotation.Nonnull Long size) { + this.size = size; + return this; + } + + /** + * Get size + * @return size + */ + @javax.annotation.Nonnull + public Long getSize() { + return size; + } + + public void setSize(@javax.annotation.Nonnull Long size) { + this.size = size; + } + + + public PcapBodyInfo yaraHits(@javax.annotation.Nullable List yaraHits) { + this.yaraHits = yaraHits; + return this; + } + + public PcapBodyInfo addYaraHitsItem(String yaraHitsItem) { + if (this.yaraHits == null) { + this.yaraHits = new ArrayList<>(); + } + this.yaraHits.add(yaraHitsItem); + return this; + } + + /** + * Get yaraHits + * @return yaraHits + */ + @javax.annotation.Nullable + public List getYaraHits() { + return yaraHits; + } + + public void setYaraHits(@javax.annotation.Nullable List yaraHits) { + this.yaraHits = yaraHits; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PcapBodyInfo pcapBodyInfo = (PcapBodyInfo) o; + return Objects.equals(this.filename, pcapBodyInfo.filename) && + Objects.equals(this.isPe, pcapBodyInfo.isPe) && + Objects.equals(this.mimeType, pcapBodyInfo.mimeType) && + Objects.equals(this.preview, pcapBodyInfo.preview) && + Objects.equals(this.sha256, pcapBodyInfo.sha256) && + Objects.equals(this.size, pcapBodyInfo.size) && + Objects.equals(this.yaraHits, pcapBodyInfo.yaraHits); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(filename, isPe, mimeType, preview, sha256, size, yaraHits); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PcapBodyInfo {\n"); + sb.append(" filename: ").append(toIndentedString(filename)).append("\n"); + sb.append(" isPe: ").append(toIndentedString(isPe)).append("\n"); + sb.append(" mimeType: ").append(toIndentedString(mimeType)).append("\n"); + sb.append(" preview: ").append(toIndentedString(preview)).append("\n"); + sb.append(" sha256: ").append(toIndentedString(sha256)).append("\n"); + sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" yaraHits: ").append(toIndentedString(yaraHits)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("filename", "is_pe", "mime_type", "preview", "sha256", "size", "yara_hits")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("is_pe", "size")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to PcapBodyInfo + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!PcapBodyInfo.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in PcapBodyInfo is not found in the empty JSON string", PcapBodyInfo.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PcapBodyInfo.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PcapBodyInfo` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : PcapBodyInfo.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("filename") != null && !jsonObj.get("filename").isJsonNull()) && !jsonObj.get("filename").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `filename` to be a primitive type in the JSON string but got `%s`", jsonObj.get("filename").toString())); + } + if ((jsonObj.get("mime_type") != null && !jsonObj.get("mime_type").isJsonNull()) && !jsonObj.get("mime_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `mime_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mime_type").toString())); + } + if ((jsonObj.get("preview") != null && !jsonObj.get("preview").isJsonNull()) && !jsonObj.get("preview").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `preview` to be a primitive type in the JSON string but got `%s`", jsonObj.get("preview").toString())); + } + if ((jsonObj.get("sha256") != null && !jsonObj.get("sha256").isJsonNull()) && !jsonObj.get("sha256").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha256` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha256").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("yara_hits") != null && !jsonObj.get("yara_hits").isJsonNull() && !jsonObj.get("yara_hits").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `yara_hits` to be an array in the JSON string but got `%s`", jsonObj.get("yara_hits").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PcapBodyInfo.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PcapBodyInfo' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PcapBodyInfo.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PcapBodyInfo value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PcapBodyInfo read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PcapBodyInfo given an JSON string + * + * @param jsonString JSON string + * @return An instance of PcapBodyInfo + * @throws IOException if the JSON string is invalid with respect to PcapBodyInfo + */ + public static PcapBodyInfo fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PcapBodyInfo.class); + } + + /** + * Convert an instance of PcapBodyInfo to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/Platform.java b/src/main/java/ai/reveng/model/Platform.java index 5c03303f..21d97882 100644 --- a/src/main/java/ai/reveng/model/Platform.java +++ b/src/main/java/ai/reveng/model/Platform.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/PriceOutput.java b/src/main/java/ai/reveng/model/PriceOutput.java index bd7e0db0..f1433585 100644 --- a/src/main/java/ai/reveng/model/PriceOutput.java +++ b/src/main/java/ai/reveng/model/PriceOutput.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -203,50 +201,6 @@ public void setUnitAmount(@javax.annotation.Nonnull Long unitAmount) { this.unitAmount = unitAmount; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the PriceOutput instance itself - */ - public PriceOutput putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -261,13 +215,12 @@ public boolean equals(Object o) { return Objects.equals(this.currency, priceOutput.currency) && Objects.equals(this.id, priceOutput.id) && Objects.equals(this.interval, priceOutput.interval) && - Objects.equals(this.unitAmount, priceOutput.unitAmount)&& - Objects.equals(this.additionalProperties, priceOutput.additionalProperties); + Objects.equals(this.unitAmount, priceOutput.unitAmount); } @Override public int hashCode() { - return Objects.hash(currency, id, interval, unitAmount, additionalProperties); + return Objects.hash(currency, id, interval, unitAmount); } @Override @@ -278,7 +231,6 @@ public String toString() { sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" interval: ").append(toIndentedString(interval)).append("\n"); sb.append(" unitAmount: ").append(toIndentedString(unitAmount)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -288,10 +240,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -315,25 +264,33 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!PriceOutput.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in PriceOutput is not found in the empty JSON string", PriceOutput.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in PriceOutput is not found in the empty JSON string", PriceOutput.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PriceOutput.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PriceOutput` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PriceOutput.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("currency").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `currency` to be a primitive type in the JSON string but got `%s`", jsonObj.get("currency").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `currency` to be a primitive type in the JSON string but got `%s`", jsonObj.get("currency").toString())); } if (!jsonObj.get("id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); } if (!jsonObj.get("interval").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `interval` to be a primitive type in the JSON string but got `%s`", jsonObj.get("interval").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `interval` to be a primitive type in the JSON string but got `%s`", jsonObj.get("interval").toString())); } // validate the required field `interval` IntervalEnum.validateJsonElement(jsonObj.get("interval")); @@ -354,28 +311,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PriceOutput value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -383,28 +318,7 @@ else if (entry.getValue() instanceof Character) public PriceOutput read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - PriceOutput instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/PriceSummary.java b/src/main/java/ai/reveng/model/PriceSummary.java index 8544aaa7..42ea5d4d 100644 --- a/src/main/java/ai/reveng/model/PriceSummary.java +++ b/src/main/java/ai/reveng/model/PriceSummary.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -179,50 +177,6 @@ public void setUnitAmount(@javax.annotation.Nonnull Long unitAmount) { this.unitAmount = unitAmount; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the PriceSummary instance itself - */ - public PriceSummary putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -236,13 +190,12 @@ public boolean equals(Object o) { PriceSummary priceSummary = (PriceSummary) o; return Objects.equals(this.currency, priceSummary.currency) && Objects.equals(this.interval, priceSummary.interval) && - Objects.equals(this.unitAmount, priceSummary.unitAmount)&& - Objects.equals(this.additionalProperties, priceSummary.additionalProperties); + Objects.equals(this.unitAmount, priceSummary.unitAmount); } @Override public int hashCode() { - return Objects.hash(currency, interval, unitAmount, additionalProperties); + return Objects.hash(currency, interval, unitAmount); } @Override @@ -252,7 +205,6 @@ public String toString() { sb.append(" currency: ").append(toIndentedString(currency)).append("\n"); sb.append(" interval: ").append(toIndentedString(interval)).append("\n"); sb.append(" unitAmount: ").append(toIndentedString(unitAmount)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -262,10 +214,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -289,22 +238,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!PriceSummary.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in PriceSummary is not found in the empty JSON string", PriceSummary.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in PriceSummary is not found in the empty JSON string", PriceSummary.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PriceSummary.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PriceSummary` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PriceSummary.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("currency").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `currency` to be a primitive type in the JSON string but got `%s`", jsonObj.get("currency").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `currency` to be a primitive type in the JSON string but got `%s`", jsonObj.get("currency").toString())); } if (!jsonObj.get("interval").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `interval` to be a primitive type in the JSON string but got `%s`", jsonObj.get("interval").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `interval` to be a primitive type in the JSON string but got `%s`", jsonObj.get("interval").toString())); } // validate the required field `interval` IntervalEnum.validateJsonElement(jsonObj.get("interval")); @@ -325,28 +282,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PriceSummary value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -354,28 +289,7 @@ else if (entry.getValue() instanceof Character) public PriceSummary read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - PriceSummary instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ProcessActivityEntry.java b/src/main/java/ai/reveng/model/ProcessActivityEntry.java index 3253fada..eb27cf14 100644 --- a/src/main/java/ai/reveng/model/ProcessActivityEntry.java +++ b/src/main/java/ai/reveng/model/ProcessActivityEntry.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ReportEvent; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -82,7 +80,7 @@ public class ProcessActivityEntry { public static final String SERIALIZED_NAME_NAME = "name"; @SerializedName(SERIALIZED_NAME_NAME) - @javax.annotation.Nullable + @javax.annotation.Nonnull private String name; public static final String SERIALIZED_NAME_PID = "pid"; @@ -204,7 +202,7 @@ public void setExitCodeStr(@javax.annotation.Nullable String exitCodeStr) { } - public ProcessActivityEntry name(@javax.annotation.Nullable String name) { + public ProcessActivityEntry name(@javax.annotation.Nonnull String name) { this.name = name; return this; } @@ -213,12 +211,12 @@ public ProcessActivityEntry name(@javax.annotation.Nullable String name) { * Get name * @return name */ - @javax.annotation.Nullable + @javax.annotation.Nonnull public String getName() { return name; } - public void setName(@javax.annotation.Nullable String name) { + public void setName(@javax.annotation.Nonnull String name) { this.name = name; } @@ -241,50 +239,6 @@ public void setPid(@javax.annotation.Nonnull Long pid) { this.pid = pid; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ProcessActivityEntry instance itself - */ - public ProcessActivityEntry putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -302,8 +256,7 @@ public boolean equals(Object o) { Objects.equals(this.exitCode, processActivityEntry.exitCode) && Objects.equals(this.exitCodeStr, processActivityEntry.exitCodeStr) && Objects.equals(this.name, processActivityEntry.name) && - Objects.equals(this.pid, processActivityEntry.pid)&& - Objects.equals(this.additionalProperties, processActivityEntry.additionalProperties); + Objects.equals(this.pid, processActivityEntry.pid); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -312,7 +265,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(args, childSeqid, events, exitCode, exitCodeStr, name, pid, additionalProperties); + return Objects.hash(args, childSeqid, events, exitCode, exitCodeStr, name, pid); } private static int hashCodeNullable(JsonNullable a) { @@ -333,7 +286,6 @@ public String toString() { sb.append(" exitCodeStr: ").append(toIndentedString(exitCodeStr)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" pid: ").append(toIndentedString(pid)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -343,10 +295,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -370,30 +319,48 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ProcessActivityEntry.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ProcessActivityEntry is not found in the empty JSON string", ProcessActivityEntry.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ProcessActivityEntry is not found in the empty JSON string", ProcessActivityEntry.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ProcessActivityEntry.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProcessActivityEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ProcessActivityEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the optional json data is an array if present if (jsonObj.get("args") != null && !jsonObj.get("args").isJsonNull() && !jsonObj.get("args").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `args` to be an array in the JSON string but got `%s`", jsonObj.get("args").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `args` to be an array in the JSON string but got `%s`", jsonObj.get("args").toString())); } - // ensure the optional json data is an array if present - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull() && !jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { + JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); + if (jsonArrayevents != null) { + // ensure the json data is an array + if (!jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + } + + // validate the optional field `events` (array) + for (int i = 0; i < jsonArrayevents.size(); i++) { + ReportEvent.validateJsonElement(jsonArrayevents.get(i)); + }; + } } if ((jsonObj.get("exit_code_str") != null && !jsonObj.get("exit_code_str").isJsonNull()) && !jsonObj.get("exit_code_str").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `exit_code_str` to be a primitive type in the JSON string but got `%s`", jsonObj.get("exit_code_str").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `exit_code_str` to be a primitive type in the JSON string but got `%s`", jsonObj.get("exit_code_str").toString())); } - if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } } @@ -412,28 +379,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProcessActivityEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -441,28 +386,7 @@ else if (entry.getValue() instanceof Character) public ProcessActivityEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ProcessActivityEntry instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ProcessExtractedFiles.java b/src/main/java/ai/reveng/model/ProcessExtractedFiles.java deleted file mode 100644 index 6e8ce610..00000000 --- a/src/main/java/ai/reveng/model/ProcessExtractedFiles.java +++ /dev/null @@ -1,344 +0,0 @@ -/* - * RevEng.AI API - * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. - * - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package ai.reveng.model; - -import java.util.Objects; -import java.util.Locale; -import ai.reveng.model.ExtractedFileEntry; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.openapitools.jackson.nullable.JsonNullable; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Locale; - -import ai.reveng.invoker.JSON; - -/** - * ProcessExtractedFiles - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class ProcessExtractedFiles { - public static final String SERIALIZED_NAME_FILES = "files"; - @SerializedName(SERIALIZED_NAME_FILES) - @javax.annotation.Nullable - private List files; - - public static final String SERIALIZED_NAME_PROCESS_SEQID = "process_seqid"; - @SerializedName(SERIALIZED_NAME_PROCESS_SEQID) - @javax.annotation.Nonnull - private Long processSeqid; - - public ProcessExtractedFiles() { - } - - public ProcessExtractedFiles files(@javax.annotation.Nullable List files) { - this.files = files; - return this; - } - - public ProcessExtractedFiles addFilesItem(ExtractedFileEntry filesItem) { - if (this.files == null) { - this.files = new ArrayList<>(); - } - this.files.add(filesItem); - return this; - } - - /** - * Get files - * @return files - */ - @javax.annotation.Nullable - public List getFiles() { - return files; - } - - public void setFiles(@javax.annotation.Nullable List files) { - this.files = files; - } - - - public ProcessExtractedFiles processSeqid(@javax.annotation.Nonnull Long processSeqid) { - this.processSeqid = processSeqid; - return this; - } - - /** - * Get processSeqid - * @return processSeqid - */ - @javax.annotation.Nonnull - public Long getProcessSeqid() { - return processSeqid; - } - - public void setProcessSeqid(@javax.annotation.Nonnull Long processSeqid) { - this.processSeqid = processSeqid; - } - - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ProcessExtractedFiles instance itself - */ - public ProcessExtractedFiles putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ProcessExtractedFiles processExtractedFiles = (ProcessExtractedFiles) o; - return Objects.equals(this.files, processExtractedFiles.files) && - Objects.equals(this.processSeqid, processExtractedFiles.processSeqid)&& - Objects.equals(this.additionalProperties, processExtractedFiles.additionalProperties); - } - - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); - } - - @Override - public int hashCode() { - return Objects.hash(files, processSeqid, additionalProperties); - } - - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ProcessExtractedFiles {\n"); - sb.append(" files: ").append(toIndentedString(files)).append("\n"); - sb.append(" processSeqid: ").append(toIndentedString(processSeqid)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("files", "process_seqid")); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(Arrays.asList("process_seqid")); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to ProcessExtractedFiles - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!ProcessExtractedFiles.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ProcessExtractedFiles is not found in the empty JSON string", ProcessExtractedFiles.openapiRequiredFields.toString())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : ProcessExtractedFiles.openapiRequiredFields) { - if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the optional json data is an array if present - if (jsonObj.get("files") != null && !jsonObj.get("files").isJsonNull() && !jsonObj.get("files").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `files` to be an array in the JSON string but got `%s`", jsonObj.get("files").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!ProcessExtractedFiles.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'ProcessExtractedFiles' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(ProcessExtractedFiles.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, ProcessExtractedFiles value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } - elementAdapter.write(out, obj); - } - - @Override - public ProcessExtractedFiles read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ProcessExtractedFiles instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; - } - - }.nullSafe(); - } - } - - /** - * Create an instance of ProcessExtractedFiles given an JSON string - * - * @param jsonString JSON string - * @return An instance of ProcessExtractedFiles - * @throws IOException if the JSON string is invalid with respect to ProcessExtractedFiles - */ - public static ProcessExtractedFiles fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, ProcessExtractedFiles.class); - } - - /** - * Convert an instance of ProcessExtractedFiles to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/ai/reveng/model/ProcessMemdumps.java b/src/main/java/ai/reveng/model/ProcessMemdumps.java index 654b1521..c395acab 100644 --- a/src/main/java/ai/reveng/model/ProcessMemdumps.java +++ b/src/main/java/ai/reveng/model/ProcessMemdumps.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.MemdumpEntry; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -113,50 +111,6 @@ public void setProcessSeqid(@javax.annotation.Nonnull Long processSeqid) { this.processSeqid = processSeqid; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ProcessMemdumps instance itself - */ - public ProcessMemdumps putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -169,8 +123,7 @@ public boolean equals(Object o) { } ProcessMemdumps processMemdumps = (ProcessMemdumps) o; return Objects.equals(this.dumps, processMemdumps.dumps) && - Objects.equals(this.processSeqid, processMemdumps.processSeqid)&& - Objects.equals(this.additionalProperties, processMemdumps.additionalProperties); + Objects.equals(this.processSeqid, processMemdumps.processSeqid); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -179,7 +132,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(dumps, processSeqid, additionalProperties); + return Objects.hash(dumps, processSeqid); } private static int hashCodeNullable(JsonNullable a) { @@ -195,7 +148,6 @@ public String toString() { sb.append("class ProcessMemdumps {\n"); sb.append(" dumps: ").append(toIndentedString(dumps)).append("\n"); sb.append(" processSeqid: ").append(toIndentedString(processSeqid)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -205,10 +157,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -232,20 +181,38 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ProcessMemdumps.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ProcessMemdumps is not found in the empty JSON string", ProcessMemdumps.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ProcessMemdumps is not found in the empty JSON string", ProcessMemdumps.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ProcessMemdumps.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProcessMemdumps` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ProcessMemdumps.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the optional json data is an array if present - if (jsonObj.get("dumps") != null && !jsonObj.get("dumps").isJsonNull() && !jsonObj.get("dumps").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `dumps` to be an array in the JSON string but got `%s`", jsonObj.get("dumps").toString())); + if (jsonObj.get("dumps") != null && !jsonObj.get("dumps").isJsonNull()) { + JsonArray jsonArraydumps = jsonObj.getAsJsonArray("dumps"); + if (jsonArraydumps != null) { + // ensure the json data is an array + if (!jsonObj.get("dumps").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `dumps` to be an array in the JSON string but got `%s`", jsonObj.get("dumps").toString())); + } + + // validate the optional field `dumps` (array) + for (int i = 0; i < jsonArraydumps.size(); i++) { + MemdumpEntry.validateJsonElement(jsonArraydumps.get(i)); + }; + } } } @@ -264,28 +231,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProcessMemdumps value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -293,28 +238,7 @@ else if (entry.getValue() instanceof Character) public ProcessMemdumps read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ProcessMemdumps instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ProcessNode.java b/src/main/java/ai/reveng/model/ProcessNode.java index f7d8a933..8a8df65a 100644 --- a/src/main/java/ai/reveng/model/ProcessNode.java +++ b/src/main/java/ai/reveng/model/ProcessNode.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -91,7 +89,7 @@ public class ProcessNode { public static final String SERIALIZED_NAME_NAME = "name"; @SerializedName(SERIALIZED_NAME_NAME) - @javax.annotation.Nullable + @javax.annotation.Nonnull private String name; public static final String SERIALIZED_NAME_PID = "pid"; @@ -261,7 +259,7 @@ public void setKilledBy(@javax.annotation.Nullable Long killedBy) { } - public ProcessNode name(@javax.annotation.Nullable String name) { + public ProcessNode name(@javax.annotation.Nonnull String name) { this.name = name; return this; } @@ -270,12 +268,12 @@ public ProcessNode name(@javax.annotation.Nullable String name) { * Get name * @return name */ - @javax.annotation.Nullable + @javax.annotation.Nonnull public String getName() { return name; } - public void setName(@javax.annotation.Nullable String name) { + public void setName(@javax.annotation.Nonnull String name) { this.name = name; } @@ -336,50 +334,6 @@ public void setStartedAt(@javax.annotation.Nullable Double startedAt) { this.startedAt = startedAt; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ProcessNode instance itself - */ - public ProcessNode putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -401,8 +355,7 @@ public boolean equals(Object o) { Objects.equals(this.name, processNode.name) && Objects.equals(this.pid, processNode.pid) && Objects.equals(this.seqid, processNode.seqid) && - Objects.equals(this.startedAt, processNode.startedAt)&& - Objects.equals(this.additionalProperties, processNode.additionalProperties); + Objects.equals(this.startedAt, processNode.startedAt); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -411,7 +364,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(args, attributed, children, exitCode, exitCodeStr, exitedAt, killedBy, name, pid, seqid, startedAt, additionalProperties); + return Objects.hash(args, attributed, children, exitCode, exitCodeStr, exitedAt, killedBy, name, pid, seqid, startedAt); } private static int hashCodeNullable(JsonNullable a) { @@ -436,7 +389,6 @@ public String toString() { sb.append(" pid: ").append(toIndentedString(pid)).append("\n"); sb.append(" seqid: ").append(toIndentedString(seqid)).append("\n"); sb.append(" startedAt: ").append(toIndentedString(startedAt)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -446,10 +398,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -473,30 +422,48 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ProcessNode.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ProcessNode is not found in the empty JSON string", ProcessNode.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ProcessNode is not found in the empty JSON string", ProcessNode.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ProcessNode.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProcessNode` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ProcessNode.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the optional json data is an array if present if (jsonObj.get("args") != null && !jsonObj.get("args").isJsonNull() && !jsonObj.get("args").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `args` to be an array in the JSON string but got `%s`", jsonObj.get("args").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `args` to be an array in the JSON string but got `%s`", jsonObj.get("args").toString())); } - // ensure the optional json data is an array if present - if (jsonObj.get("children") != null && !jsonObj.get("children").isJsonNull() && !jsonObj.get("children").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `children` to be an array in the JSON string but got `%s`", jsonObj.get("children").toString())); + if (jsonObj.get("children") != null && !jsonObj.get("children").isJsonNull()) { + JsonArray jsonArraychildren = jsonObj.getAsJsonArray("children"); + if (jsonArraychildren != null) { + // ensure the json data is an array + if (!jsonObj.get("children").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `children` to be an array in the JSON string but got `%s`", jsonObj.get("children").toString())); + } + + // validate the optional field `children` (array) + for (int i = 0; i < jsonArraychildren.size(); i++) { + ProcessNode.validateJsonElement(jsonArraychildren.get(i)); + }; + } } if ((jsonObj.get("exit_code_str") != null && !jsonObj.get("exit_code_str").isJsonNull()) && !jsonObj.get("exit_code_str").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `exit_code_str` to be a primitive type in the JSON string but got `%s`", jsonObj.get("exit_code_str").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `exit_code_str` to be a primitive type in the JSON string but got `%s`", jsonObj.get("exit_code_str").toString())); } - if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } } @@ -515,28 +482,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProcessNode value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -544,28 +489,7 @@ else if (entry.getValue() instanceof Character) public ProcessNode read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ProcessNode instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ProcessTree.java b/src/main/java/ai/reveng/model/ProcessTree.java index b5e1b82f..f05f2472 100644 --- a/src/main/java/ai/reveng/model/ProcessTree.java +++ b/src/main/java/ai/reveng/model/ProcessTree.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ProcessNode; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -113,50 +111,6 @@ public void setSampleSeqid(@javax.annotation.Nullable Long sampleSeqid) { this.sampleSeqid = sampleSeqid; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ProcessTree instance itself - */ - public ProcessTree putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -169,8 +123,7 @@ public boolean equals(Object o) { } ProcessTree processTree = (ProcessTree) o; return Objects.equals(this.nodes, processTree.nodes) && - Objects.equals(this.sampleSeqid, processTree.sampleSeqid)&& - Objects.equals(this.additionalProperties, processTree.additionalProperties); + Objects.equals(this.sampleSeqid, processTree.sampleSeqid); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -179,7 +132,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(nodes, sampleSeqid, additionalProperties); + return Objects.hash(nodes, sampleSeqid); } private static int hashCodeNullable(JsonNullable a) { @@ -195,7 +148,6 @@ public String toString() { sb.append("class ProcessTree {\n"); sb.append(" nodes: ").append(toIndentedString(nodes)).append("\n"); sb.append(" sampleSeqid: ").append(toIndentedString(sampleSeqid)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -205,10 +157,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -232,13 +181,31 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ProcessTree.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ProcessTree is not found in the empty JSON string", ProcessTree.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ProcessTree is not found in the empty JSON string", ProcessTree.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ProcessTree.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProcessTree` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the optional json data is an array if present - if (jsonObj.get("nodes") != null && !jsonObj.get("nodes").isJsonNull() && !jsonObj.get("nodes").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `nodes` to be an array in the JSON string but got `%s`", jsonObj.get("nodes").toString())); + if (jsonObj.get("nodes") != null && !jsonObj.get("nodes").isJsonNull()) { + JsonArray jsonArraynodes = jsonObj.getAsJsonArray("nodes"); + if (jsonArraynodes != null) { + // ensure the json data is an array + if (!jsonObj.get("nodes").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `nodes` to be an array in the JSON string but got `%s`", jsonObj.get("nodes").toString())); + } + + // validate the optional field `nodes` (array) + for (int i = 0; i < jsonArraynodes.size(); i++) { + ProcessNode.validateJsonElement(jsonArraynodes.get(i)); + }; + } } } @@ -257,28 +224,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProcessTree value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -286,28 +231,7 @@ else if (entry.getValue() instanceof Character) public ProcessTree read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ProcessTree instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ProductOutput.java b/src/main/java/ai/reveng/model/ProductOutput.java index 817014fc..9cd4550d 100644 --- a/src/main/java/ai/reveng/model/ProductOutput.java +++ b/src/main/java/ai/reveng/model/ProductOutput.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.PriceOutput; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -240,50 +238,6 @@ public void setTier(@javax.annotation.Nullable String tier) { this.tier = tier; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ProductOutput instance itself - */ - public ProductOutput putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -301,13 +255,12 @@ public boolean equals(Object o) { Objects.equals(this.id, productOutput.id) && Objects.equals(this.name, productOutput.name) && Objects.equals(this.prices, productOutput.prices) && - Objects.equals(this.tier, productOutput.tier)&& - Objects.equals(this.additionalProperties, productOutput.additionalProperties); + Objects.equals(this.tier, productOutput.tier); } @Override public int hashCode() { - return Objects.hash(creditsPerMonth, description, features, id, name, prices, tier, additionalProperties); + return Objects.hash(creditsPerMonth, description, features, id, name, prices, tier); } @Override @@ -321,7 +274,6 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" prices: ").append(toIndentedString(prices)).append("\n"); sb.append(" tier: ").append(toIndentedString(tier)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -331,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -358,40 +307,52 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ProductOutput.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ProductOutput is not found in the empty JSON string", ProductOutput.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ProductOutput is not found in the empty JSON string", ProductOutput.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ProductOutput.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProductOutput` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ProductOutput.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("description").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); } // ensure the required json array is present if (jsonObj.get("features") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); - } else if (!jsonObj.get("features").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `features` to be an array in the JSON string but got `%s`", jsonObj.get("features").toString())); + } else if (!jsonObj.get("features").isJsonArray() && !jsonObj.get("features").isJsonNull()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `features` to be an array in the JSON string but got `%s`", jsonObj.get("features").toString())); } if (!jsonObj.get("id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); } if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } - // ensure the required json array is present - if (jsonObj.get("prices") == null) { - throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); - } else if (!jsonObj.get("prices").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `prices` to be an array in the JSON string but got `%s`", jsonObj.get("prices").toString())); + if (jsonObj.get("prices") != null && !jsonObj.get("prices").isJsonNull()) { + if (!jsonObj.get("prices").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `prices` to be an array in the JSON string but got `%s`", jsonObj.get("prices").toString())); + } + JsonArray jsonArrayprices = jsonObj.getAsJsonArray("prices"); + // validate the required field `prices` (array) + for (int i = 0; i < jsonArrayprices.size(); i++) { + PriceOutput.validateJsonElement(jsonArrayprices.get(i)); + } } if ((jsonObj.get("tier") != null && !jsonObj.get("tier").isJsonNull()) && !jsonObj.get("tier").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tier` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tier").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tier` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tier").toString())); } } @@ -410,28 +371,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProductOutput value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -439,28 +378,7 @@ else if (entry.getValue() instanceof Character) public ProductOutput read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ProductOutput instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ProductSummary.java b/src/main/java/ai/reveng/model/ProductSummary.java index 4f02b2d3..cdd6fb96 100644 --- a/src/main/java/ai/reveng/model/ProductSummary.java +++ b/src/main/java/ai/reveng/model/ProductSummary.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -77,50 +75,6 @@ public void setName(@javax.annotation.Nonnull String name) { this.name = name; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ProductSummary instance itself - */ - public ProductSummary putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -132,13 +86,12 @@ public boolean equals(Object o) { return false; } ProductSummary productSummary = (ProductSummary) o; - return Objects.equals(this.name, productSummary.name)&& - Objects.equals(this.additionalProperties, productSummary.additionalProperties); + return Objects.equals(this.name, productSummary.name); } @Override public int hashCode() { - return Objects.hash(name, additionalProperties); + return Objects.hash(name); } @Override @@ -146,7 +99,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ProductSummary {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -156,10 +108,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,19 +132,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ProductSummary.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ProductSummary is not found in the empty JSON string", ProductSummary.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ProductSummary is not found in the empty JSON string", ProductSummary.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ProductSummary.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProductSummary` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ProductSummary.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } } @@ -214,28 +171,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProductSummary value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -243,28 +178,7 @@ else if (entry.getValue() instanceof Character) public ProductSummary read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ProductSummary instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ProgressMessage.java b/src/main/java/ai/reveng/model/ProgressMessage.java index f0a45149..ce0ee39e 100644 --- a/src/main/java/ai/reveng/model/ProgressMessage.java +++ b/src/main/java/ai/reveng/model/ProgressMessage.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -206,50 +204,6 @@ public void setTimestamp(@javax.annotation.Nonnull OffsetDateTime timestamp) { this.timestamp = timestamp; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ProgressMessage instance itself - */ - public ProgressMessage putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -264,13 +218,12 @@ public boolean equals(Object o) { return Objects.equals(this.level, progressMessage.level) && Objects.equals(this.step, progressMessage.step) && Objects.equals(this.text, progressMessage.text) && - Objects.equals(this.timestamp, progressMessage.timestamp)&& - Objects.equals(this.additionalProperties, progressMessage.additionalProperties); + Objects.equals(this.timestamp, progressMessage.timestamp); } @Override public int hashCode() { - return Objects.hash(level, step, text, timestamp, additionalProperties); + return Objects.hash(level, step, text, timestamp); } @Override @@ -281,7 +234,6 @@ public String toString() { sb.append(" step: ").append(toIndentedString(step)).append("\n"); sb.append(" text: ").append(toIndentedString(text)).append("\n"); sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -291,10 +243,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -318,27 +267,35 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ProgressMessage.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ProgressMessage is not found in the empty JSON string", ProgressMessage.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ProgressMessage is not found in the empty JSON string", ProgressMessage.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ProgressMessage.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProgressMessage` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ProgressMessage.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("level").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `level` to be a primitive type in the JSON string but got `%s`", jsonObj.get("level").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `level` to be a primitive type in the JSON string but got `%s`", jsonObj.get("level").toString())); } // validate the required field `level` LevelEnum.validateJsonElement(jsonObj.get("level")); if (!jsonObj.get("step").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `step` to be a primitive type in the JSON string but got `%s`", jsonObj.get("step").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `step` to be a primitive type in the JSON string but got `%s`", jsonObj.get("step").toString())); } if (!jsonObj.get("text").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); } } @@ -357,28 +314,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProgressMessage value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -386,28 +321,7 @@ else if (entry.getValue() instanceof Character) public ProgressMessage read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ProgressMessage instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ProseEvent.java b/src/main/java/ai/reveng/model/ProseEvent.java index 49ceef08..b0a57aa2 100644 --- a/src/main/java/ai/reveng/model/ProseEvent.java +++ b/src/main/java/ai/reveng/model/ProseEvent.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -149,50 +147,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ProseEvent instance itself - */ - public ProseEvent putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -207,13 +161,12 @@ public boolean equals(Object o) { return Objects.equals(this.attempt, proseEvent.attempt) && Objects.equals(this.seq, proseEvent.seq) && Objects.equals(this.text, proseEvent.text) && - Objects.equals(this.type, proseEvent.type)&& - Objects.equals(this.additionalProperties, proseEvent.additionalProperties); + Objects.equals(this.type, proseEvent.type); } @Override public int hashCode() { - return Objects.hash(attempt, seq, text, type, additionalProperties); + return Objects.hash(attempt, seq, text, type); } @Override @@ -224,7 +177,6 @@ public String toString() { sb.append(" seq: ").append(toIndentedString(seq)).append("\n"); sb.append(" text: ").append(toIndentedString(text)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -234,10 +186,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,22 +210,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ProseEvent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ProseEvent is not found in the empty JSON string", ProseEvent.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ProseEvent is not found in the empty JSON string", ProseEvent.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ProseEvent.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProseEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ProseEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("text").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -295,28 +252,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProseEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -324,28 +259,7 @@ else if (entry.getValue() instanceof Character) public ProseEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ProseEvent instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/PutAnalysisStringsRequest.java b/src/main/java/ai/reveng/model/PutAnalysisStringsRequest.java index 89d21b32..c09daaff 100644 --- a/src/main/java/ai/reveng/model/PutAnalysisStringsRequest.java +++ b/src/main/java/ai/reveng/model/PutAnalysisStringsRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AnalysisStringInput; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -167,10 +165,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,27 +189,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!PutAnalysisStringsRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in PutAnalysisStringsRequest is not found in the empty JSON string", PutAnalysisStringsRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in PutAnalysisStringsRequest is not found in the empty JSON string", PutAnalysisStringsRequest.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PutAnalysisStringsRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("strings").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `strings` to be an array in the JSON string but got `%s`", jsonObj.get("strings").toString())); + if (jsonObj.get("strings") != null) { + if (!jsonObj.get("strings").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `strings` to be an array in the JSON string but got `%s`", jsonObj.get("strings").toString())); + } + JsonArray jsonArraystrings = jsonObj.getAsJsonArray("strings"); + // validate the required field `strings` (array) + for (int i = 0; i < jsonArraystrings.size(); i++) { + AnalysisStringInput.validateJsonElement(jsonArraystrings.get(i)); + } } - - JsonArray jsonArraystrings = jsonObj.getAsJsonArray("strings"); - // validate the required field `strings` (array) - for (int i = 0; i < jsonArraystrings.size(); i++) { - AnalysisStringInput.validateJsonElement(jsonArraystrings.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -274,7 +269,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/QueuedWorkflowTaskResponse.java b/src/main/java/ai/reveng/model/QueuedWorkflowTaskResponse.java index 74867436..18aeb9ff 100644 --- a/src/main/java/ai/reveng/model/QueuedWorkflowTaskResponse.java +++ b/src/main/java/ai/reveng/model/QueuedWorkflowTaskResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -156,10 +154,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,19 +178,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!QueuedWorkflowTaskResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in QueuedWorkflowTaskResponse is not found in the empty JSON string", QueuedWorkflowTaskResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in QueuedWorkflowTaskResponse is not found in the empty JSON string", QueuedWorkflowTaskResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : QueuedWorkflowTaskResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("task_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `task_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("task_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `task_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("task_id").toString())); } } @@ -256,7 +251,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ReAnalysisForm.java b/src/main/java/ai/reveng/model/ReAnalysisForm.java index 1d0b6bc3..66dad142 100644 --- a/src/main/java/ai/reveng/model/ReAnalysisForm.java +++ b/src/main/java/ai/reveng/model/ReAnalysisForm.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -182,7 +180,7 @@ public ReAnalysisForm modelName(@javax.annotation.Nullable String modelName) { } /** - * Get modelName + * Model name allows reprocessing using a different model * @return modelName */ @javax.annotation.Nullable @@ -313,10 +311,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -340,19 +335,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ReAnalysisForm.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ReAnalysisForm is not found in the empty JSON string", ReAnalysisForm.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ReAnalysisForm is not found in the empty JSON string", ReAnalysisForm.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the optional json data is an array if present if (jsonObj.get("tags") != null && !jsonObj.get("tags").isJsonNull() && !jsonObj.get("tags").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); } if ((jsonObj.get("command_line_args") != null && !jsonObj.get("command_line_args").isJsonNull()) && !jsonObj.get("command_line_args").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `command_line_args` to be a primitive type in the JSON string but got `%s`", jsonObj.get("command_line_args").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `command_line_args` to be a primitive type in the JSON string but got `%s`", jsonObj.get("command_line_args").toString())); } if ((jsonObj.get("model_name") != null && !jsonObj.get("model_name").isJsonNull()) && !jsonObj.get("model_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `model_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("model_name").toString())); } } @@ -413,7 +408,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/Recent.java b/src/main/java/ai/reveng/model/Recent.java index 34286d56..bf19a3d8 100644 --- a/src/main/java/ai/reveng/model/Recent.java +++ b/src/main/java/ai/reveng/model/Recent.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AnalysisRecord; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -167,10 +165,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,27 +189,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Recent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Recent is not found in the empty JSON string", Recent.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Recent is not found in the empty JSON string", Recent.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Recent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("results").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); + if (jsonObj.get("results") != null) { + if (!jsonObj.get("results").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); + } + JsonArray jsonArrayresults = jsonObj.getAsJsonArray("results"); + // validate the required field `results` (array) + for (int i = 0; i < jsonArrayresults.size(); i++) { + AnalysisRecord.validateJsonElement(jsonArrayresults.get(i)); + } } - - JsonArray jsonArrayresults = jsonObj.getAsJsonArray("results"); - // validate the required field `results` (array) - for (int i = 0; i < jsonArrayresults.size(); i++) { - AnalysisRecord.validateJsonElement(jsonArrayresults.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -274,7 +269,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/RegenerateOutputBody.java b/src/main/java/ai/reveng/model/RegenerateOutputBody.java index c90dcc29..3299d351 100644 --- a/src/main/java/ai/reveng/model/RegenerateOutputBody.java +++ b/src/main/java/ai/reveng/model/RegenerateOutputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -77,50 +75,6 @@ public void setStatus(@javax.annotation.Nonnull Boolean status) { this.status = status; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the RegenerateOutputBody instance itself - */ - public RegenerateOutputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -132,13 +86,12 @@ public boolean equals(Object o) { return false; } RegenerateOutputBody regenerateOutputBody = (RegenerateOutputBody) o; - return Objects.equals(this.status, regenerateOutputBody.status)&& - Objects.equals(this.additionalProperties, regenerateOutputBody.additionalProperties); + return Objects.equals(this.status, regenerateOutputBody.status); } @Override public int hashCode() { - return Objects.hash(status, additionalProperties); + return Objects.hash(status); } @Override @@ -146,7 +99,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class RegenerateOutputBody {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -156,10 +108,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,14 +132,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!RegenerateOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in RegenerateOutputBody is not found in the empty JSON string", RegenerateOutputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in RegenerateOutputBody is not found in the empty JSON string", RegenerateOutputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!RegenerateOutputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `RegenerateOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RegenerateOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -211,28 +168,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RegenerateOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -240,28 +175,7 @@ else if (entry.getValue() instanceof Character) public RegenerateOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - RegenerateOutputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/RegenerateTarget.java b/src/main/java/ai/reveng/model/RegenerateTarget.java index f1a0c02c..b82a8c4f 100644 --- a/src/main/java/ai/reveng/model/RegenerateTarget.java +++ b/src/main/java/ai/reveng/model/RegenerateTarget.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/RegistryOperation.java b/src/main/java/ai/reveng/model/RegistryOperation.java index 449ea2b3..7af6ebe8 100644 --- a/src/main/java/ai/reveng/model/RegistryOperation.java +++ b/src/main/java/ai/reveng/model/RegistryOperation.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ReportEvent; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -62,7 +60,7 @@ public class RegistryOperation { public static final String SERIALIZED_NAME_KEY = "key"; @SerializedName(SERIALIZED_NAME_KEY) - @javax.annotation.Nullable + @javax.annotation.Nonnull private String key; public RegistryOperation() { @@ -95,7 +93,7 @@ public void setEvents(@javax.annotation.Nullable List events) { } - public RegistryOperation key(@javax.annotation.Nullable String key) { + public RegistryOperation key(@javax.annotation.Nonnull String key) { this.key = key; return this; } @@ -104,59 +102,15 @@ public RegistryOperation key(@javax.annotation.Nullable String key) { * Get key * @return key */ - @javax.annotation.Nullable + @javax.annotation.Nonnull public String getKey() { return key; } - public void setKey(@javax.annotation.Nullable String key) { + public void setKey(@javax.annotation.Nonnull String key) { this.key = key; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the RegistryOperation instance itself - */ - public RegistryOperation putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -169,8 +123,7 @@ public boolean equals(Object o) { } RegistryOperation registryOperation = (RegistryOperation) o; return Objects.equals(this.events, registryOperation.events) && - Objects.equals(this.key, registryOperation.key)&& - Objects.equals(this.additionalProperties, registryOperation.additionalProperties); + Objects.equals(this.key, registryOperation.key); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -179,7 +132,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(events, key, additionalProperties); + return Objects.hash(events, key); } private static int hashCodeNullable(JsonNullable a) { @@ -195,7 +148,6 @@ public String toString() { sb.append("class RegistryOperation {\n"); sb.append(" events: ").append(toIndentedString(events)).append("\n"); sb.append(" key: ").append(toIndentedString(key)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -205,10 +157,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -232,23 +181,41 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!RegistryOperation.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in RegistryOperation is not found in the empty JSON string", RegistryOperation.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in RegistryOperation is not found in the empty JSON string", RegistryOperation.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!RegistryOperation.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `RegistryOperation` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RegistryOperation.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the optional json data is an array if present - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull() && !jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { + JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); + if (jsonArrayevents != null) { + // ensure the json data is an array + if (!jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + } + + // validate the optional field `events` (array) + for (int i = 0; i < jsonArrayevents.size(); i++) { + ReportEvent.validateJsonElement(jsonArrayevents.get(i)); + }; + } } - if ((jsonObj.get("key") != null && !jsonObj.get("key").isJsonNull()) && !jsonObj.get("key").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `key` to be a primitive type in the JSON string but got `%s`", jsonObj.get("key").toString())); + if (!jsonObj.get("key").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `key` to be a primitive type in the JSON string but got `%s`", jsonObj.get("key").toString())); } } @@ -267,28 +234,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RegistryOperation value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -296,28 +241,7 @@ else if (entry.getValue() instanceof Character) public RegistryOperation read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - RegistryOperation instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/RelativeBinaryResponse.java b/src/main/java/ai/reveng/model/RelativeBinaryResponse.java index 2d1c7d30..92b7f8df 100644 --- a/src/main/java/ai/reveng/model/RelativeBinaryResponse.java +++ b/src/main/java/ai/reveng/model/RelativeBinaryResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -100,7 +98,7 @@ public RelativeBinaryResponse analysisId(@javax.annotation.Nullable Integer anal } /** - * Get analysisId + * ID of the active analysis for this binary * @return analysisId */ @javax.annotation.Nullable @@ -246,10 +244,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -273,22 +268,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!RelativeBinaryResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in RelativeBinaryResponse is not found in the empty JSON string", RelativeBinaryResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in RelativeBinaryResponse is not found in the empty JSON string", RelativeBinaryResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RelativeBinaryResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if (!jsonObj.get("sha256").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha256` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha256").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha256` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha256").toString())); } } @@ -349,7 +344,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/RenameAppliedEvent.java b/src/main/java/ai/reveng/model/RenameAppliedEvent.java index fd6a7302..bfc56487 100644 --- a/src/main/java/ai/reveng/model/RenameAppliedEvent.java +++ b/src/main/java/ai/reveng/model/RenameAppliedEvent.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -197,50 +195,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the RenameAppliedEvent instance itself - */ - public RenameAppliedEvent putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -257,13 +211,12 @@ public boolean equals(Object o) { Objects.equals(this.newName, renameAppliedEvent.newName) && Objects.equals(this.oldName, renameAppliedEvent.oldName) && Objects.equals(this.seq, renameAppliedEvent.seq) && - Objects.equals(this.type, renameAppliedEvent.type)&& - Objects.equals(this.additionalProperties, renameAppliedEvent.additionalProperties); + Objects.equals(this.type, renameAppliedEvent.type); } @Override public int hashCode() { - return Objects.hash(addrHex, attempt, newName, oldName, seq, type, additionalProperties); + return Objects.hash(addrHex, attempt, newName, oldName, seq, type); } @Override @@ -276,7 +229,6 @@ public String toString() { sb.append(" oldName: ").append(toIndentedString(oldName)).append("\n"); sb.append(" seq: ").append(toIndentedString(seq)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -286,10 +238,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -313,28 +262,36 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!RenameAppliedEvent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in RenameAppliedEvent is not found in the empty JSON string", RenameAppliedEvent.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in RenameAppliedEvent is not found in the empty JSON string", RenameAppliedEvent.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!RenameAppliedEvent.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `RenameAppliedEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RenameAppliedEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("addr_hex") != null && !jsonObj.get("addr_hex").isJsonNull()) && !jsonObj.get("addr_hex").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `addr_hex` to be a primitive type in the JSON string but got `%s`", jsonObj.get("addr_hex").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `addr_hex` to be a primitive type in the JSON string but got `%s`", jsonObj.get("addr_hex").toString())); } if (!jsonObj.get("new_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `new_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("new_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `new_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("new_name").toString())); } if (!jsonObj.get("old_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `old_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("old_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `old_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("old_name").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -353,28 +310,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RenameAppliedEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -382,28 +317,7 @@ else if (entry.getValue() instanceof Character) public RenameAppliedEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - RenameAppliedEvent instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/RenameInputBody.java b/src/main/java/ai/reveng/model/RenameInputBody.java index ea204996..dd7ca40c 100644 --- a/src/main/java/ai/reveng/model/RenameInputBody.java +++ b/src/main/java/ai/reveng/model/RenameInputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -101,50 +99,6 @@ public void setNewName(@javax.annotation.Nonnull String newName) { this.newName = newName; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the RenameInputBody instance itself - */ - public RenameInputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -157,13 +111,12 @@ public boolean equals(Object o) { } RenameInputBody renameInputBody = (RenameInputBody) o; return Objects.equals(this.newMangledName, renameInputBody.newMangledName) && - Objects.equals(this.newName, renameInputBody.newName)&& - Objects.equals(this.additionalProperties, renameInputBody.additionalProperties); + Objects.equals(this.newName, renameInputBody.newName); } @Override public int hashCode() { - return Objects.hash(newMangledName, newName, additionalProperties); + return Objects.hash(newMangledName, newName); } @Override @@ -172,7 +125,6 @@ public String toString() { sb.append("class RenameInputBody {\n"); sb.append(" newMangledName: ").append(toIndentedString(newMangledName)).append("\n"); sb.append(" newName: ").append(toIndentedString(newName)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -182,10 +134,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -209,22 +158,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!RenameInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in RenameInputBody is not found in the empty JSON string", RenameInputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in RenameInputBody is not found in the empty JSON string", RenameInputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!RenameInputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `RenameInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RenameInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("new_mangled_name") != null && !jsonObj.get("new_mangled_name").isJsonNull()) && !jsonObj.get("new_mangled_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `new_mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("new_mangled_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `new_mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("new_mangled_name").toString())); } if (!jsonObj.get("new_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `new_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("new_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `new_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("new_name").toString())); } } @@ -243,28 +200,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RenameInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -272,28 +207,7 @@ else if (entry.getValue() instanceof Character) public RenameInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - RenameInputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/RenameOutputBody.java b/src/main/java/ai/reveng/model/RenameOutputBody.java index 0c713bca..5eae25ca 100644 --- a/src/main/java/ai/reveng/model/RenameOutputBody.java +++ b/src/main/java/ai/reveng/model/RenameOutputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -77,50 +75,6 @@ public void setRenamedCount(@javax.annotation.Nonnull Long renamedCount) { this.renamedCount = renamedCount; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the RenameOutputBody instance itself - */ - public RenameOutputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -132,13 +86,12 @@ public boolean equals(Object o) { return false; } RenameOutputBody renameOutputBody = (RenameOutputBody) o; - return Objects.equals(this.renamedCount, renameOutputBody.renamedCount)&& - Objects.equals(this.additionalProperties, renameOutputBody.additionalProperties); + return Objects.equals(this.renamedCount, renameOutputBody.renamedCount); } @Override public int hashCode() { - return Objects.hash(renamedCount, additionalProperties); + return Objects.hash(renamedCount); } @Override @@ -146,7 +99,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class RenameOutputBody {\n"); sb.append(" renamedCount: ").append(toIndentedString(renamedCount)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -156,10 +108,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,14 +132,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!RenameOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in RenameOutputBody is not found in the empty JSON string", RenameOutputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in RenameOutputBody is not found in the empty JSON string", RenameOutputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!RenameOutputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `RenameOutputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RenameOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -211,28 +168,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RenameOutputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -240,28 +175,7 @@ else if (entry.getValue() instanceof Character) public RenameOutputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - RenameOutputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ReplacementValue.java b/src/main/java/ai/reveng/model/ReplacementValue.java index 9cb4954c..8e9a93dd 100644 --- a/src/main/java/ai/reveng/model/ReplacementValue.java +++ b/src/main/java/ai/reveng/model/ReplacementValue.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -77,50 +75,6 @@ public void setValue(@javax.annotation.Nonnull String value) { this.value = value; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ReplacementValue instance itself - */ - public ReplacementValue putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -132,13 +86,12 @@ public boolean equals(Object o) { return false; } ReplacementValue replacementValue = (ReplacementValue) o; - return Objects.equals(this.value, replacementValue.value)&& - Objects.equals(this.additionalProperties, replacementValue.additionalProperties); + return Objects.equals(this.value, replacementValue.value); } @Override public int hashCode() { - return Objects.hash(value, additionalProperties); + return Objects.hash(value); } @Override @@ -146,7 +99,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ReplacementValue {\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -156,10 +108,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,19 +132,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ReplacementValue.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ReplacementValue is not found in the empty JSON string", ReplacementValue.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ReplacementValue is not found in the empty JSON string", ReplacementValue.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ReplacementValue.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ReplacementValue` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ReplacementValue.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("value").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); } } @@ -214,28 +171,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ReplacementValue value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -243,28 +178,7 @@ else if (entry.getValue() instanceof Character) public ReplacementValue read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ReplacementValue instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ReportAnalysisResponse.java b/src/main/java/ai/reveng/model/ReportAnalysisResponse.java index c6db1c2a..5722c0de 100644 --- a/src/main/java/ai/reveng/model/ReportAnalysisResponse.java +++ b/src/main/java/ai/reveng/model/ReportAnalysisResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.IOC; import ai.reveng.model.MITRETechnique; import com.google.gson.TypeAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -418,10 +416,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -445,50 +440,50 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ReportAnalysisResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ReportAnalysisResponse is not found in the empty JSON string", ReportAnalysisResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ReportAnalysisResponse is not found in the empty JSON string", ReportAnalysisResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ReportAnalysisResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("summary").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("summary").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("summary").toString())); } if (!jsonObj.get("software_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `software_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("software_type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `software_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("software_type").toString())); } // validate the required field `software_type` SoftwareTypeEnum.validateJsonElement(jsonObj.get("software_type")); if (!jsonObj.get("attack_flow_summary").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `attack_flow_summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("attack_flow_summary").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `attack_flow_summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("attack_flow_summary").toString())); } - // ensure the json data is an array - if (!jsonObj.get("IOCs").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `IOCs` to be an array in the JSON string but got `%s`", jsonObj.get("IOCs").toString())); + if (jsonObj.get("IOCs") != null) { + if (!jsonObj.get("IOCs").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `IOCs` to be an array in the JSON string but got `%s`", jsonObj.get("IOCs").toString())); + } + JsonArray jsonArrayioCs = jsonObj.getAsJsonArray("IOCs"); + // validate the required field `IOCs` (array) + for (int i = 0; i < jsonArrayioCs.size(); i++) { + IOC.validateJsonElement(jsonArrayioCs.get(i)); + } } - - JsonArray jsonArrayioCs = jsonObj.getAsJsonArray("IOCs"); - // validate the required field `IOCs` (array) - for (int i = 0; i < jsonArrayioCs.size(); i++) { - IOC.validateJsonElement(jsonArrayioCs.get(i)); - }; - // ensure the json data is an array - if (!jsonObj.get("executable_techniques").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `executable_techniques` to be an array in the JSON string but got `%s`", jsonObj.get("executable_techniques").toString())); + if (jsonObj.get("executable_techniques") != null) { + if (!jsonObj.get("executable_techniques").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `executable_techniques` to be an array in the JSON string but got `%s`", jsonObj.get("executable_techniques").toString())); + } + JsonArray jsonArrayexecutableTechniques = jsonObj.getAsJsonArray("executable_techniques"); + // validate the required field `executable_techniques` (array) + for (int i = 0; i < jsonArrayexecutableTechniques.size(); i++) { + MITRETechnique.validateJsonElement(jsonArrayexecutableTechniques.get(i)); + } } - - JsonArray jsonArrayexecutableTechniques = jsonObj.getAsJsonArray("executable_techniques"); - // validate the required field `executable_techniques` (array) - for (int i = 0; i < jsonArrayexecutableTechniques.size(); i++) { - MITRETechnique.validateJsonElement(jsonArrayexecutableTechniques.get(i)); - }; if (!jsonObj.get("yara_rule").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `yara_rule` to be a primitive type in the JSON string but got `%s`", jsonObj.get("yara_rule").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `yara_rule` to be a primitive type in the JSON string but got `%s`", jsonObj.get("yara_rule").toString())); } } @@ -549,7 +544,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/ReportEvent.java b/src/main/java/ai/reveng/model/ReportEvent.java index f46a6cc6..49738af9 100644 --- a/src/main/java/ai/reveng/model/ReportEvent.java +++ b/src/main/java/ai/reveng/model/ReportEvent.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ApiCall; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -60,19 +58,29 @@ public class ReportEvent { @javax.annotation.Nullable private List apiCalls; + public static final String SERIALIZED_NAME_COUNT = "count"; + @SerializedName(SERIALIZED_NAME_COUNT) + @javax.annotation.Nullable + private Long count; + + public static final String SERIALIZED_NAME_DESIRED_ACCESS = "desired_access"; + @SerializedName(SERIALIZED_NAME_DESIRED_ACCESS) + @javax.annotation.Nullable + private List desiredAccess; + public static final String SERIALIZED_NAME_PROCESS_SEQID = "process_seqid"; @SerializedName(SERIALIZED_NAME_PROCESS_SEQID) @javax.annotation.Nullable private Long processSeqid; - public static final String SERIALIZED_NAME_TOTAL_BYTES_REQUESTED = "total_bytes_requested"; - @SerializedName(SERIALIZED_NAME_TOTAL_BYTES_REQUESTED) + public static final String SERIALIZED_NAME_TOTAL_BYTES = "total_bytes"; + @SerializedName(SERIALIZED_NAME_TOTAL_BYTES) @javax.annotation.Nullable - private Long totalBytesRequested; + private Long totalBytes; public static final String SERIALIZED_NAME_TYPE = "type"; @SerializedName(SERIALIZED_NAME_TYPE) - @javax.annotation.Nullable + @javax.annotation.Nonnull private String type; public static final String SERIALIZED_NAME_VALUE = "value"; @@ -85,11 +93,6 @@ public class ReportEvent { @javax.annotation.Nullable private String valueName; - public static final String SERIALIZED_NAME_WRITE_COUNT = "write_count"; - @SerializedName(SERIALIZED_NAME_WRITE_COUNT) - @javax.annotation.Nullable - private Long writeCount; - public ReportEvent() { } @@ -120,6 +123,52 @@ public void setApiCalls(@javax.annotation.Nullable List apiCalls) { } + public ReportEvent count(@javax.annotation.Nullable Long count) { + this.count = count; + return this; + } + + /** + * Get count + * @return count + */ + @javax.annotation.Nullable + public Long getCount() { + return count; + } + + public void setCount(@javax.annotation.Nullable Long count) { + this.count = count; + } + + + public ReportEvent desiredAccess(@javax.annotation.Nullable List desiredAccess) { + this.desiredAccess = desiredAccess; + return this; + } + + public ReportEvent addDesiredAccessItem(String desiredAccessItem) { + if (this.desiredAccess == null) { + this.desiredAccess = new ArrayList<>(); + } + this.desiredAccess.add(desiredAccessItem); + return this; + } + + /** + * Get desiredAccess + * @return desiredAccess + */ + @javax.annotation.Nullable + public List getDesiredAccess() { + return desiredAccess; + } + + public void setDesiredAccess(@javax.annotation.Nullable List desiredAccess) { + this.desiredAccess = desiredAccess; + } + + public ReportEvent processSeqid(@javax.annotation.Nullable Long processSeqid) { this.processSeqid = processSeqid; return this; @@ -139,26 +188,26 @@ public void setProcessSeqid(@javax.annotation.Nullable Long processSeqid) { } - public ReportEvent totalBytesRequested(@javax.annotation.Nullable Long totalBytesRequested) { - this.totalBytesRequested = totalBytesRequested; + public ReportEvent totalBytes(@javax.annotation.Nullable Long totalBytes) { + this.totalBytes = totalBytes; return this; } /** - * Get totalBytesRequested - * @return totalBytesRequested + * Get totalBytes + * @return totalBytes */ @javax.annotation.Nullable - public Long getTotalBytesRequested() { - return totalBytesRequested; + public Long getTotalBytes() { + return totalBytes; } - public void setTotalBytesRequested(@javax.annotation.Nullable Long totalBytesRequested) { - this.totalBytesRequested = totalBytesRequested; + public void setTotalBytes(@javax.annotation.Nullable Long totalBytes) { + this.totalBytes = totalBytes; } - public ReportEvent type(@javax.annotation.Nullable String type) { + public ReportEvent type(@javax.annotation.Nonnull String type) { this.type = type; return this; } @@ -167,12 +216,12 @@ public ReportEvent type(@javax.annotation.Nullable String type) { * Get type * @return type */ - @javax.annotation.Nullable + @javax.annotation.Nonnull public String getType() { return type; } - public void setType(@javax.annotation.Nullable String type) { + public void setType(@javax.annotation.Nonnull String type) { this.type = type; } @@ -215,69 +264,6 @@ public void setValueName(@javax.annotation.Nullable String valueName) { } - public ReportEvent writeCount(@javax.annotation.Nullable Long writeCount) { - this.writeCount = writeCount; - return this; - } - - /** - * Get writeCount - * @return writeCount - */ - @javax.annotation.Nullable - public Long getWriteCount() { - return writeCount; - } - - public void setWriteCount(@javax.annotation.Nullable Long writeCount) { - this.writeCount = writeCount; - } - - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ReportEvent instance itself - */ - public ReportEvent putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } - @Override public boolean equals(Object o) { @@ -289,13 +275,13 @@ public boolean equals(Object o) { } ReportEvent reportEvent = (ReportEvent) o; return Objects.equals(this.apiCalls, reportEvent.apiCalls) && + Objects.equals(this.count, reportEvent.count) && + Objects.equals(this.desiredAccess, reportEvent.desiredAccess) && Objects.equals(this.processSeqid, reportEvent.processSeqid) && - Objects.equals(this.totalBytesRequested, reportEvent.totalBytesRequested) && + Objects.equals(this.totalBytes, reportEvent.totalBytes) && Objects.equals(this.type, reportEvent.type) && Objects.equals(this.value, reportEvent.value) && - Objects.equals(this.valueName, reportEvent.valueName) && - Objects.equals(this.writeCount, reportEvent.writeCount)&& - Objects.equals(this.additionalProperties, reportEvent.additionalProperties); + Objects.equals(this.valueName, reportEvent.valueName); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -304,7 +290,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(apiCalls, processSeqid, totalBytesRequested, type, value, valueName, writeCount, additionalProperties); + return Objects.hash(apiCalls, count, desiredAccess, processSeqid, totalBytes, type, value, valueName); } private static int hashCodeNullable(JsonNullable a) { @@ -319,13 +305,13 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ReportEvent {\n"); sb.append(" apiCalls: ").append(toIndentedString(apiCalls)).append("\n"); + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" desiredAccess: ").append(toIndentedString(desiredAccess)).append("\n"); sb.append(" processSeqid: ").append(toIndentedString(processSeqid)).append("\n"); - sb.append(" totalBytesRequested: ").append(toIndentedString(totalBytesRequested)).append("\n"); + sb.append(" totalBytes: ").append(toIndentedString(totalBytes)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); sb.append(" valueName: ").append(toIndentedString(valueName)).append("\n"); - sb.append(" writeCount: ").append(toIndentedString(writeCount)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -335,10 +321,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -347,7 +330,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("api_calls", "process_seqid", "total_bytes_requested", "type", "value", "value_name", "write_count")); + openapiFields = new HashSet(Arrays.asList("api_calls", "count", "desired_access", "process_seqid", "total_bytes", "type", "value", "value_name")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("type")); @@ -362,29 +345,51 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ReportEvent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ReportEvent is not found in the empty JSON string", ReportEvent.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ReportEvent is not found in the empty JSON string", ReportEvent.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ReportEvent.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ReportEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ReportEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("api_calls") != null && !jsonObj.get("api_calls").isJsonNull()) { + JsonArray jsonArrayapiCalls = jsonObj.getAsJsonArray("api_calls"); + if (jsonArrayapiCalls != null) { + // ensure the json data is an array + if (!jsonObj.get("api_calls").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `api_calls` to be an array in the JSON string but got `%s`", jsonObj.get("api_calls").toString())); + } + + // validate the optional field `api_calls` (array) + for (int i = 0; i < jsonArrayapiCalls.size(); i++) { + ApiCall.validateJsonElement(jsonArrayapiCalls.get(i)); + }; + } + } // ensure the optional json data is an array if present - if (jsonObj.get("api_calls") != null && !jsonObj.get("api_calls").isJsonNull() && !jsonObj.get("api_calls").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `api_calls` to be an array in the JSON string but got `%s`", jsonObj.get("api_calls").toString())); + if (jsonObj.get("desired_access") != null && !jsonObj.get("desired_access").isJsonNull() && !jsonObj.get("desired_access").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `desired_access` to be an array in the JSON string but got `%s`", jsonObj.get("desired_access").toString())); } - if ((jsonObj.get("type") != null && !jsonObj.get("type").isJsonNull()) && !jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } if ((jsonObj.get("value") != null && !jsonObj.get("value").isJsonNull()) && !jsonObj.get("value").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); } if ((jsonObj.get("value_name") != null && !jsonObj.get("value_name").isJsonNull()) && !jsonObj.get("value_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `value_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `value_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value_name").toString())); } } @@ -403,28 +408,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ReportEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -432,28 +415,7 @@ else if (entry.getValue() instanceof Character) public ReportEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ReportEvent instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ReportInfo.java b/src/main/java/ai/reveng/model/ReportInfo.java index d8009ebd..7ae8efc4 100644 --- a/src/main/java/ai/reveng/model/ReportInfo.java +++ b/src/main/java/ai/reveng/model/ReportInfo.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.DrakvufFileMetadata; import ai.reveng.model.ReportOptions; import com.google.gson.TypeAdapter; @@ -23,7 +22,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; -import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -45,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -61,7 +58,7 @@ public class ReportInfo { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) - @javax.annotation.Nullable + @javax.annotation.Nonnull private String id; public static final String SERIALIZED_NAME_OPTIONS = "options"; @@ -116,7 +113,7 @@ public void setFile(@javax.annotation.Nullable DrakvufFileMetadata _file) { } - public ReportInfo id(@javax.annotation.Nullable String id) { + public ReportInfo id(@javax.annotation.Nonnull String id) { this.id = id; return this; } @@ -125,12 +122,12 @@ public ReportInfo id(@javax.annotation.Nullable String id) { * Get id * @return id */ - @javax.annotation.Nullable + @javax.annotation.Nonnull public String getId() { return id; } - public void setId(@javax.annotation.Nullable String id) { + public void setId(@javax.annotation.Nonnull String id) { this.id = id; } @@ -248,50 +245,6 @@ public void setTimeStarted(@javax.annotation.Nullable String timeStarted) { this.timeStarted = timeStarted; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ReportInfo instance itself - */ - public ReportInfo putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -310,24 +263,12 @@ public boolean equals(Object o) { Objects.equals(this.status, reportInfo.status) && Objects.equals(this.timeAnalysisFinished, reportInfo.timeAnalysisFinished) && Objects.equals(this.timeExecutionStarted, reportInfo.timeExecutionStarted) && - Objects.equals(this.timeStarted, reportInfo.timeStarted)&& - Objects.equals(this.additionalProperties, reportInfo.additionalProperties); - } - - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + Objects.equals(this.timeStarted, reportInfo.timeStarted); } @Override public int hashCode() { - return Objects.hash(_file, id, options, osProfile, status, timeAnalysisFinished, timeExecutionStarted, timeStarted, additionalProperties); - } - - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + return Objects.hash(_file, id, options, osProfile, status, timeAnalysisFinished, timeExecutionStarted, timeStarted); } @Override @@ -342,7 +283,6 @@ public String toString() { sb.append(" timeAnalysisFinished: ").append(toIndentedString(timeAnalysisFinished)).append("\n"); sb.append(" timeExecutionStarted: ").append(toIndentedString(timeExecutionStarted)).append("\n"); sb.append(" timeStarted: ").append(toIndentedString(timeStarted)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -352,10 +292,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -379,34 +316,50 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ReportInfo.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ReportInfo is not found in the empty JSON string", ReportInfo.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ReportInfo is not found in the empty JSON string", ReportInfo.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ReportInfo.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ReportInfo` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ReportInfo.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + // validate the optional field `file` + if (jsonObj.get("file") != null && !jsonObj.get("file").isJsonNull()) { + DrakvufFileMetadata.validateJsonElement(jsonObj.get("file")); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // validate the optional field `options` + if (jsonObj.get("options") != null && !jsonObj.get("options").isJsonNull()) { + ReportOptions.validateJsonElement(jsonObj.get("options")); } if ((jsonObj.get("os_profile") != null && !jsonObj.get("os_profile").isJsonNull()) && !jsonObj.get("os_profile").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `os_profile` to be a primitive type in the JSON string but got `%s`", jsonObj.get("os_profile").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `os_profile` to be a primitive type in the JSON string but got `%s`", jsonObj.get("os_profile").toString())); } if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); } if ((jsonObj.get("time_analysis_finished") != null && !jsonObj.get("time_analysis_finished").isJsonNull()) && !jsonObj.get("time_analysis_finished").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `time_analysis_finished` to be a primitive type in the JSON string but got `%s`", jsonObj.get("time_analysis_finished").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `time_analysis_finished` to be a primitive type in the JSON string but got `%s`", jsonObj.get("time_analysis_finished").toString())); } if ((jsonObj.get("time_execution_started") != null && !jsonObj.get("time_execution_started").isJsonNull()) && !jsonObj.get("time_execution_started").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `time_execution_started` to be a primitive type in the JSON string but got `%s`", jsonObj.get("time_execution_started").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `time_execution_started` to be a primitive type in the JSON string but got `%s`", jsonObj.get("time_execution_started").toString())); } if ((jsonObj.get("time_started") != null && !jsonObj.get("time_started").isJsonNull()) && !jsonObj.get("time_started").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `time_started` to be a primitive type in the JSON string but got `%s`", jsonObj.get("time_started").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `time_started` to be a primitive type in the JSON string but got `%s`", jsonObj.get("time_started").toString())); } } @@ -425,28 +378,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ReportInfo value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -454,28 +385,7 @@ else if (entry.getValue() instanceof Character) public ReportInfo read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ReportInfo instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ReportOptions.java b/src/main/java/ai/reveng/model/ReportOptions.java index 6c0f1b4a..80e4dcaf 100644 --- a/src/main/java/ai/reveng/model/ReportOptions.java +++ b/src/main/java/ai/reveng/model/ReportOptions.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -352,50 +350,6 @@ public void setTimeout(@javax.annotation.Nullable Long timeout) { this.timeout = timeout; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ReportOptions instance itself - */ - public ReportOptions putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -418,8 +372,7 @@ public boolean equals(Object o) { Objects.equals(this.sampleFilename, reportOptions.sampleFilename) && Objects.equals(this.startCommand, reportOptions.startCommand) && Objects.equals(this.startMethod, reportOptions.startMethod) && - Objects.equals(this.timeout, reportOptions.timeout)&& - Objects.equals(this.additionalProperties, reportOptions.additionalProperties); + Objects.equals(this.timeout, reportOptions.timeout); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -428,7 +381,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(archiveEntryPath, extractArchive, guestTargetDirectory, guestWorkingDirectory, netEnable, osProfile, plugins, preset, sampleFilename, startCommand, startMethod, timeout, additionalProperties); + return Objects.hash(archiveEntryPath, extractArchive, guestTargetDirectory, guestWorkingDirectory, netEnable, osProfile, plugins, preset, sampleFilename, startCommand, startMethod, timeout); } private static int hashCodeNullable(JsonNullable a) { @@ -454,7 +407,6 @@ public String toString() { sb.append(" startCommand: ").append(toIndentedString(startCommand)).append("\n"); sb.append(" startMethod: ").append(toIndentedString(startMethod)).append("\n"); sb.append(" timeout: ").append(toIndentedString(timeout)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -464,10 +416,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -491,37 +440,45 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ReportOptions.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ReportOptions is not found in the empty JSON string", ReportOptions.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ReportOptions is not found in the empty JSON string", ReportOptions.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ReportOptions.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ReportOptions` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("archive_entry_path") != null && !jsonObj.get("archive_entry_path").isJsonNull()) && !jsonObj.get("archive_entry_path").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `archive_entry_path` to be a primitive type in the JSON string but got `%s`", jsonObj.get("archive_entry_path").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `archive_entry_path` to be a primitive type in the JSON string but got `%s`", jsonObj.get("archive_entry_path").toString())); } if ((jsonObj.get("guest_target_directory") != null && !jsonObj.get("guest_target_directory").isJsonNull()) && !jsonObj.get("guest_target_directory").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `guest_target_directory` to be a primitive type in the JSON string but got `%s`", jsonObj.get("guest_target_directory").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `guest_target_directory` to be a primitive type in the JSON string but got `%s`", jsonObj.get("guest_target_directory").toString())); } if ((jsonObj.get("guest_working_directory") != null && !jsonObj.get("guest_working_directory").isJsonNull()) && !jsonObj.get("guest_working_directory").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `guest_working_directory` to be a primitive type in the JSON string but got `%s`", jsonObj.get("guest_working_directory").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `guest_working_directory` to be a primitive type in the JSON string but got `%s`", jsonObj.get("guest_working_directory").toString())); } if ((jsonObj.get("os_profile") != null && !jsonObj.get("os_profile").isJsonNull()) && !jsonObj.get("os_profile").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `os_profile` to be a primitive type in the JSON string but got `%s`", jsonObj.get("os_profile").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `os_profile` to be a primitive type in the JSON string but got `%s`", jsonObj.get("os_profile").toString())); } // ensure the optional json data is an array if present if (jsonObj.get("plugins") != null && !jsonObj.get("plugins").isJsonNull() && !jsonObj.get("plugins").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `plugins` to be an array in the JSON string but got `%s`", jsonObj.get("plugins").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `plugins` to be an array in the JSON string but got `%s`", jsonObj.get("plugins").toString())); } if ((jsonObj.get("preset") != null && !jsonObj.get("preset").isJsonNull()) && !jsonObj.get("preset").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `preset` to be a primitive type in the JSON string but got `%s`", jsonObj.get("preset").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `preset` to be a primitive type in the JSON string but got `%s`", jsonObj.get("preset").toString())); } if ((jsonObj.get("sample_filename") != null && !jsonObj.get("sample_filename").isJsonNull()) && !jsonObj.get("sample_filename").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sample_filename` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sample_filename").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sample_filename` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sample_filename").toString())); } if ((jsonObj.get("start_command") != null && !jsonObj.get("start_command").isJsonNull()) && !jsonObj.get("start_command").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `start_command` to be a primitive type in the JSON string but got `%s`", jsonObj.get("start_command").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `start_command` to be a primitive type in the JSON string but got `%s`", jsonObj.get("start_command").toString())); } if ((jsonObj.get("start_method") != null && !jsonObj.get("start_method").isJsonNull()) && !jsonObj.get("start_method").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `start_method` to be a primitive type in the JSON string but got `%s`", jsonObj.get("start_method").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `start_method` to be a primitive type in the JSON string but got `%s`", jsonObj.get("start_method").toString())); } } @@ -540,28 +497,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ReportOptions value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -569,28 +504,7 @@ else if (entry.getValue() instanceof Character) public ReportOptions read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ReportOptions instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SBOM.java b/src/main/java/ai/reveng/model/SBOM.java index 34432e06..3de5aca5 100644 --- a/src/main/java/ai/reveng/model/SBOM.java +++ b/src/main/java/ai/reveng/model/SBOM.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SBOMPackage; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -201,10 +199,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -228,32 +223,32 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SBOM.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SBOM is not found in the empty JSON string", SBOM.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SBOM is not found in the empty JSON string", SBOM.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SBOM.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("packages").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `packages` to be an array in the JSON string but got `%s`", jsonObj.get("packages").toString())); + if (jsonObj.get("packages") != null) { + if (!jsonObj.get("packages").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `packages` to be an array in the JSON string but got `%s`", jsonObj.get("packages").toString())); + } + JsonArray jsonArraypackages = jsonObj.getAsJsonArray("packages"); + // validate the required field `packages` (array) + for (int i = 0; i < jsonArraypackages.size(); i++) { + SBOMPackage.validateJsonElement(jsonArraypackages.get(i)); + } } - - JsonArray jsonArraypackages = jsonObj.getAsJsonArray("packages"); - // validate the required field `packages` (array) - for (int i = 0; i < jsonArraypackages.size(); i++) { - SBOMPackage.validateJsonElement(jsonArraypackages.get(i)); - }; // ensure the required json array is present if (jsonObj.get("imported_libs") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("imported_libs").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `imported_libs` to be an array in the JSON string but got `%s`", jsonObj.get("imported_libs").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `imported_libs` to be an array in the JSON string but got `%s`", jsonObj.get("imported_libs").toString())); } } @@ -314,7 +309,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/SBOMPackage.java b/src/main/java/ai/reveng/model/SBOMPackage.java index 3a6c51f0..d0b3fe30 100644 --- a/src/main/java/ai/reveng/model/SBOMPackage.java +++ b/src/main/java/ai/reveng/model/SBOMPackage.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -182,10 +180,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -209,22 +204,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SBOMPackage.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SBOMPackage is not found in the empty JSON string", SBOMPackage.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SBOMPackage is not found in the empty JSON string", SBOMPackage.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SBOMPackage.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if (!jsonObj.get("version").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("version").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("version").toString())); } } @@ -285,7 +280,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/SandboxOptions.java b/src/main/java/ai/reveng/model/SandboxOptions.java index ba9d206c..45e41a2f 100644 --- a/src/main/java/ai/reveng/model/SandboxOptions.java +++ b/src/main/java/ai/reveng/model/SandboxOptions.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SandboxStartMethod; import ai.reveng.model.SandboxTimeout; import com.google.gson.TypeAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -72,7 +70,7 @@ public class SandboxOptions { public static final String SERIALIZED_NAME_TIMEOUT = "timeout"; @SerializedName(SERIALIZED_NAME_TIMEOUT) @javax.annotation.Nullable - private SandboxTimeout timeout; + private SandboxTimeout timeout = SandboxTimeout.NUMBER_120; public SandboxOptions() { } @@ -121,7 +119,7 @@ public SandboxOptions startMethod(@javax.annotation.Nullable SandboxStartMethod } /** - * Get startMethod + * The method used by the sandbox to launch the sample. * @return startMethod */ @javax.annotation.Nullable @@ -248,10 +246,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -275,12 +270,12 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SandboxOptions.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SandboxOptions is not found in the empty JSON string", SandboxOptions.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SandboxOptions is not found in the empty JSON string", SandboxOptions.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("command_line_args") != null && !jsonObj.get("command_line_args").isJsonNull()) && !jsonObj.get("command_line_args").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `command_line_args` to be a primitive type in the JSON string but got `%s`", jsonObj.get("command_line_args").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `command_line_args` to be a primitive type in the JSON string but got `%s`", jsonObj.get("command_line_args").toString())); } // validate the optional field `start_method` if (jsonObj.get("start_method") != null && !jsonObj.get("start_method").isJsonNull()) { @@ -349,7 +344,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/SandboxStartMethod.java b/src/main/java/ai/reveng/model/SandboxStartMethod.java index 8b26b853..3dc96419 100644 --- a/src/main/java/ai/reveng/model/SandboxStartMethod.java +++ b/src/main/java/ai/reveng/model/SandboxStartMethod.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/SandboxTimeout.java b/src/main/java/ai/reveng/model/SandboxTimeout.java index 8d2aedbc..8c397022 100644 --- a/src/main/java/ai/reveng/model/SandboxTimeout.java +++ b/src/main/java/ai/reveng/model/SandboxTimeout.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/ScheduledTaskEntry.java b/src/main/java/ai/reveng/model/ScheduledTaskEntry.java index 0fdc9e49..1b2325ba 100644 --- a/src/main/java/ai/reveng/model/ScheduledTaskEntry.java +++ b/src/main/java/ai/reveng/model/ScheduledTaskEntry.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ReportEvent; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -329,50 +327,6 @@ public void setTaskName(@javax.annotation.Nullable String taskName) { this.taskName = taskName; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ScheduledTaskEntry instance itself - */ - public ScheduledTaskEntry putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -394,8 +348,7 @@ public boolean equals(Object o) { Objects.equals(this.scheduleType, scheduledTaskEntry.scheduleType) && Objects.equals(this.startDate, scheduledTaskEntry.startDate) && Objects.equals(this.startTime, scheduledTaskEntry.startTime) && - Objects.equals(this.taskName, scheduledTaskEntry.taskName)&& - Objects.equals(this.additionalProperties, scheduledTaskEntry.additionalProperties); + Objects.equals(this.taskName, scheduledTaskEntry.taskName); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -404,7 +357,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(command, day, endDate, events, executable, modifier, runAs, scheduleType, startDate, startTime, taskName, additionalProperties); + return Objects.hash(command, day, endDate, events, executable, modifier, runAs, scheduleType, startDate, startTime, taskName); } private static int hashCodeNullable(JsonNullable a) { @@ -429,7 +382,6 @@ public String toString() { sb.append(" startDate: ").append(toIndentedString(startDate)).append("\n"); sb.append(" startTime: ").append(toIndentedString(startTime)).append("\n"); sb.append(" taskName: ").append(toIndentedString(taskName)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -439,10 +391,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -466,43 +415,61 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ScheduledTaskEntry.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ScheduledTaskEntry is not found in the empty JSON string", ScheduledTaskEntry.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ScheduledTaskEntry is not found in the empty JSON string", ScheduledTaskEntry.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ScheduledTaskEntry.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ScheduledTaskEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("command") != null && !jsonObj.get("command").isJsonNull()) && !jsonObj.get("command").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `command` to be a primitive type in the JSON string but got `%s`", jsonObj.get("command").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `command` to be a primitive type in the JSON string but got `%s`", jsonObj.get("command").toString())); } if ((jsonObj.get("day") != null && !jsonObj.get("day").isJsonNull()) && !jsonObj.get("day").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `day` to be a primitive type in the JSON string but got `%s`", jsonObj.get("day").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `day` to be a primitive type in the JSON string but got `%s`", jsonObj.get("day").toString())); } if ((jsonObj.get("end_date") != null && !jsonObj.get("end_date").isJsonNull()) && !jsonObj.get("end_date").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `end_date` to be a primitive type in the JSON string but got `%s`", jsonObj.get("end_date").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `end_date` to be a primitive type in the JSON string but got `%s`", jsonObj.get("end_date").toString())); } - // ensure the optional json data is an array if present - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull() && !jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { + JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); + if (jsonArrayevents != null) { + // ensure the json data is an array + if (!jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + } + + // validate the optional field `events` (array) + for (int i = 0; i < jsonArrayevents.size(); i++) { + ReportEvent.validateJsonElement(jsonArrayevents.get(i)); + }; + } } if ((jsonObj.get("executable") != null && !jsonObj.get("executable").isJsonNull()) && !jsonObj.get("executable").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `executable` to be a primitive type in the JSON string but got `%s`", jsonObj.get("executable").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `executable` to be a primitive type in the JSON string but got `%s`", jsonObj.get("executable").toString())); } if ((jsonObj.get("modifier") != null && !jsonObj.get("modifier").isJsonNull()) && !jsonObj.get("modifier").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `modifier` to be a primitive type in the JSON string but got `%s`", jsonObj.get("modifier").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `modifier` to be a primitive type in the JSON string but got `%s`", jsonObj.get("modifier").toString())); } if ((jsonObj.get("run_as") != null && !jsonObj.get("run_as").isJsonNull()) && !jsonObj.get("run_as").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `run_as` to be a primitive type in the JSON string but got `%s`", jsonObj.get("run_as").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `run_as` to be a primitive type in the JSON string but got `%s`", jsonObj.get("run_as").toString())); } if ((jsonObj.get("schedule_type") != null && !jsonObj.get("schedule_type").isJsonNull()) && !jsonObj.get("schedule_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `schedule_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("schedule_type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `schedule_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("schedule_type").toString())); } if ((jsonObj.get("start_date") != null && !jsonObj.get("start_date").isJsonNull()) && !jsonObj.get("start_date").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `start_date` to be a primitive type in the JSON string but got `%s`", jsonObj.get("start_date").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `start_date` to be a primitive type in the JSON string but got `%s`", jsonObj.get("start_date").toString())); } if ((jsonObj.get("start_time") != null && !jsonObj.get("start_time").isJsonNull()) && !jsonObj.get("start_time").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `start_time` to be a primitive type in the JSON string but got `%s`", jsonObj.get("start_time").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `start_time` to be a primitive type in the JSON string but got `%s`", jsonObj.get("start_time").toString())); } if ((jsonObj.get("task_name") != null && !jsonObj.get("task_name").isJsonNull()) && !jsonObj.get("task_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `task_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("task_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `task_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("task_name").toString())); } } @@ -521,28 +488,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ScheduledTaskEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -550,28 +495,7 @@ else if (entry.getValue() instanceof Character) public ScheduledTaskEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ScheduledTaskEntry instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/ScrapeThirdPartyConfig.java b/src/main/java/ai/reveng/model/ScrapeThirdPartyConfig.java index 42a5314f..0549e4d5 100644 --- a/src/main/java/ai/reveng/model/ScrapeThirdPartyConfig.java +++ b/src/main/java/ai/reveng/model/ScrapeThirdPartyConfig.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -156,10 +154,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,7 +178,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ScrapeThirdPartyConfig.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ScrapeThirdPartyConfig is not found in the empty JSON string", ScrapeThirdPartyConfig.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ScrapeThirdPartyConfig is not found in the empty JSON string", ScrapeThirdPartyConfig.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -246,7 +241,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/SectionModel.java b/src/main/java/ai/reveng/model/SectionModel.java index 4d2bf65a..8663e76f 100644 --- a/src/main/java/ai/reveng/model/SectionModel.java +++ b/src/main/java/ai/reveng/model/SectionModel.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SingleSectionModel; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -193,10 +191,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -220,27 +215,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SectionModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SectionModel is not found in the empty JSON string", SectionModel.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SectionModel is not found in the empty JSON string", SectionModel.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SectionModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("sections").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sections` to be an array in the JSON string but got `%s`", jsonObj.get("sections").toString())); + if (jsonObj.get("sections") != null) { + if (!jsonObj.get("sections").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sections` to be an array in the JSON string but got `%s`", jsonObj.get("sections").toString())); + } + JsonArray jsonArraysections = jsonObj.getAsJsonArray("sections"); + // validate the required field `sections` (array) + for (int i = 0; i < jsonArraysections.size(); i++) { + SingleSectionModel.validateJsonElement(jsonArraysections.get(i)); + } } - - JsonArray jsonArraysections = jsonObj.getAsJsonArray("sections"); - // validate the required field `sections` (array) - for (int i = 0; i < jsonArraysections.size(); i++) { - SingleSectionModel.validateJsonElement(jsonArraysections.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -300,7 +295,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/SecurityModel.java b/src/main/java/ai/reveng/model/SecurityModel.java index b3c269d7..ac032e90 100644 --- a/src/main/java/ai/reveng/model/SecurityModel.java +++ b/src/main/java/ai/reveng/model/SecurityModel.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -416,10 +414,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -443,14 +438,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SecurityModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SecurityModel is not found in the empty JSON string", SecurityModel.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SecurityModel is not found in the empty JSON string", SecurityModel.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SecurityModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -513,7 +508,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/SegmentInfo.java b/src/main/java/ai/reveng/model/SegmentInfo.java index ab45090f..b6e66ee8 100644 --- a/src/main/java/ai/reveng/model/SegmentInfo.java +++ b/src/main/java/ai/reveng/model/SegmentInfo.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -298,10 +296,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -325,12 +320,12 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SegmentInfo.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SegmentInfo is not found in the empty JSON string", SegmentInfo.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SegmentInfo is not found in the empty JSON string", SegmentInfo.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } } @@ -391,7 +386,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/SendMessageRequest.java b/src/main/java/ai/reveng/model/SendMessageRequest.java index 45b680c8..1def1d06 100644 --- a/src/main/java/ai/reveng/model/SendMessageRequest.java +++ b/src/main/java/ai/reveng/model/SendMessageRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ConversationContext; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -102,50 +100,6 @@ public void setContext(@javax.annotation.Nullable ConversationContext context) { this.context = context; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the SendMessageRequest instance itself - */ - public SendMessageRequest putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -158,13 +112,12 @@ public boolean equals(Object o) { } SendMessageRequest sendMessageRequest = (SendMessageRequest) o; return Objects.equals(this.content, sendMessageRequest.content) && - Objects.equals(this.context, sendMessageRequest.context)&& - Objects.equals(this.additionalProperties, sendMessageRequest.additionalProperties); + Objects.equals(this.context, sendMessageRequest.context); } @Override public int hashCode() { - return Objects.hash(content, context, additionalProperties); + return Objects.hash(content, context); } @Override @@ -173,7 +126,6 @@ public String toString() { sb.append("class SendMessageRequest {\n"); sb.append(" content: ").append(toIndentedString(content)).append("\n"); sb.append(" context: ").append(toIndentedString(context)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -183,10 +135,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -210,19 +159,31 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SendMessageRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SendMessageRequest is not found in the empty JSON string", SendMessageRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SendMessageRequest is not found in the empty JSON string", SendMessageRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SendMessageRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SendMessageRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SendMessageRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("content").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `content` to be a primitive type in the JSON string but got `%s`", jsonObj.get("content").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `content` to be a primitive type in the JSON string but got `%s`", jsonObj.get("content").toString())); + } + // validate the optional field `context` + if (jsonObj.get("context") != null && !jsonObj.get("context").isJsonNull()) { + ConversationContext.validateJsonElement(jsonObj.get("context")); } } @@ -241,28 +202,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SendMessageRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -270,28 +209,7 @@ else if (entry.getValue() instanceof Character) public SendMessageRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - SendMessageRequest instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/StreamEvents200ResponseInner.java b/src/main/java/ai/reveng/model/ServerSentEventsInner.java similarity index 85% rename from src/main/java/ai/reveng/model/StreamEvents200ResponseInner.java rename to src/main/java/ai/reveng/model/ServerSentEventsInner.java index f544127a..4b18a69b 100644 --- a/src/main/java/ai/reveng/model/StreamEvents200ResponseInner.java +++ b/src/main/java/ai/reveng/model/ServerSentEventsInner.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.EventCONTEXTCOMPACTED; import ai.reveng.model.EventRUNCANCELLED; import ai.reveng.model.EventRUNERROR; @@ -51,7 +50,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Locale; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -76,15 +74,15 @@ import ai.reveng.invoker.JSON; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class StreamEvents200ResponseInner extends AbstractOpenApiSchema { - private static final Logger log = Logger.getLogger(StreamEvents200ResponseInner.class.getName()); +public class ServerSentEventsInner extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(ServerSentEventsInner.class.getName()); public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!StreamEvents200ResponseInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'StreamEvents200ResponseInner' and its subtypes + if (!ServerSentEventsInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ServerSentEventsInner' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); final TypeAdapter adapterEventCONTEXTCOMPACTED = gson.getDelegateAdapter(this, TypeToken.get(EventCONTEXTCOMPACTED.class)); @@ -104,9 +102,9 @@ public TypeAdapter create(Gson gson, TypeToken type) { final TypeAdapter adapterEventTOOLCALLSTART = gson.getDelegateAdapter(this, TypeToken.get(EventTOOLCALLSTART.class)); final TypeAdapter adapterEventTOOLCONFIRMATIONREQUIRED = gson.getDelegateAdapter(this, TypeToken.get(EventTOOLCONFIRMATIONREQUIRED.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, StreamEvents200ResponseInner value) throws IOException { + public void write(JsonWriter out, ServerSentEventsInner value) throws IOException { if (value == null || value.getActualInstance() == null) { elementAdapter.write(out, null); return; @@ -212,7 +210,7 @@ public void write(JsonWriter out, StreamEvents200ResponseInner value) throws IOE } @Override - public StreamEvents200ResponseInner read(JsonReader in) throws IOException { + public ServerSentEventsInner read(JsonReader in) throws IOException { Object deserialized = null; JsonElement jsonElement = elementAdapter.read(in); @@ -229,7 +227,7 @@ public StreamEvents200ResponseInner read(JsonReader in) throws IOException { log.log(Level.FINER, "Input data matches schema 'EventCONTEXTCOMPACTED'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventCONTEXTCOMPACTED failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventCONTEXTCOMPACTED failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventCONTEXTCOMPACTED'", e); } // deserialize EventRUNCANCELLED @@ -241,7 +239,7 @@ public StreamEvents200ResponseInner read(JsonReader in) throws IOException { log.log(Level.FINER, "Input data matches schema 'EventRUNCANCELLED'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventRUNCANCELLED failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventRUNCANCELLED failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventRUNCANCELLED'", e); } // deserialize EventRUNERROR @@ -253,7 +251,7 @@ public StreamEvents200ResponseInner read(JsonReader in) throws IOException { log.log(Level.FINER, "Input data matches schema 'EventRUNERROR'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventRUNERROR failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventRUNERROR failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventRUNERROR'", e); } // deserialize EventRUNFINISHED @@ -265,7 +263,7 @@ public StreamEvents200ResponseInner read(JsonReader in) throws IOException { log.log(Level.FINER, "Input data matches schema 'EventRUNFINISHED'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventRUNFINISHED failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventRUNFINISHED failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventRUNFINISHED'", e); } // deserialize EventRUNSTARTED @@ -277,7 +275,7 @@ public StreamEvents200ResponseInner read(JsonReader in) throws IOException { log.log(Level.FINER, "Input data matches schema 'EventRUNSTARTED'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventRUNSTARTED failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventRUNSTARTED failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventRUNSTARTED'", e); } // deserialize EventSTEPFINISHED @@ -289,7 +287,7 @@ public StreamEvents200ResponseInner read(JsonReader in) throws IOException { log.log(Level.FINER, "Input data matches schema 'EventSTEPFINISHED'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventSTEPFINISHED failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventSTEPFINISHED failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventSTEPFINISHED'", e); } // deserialize EventSTEPSTARTED @@ -301,7 +299,7 @@ public StreamEvents200ResponseInner read(JsonReader in) throws IOException { log.log(Level.FINER, "Input data matches schema 'EventSTEPSTARTED'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventSTEPSTARTED failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventSTEPSTARTED failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventSTEPSTARTED'", e); } // deserialize EventTEXTMESSAGECONTENT @@ -313,7 +311,7 @@ public StreamEvents200ResponseInner read(JsonReader in) throws IOException { log.log(Level.FINER, "Input data matches schema 'EventTEXTMESSAGECONTENT'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventTEXTMESSAGECONTENT failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventTEXTMESSAGECONTENT failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventTEXTMESSAGECONTENT'", e); } // deserialize EventTEXTMESSAGEEND @@ -325,7 +323,7 @@ public StreamEvents200ResponseInner read(JsonReader in) throws IOException { log.log(Level.FINER, "Input data matches schema 'EventTEXTMESSAGEEND'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventTEXTMESSAGEEND failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventTEXTMESSAGEEND failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventTEXTMESSAGEEND'", e); } // deserialize EventTEXTMESSAGESTART @@ -337,7 +335,7 @@ public StreamEvents200ResponseInner read(JsonReader in) throws IOException { log.log(Level.FINER, "Input data matches schema 'EventTEXTMESSAGESTART'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventTEXTMESSAGESTART failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventTEXTMESSAGESTART failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventTEXTMESSAGESTART'", e); } // deserialize EventTITLEUPDATED @@ -349,7 +347,7 @@ public StreamEvents200ResponseInner read(JsonReader in) throws IOException { log.log(Level.FINER, "Input data matches schema 'EventTITLEUPDATED'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventTITLEUPDATED failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventTITLEUPDATED failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventTITLEUPDATED'", e); } // deserialize EventTOOLCALLARGSDELTA @@ -361,7 +359,7 @@ public StreamEvents200ResponseInner read(JsonReader in) throws IOException { log.log(Level.FINER, "Input data matches schema 'EventTOOLCALLARGSDELTA'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventTOOLCALLARGSDELTA failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventTOOLCALLARGSDELTA failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventTOOLCALLARGSDELTA'", e); } // deserialize EventTOOLCALLEND @@ -373,7 +371,7 @@ public StreamEvents200ResponseInner read(JsonReader in) throws IOException { log.log(Level.FINER, "Input data matches schema 'EventTOOLCALLEND'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventTOOLCALLEND failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventTOOLCALLEND failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventTOOLCALLEND'", e); } // deserialize EventTOOLCALLRESULT @@ -385,7 +383,7 @@ public StreamEvents200ResponseInner read(JsonReader in) throws IOException { log.log(Level.FINER, "Input data matches schema 'EventTOOLCALLRESULT'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventTOOLCALLRESULT failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventTOOLCALLRESULT failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventTOOLCALLRESULT'", e); } // deserialize EventTOOLCALLSTART @@ -397,7 +395,7 @@ public StreamEvents200ResponseInner read(JsonReader in) throws IOException { log.log(Level.FINER, "Input data matches schema 'EventTOOLCALLSTART'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventTOOLCALLSTART failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventTOOLCALLSTART failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventTOOLCALLSTART'", e); } // deserialize EventTOOLCONFIRMATIONREQUIRED @@ -409,17 +407,17 @@ public StreamEvents200ResponseInner read(JsonReader in) throws IOException { log.log(Level.FINER, "Input data matches schema 'EventTOOLCONFIRMATIONREQUIRED'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventTOOLCONFIRMATIONREQUIRED failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventTOOLCONFIRMATIONREQUIRED failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventTOOLCONFIRMATIONREQUIRED'", e); } if (match == 1) { - StreamEvents200ResponseInner ret = new StreamEvents200ResponseInner(); + ServerSentEventsInner ret = new ServerSentEventsInner(); ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); return ret; } - throw new IOException(String.format(Locale.ROOT, "Failed deserialization for StreamEvents200ResponseInner: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonElement.toString())); + throw new IOException(String.format(java.util.Locale.ROOT, "Failed deserialization for ServerSentEventsInner: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonElement.toString())); } }.nullSafe(); } @@ -428,11 +426,11 @@ public StreamEvents200ResponseInner read(JsonReader in) throws IOException { // store a list of schema names defined in oneOf public static final Map> schemas = new HashMap>(); - public StreamEvents200ResponseInner() { + public ServerSentEventsInner() { super("oneOf", Boolean.FALSE); } - public StreamEvents200ResponseInner(Object o) { + public ServerSentEventsInner(Object o) { super("oneOf", Boolean.FALSE); setActualInstance(o); } @@ -458,7 +456,7 @@ public StreamEvents200ResponseInner(Object o) { @Override public Map> getSchemas() { - return StreamEvents200ResponseInner.schemas; + return ServerSentEventsInner.schemas; } /** @@ -572,6 +570,7 @@ public Object getActualInstance() { * @return The actual instance of `EventCONTEXTCOMPACTED` * @throws ClassCastException if the instance is not `EventCONTEXTCOMPACTED` */ + @SuppressWarnings("unchecked") public EventCONTEXTCOMPACTED getEventCONTEXTCOMPACTED() throws ClassCastException { return (EventCONTEXTCOMPACTED)super.getActualInstance(); } @@ -583,6 +582,7 @@ public EventCONTEXTCOMPACTED getEventCONTEXTCOMPACTED() throws ClassCastExceptio * @return The actual instance of `EventRUNCANCELLED` * @throws ClassCastException if the instance is not `EventRUNCANCELLED` */ + @SuppressWarnings("unchecked") public EventRUNCANCELLED getEventRUNCANCELLED() throws ClassCastException { return (EventRUNCANCELLED)super.getActualInstance(); } @@ -594,6 +594,7 @@ public EventRUNCANCELLED getEventRUNCANCELLED() throws ClassCastException { * @return The actual instance of `EventRUNERROR` * @throws ClassCastException if the instance is not `EventRUNERROR` */ + @SuppressWarnings("unchecked") public EventRUNERROR getEventRUNERROR() throws ClassCastException { return (EventRUNERROR)super.getActualInstance(); } @@ -605,6 +606,7 @@ public EventRUNERROR getEventRUNERROR() throws ClassCastException { * @return The actual instance of `EventRUNFINISHED` * @throws ClassCastException if the instance is not `EventRUNFINISHED` */ + @SuppressWarnings("unchecked") public EventRUNFINISHED getEventRUNFINISHED() throws ClassCastException { return (EventRUNFINISHED)super.getActualInstance(); } @@ -616,6 +618,7 @@ public EventRUNFINISHED getEventRUNFINISHED() throws ClassCastException { * @return The actual instance of `EventRUNSTARTED` * @throws ClassCastException if the instance is not `EventRUNSTARTED` */ + @SuppressWarnings("unchecked") public EventRUNSTARTED getEventRUNSTARTED() throws ClassCastException { return (EventRUNSTARTED)super.getActualInstance(); } @@ -627,6 +630,7 @@ public EventRUNSTARTED getEventRUNSTARTED() throws ClassCastException { * @return The actual instance of `EventSTEPFINISHED` * @throws ClassCastException if the instance is not `EventSTEPFINISHED` */ + @SuppressWarnings("unchecked") public EventSTEPFINISHED getEventSTEPFINISHED() throws ClassCastException { return (EventSTEPFINISHED)super.getActualInstance(); } @@ -638,6 +642,7 @@ public EventSTEPFINISHED getEventSTEPFINISHED() throws ClassCastException { * @return The actual instance of `EventSTEPSTARTED` * @throws ClassCastException if the instance is not `EventSTEPSTARTED` */ + @SuppressWarnings("unchecked") public EventSTEPSTARTED getEventSTEPSTARTED() throws ClassCastException { return (EventSTEPSTARTED)super.getActualInstance(); } @@ -649,6 +654,7 @@ public EventSTEPSTARTED getEventSTEPSTARTED() throws ClassCastException { * @return The actual instance of `EventTEXTMESSAGECONTENT` * @throws ClassCastException if the instance is not `EventTEXTMESSAGECONTENT` */ + @SuppressWarnings("unchecked") public EventTEXTMESSAGECONTENT getEventTEXTMESSAGECONTENT() throws ClassCastException { return (EventTEXTMESSAGECONTENT)super.getActualInstance(); } @@ -660,6 +666,7 @@ public EventTEXTMESSAGECONTENT getEventTEXTMESSAGECONTENT() throws ClassCastExce * @return The actual instance of `EventTEXTMESSAGEEND` * @throws ClassCastException if the instance is not `EventTEXTMESSAGEEND` */ + @SuppressWarnings("unchecked") public EventTEXTMESSAGEEND getEventTEXTMESSAGEEND() throws ClassCastException { return (EventTEXTMESSAGEEND)super.getActualInstance(); } @@ -671,6 +678,7 @@ public EventTEXTMESSAGEEND getEventTEXTMESSAGEEND() throws ClassCastException { * @return The actual instance of `EventTEXTMESSAGESTART` * @throws ClassCastException if the instance is not `EventTEXTMESSAGESTART` */ + @SuppressWarnings("unchecked") public EventTEXTMESSAGESTART getEventTEXTMESSAGESTART() throws ClassCastException { return (EventTEXTMESSAGESTART)super.getActualInstance(); } @@ -682,6 +690,7 @@ public EventTEXTMESSAGESTART getEventTEXTMESSAGESTART() throws ClassCastExceptio * @return The actual instance of `EventTITLEUPDATED` * @throws ClassCastException if the instance is not `EventTITLEUPDATED` */ + @SuppressWarnings("unchecked") public EventTITLEUPDATED getEventTITLEUPDATED() throws ClassCastException { return (EventTITLEUPDATED)super.getActualInstance(); } @@ -693,6 +702,7 @@ public EventTITLEUPDATED getEventTITLEUPDATED() throws ClassCastException { * @return The actual instance of `EventTOOLCALLARGSDELTA` * @throws ClassCastException if the instance is not `EventTOOLCALLARGSDELTA` */ + @SuppressWarnings("unchecked") public EventTOOLCALLARGSDELTA getEventTOOLCALLARGSDELTA() throws ClassCastException { return (EventTOOLCALLARGSDELTA)super.getActualInstance(); } @@ -704,6 +714,7 @@ public EventTOOLCALLARGSDELTA getEventTOOLCALLARGSDELTA() throws ClassCastExcept * @return The actual instance of `EventTOOLCALLEND` * @throws ClassCastException if the instance is not `EventTOOLCALLEND` */ + @SuppressWarnings("unchecked") public EventTOOLCALLEND getEventTOOLCALLEND() throws ClassCastException { return (EventTOOLCALLEND)super.getActualInstance(); } @@ -715,6 +726,7 @@ public EventTOOLCALLEND getEventTOOLCALLEND() throws ClassCastException { * @return The actual instance of `EventTOOLCALLRESULT` * @throws ClassCastException if the instance is not `EventTOOLCALLRESULT` */ + @SuppressWarnings("unchecked") public EventTOOLCALLRESULT getEventTOOLCALLRESULT() throws ClassCastException { return (EventTOOLCALLRESULT)super.getActualInstance(); } @@ -726,6 +738,7 @@ public EventTOOLCALLRESULT getEventTOOLCALLRESULT() throws ClassCastException { * @return The actual instance of `EventTOOLCALLSTART` * @throws ClassCastException if the instance is not `EventTOOLCALLSTART` */ + @SuppressWarnings("unchecked") public EventTOOLCALLSTART getEventTOOLCALLSTART() throws ClassCastException { return (EventTOOLCALLSTART)super.getActualInstance(); } @@ -737,6 +750,7 @@ public EventTOOLCALLSTART getEventTOOLCALLSTART() throws ClassCastException { * @return The actual instance of `EventTOOLCONFIRMATIONREQUIRED` * @throws ClassCastException if the instance is not `EventTOOLCONFIRMATIONREQUIRED` */ + @SuppressWarnings("unchecked") public EventTOOLCONFIRMATIONREQUIRED getEventTOOLCONFIRMATIONREQUIRED() throws ClassCastException { return (EventTOOLCONFIRMATIONREQUIRED)super.getActualInstance(); } @@ -745,7 +759,7 @@ public EventTOOLCONFIRMATIONREQUIRED getEventTOOLCONFIRMATIONREQUIRED() throws C * Validates the JSON Element and throws an exception if issues found * * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to StreamEvents200ResponseInner + * @throws IOException if the JSON Element is invalid with respect to ServerSentEventsInner */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { // validate oneOf schemas one by one @@ -756,7 +770,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventCONTEXTCOMPACTED.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventCONTEXTCOMPACTED failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventCONTEXTCOMPACTED failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventRUNCANCELLED @@ -764,7 +778,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventRUNCANCELLED.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventRUNCANCELLED failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventRUNCANCELLED failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventRUNERROR @@ -772,7 +786,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventRUNERROR.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventRUNERROR failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventRUNERROR failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventRUNFINISHED @@ -780,7 +794,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventRUNFINISHED.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventRUNFINISHED failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventRUNFINISHED failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventRUNSTARTED @@ -788,7 +802,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventRUNSTARTED.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventRUNSTARTED failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventRUNSTARTED failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventSTEPFINISHED @@ -796,7 +810,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventSTEPFINISHED.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventSTEPFINISHED failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventSTEPFINISHED failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventSTEPSTARTED @@ -804,7 +818,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventSTEPSTARTED.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventSTEPSTARTED failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventSTEPSTARTED failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventTEXTMESSAGECONTENT @@ -812,7 +826,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventTEXTMESSAGECONTENT.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventTEXTMESSAGECONTENT failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventTEXTMESSAGECONTENT failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventTEXTMESSAGEEND @@ -820,7 +834,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventTEXTMESSAGEEND.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventTEXTMESSAGEEND failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventTEXTMESSAGEEND failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventTEXTMESSAGESTART @@ -828,7 +842,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventTEXTMESSAGESTART.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventTEXTMESSAGESTART failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventTEXTMESSAGESTART failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventTITLEUPDATED @@ -836,7 +850,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventTITLEUPDATED.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventTITLEUPDATED failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventTITLEUPDATED failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventTOOLCALLARGSDELTA @@ -844,7 +858,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventTOOLCALLARGSDELTA.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventTOOLCALLARGSDELTA failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventTOOLCALLARGSDELTA failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventTOOLCALLEND @@ -852,7 +866,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventTOOLCALLEND.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventTOOLCALLEND failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventTOOLCALLEND failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventTOOLCALLRESULT @@ -860,7 +874,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventTOOLCALLRESULT.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventTOOLCALLRESULT failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventTOOLCALLRESULT failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventTOOLCALLSTART @@ -868,7 +882,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventTOOLCALLSTART.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventTOOLCALLSTART failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventTOOLCALLSTART failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventTOOLCONFIRMATIONREQUIRED @@ -876,27 +890,27 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventTOOLCONFIRMATIONREQUIRED.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventTOOLCONFIRMATIONREQUIRED failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventTOOLCONFIRMATIONREQUIRED failed with `%s`.", e.getMessage())); // continue to the next one } if (validCount != 1) { - throw new IOException(String.format(Locale.ROOT, "The JSON string is invalid for StreamEvents200ResponseInner with oneOf schemas: EventCONTEXTCOMPACTED, EventRUNCANCELLED, EventRUNERROR, EventRUNFINISHED, EventRUNSTARTED, EventSTEPFINISHED, EventSTEPSTARTED, EventTEXTMESSAGECONTENT, EventTEXTMESSAGEEND, EventTEXTMESSAGESTART, EventTITLEUPDATED, EventTOOLCALLARGSDELTA, EventTOOLCALLEND, EventTOOLCALLRESULT, EventTOOLCALLSTART, EventTOOLCONFIRMATIONREQUIRED. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonElement.toString())); + throw new IOException(String.format(java.util.Locale.ROOT, "The JSON string is invalid for ServerSentEventsInner with oneOf schemas: EventCONTEXTCOMPACTED, EventRUNCANCELLED, EventRUNERROR, EventRUNFINISHED, EventRUNSTARTED, EventSTEPFINISHED, EventSTEPSTARTED, EventTEXTMESSAGECONTENT, EventTEXTMESSAGEEND, EventTEXTMESSAGESTART, EventTITLEUPDATED, EventTOOLCALLARGSDELTA, EventTOOLCALLEND, EventTOOLCALLRESULT, EventTOOLCALLSTART, EventTOOLCONFIRMATIONREQUIRED. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonElement.toString())); } } /** - * Create an instance of StreamEvents200ResponseInner given an JSON string + * Create an instance of ServerSentEventsInner given an JSON string * * @param jsonString JSON string - * @return An instance of StreamEvents200ResponseInner - * @throws IOException if the JSON string is invalid with respect to StreamEvents200ResponseInner + * @return An instance of ServerSentEventsInner + * @throws IOException if the JSON string is invalid with respect to ServerSentEventsInner */ - public static StreamEvents200ResponseInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, StreamEvents200ResponseInner.class); + public static ServerSentEventsInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ServerSentEventsInner.class); } /** - * Convert an instance of StreamEvents200ResponseInner to an JSON string + * Convert an instance of ServerSentEventsInner to an JSON string * * @return JSON string */ diff --git a/src/main/java/ai/reveng/model/StreamAiDecompilation200ResponseInner.java b/src/main/java/ai/reveng/model/ServerSentEventsInner1.java similarity index 83% rename from src/main/java/ai/reveng/model/StreamAiDecompilation200ResponseInner.java rename to src/main/java/ai/reveng/model/ServerSentEventsInner1.java index 9b90505d..74f47afb 100644 --- a/src/main/java/ai/reveng/model/StreamAiDecompilation200ResponseInner.java +++ b/src/main/java/ai/reveng/model/ServerSentEventsInner1.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.EventAttemptFailed; import ai.reveng.model.EventAttemptStarted; import ai.reveng.model.EventDecompFailed; @@ -44,7 +43,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Locale; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -69,15 +67,15 @@ import ai.reveng.invoker.JSON; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class StreamAiDecompilation200ResponseInner extends AbstractOpenApiSchema { - private static final Logger log = Logger.getLogger(StreamAiDecompilation200ResponseInner.class.getName()); +public class ServerSentEventsInner1 extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(ServerSentEventsInner1.class.getName()); public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!StreamAiDecompilation200ResponseInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'StreamAiDecompilation200ResponseInner' and its subtypes + if (!ServerSentEventsInner1.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ServerSentEventsInner1' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); final TypeAdapter adapterEventAttemptFailed = gson.getDelegateAdapter(this, TypeToken.get(EventAttemptFailed.class)); @@ -90,9 +88,9 @@ public TypeAdapter create(Gson gson, TypeToken type) { final TypeAdapter adapterEventSourceReset = gson.getDelegateAdapter(this, TypeToken.get(EventSourceReset.class)); final TypeAdapter adapterEventWarning = gson.getDelegateAdapter(this, TypeToken.get(EventWarning.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, StreamAiDecompilation200ResponseInner value) throws IOException { + public void write(JsonWriter out, ServerSentEventsInner1 value) throws IOException { if (value == null || value.getActualInstance() == null) { elementAdapter.write(out, null); return; @@ -156,7 +154,7 @@ public void write(JsonWriter out, StreamAiDecompilation200ResponseInner value) t } @Override - public StreamAiDecompilation200ResponseInner read(JsonReader in) throws IOException { + public ServerSentEventsInner1 read(JsonReader in) throws IOException { Object deserialized = null; JsonElement jsonElement = elementAdapter.read(in); @@ -173,7 +171,7 @@ public StreamAiDecompilation200ResponseInner read(JsonReader in) throws IOExcept log.log(Level.FINER, "Input data matches schema 'EventAttemptFailed'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventAttemptFailed failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventAttemptFailed failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventAttemptFailed'", e); } // deserialize EventAttemptStarted @@ -185,7 +183,7 @@ public StreamAiDecompilation200ResponseInner read(JsonReader in) throws IOExcept log.log(Level.FINER, "Input data matches schema 'EventAttemptStarted'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventAttemptStarted failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventAttemptStarted failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventAttemptStarted'", e); } // deserialize EventDecompFailed @@ -197,7 +195,7 @@ public StreamAiDecompilation200ResponseInner read(JsonReader in) throws IOExcept log.log(Level.FINER, "Input data matches schema 'EventDecompFailed'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventDecompFailed failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventDecompFailed failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventDecompFailed'", e); } // deserialize EventDecompFinished @@ -209,7 +207,7 @@ public StreamAiDecompilation200ResponseInner read(JsonReader in) throws IOExcept log.log(Level.FINER, "Input data matches schema 'EventDecompFinished'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventDecompFinished failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventDecompFinished failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventDecompFinished'", e); } // deserialize EventProse @@ -221,7 +219,7 @@ public StreamAiDecompilation200ResponseInner read(JsonReader in) throws IOExcept log.log(Level.FINER, "Input data matches schema 'EventProse'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventProse failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventProse failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventProse'", e); } // deserialize EventRenameApplied @@ -233,7 +231,7 @@ public StreamAiDecompilation200ResponseInner read(JsonReader in) throws IOExcept log.log(Level.FINER, "Input data matches schema 'EventRenameApplied'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventRenameApplied failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventRenameApplied failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventRenameApplied'", e); } // deserialize EventSourceDelta @@ -245,7 +243,7 @@ public StreamAiDecompilation200ResponseInner read(JsonReader in) throws IOExcept log.log(Level.FINER, "Input data matches schema 'EventSourceDelta'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventSourceDelta failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventSourceDelta failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventSourceDelta'", e); } // deserialize EventSourceReset @@ -257,7 +255,7 @@ public StreamAiDecompilation200ResponseInner read(JsonReader in) throws IOExcept log.log(Level.FINER, "Input data matches schema 'EventSourceReset'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventSourceReset failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventSourceReset failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventSourceReset'", e); } // deserialize EventWarning @@ -269,17 +267,17 @@ public StreamAiDecompilation200ResponseInner read(JsonReader in) throws IOExcept log.log(Level.FINER, "Input data matches schema 'EventWarning'"); } catch (Exception e) { // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventWarning failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventWarning failed with `%s`.", e.getMessage())); log.log(Level.FINER, "Input data does not match schema 'EventWarning'", e); } if (match == 1) { - StreamAiDecompilation200ResponseInner ret = new StreamAiDecompilation200ResponseInner(); + ServerSentEventsInner1 ret = new ServerSentEventsInner1(); ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); return ret; } - throw new IOException(String.format(Locale.ROOT, "Failed deserialization for StreamAiDecompilation200ResponseInner: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonElement.toString())); + throw new IOException(String.format(java.util.Locale.ROOT, "Failed deserialization for ServerSentEventsInner1: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonElement.toString())); } }.nullSafe(); } @@ -288,11 +286,11 @@ public StreamAiDecompilation200ResponseInner read(JsonReader in) throws IOExcept // store a list of schema names defined in oneOf public static final Map> schemas = new HashMap>(); - public StreamAiDecompilation200ResponseInner() { + public ServerSentEventsInner1() { super("oneOf", Boolean.FALSE); } - public StreamAiDecompilation200ResponseInner(Object o) { + public ServerSentEventsInner1(Object o) { super("oneOf", Boolean.FALSE); setActualInstance(o); } @@ -311,7 +309,7 @@ public StreamAiDecompilation200ResponseInner(Object o) { @Override public Map> getSchemas() { - return StreamAiDecompilation200ResponseInner.schemas; + return ServerSentEventsInner1.schemas; } /** @@ -390,6 +388,7 @@ public Object getActualInstance() { * @return The actual instance of `EventAttemptFailed` * @throws ClassCastException if the instance is not `EventAttemptFailed` */ + @SuppressWarnings("unchecked") public EventAttemptFailed getEventAttemptFailed() throws ClassCastException { return (EventAttemptFailed)super.getActualInstance(); } @@ -401,6 +400,7 @@ public EventAttemptFailed getEventAttemptFailed() throws ClassCastException { * @return The actual instance of `EventAttemptStarted` * @throws ClassCastException if the instance is not `EventAttemptStarted` */ + @SuppressWarnings("unchecked") public EventAttemptStarted getEventAttemptStarted() throws ClassCastException { return (EventAttemptStarted)super.getActualInstance(); } @@ -412,6 +412,7 @@ public EventAttemptStarted getEventAttemptStarted() throws ClassCastException { * @return The actual instance of `EventDecompFailed` * @throws ClassCastException if the instance is not `EventDecompFailed` */ + @SuppressWarnings("unchecked") public EventDecompFailed getEventDecompFailed() throws ClassCastException { return (EventDecompFailed)super.getActualInstance(); } @@ -423,6 +424,7 @@ public EventDecompFailed getEventDecompFailed() throws ClassCastException { * @return The actual instance of `EventDecompFinished` * @throws ClassCastException if the instance is not `EventDecompFinished` */ + @SuppressWarnings("unchecked") public EventDecompFinished getEventDecompFinished() throws ClassCastException { return (EventDecompFinished)super.getActualInstance(); } @@ -434,6 +436,7 @@ public EventDecompFinished getEventDecompFinished() throws ClassCastException { * @return The actual instance of `EventProse` * @throws ClassCastException if the instance is not `EventProse` */ + @SuppressWarnings("unchecked") public EventProse getEventProse() throws ClassCastException { return (EventProse)super.getActualInstance(); } @@ -445,6 +448,7 @@ public EventProse getEventProse() throws ClassCastException { * @return The actual instance of `EventRenameApplied` * @throws ClassCastException if the instance is not `EventRenameApplied` */ + @SuppressWarnings("unchecked") public EventRenameApplied getEventRenameApplied() throws ClassCastException { return (EventRenameApplied)super.getActualInstance(); } @@ -456,6 +460,7 @@ public EventRenameApplied getEventRenameApplied() throws ClassCastException { * @return The actual instance of `EventSourceDelta` * @throws ClassCastException if the instance is not `EventSourceDelta` */ + @SuppressWarnings("unchecked") public EventSourceDelta getEventSourceDelta() throws ClassCastException { return (EventSourceDelta)super.getActualInstance(); } @@ -467,6 +472,7 @@ public EventSourceDelta getEventSourceDelta() throws ClassCastException { * @return The actual instance of `EventSourceReset` * @throws ClassCastException if the instance is not `EventSourceReset` */ + @SuppressWarnings("unchecked") public EventSourceReset getEventSourceReset() throws ClassCastException { return (EventSourceReset)super.getActualInstance(); } @@ -478,6 +484,7 @@ public EventSourceReset getEventSourceReset() throws ClassCastException { * @return The actual instance of `EventWarning` * @throws ClassCastException if the instance is not `EventWarning` */ + @SuppressWarnings("unchecked") public EventWarning getEventWarning() throws ClassCastException { return (EventWarning)super.getActualInstance(); } @@ -486,7 +493,7 @@ public EventWarning getEventWarning() throws ClassCastException { * Validates the JSON Element and throws an exception if issues found * * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to StreamAiDecompilation200ResponseInner + * @throws IOException if the JSON Element is invalid with respect to ServerSentEventsInner1 */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { // validate oneOf schemas one by one @@ -497,7 +504,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventAttemptFailed.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventAttemptFailed failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventAttemptFailed failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventAttemptStarted @@ -505,7 +512,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventAttemptStarted.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventAttemptStarted failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventAttemptStarted failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventDecompFailed @@ -513,7 +520,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventDecompFailed.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventDecompFailed failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventDecompFailed failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventDecompFinished @@ -521,7 +528,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventDecompFinished.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventDecompFinished failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventDecompFinished failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventProse @@ -529,7 +536,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventProse.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventProse failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventProse failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventRenameApplied @@ -537,7 +544,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventRenameApplied.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventRenameApplied failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventRenameApplied failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventSourceDelta @@ -545,7 +552,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventSourceDelta.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventSourceDelta failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventSourceDelta failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventSourceReset @@ -553,7 +560,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventSourceReset.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventSourceReset failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventSourceReset failed with `%s`.", e.getMessage())); // continue to the next one } // validate the json string with EventWarning @@ -561,27 +568,27 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EventWarning.validateJsonElement(jsonElement); validCount++; } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for EventWarning failed with `%s`.", e.getMessage())); + errorMessages.add(String.format(java.util.Locale.ROOT, "Deserialization for EventWarning failed with `%s`.", e.getMessage())); // continue to the next one } if (validCount != 1) { - throw new IOException(String.format(Locale.ROOT, "The JSON string is invalid for StreamAiDecompilation200ResponseInner with oneOf schemas: EventAttemptFailed, EventAttemptStarted, EventDecompFailed, EventDecompFinished, EventProse, EventRenameApplied, EventSourceDelta, EventSourceReset, EventWarning. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonElement.toString())); + throw new IOException(String.format(java.util.Locale.ROOT, "The JSON string is invalid for ServerSentEventsInner1 with oneOf schemas: EventAttemptFailed, EventAttemptStarted, EventDecompFailed, EventDecompFinished, EventProse, EventRenameApplied, EventSourceDelta, EventSourceReset, EventWarning. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonElement.toString())); } } /** - * Create an instance of StreamAiDecompilation200ResponseInner given an JSON string + * Create an instance of ServerSentEventsInner1 given an JSON string * * @param jsonString JSON string - * @return An instance of StreamAiDecompilation200ResponseInner - * @throws IOException if the JSON string is invalid with respect to StreamAiDecompilation200ResponseInner + * @return An instance of ServerSentEventsInner1 + * @throws IOException if the JSON string is invalid with respect to ServerSentEventsInner1 */ - public static StreamAiDecompilation200ResponseInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, StreamAiDecompilation200ResponseInner.class); + public static ServerSentEventsInner1 fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ServerSentEventsInner1.class); } /** - * Convert an instance of StreamAiDecompilation200ResponseInner to an JSON string + * Convert an instance of ServerSentEventsInner1 to an JSON string * * @return JSON string */ diff --git a/src/main/java/ai/reveng/model/ServiceEntry.java b/src/main/java/ai/reveng/model/ServiceEntry.java index 0e727cd8..869a5a61 100644 --- a/src/main/java/ai/reveng/model/ServiceEntry.java +++ b/src/main/java/ai/reveng/model/ServiceEntry.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ReportEvent; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -209,50 +207,6 @@ public void setStartType(@javax.annotation.Nullable String startType) { this.startType = startType; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ServiceEntry instance itself - */ - public ServiceEntry putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -269,8 +223,7 @@ public boolean equals(Object o) { Objects.equals(this.events, serviceEntry.events) && Objects.equals(this.name, serviceEntry.name) && Objects.equals(this.serviceType, serviceEntry.serviceType) && - Objects.equals(this.startType, serviceEntry.startType)&& - Objects.equals(this.additionalProperties, serviceEntry.additionalProperties); + Objects.equals(this.startType, serviceEntry.startType); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -279,7 +232,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(binaryPath, displayName, events, name, serviceType, startType, additionalProperties); + return Objects.hash(binaryPath, displayName, events, name, serviceType, startType); } private static int hashCodeNullable(JsonNullable a) { @@ -299,7 +252,6 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" serviceType: ").append(toIndentedString(serviceType)).append("\n"); sb.append(" startType: ").append(toIndentedString(startType)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -309,10 +261,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -336,28 +285,46 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ServiceEntry.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ServiceEntry is not found in the empty JSON string", ServiceEntry.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ServiceEntry is not found in the empty JSON string", ServiceEntry.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ServiceEntry.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ServiceEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("binary_path") != null && !jsonObj.get("binary_path").isJsonNull()) && !jsonObj.get("binary_path").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binary_path` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_path").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `binary_path` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_path").toString())); } if ((jsonObj.get("display_name") != null && !jsonObj.get("display_name").isJsonNull()) && !jsonObj.get("display_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `display_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("display_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `display_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("display_name").toString())); } - // ensure the optional json data is an array if present - if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull() && !jsonObj.get("events").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + if (jsonObj.get("events") != null && !jsonObj.get("events").isJsonNull()) { + JsonArray jsonArrayevents = jsonObj.getAsJsonArray("events"); + if (jsonArrayevents != null) { + // ensure the json data is an array + if (!jsonObj.get("events").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `events` to be an array in the JSON string but got `%s`", jsonObj.get("events").toString())); + } + + // validate the optional field `events` (array) + for (int i = 0; i < jsonArrayevents.size(); i++) { + ReportEvent.validateJsonElement(jsonArrayevents.get(i)); + }; + } } if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if ((jsonObj.get("service_type") != null && !jsonObj.get("service_type").isJsonNull()) && !jsonObj.get("service_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `service_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("service_type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `service_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("service_type").toString())); } if ((jsonObj.get("start_type") != null && !jsonObj.get("start_type").isJsonNull()) && !jsonObj.get("start_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `start_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("start_type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `start_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("start_type").toString())); } } @@ -376,28 +343,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ServiceEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -405,28 +350,7 @@ else if (entry.getValue() instanceof Character) public ServiceEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ServiceEntry instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SessionOutputBody.java b/src/main/java/ai/reveng/model/SessionOutputBody.java index 9a5731af..c705dd50 100644 --- a/src/main/java/ai/reveng/model/SessionOutputBody.java +++ b/src/main/java/ai/reveng/model/SessionOutputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -156,10 +154,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,19 +178,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SessionOutputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SessionOutputBody is not found in the empty JSON string", SessionOutputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SessionOutputBody is not found in the empty JSON string", SessionOutputBody.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SessionOutputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("url").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("url").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("url").toString())); } } @@ -256,7 +251,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/SingleCodeCertificateModel.java b/src/main/java/ai/reveng/model/SingleCodeCertificateModel.java index 71f0951f..3177e66d 100644 --- a/src/main/java/ai/reveng/model/SingleCodeCertificateModel.java +++ b/src/main/java/ai/reveng/model/SingleCodeCertificateModel.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -286,10 +284,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -313,31 +308,31 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SingleCodeCertificateModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SingleCodeCertificateModel is not found in the empty JSON string", SingleCodeCertificateModel.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SingleCodeCertificateModel is not found in the empty JSON string", SingleCodeCertificateModel.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SingleCodeCertificateModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("issued_on").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `issued_on` to be a primitive type in the JSON string but got `%s`", jsonObj.get("issued_on").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `issued_on` to be a primitive type in the JSON string but got `%s`", jsonObj.get("issued_on").toString())); } if (!jsonObj.get("expires_on").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `expires_on` to be a primitive type in the JSON string but got `%s`", jsonObj.get("expires_on").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `expires_on` to be a primitive type in the JSON string but got `%s`", jsonObj.get("expires_on").toString())); } if (!jsonObj.get("issuer_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `issuer_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("issuer_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `issuer_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("issuer_name").toString())); } if (!jsonObj.get("serial_number").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `serial_number` to be a primitive type in the JSON string but got `%s`", jsonObj.get("serial_number").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `serial_number` to be a primitive type in the JSON string but got `%s`", jsonObj.get("serial_number").toString())); } if (!jsonObj.get("subject_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `subject_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("subject_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `subject_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("subject_name").toString())); } } @@ -398,7 +393,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/SingleCodeSignatureModel.java b/src/main/java/ai/reveng/model/SingleCodeSignatureModel.java index 39fd7e04..39df97dc 100644 --- a/src/main/java/ai/reveng/model/SingleCodeSignatureModel.java +++ b/src/main/java/ai/reveng/model/SingleCodeSignatureModel.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SingleCodeCertificateModel; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -193,10 +191,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -220,29 +215,29 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SingleCodeSignatureModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SingleCodeSignatureModel is not found in the empty JSON string", SingleCodeSignatureModel.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SingleCodeSignatureModel is not found in the empty JSON string", SingleCodeSignatureModel.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SingleCodeSignatureModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("certificates").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `certificates` to be an array in the JSON string but got `%s`", jsonObj.get("certificates").toString())); + if (jsonObj.get("certificates") != null) { + if (!jsonObj.get("certificates").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `certificates` to be an array in the JSON string but got `%s`", jsonObj.get("certificates").toString())); + } + JsonArray jsonArraycertificates = jsonObj.getAsJsonArray("certificates"); + // validate the required field `certificates` (array) + for (int i = 0; i < jsonArraycertificates.size(); i++) { + SingleCodeCertificateModel.validateJsonElement(jsonArraycertificates.get(i)); + } } - - JsonArray jsonArraycertificates = jsonObj.getAsJsonArray("certificates"); - // validate the required field `certificates` (array) - for (int i = 0; i < jsonArraycertificates.size(); i++) { - SingleCodeCertificateModel.validateJsonElement(jsonArraycertificates.get(i)); - }; if (!jsonObj.get("authenticode_digest").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `authenticode_digest` to be a primitive type in the JSON string but got `%s`", jsonObj.get("authenticode_digest").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `authenticode_digest` to be a primitive type in the JSON string but got `%s`", jsonObj.get("authenticode_digest").toString())); } } @@ -303,7 +298,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/SinglePDBEntryModel.java b/src/main/java/ai/reveng/model/SinglePDBEntryModel.java index d071024f..24226b20 100644 --- a/src/main/java/ai/reveng/model/SinglePDBEntryModel.java +++ b/src/main/java/ai/reveng/model/SinglePDBEntryModel.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -208,10 +206,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -235,22 +230,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SinglePDBEntryModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SinglePDBEntryModel is not found in the empty JSON string", SinglePDBEntryModel.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SinglePDBEntryModel is not found in the empty JSON string", SinglePDBEntryModel.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SinglePDBEntryModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("guid").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `guid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("guid").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `guid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("guid").toString())); } if (!jsonObj.get("path").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `path` to be a primitive type in the JSON string but got `%s`", jsonObj.get("path").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `path` to be a primitive type in the JSON string but got `%s`", jsonObj.get("path").toString())); } } @@ -311,7 +306,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/SingleSectionModel.java b/src/main/java/ai/reveng/model/SingleSectionModel.java index a06b42d9..c16fa315 100644 --- a/src/main/java/ai/reveng/model/SingleSectionModel.java +++ b/src/main/java/ai/reveng/model/SingleSectionModel.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -313,10 +311,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -340,25 +335,25 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SingleSectionModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SingleSectionModel is not found in the empty JSON string", SingleSectionModel.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SingleSectionModel is not found in the empty JSON string", SingleSectionModel.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SingleSectionModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if (!jsonObj.get("characteristics").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `characteristics` to be a primitive type in the JSON string but got `%s`", jsonObj.get("characteristics").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `characteristics` to be a primitive type in the JSON string but got `%s`", jsonObj.get("characteristics").toString())); } if (!jsonObj.get("sha3_256").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha3_256` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha3_256").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha3_256` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha3_256").toString())); } } @@ -419,7 +414,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/SourceDeltaEvent.java b/src/main/java/ai/reveng/model/SourceDeltaEvent.java index 892a04f9..af85414e 100644 --- a/src/main/java/ai/reveng/model/SourceDeltaEvent.java +++ b/src/main/java/ai/reveng/model/SourceDeltaEvent.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -149,50 +147,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the SourceDeltaEvent instance itself - */ - public SourceDeltaEvent putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -207,13 +161,12 @@ public boolean equals(Object o) { return Objects.equals(this.attempt, sourceDeltaEvent.attempt) && Objects.equals(this.content, sourceDeltaEvent.content) && Objects.equals(this.seq, sourceDeltaEvent.seq) && - Objects.equals(this.type, sourceDeltaEvent.type)&& - Objects.equals(this.additionalProperties, sourceDeltaEvent.additionalProperties); + Objects.equals(this.type, sourceDeltaEvent.type); } @Override public int hashCode() { - return Objects.hash(attempt, content, seq, type, additionalProperties); + return Objects.hash(attempt, content, seq, type); } @Override @@ -224,7 +177,6 @@ public String toString() { sb.append(" content: ").append(toIndentedString(content)).append("\n"); sb.append(" seq: ").append(toIndentedString(seq)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -234,10 +186,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,22 +210,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SourceDeltaEvent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SourceDeltaEvent is not found in the empty JSON string", SourceDeltaEvent.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SourceDeltaEvent is not found in the empty JSON string", SourceDeltaEvent.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SourceDeltaEvent.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SourceDeltaEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SourceDeltaEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("content").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `content` to be a primitive type in the JSON string but got `%s`", jsonObj.get("content").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `content` to be a primitive type in the JSON string but got `%s`", jsonObj.get("content").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -295,28 +252,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SourceDeltaEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -324,28 +259,7 @@ else if (entry.getValue() instanceof Character) public SourceDeltaEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - SourceDeltaEvent instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SourceResetEvent.java b/src/main/java/ai/reveng/model/SourceResetEvent.java index fdd6e1d3..d8ab225c 100644 --- a/src/main/java/ai/reveng/model/SourceResetEvent.java +++ b/src/main/java/ai/reveng/model/SourceResetEvent.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -125,50 +123,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the SourceResetEvent instance itself - */ - public SourceResetEvent putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -182,13 +136,12 @@ public boolean equals(Object o) { SourceResetEvent sourceResetEvent = (SourceResetEvent) o; return Objects.equals(this.attempt, sourceResetEvent.attempt) && Objects.equals(this.seq, sourceResetEvent.seq) && - Objects.equals(this.type, sourceResetEvent.type)&& - Objects.equals(this.additionalProperties, sourceResetEvent.additionalProperties); + Objects.equals(this.type, sourceResetEvent.type); } @Override public int hashCode() { - return Objects.hash(attempt, seq, type, additionalProperties); + return Objects.hash(attempt, seq, type); } @Override @@ -198,7 +151,6 @@ public String toString() { sb.append(" attempt: ").append(toIndentedString(attempt)).append("\n"); sb.append(" seq: ").append(toIndentedString(seq)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -208,10 +160,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -235,19 +184,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SourceResetEvent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SourceResetEvent is not found in the empty JSON string", SourceResetEvent.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SourceResetEvent is not found in the empty JSON string", SourceResetEvent.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SourceResetEvent.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SourceResetEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SourceResetEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -266,28 +223,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SourceResetEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -295,28 +230,7 @@ else if (entry.getValue() instanceof Character) public SourceResetEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - SourceResetEvent instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventContextCompactedData.java b/src/main/java/ai/reveng/model/SseEventContextCompactedData.java index 910a5158..7e62a9c5 100644 --- a/src/main/java/ai/reveng/model/SseEventContextCompactedData.java +++ b/src/main/java/ai/reveng/model/SseEventContextCompactedData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -149,50 +147,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the SseEventContextCompactedData instance itself - */ - public SseEventContextCompactedData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -207,13 +161,12 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventContextCompactedData.data) && Objects.equals(this.eventId, sseEventContextCompactedData.eventId) && Objects.equals(this.sourceRunId, sseEventContextCompactedData.sourceRunId) && - Objects.equals(this.type, sseEventContextCompactedData.type)&& - Objects.equals(this.additionalProperties, sseEventContextCompactedData.additionalProperties); + Objects.equals(this.type, sseEventContextCompactedData.type); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); + return Objects.hash(data, eventId, sourceRunId, type); } @Override @@ -224,7 +177,6 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -234,10 +186,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,22 +210,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SseEventContextCompactedData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SseEventContextCompactedData is not found in the empty JSON string", SseEventContextCompactedData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SseEventContextCompactedData is not found in the empty JSON string", SseEventContextCompactedData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SseEventContextCompactedData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventContextCompactedData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventContextCompactedData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("source_run_id") != null && !jsonObj.get("source_run_id").isJsonNull()) && !jsonObj.get("source_run_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -295,28 +252,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventContextCompactedData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -324,28 +259,7 @@ else if (entry.getValue() instanceof Character) public SseEventContextCompactedData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - SseEventContextCompactedData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventRunCancelledData.java b/src/main/java/ai/reveng/model/SseEventRunCancelledData.java index 563774c6..d933b117 100644 --- a/src/main/java/ai/reveng/model/SseEventRunCancelledData.java +++ b/src/main/java/ai/reveng/model/SseEventRunCancelledData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -149,50 +147,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the SseEventRunCancelledData instance itself - */ - public SseEventRunCancelledData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -207,13 +161,12 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventRunCancelledData.data) && Objects.equals(this.eventId, sseEventRunCancelledData.eventId) && Objects.equals(this.sourceRunId, sseEventRunCancelledData.sourceRunId) && - Objects.equals(this.type, sseEventRunCancelledData.type)&& - Objects.equals(this.additionalProperties, sseEventRunCancelledData.additionalProperties); + Objects.equals(this.type, sseEventRunCancelledData.type); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); + return Objects.hash(data, eventId, sourceRunId, type); } @Override @@ -224,7 +177,6 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -234,10 +186,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,22 +210,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SseEventRunCancelledData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SseEventRunCancelledData is not found in the empty JSON string", SseEventRunCancelledData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SseEventRunCancelledData is not found in the empty JSON string", SseEventRunCancelledData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SseEventRunCancelledData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventRunCancelledData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventRunCancelledData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("source_run_id") != null && !jsonObj.get("source_run_id").isJsonNull()) && !jsonObj.get("source_run_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -295,28 +252,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventRunCancelledData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -324,28 +259,7 @@ else if (entry.getValue() instanceof Character) public SseEventRunCancelledData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - SseEventRunCancelledData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventRunErrorData.java b/src/main/java/ai/reveng/model/SseEventRunErrorData.java index 349f5bb9..b46fa790 100644 --- a/src/main/java/ai/reveng/model/SseEventRunErrorData.java +++ b/src/main/java/ai/reveng/model/SseEventRunErrorData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -149,50 +147,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the SseEventRunErrorData instance itself - */ - public SseEventRunErrorData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -207,13 +161,12 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventRunErrorData.data) && Objects.equals(this.eventId, sseEventRunErrorData.eventId) && Objects.equals(this.sourceRunId, sseEventRunErrorData.sourceRunId) && - Objects.equals(this.type, sseEventRunErrorData.type)&& - Objects.equals(this.additionalProperties, sseEventRunErrorData.additionalProperties); + Objects.equals(this.type, sseEventRunErrorData.type); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); + return Objects.hash(data, eventId, sourceRunId, type); } @Override @@ -224,7 +177,6 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -234,10 +186,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,22 +210,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SseEventRunErrorData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SseEventRunErrorData is not found in the empty JSON string", SseEventRunErrorData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SseEventRunErrorData is not found in the empty JSON string", SseEventRunErrorData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SseEventRunErrorData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventRunErrorData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventRunErrorData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("source_run_id") != null && !jsonObj.get("source_run_id").isJsonNull()) && !jsonObj.get("source_run_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -295,28 +252,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventRunErrorData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -324,28 +259,7 @@ else if (entry.getValue() instanceof Character) public SseEventRunErrorData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - SseEventRunErrorData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventRunFinishedData.java b/src/main/java/ai/reveng/model/SseEventRunFinishedData.java index 33e735dc..b573d2b4 100644 --- a/src/main/java/ai/reveng/model/SseEventRunFinishedData.java +++ b/src/main/java/ai/reveng/model/SseEventRunFinishedData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -149,50 +147,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the SseEventRunFinishedData instance itself - */ - public SseEventRunFinishedData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -207,13 +161,12 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventRunFinishedData.data) && Objects.equals(this.eventId, sseEventRunFinishedData.eventId) && Objects.equals(this.sourceRunId, sseEventRunFinishedData.sourceRunId) && - Objects.equals(this.type, sseEventRunFinishedData.type)&& - Objects.equals(this.additionalProperties, sseEventRunFinishedData.additionalProperties); + Objects.equals(this.type, sseEventRunFinishedData.type); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); + return Objects.hash(data, eventId, sourceRunId, type); } @Override @@ -224,7 +177,6 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -234,10 +186,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,22 +210,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SseEventRunFinishedData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SseEventRunFinishedData is not found in the empty JSON string", SseEventRunFinishedData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SseEventRunFinishedData is not found in the empty JSON string", SseEventRunFinishedData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SseEventRunFinishedData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventRunFinishedData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventRunFinishedData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("source_run_id") != null && !jsonObj.get("source_run_id").isJsonNull()) && !jsonObj.get("source_run_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -295,28 +252,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventRunFinishedData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -324,28 +259,7 @@ else if (entry.getValue() instanceof Character) public SseEventRunFinishedData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - SseEventRunFinishedData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventRunStartedData.java b/src/main/java/ai/reveng/model/SseEventRunStartedData.java index 8348022a..f69526ca 100644 --- a/src/main/java/ai/reveng/model/SseEventRunStartedData.java +++ b/src/main/java/ai/reveng/model/SseEventRunStartedData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -149,50 +147,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the SseEventRunStartedData instance itself - */ - public SseEventRunStartedData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -207,13 +161,12 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventRunStartedData.data) && Objects.equals(this.eventId, sseEventRunStartedData.eventId) && Objects.equals(this.sourceRunId, sseEventRunStartedData.sourceRunId) && - Objects.equals(this.type, sseEventRunStartedData.type)&& - Objects.equals(this.additionalProperties, sseEventRunStartedData.additionalProperties); + Objects.equals(this.type, sseEventRunStartedData.type); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); + return Objects.hash(data, eventId, sourceRunId, type); } @Override @@ -224,7 +177,6 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -234,10 +186,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,22 +210,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SseEventRunStartedData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SseEventRunStartedData is not found in the empty JSON string", SseEventRunStartedData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SseEventRunStartedData is not found in the empty JSON string", SseEventRunStartedData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SseEventRunStartedData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventRunStartedData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventRunStartedData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("source_run_id") != null && !jsonObj.get("source_run_id").isJsonNull()) && !jsonObj.get("source_run_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -295,28 +252,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventRunStartedData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -324,28 +259,7 @@ else if (entry.getValue() instanceof Character) public SseEventRunStartedData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - SseEventRunStartedData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventStepFinishedData.java b/src/main/java/ai/reveng/model/SseEventStepFinishedData.java index 15b139c9..e4fabb46 100644 --- a/src/main/java/ai/reveng/model/SseEventStepFinishedData.java +++ b/src/main/java/ai/reveng/model/SseEventStepFinishedData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -149,50 +147,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the SseEventStepFinishedData instance itself - */ - public SseEventStepFinishedData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -207,13 +161,12 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventStepFinishedData.data) && Objects.equals(this.eventId, sseEventStepFinishedData.eventId) && Objects.equals(this.sourceRunId, sseEventStepFinishedData.sourceRunId) && - Objects.equals(this.type, sseEventStepFinishedData.type)&& - Objects.equals(this.additionalProperties, sseEventStepFinishedData.additionalProperties); + Objects.equals(this.type, sseEventStepFinishedData.type); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); + return Objects.hash(data, eventId, sourceRunId, type); } @Override @@ -224,7 +177,6 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -234,10 +186,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,22 +210,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SseEventStepFinishedData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SseEventStepFinishedData is not found in the empty JSON string", SseEventStepFinishedData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SseEventStepFinishedData is not found in the empty JSON string", SseEventStepFinishedData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SseEventStepFinishedData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventStepFinishedData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventStepFinishedData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("source_run_id") != null && !jsonObj.get("source_run_id").isJsonNull()) && !jsonObj.get("source_run_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -295,28 +252,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventStepFinishedData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -324,28 +259,7 @@ else if (entry.getValue() instanceof Character) public SseEventStepFinishedData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - SseEventStepFinishedData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventStepStartedData.java b/src/main/java/ai/reveng/model/SseEventStepStartedData.java index 443840be..ec2d8f73 100644 --- a/src/main/java/ai/reveng/model/SseEventStepStartedData.java +++ b/src/main/java/ai/reveng/model/SseEventStepStartedData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -149,50 +147,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the SseEventStepStartedData instance itself - */ - public SseEventStepStartedData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -207,13 +161,12 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventStepStartedData.data) && Objects.equals(this.eventId, sseEventStepStartedData.eventId) && Objects.equals(this.sourceRunId, sseEventStepStartedData.sourceRunId) && - Objects.equals(this.type, sseEventStepStartedData.type)&& - Objects.equals(this.additionalProperties, sseEventStepStartedData.additionalProperties); + Objects.equals(this.type, sseEventStepStartedData.type); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); + return Objects.hash(data, eventId, sourceRunId, type); } @Override @@ -224,7 +177,6 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -234,10 +186,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,22 +210,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SseEventStepStartedData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SseEventStepStartedData is not found in the empty JSON string", SseEventStepStartedData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SseEventStepStartedData is not found in the empty JSON string", SseEventStepStartedData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SseEventStepStartedData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventStepStartedData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventStepStartedData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("source_run_id") != null && !jsonObj.get("source_run_id").isJsonNull()) && !jsonObj.get("source_run_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -295,28 +252,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventStepStartedData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -324,28 +259,7 @@ else if (entry.getValue() instanceof Character) public SseEventStepStartedData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - SseEventStepStartedData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventTextMessageContentData.java b/src/main/java/ai/reveng/model/SseEventTextMessageContentData.java index 1ae894e0..e4beeddb 100644 --- a/src/main/java/ai/reveng/model/SseEventTextMessageContentData.java +++ b/src/main/java/ai/reveng/model/SseEventTextMessageContentData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -149,50 +147,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the SseEventTextMessageContentData instance itself - */ - public SseEventTextMessageContentData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -207,13 +161,12 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventTextMessageContentData.data) && Objects.equals(this.eventId, sseEventTextMessageContentData.eventId) && Objects.equals(this.sourceRunId, sseEventTextMessageContentData.sourceRunId) && - Objects.equals(this.type, sseEventTextMessageContentData.type)&& - Objects.equals(this.additionalProperties, sseEventTextMessageContentData.additionalProperties); + Objects.equals(this.type, sseEventTextMessageContentData.type); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); + return Objects.hash(data, eventId, sourceRunId, type); } @Override @@ -224,7 +177,6 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -234,10 +186,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,22 +210,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SseEventTextMessageContentData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SseEventTextMessageContentData is not found in the empty JSON string", SseEventTextMessageContentData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SseEventTextMessageContentData is not found in the empty JSON string", SseEventTextMessageContentData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SseEventTextMessageContentData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventTextMessageContentData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventTextMessageContentData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("source_run_id") != null && !jsonObj.get("source_run_id").isJsonNull()) && !jsonObj.get("source_run_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -295,28 +252,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventTextMessageContentData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -324,28 +259,7 @@ else if (entry.getValue() instanceof Character) public SseEventTextMessageContentData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - SseEventTextMessageContentData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventTextMessageEndData.java b/src/main/java/ai/reveng/model/SseEventTextMessageEndData.java index a986929f..a6960476 100644 --- a/src/main/java/ai/reveng/model/SseEventTextMessageEndData.java +++ b/src/main/java/ai/reveng/model/SseEventTextMessageEndData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -149,50 +147,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the SseEventTextMessageEndData instance itself - */ - public SseEventTextMessageEndData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -207,13 +161,12 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventTextMessageEndData.data) && Objects.equals(this.eventId, sseEventTextMessageEndData.eventId) && Objects.equals(this.sourceRunId, sseEventTextMessageEndData.sourceRunId) && - Objects.equals(this.type, sseEventTextMessageEndData.type)&& - Objects.equals(this.additionalProperties, sseEventTextMessageEndData.additionalProperties); + Objects.equals(this.type, sseEventTextMessageEndData.type); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); + return Objects.hash(data, eventId, sourceRunId, type); } @Override @@ -224,7 +177,6 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -234,10 +186,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,22 +210,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SseEventTextMessageEndData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SseEventTextMessageEndData is not found in the empty JSON string", SseEventTextMessageEndData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SseEventTextMessageEndData is not found in the empty JSON string", SseEventTextMessageEndData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SseEventTextMessageEndData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventTextMessageEndData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventTextMessageEndData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("source_run_id") != null && !jsonObj.get("source_run_id").isJsonNull()) && !jsonObj.get("source_run_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -295,28 +252,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventTextMessageEndData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -324,28 +259,7 @@ else if (entry.getValue() instanceof Character) public SseEventTextMessageEndData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - SseEventTextMessageEndData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventTextMessageStartData.java b/src/main/java/ai/reveng/model/SseEventTextMessageStartData.java index 63165f66..c82339a0 100644 --- a/src/main/java/ai/reveng/model/SseEventTextMessageStartData.java +++ b/src/main/java/ai/reveng/model/SseEventTextMessageStartData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -149,50 +147,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the SseEventTextMessageStartData instance itself - */ - public SseEventTextMessageStartData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -207,13 +161,12 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventTextMessageStartData.data) && Objects.equals(this.eventId, sseEventTextMessageStartData.eventId) && Objects.equals(this.sourceRunId, sseEventTextMessageStartData.sourceRunId) && - Objects.equals(this.type, sseEventTextMessageStartData.type)&& - Objects.equals(this.additionalProperties, sseEventTextMessageStartData.additionalProperties); + Objects.equals(this.type, sseEventTextMessageStartData.type); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); + return Objects.hash(data, eventId, sourceRunId, type); } @Override @@ -224,7 +177,6 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -234,10 +186,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,22 +210,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SseEventTextMessageStartData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SseEventTextMessageStartData is not found in the empty JSON string", SseEventTextMessageStartData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SseEventTextMessageStartData is not found in the empty JSON string", SseEventTextMessageStartData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SseEventTextMessageStartData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventTextMessageStartData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventTextMessageStartData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("source_run_id") != null && !jsonObj.get("source_run_id").isJsonNull()) && !jsonObj.get("source_run_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -295,28 +252,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventTextMessageStartData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -324,28 +259,7 @@ else if (entry.getValue() instanceof Character) public SseEventTextMessageStartData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - SseEventTextMessageStartData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventTitleUpdatedData.java b/src/main/java/ai/reveng/model/SseEventTitleUpdatedData.java index 19208818..5ec54178 100644 --- a/src/main/java/ai/reveng/model/SseEventTitleUpdatedData.java +++ b/src/main/java/ai/reveng/model/SseEventTitleUpdatedData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -149,50 +147,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the SseEventTitleUpdatedData instance itself - */ - public SseEventTitleUpdatedData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -207,13 +161,12 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventTitleUpdatedData.data) && Objects.equals(this.eventId, sseEventTitleUpdatedData.eventId) && Objects.equals(this.sourceRunId, sseEventTitleUpdatedData.sourceRunId) && - Objects.equals(this.type, sseEventTitleUpdatedData.type)&& - Objects.equals(this.additionalProperties, sseEventTitleUpdatedData.additionalProperties); + Objects.equals(this.type, sseEventTitleUpdatedData.type); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); + return Objects.hash(data, eventId, sourceRunId, type); } @Override @@ -224,7 +177,6 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -234,10 +186,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,22 +210,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SseEventTitleUpdatedData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SseEventTitleUpdatedData is not found in the empty JSON string", SseEventTitleUpdatedData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SseEventTitleUpdatedData is not found in the empty JSON string", SseEventTitleUpdatedData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SseEventTitleUpdatedData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventTitleUpdatedData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventTitleUpdatedData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("source_run_id") != null && !jsonObj.get("source_run_id").isJsonNull()) && !jsonObj.get("source_run_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -295,28 +252,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventTitleUpdatedData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -324,28 +259,7 @@ else if (entry.getValue() instanceof Character) public SseEventTitleUpdatedData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - SseEventTitleUpdatedData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventToolCallArgsDeltaData.java b/src/main/java/ai/reveng/model/SseEventToolCallArgsDeltaData.java index 38b4f9f4..3395bd14 100644 --- a/src/main/java/ai/reveng/model/SseEventToolCallArgsDeltaData.java +++ b/src/main/java/ai/reveng/model/SseEventToolCallArgsDeltaData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -149,50 +147,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the SseEventToolCallArgsDeltaData instance itself - */ - public SseEventToolCallArgsDeltaData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -207,13 +161,12 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventToolCallArgsDeltaData.data) && Objects.equals(this.eventId, sseEventToolCallArgsDeltaData.eventId) && Objects.equals(this.sourceRunId, sseEventToolCallArgsDeltaData.sourceRunId) && - Objects.equals(this.type, sseEventToolCallArgsDeltaData.type)&& - Objects.equals(this.additionalProperties, sseEventToolCallArgsDeltaData.additionalProperties); + Objects.equals(this.type, sseEventToolCallArgsDeltaData.type); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); + return Objects.hash(data, eventId, sourceRunId, type); } @Override @@ -224,7 +177,6 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -234,10 +186,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,22 +210,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SseEventToolCallArgsDeltaData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SseEventToolCallArgsDeltaData is not found in the empty JSON string", SseEventToolCallArgsDeltaData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SseEventToolCallArgsDeltaData is not found in the empty JSON string", SseEventToolCallArgsDeltaData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SseEventToolCallArgsDeltaData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventToolCallArgsDeltaData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventToolCallArgsDeltaData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("source_run_id") != null && !jsonObj.get("source_run_id").isJsonNull()) && !jsonObj.get("source_run_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -295,28 +252,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventToolCallArgsDeltaData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -324,28 +259,7 @@ else if (entry.getValue() instanceof Character) public SseEventToolCallArgsDeltaData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - SseEventToolCallArgsDeltaData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventToolCallEndData.java b/src/main/java/ai/reveng/model/SseEventToolCallEndData.java index 2e96fa78..a885cf9b 100644 --- a/src/main/java/ai/reveng/model/SseEventToolCallEndData.java +++ b/src/main/java/ai/reveng/model/SseEventToolCallEndData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -149,50 +147,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the SseEventToolCallEndData instance itself - */ - public SseEventToolCallEndData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -207,13 +161,12 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventToolCallEndData.data) && Objects.equals(this.eventId, sseEventToolCallEndData.eventId) && Objects.equals(this.sourceRunId, sseEventToolCallEndData.sourceRunId) && - Objects.equals(this.type, sseEventToolCallEndData.type)&& - Objects.equals(this.additionalProperties, sseEventToolCallEndData.additionalProperties); + Objects.equals(this.type, sseEventToolCallEndData.type); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); + return Objects.hash(data, eventId, sourceRunId, type); } @Override @@ -224,7 +177,6 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -234,10 +186,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,22 +210,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SseEventToolCallEndData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SseEventToolCallEndData is not found in the empty JSON string", SseEventToolCallEndData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SseEventToolCallEndData is not found in the empty JSON string", SseEventToolCallEndData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SseEventToolCallEndData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventToolCallEndData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventToolCallEndData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("source_run_id") != null && !jsonObj.get("source_run_id").isJsonNull()) && !jsonObj.get("source_run_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -295,28 +252,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventToolCallEndData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -324,28 +259,7 @@ else if (entry.getValue() instanceof Character) public SseEventToolCallEndData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - SseEventToolCallEndData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventToolCallResultData.java b/src/main/java/ai/reveng/model/SseEventToolCallResultData.java index 25f5d015..69a18e67 100644 --- a/src/main/java/ai/reveng/model/SseEventToolCallResultData.java +++ b/src/main/java/ai/reveng/model/SseEventToolCallResultData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -149,50 +147,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the SseEventToolCallResultData instance itself - */ - public SseEventToolCallResultData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -207,13 +161,12 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventToolCallResultData.data) && Objects.equals(this.eventId, sseEventToolCallResultData.eventId) && Objects.equals(this.sourceRunId, sseEventToolCallResultData.sourceRunId) && - Objects.equals(this.type, sseEventToolCallResultData.type)&& - Objects.equals(this.additionalProperties, sseEventToolCallResultData.additionalProperties); + Objects.equals(this.type, sseEventToolCallResultData.type); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); + return Objects.hash(data, eventId, sourceRunId, type); } @Override @@ -224,7 +177,6 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -234,10 +186,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,22 +210,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SseEventToolCallResultData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SseEventToolCallResultData is not found in the empty JSON string", SseEventToolCallResultData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SseEventToolCallResultData is not found in the empty JSON string", SseEventToolCallResultData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SseEventToolCallResultData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventToolCallResultData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventToolCallResultData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("source_run_id") != null && !jsonObj.get("source_run_id").isJsonNull()) && !jsonObj.get("source_run_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -295,28 +252,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventToolCallResultData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -324,28 +259,7 @@ else if (entry.getValue() instanceof Character) public SseEventToolCallResultData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - SseEventToolCallResultData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventToolCallStartData.java b/src/main/java/ai/reveng/model/SseEventToolCallStartData.java index 4c04c2db..7b026ca2 100644 --- a/src/main/java/ai/reveng/model/SseEventToolCallStartData.java +++ b/src/main/java/ai/reveng/model/SseEventToolCallStartData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -149,50 +147,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the SseEventToolCallStartData instance itself - */ - public SseEventToolCallStartData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -207,13 +161,12 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventToolCallStartData.data) && Objects.equals(this.eventId, sseEventToolCallStartData.eventId) && Objects.equals(this.sourceRunId, sseEventToolCallStartData.sourceRunId) && - Objects.equals(this.type, sseEventToolCallStartData.type)&& - Objects.equals(this.additionalProperties, sseEventToolCallStartData.additionalProperties); + Objects.equals(this.type, sseEventToolCallStartData.type); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); + return Objects.hash(data, eventId, sourceRunId, type); } @Override @@ -224,7 +177,6 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -234,10 +186,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,22 +210,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SseEventToolCallStartData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SseEventToolCallStartData is not found in the empty JSON string", SseEventToolCallStartData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SseEventToolCallStartData is not found in the empty JSON string", SseEventToolCallStartData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SseEventToolCallStartData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventToolCallStartData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventToolCallStartData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("source_run_id") != null && !jsonObj.get("source_run_id").isJsonNull()) && !jsonObj.get("source_run_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -295,28 +252,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventToolCallStartData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -324,28 +259,7 @@ else if (entry.getValue() instanceof Character) public SseEventToolCallStartData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - SseEventToolCallStartData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/SseEventToolConfirmationRequiredData.java b/src/main/java/ai/reveng/model/SseEventToolConfirmationRequiredData.java index 4a6fcd8c..f23b8cc2 100644 --- a/src/main/java/ai/reveng/model/SseEventToolConfirmationRequiredData.java +++ b/src/main/java/ai/reveng/model/SseEventToolConfirmationRequiredData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -149,50 +147,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the SseEventToolConfirmationRequiredData instance itself - */ - public SseEventToolConfirmationRequiredData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -207,13 +161,12 @@ public boolean equals(Object o) { return Objects.equals(this.data, sseEventToolConfirmationRequiredData.data) && Objects.equals(this.eventId, sseEventToolConfirmationRequiredData.eventId) && Objects.equals(this.sourceRunId, sseEventToolConfirmationRequiredData.sourceRunId) && - Objects.equals(this.type, sseEventToolConfirmationRequiredData.type)&& - Objects.equals(this.additionalProperties, sseEventToolConfirmationRequiredData.additionalProperties); + Objects.equals(this.type, sseEventToolConfirmationRequiredData.type); } @Override public int hashCode() { - return Objects.hash(data, eventId, sourceRunId, type, additionalProperties); + return Objects.hash(data, eventId, sourceRunId, type); } @Override @@ -224,7 +177,6 @@ public String toString() { sb.append(" eventId: ").append(toIndentedString(eventId)).append("\n"); sb.append(" sourceRunId: ").append(toIndentedString(sourceRunId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -234,10 +186,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -261,22 +210,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SseEventToolConfirmationRequiredData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SseEventToolConfirmationRequiredData is not found in the empty JSON string", SseEventToolConfirmationRequiredData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SseEventToolConfirmationRequiredData is not found in the empty JSON string", SseEventToolConfirmationRequiredData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SseEventToolConfirmationRequiredData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SseEventToolConfirmationRequiredData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SseEventToolConfirmationRequiredData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("source_run_id") != null && !jsonObj.get("source_run_id").isJsonNull()) && !jsonObj.get("source_run_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source_run_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_run_id").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -295,28 +252,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SseEventToolConfirmationRequiredData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -324,28 +259,7 @@ else if (entry.getValue() instanceof Character) public SseEventToolConfirmationRequiredData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - SseEventToolConfirmationRequiredData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/StackVariable.java b/src/main/java/ai/reveng/model/StackVariable.java index 729dc14d..22793bf2 100644 --- a/src/main/java/ai/reveng/model/StackVariable.java +++ b/src/main/java/ai/reveng/model/StackVariable.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -91,7 +89,7 @@ public StackVariable lastChange(@javax.annotation.Nullable String lastChange) { } /** - * Get lastChange + * Timestamp of the last change to this stack variable * @return lastChange */ @javax.annotation.Nullable @@ -298,10 +296,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -325,25 +320,25 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!StackVariable.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in StackVariable is not found in the empty JSON string", StackVariable.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in StackVariable is not found in the empty JSON string", StackVariable.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : StackVariable.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("last_change") != null && !jsonObj.get("last_change").isJsonNull()) && !jsonObj.get("last_change").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `last_change` to be a primitive type in the JSON string but got `%s`", jsonObj.get("last_change").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `last_change` to be a primitive type in the JSON string but got `%s`", jsonObj.get("last_change").toString())); } if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -404,7 +399,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/StartupInfo.java b/src/main/java/ai/reveng/model/StartupInfo.java index 3497250f..b13847e3 100644 --- a/src/main/java/ai/reveng/model/StartupInfo.java +++ b/src/main/java/ai/reveng/model/StartupInfo.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -21,7 +20,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; -import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -43,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -222,50 +219,6 @@ public void setStatus(@javax.annotation.Nullable String status) { this.status = status; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the StartupInfo instance itself - */ - public StartupInfo putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -283,24 +236,12 @@ public boolean equals(Object o) { Objects.equals(this.pid, startupInfo.pid) && Objects.equals(this.process, startupInfo.process) && Objects.equals(this.processName, startupInfo.processName) && - Objects.equals(this.status, startupInfo.status)&& - Objects.equals(this.additionalProperties, startupInfo.additionalProperties); - } - - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + Objects.equals(this.status, startupInfo.status); } @Override public int hashCode() { - return Objects.hash(arguments, error, errorCode, pid, process, processName, status, additionalProperties); - } - - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + return Objects.hash(arguments, error, errorCode, pid, process, processName, status); } @Override @@ -314,7 +255,6 @@ public String toString() { sb.append(" process: ").append(toIndentedString(process)).append("\n"); sb.append(" processName: ").append(toIndentedString(processName)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -324,10 +264,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -351,24 +288,32 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!StartupInfo.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in StartupInfo is not found in the empty JSON string", StartupInfo.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in StartupInfo is not found in the empty JSON string", StartupInfo.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!StartupInfo.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `StartupInfo` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("arguments") != null && !jsonObj.get("arguments").isJsonNull()) && !jsonObj.get("arguments").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `arguments` to be a primitive type in the JSON string but got `%s`", jsonObj.get("arguments").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `arguments` to be a primitive type in the JSON string but got `%s`", jsonObj.get("arguments").toString())); } if ((jsonObj.get("error") != null && !jsonObj.get("error").isJsonNull()) && !jsonObj.get("error").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `error` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `error` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error").toString())); } if ((jsonObj.get("error_code") != null && !jsonObj.get("error_code").isJsonNull()) && !jsonObj.get("error_code").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `error_code` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error_code").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `error_code` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error_code").toString())); } if ((jsonObj.get("process_name") != null && !jsonObj.get("process_name").isJsonNull()) && !jsonObj.get("process_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `process_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("process_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `process_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("process_name").toString())); } if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); } } @@ -387,28 +332,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, StartupInfo value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -416,28 +339,7 @@ else if (entry.getValue() instanceof Character) public StartupInfo read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - StartupInfo instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/StatusInput.java b/src/main/java/ai/reveng/model/StatusInput.java index 5c6d3c9c..dff9efd6 100644 --- a/src/main/java/ai/reveng/model/StatusInput.java +++ b/src/main/java/ai/reveng/model/StatusInput.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/StatusOutput.java b/src/main/java/ai/reveng/model/StatusOutput.java index ff4414f8..f86c9842 100644 --- a/src/main/java/ai/reveng/model/StatusOutput.java +++ b/src/main/java/ai/reveng/model/StatusOutput.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -182,10 +180,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -209,19 +204,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!StatusOutput.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in StatusOutput is not found in the empty JSON string", StatusOutput.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in StatusOutput is not found in the empty JSON string", StatusOutput.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : StatusOutput.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("analysis_status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `analysis_status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("analysis_status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `analysis_status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("analysis_status").toString())); } } @@ -282,7 +277,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/StatusResponse.java b/src/main/java/ai/reveng/model/StatusResponse.java index d58aeb83..7abb90a6 100644 --- a/src/main/java/ai/reveng/model/StatusResponse.java +++ b/src/main/java/ai/reveng/model/StatusResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -126,50 +124,6 @@ public void setTraceId(@javax.annotation.Nullable String traceId) { this.traceId = traceId; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the StatusResponse instance itself - */ - public StatusResponse putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -183,13 +137,12 @@ public boolean equals(Object o) { StatusResponse statusResponse = (StatusResponse) o; return Objects.equals(this.conversationUuid, statusResponse.conversationUuid) && Objects.equals(this.status, statusResponse.status) && - Objects.equals(this.traceId, statusResponse.traceId)&& - Objects.equals(this.additionalProperties, statusResponse.additionalProperties); + Objects.equals(this.traceId, statusResponse.traceId); } @Override public int hashCode() { - return Objects.hash(conversationUuid, status, traceId, additionalProperties); + return Objects.hash(conversationUuid, status, traceId); } @Override @@ -199,7 +152,6 @@ public String toString() { sb.append(" conversationUuid: ").append(toIndentedString(conversationUuid)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" traceId: ").append(toIndentedString(traceId)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -209,10 +161,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -236,25 +185,33 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!StatusResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in StatusResponse is not found in the empty JSON string", StatusResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in StatusResponse is not found in the empty JSON string", StatusResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!StatusResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `StatusResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : StatusResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("conversation_uuid").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `conversation_uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("conversation_uuid").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `conversation_uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("conversation_uuid").toString())); } if (!jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); } if ((jsonObj.get("trace_id") != null && !jsonObj.get("trace_id").isJsonNull()) && !jsonObj.get("trace_id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `trace_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("trace_id").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `trace_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("trace_id").toString())); } } @@ -273,28 +230,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, StatusResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -302,28 +237,7 @@ else if (entry.getValue() instanceof Character) public StatusResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - StatusResponse instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/StringFunctions.java b/src/main/java/ai/reveng/model/StringFunctions.java index c855ccad..37c2809a 100644 --- a/src/main/java/ai/reveng/model/StringFunctions.java +++ b/src/main/java/ai/reveng/model/StringFunctions.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AppApiRestV2FunctionsResponsesFunction; import ai.reveng.model.StringSource; import com.google.gson.TypeAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -68,7 +66,7 @@ public class StringFunctions { public static final String SERIALIZED_NAME_SOURCE = "source"; @SerializedName(SERIALIZED_NAME_SOURCE) @javax.annotation.Nullable - private StringSource source; + private StringSource source = StringSource.SYSTEM; public StringFunctions() { } @@ -220,10 +218,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -247,30 +242,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!StringFunctions.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in StringFunctions is not found in the empty JSON string", StringFunctions.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in StringFunctions is not found in the empty JSON string", StringFunctions.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : StringFunctions.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("value").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); } - // ensure the json data is an array - if (!jsonObj.get("functions").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); + if (jsonObj.get("functions") != null) { + if (!jsonObj.get("functions").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); + } + JsonArray jsonArrayfunctions = jsonObj.getAsJsonArray("functions"); + // validate the required field `functions` (array) + for (int i = 0; i < jsonArrayfunctions.size(); i++) { + AppApiRestV2FunctionsResponsesFunction.validateJsonElement(jsonArrayfunctions.get(i)); + } } - - JsonArray jsonArrayfunctions = jsonObj.getAsJsonArray("functions"); - // validate the required field `functions` (array) - for (int i = 0; i < jsonArrayfunctions.size(); i++) { - AppApiRestV2FunctionsResponsesFunction.validateJsonElement(jsonArrayfunctions.get(i)); - }; // validate the optional field `source` if (jsonObj.get("source") != null && !jsonObj.get("source").isJsonNull()) { StringSource.validateJsonElement(jsonObj.get("source")); @@ -334,7 +329,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/StringSource.java b/src/main/java/ai/reveng/model/StringSource.java index 5a2056ce..432b9e4c 100644 --- a/src/main/java/ai/reveng/model/StringSource.java +++ b/src/main/java/ai/reveng/model/StringSource.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/Structure.java b/src/main/java/ai/reveng/model/Structure.java index 2f7197db..b7790a7d 100644 --- a/src/main/java/ai/reveng/model/Structure.java +++ b/src/main/java/ai/reveng/model/Structure.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.StructureMember; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -89,7 +87,7 @@ public Structure lastChange(@javax.annotation.Nullable String lastChange) { } /** - * Get lastChange + * Timestamp of the last change to this structure * @return lastChange */ @javax.annotation.Nullable @@ -127,7 +125,7 @@ public Structure size(@javax.annotation.Nullable Integer size) { } /** - * Get size + * Total size of the structure in bytes * @return size */ @javax.annotation.Nullable @@ -283,10 +281,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -310,25 +305,25 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Structure.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Structure is not found in the empty JSON string", Structure.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Structure is not found in the empty JSON string", Structure.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Structure.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("last_change") != null && !jsonObj.get("last_change").isJsonNull()) && !jsonObj.get("last_change").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `last_change` to be a primitive type in the JSON string but got `%s`", jsonObj.get("last_change").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `last_change` to be a primitive type in the JSON string but got `%s`", jsonObj.get("last_change").toString())); } if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if ((jsonObj.get("artifact_type") != null && !jsonObj.get("artifact_type").isJsonNull()) && !jsonObj.get("artifact_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `artifact_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("artifact_type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `artifact_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("artifact_type").toString())); } } @@ -389,7 +384,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/StructureMember.java b/src/main/java/ai/reveng/model/StructureMember.java index 24816824..7ac675d3 100644 --- a/src/main/java/ai/reveng/model/StructureMember.java +++ b/src/main/java/ai/reveng/model/StructureMember.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -86,7 +84,7 @@ public StructureMember lastChange(@javax.annotation.Nullable String lastChange) } /** - * Get lastChange + * Timestamp of the last change to this structure member * @return lastChange */ @javax.annotation.Nullable @@ -272,10 +270,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -299,25 +294,25 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!StructureMember.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in StructureMember is not found in the empty JSON string", StructureMember.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in StructureMember is not found in the empty JSON string", StructureMember.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : StructureMember.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("last_change") != null && !jsonObj.get("last_change").isJsonNull()) && !jsonObj.get("last_change").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `last_change` to be a primitive type in the JSON string but got `%s`", jsonObj.get("last_change").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `last_change` to be a primitive type in the JSON string but got `%s`", jsonObj.get("last_change").toString())); } if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -378,7 +373,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/SubmitUserFeedbackRequest.java b/src/main/java/ai/reveng/model/SubmitUserFeedbackRequest.java index cd9c6e85..846c6fbe 100644 --- a/src/main/java/ai/reveng/model/SubmitUserFeedbackRequest.java +++ b/src/main/java/ai/reveng/model/SubmitUserFeedbackRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -114,7 +112,7 @@ public SubmitUserFeedbackRequest screenCaptureUrl(@javax.annotation.Nullable Str } /** - * Get screenCaptureUrl + * An optional URL to a screen capture related to the feedback * @return screenCaptureUrl */ @javax.annotation.Nullable @@ -220,10 +218,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -247,25 +242,25 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SubmitUserFeedbackRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SubmitUserFeedbackRequest is not found in the empty JSON string", SubmitUserFeedbackRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SubmitUserFeedbackRequest is not found in the empty JSON string", SubmitUserFeedbackRequest.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SubmitUserFeedbackRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("current_route").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `current_route` to be a primitive type in the JSON string but got `%s`", jsonObj.get("current_route").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `current_route` to be a primitive type in the JSON string but got `%s`", jsonObj.get("current_route").toString())); } if (!jsonObj.get("feedback").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `feedback` to be a primitive type in the JSON string but got `%s`", jsonObj.get("feedback").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `feedback` to be a primitive type in the JSON string but got `%s`", jsonObj.get("feedback").toString())); } if ((jsonObj.get("screen_capture_url") != null && !jsonObj.get("screen_capture_url").isJsonNull()) && !jsonObj.get("screen_capture_url").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `screen_capture_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("screen_capture_url").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `screen_capture_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("screen_capture_url").toString())); } } @@ -326,7 +321,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/SummaryData.java b/src/main/java/ai/reveng/model/SummaryData.java index 4f983567..dd8ed43f 100644 --- a/src/main/java/ai/reveng/model/SummaryData.java +++ b/src/main/java/ai/reveng/model/SummaryData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -181,50 +179,6 @@ public void setTaskStatus(@javax.annotation.Nonnull TaskStatusEnum taskStatus) { this.taskStatus = taskStatus; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the SummaryData instance itself - */ - public SummaryData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -238,13 +192,12 @@ public boolean equals(Object o) { SummaryData summaryData = (SummaryData) o; return Objects.equals(this.aiSummary, summaryData.aiSummary) && Objects.equals(this.summary, summaryData.summary) && - Objects.equals(this.taskStatus, summaryData.taskStatus)&& - Objects.equals(this.additionalProperties, summaryData.additionalProperties); + Objects.equals(this.taskStatus, summaryData.taskStatus); } @Override public int hashCode() { - return Objects.hash(aiSummary, summary, taskStatus, additionalProperties); + return Objects.hash(aiSummary, summary, taskStatus); } @Override @@ -254,7 +207,6 @@ public String toString() { sb.append(" aiSummary: ").append(toIndentedString(aiSummary)).append("\n"); sb.append(" summary: ").append(toIndentedString(summary)).append("\n"); sb.append(" taskStatus: ").append(toIndentedString(taskStatus)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -264,10 +216,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -291,25 +240,33 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SummaryData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SummaryData is not found in the empty JSON string", SummaryData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in SummaryData is not found in the empty JSON string", SummaryData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SummaryData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SummaryData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SummaryData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("ai_summary").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `ai_summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("ai_summary").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `ai_summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("ai_summary").toString())); } if (!jsonObj.get("summary").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("summary").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("summary").toString())); } if (!jsonObj.get("task_status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `task_status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("task_status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `task_status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("task_status").toString())); } // validate the required field `task_status` TaskStatusEnum.validateJsonElement(jsonObj.get("task_status")); @@ -330,28 +287,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SummaryData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -359,28 +294,7 @@ else if (entry.getValue() instanceof Character) public SummaryData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - SummaryData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/Symbols.java b/src/main/java/ai/reveng/model/Symbols.java index 29fa8564..abdd4bdb 100644 --- a/src/main/java/ai/reveng/model/Symbols.java +++ b/src/main/java/ai/reveng/model/Symbols.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FunctionBoundary; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -194,10 +192,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -221,14 +216,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Symbols.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Symbols is not found in the empty JSON string", Symbols.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Symbols is not found in the empty JSON string", Symbols.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Symbols.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -237,7 +232,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonArrayfunctionBoundaries != null) { // ensure the json data is an array if (!jsonObj.get("function_boundaries").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `function_boundaries` to be an array in the JSON string but got `%s`", jsonObj.get("function_boundaries").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `function_boundaries` to be an array in the JSON string but got `%s`", jsonObj.get("function_boundaries").toString())); } // validate the optional field `function_boundaries` (array) @@ -305,7 +300,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/Tag.java b/src/main/java/ai/reveng/model/Tag.java index 7eb8fed9..abb9d578 100644 --- a/src/main/java/ai/reveng/model/Tag.java +++ b/src/main/java/ai/reveng/model/Tag.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -156,10 +154,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -183,19 +178,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Tag.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Tag is not found in the empty JSON string", Tag.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Tag is not found in the empty JSON string", Tag.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Tag.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } } @@ -256,7 +251,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/TagItem.java b/src/main/java/ai/reveng/model/TagItem.java index a546aff5..74e54fa5 100644 --- a/src/main/java/ai/reveng/model/TagItem.java +++ b/src/main/java/ai/reveng/model/TagItem.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -114,7 +112,7 @@ public TagItem collectionId(@javax.annotation.Nullable Integer collectionId) { } /** - * Get collectionId + * The ID of the analysis owner's associated collection * @return collectionId */ @javax.annotation.Nullable @@ -220,10 +218,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -247,22 +242,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!TagItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in TagItem is not found in the empty JSON string", TagItem.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TagItem is not found in the empty JSON string", TagItem.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TagItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if (!jsonObj.get("origin").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `origin` to be a primitive type in the JSON string but got `%s`", jsonObj.get("origin").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `origin` to be a primitive type in the JSON string but got `%s`", jsonObj.get("origin").toString())); } } @@ -323,7 +318,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/TagResponse.java b/src/main/java/ai/reveng/model/TagResponse.java index bbeb090d..f61e0097 100644 --- a/src/main/java/ai/reveng/model/TagResponse.java +++ b/src/main/java/ai/reveng/model/TagResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -182,10 +180,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -209,22 +204,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!TagResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in TagResponse is not found in the empty JSON string", TagResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TagResponse is not found in the empty JSON string", TagResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TagResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if (!jsonObj.get("origin").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `origin` to be a primitive type in the JSON string but got `%s`", jsonObj.get("origin").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `origin` to be a primitive type in the JSON string but got `%s`", jsonObj.get("origin").toString())); } } @@ -285,7 +280,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/TagSearchResponse.java b/src/main/java/ai/reveng/model/TagSearchResponse.java index 3b684b51..9b7b3e7d 100644 --- a/src/main/java/ai/reveng/model/TagSearchResponse.java +++ b/src/main/java/ai/reveng/model/TagSearchResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.TagSearchResult; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -167,10 +165,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,27 +189,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!TagSearchResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in TagSearchResponse is not found in the empty JSON string", TagSearchResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TagSearchResponse is not found in the empty JSON string", TagSearchResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TagSearchResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("results").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); + if (jsonObj.get("results") != null) { + if (!jsonObj.get("results").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `results` to be an array in the JSON string but got `%s`", jsonObj.get("results").toString())); + } + JsonArray jsonArrayresults = jsonObj.getAsJsonArray("results"); + // validate the required field `results` (array) + for (int i = 0; i < jsonArrayresults.size(); i++) { + TagSearchResult.validateJsonElement(jsonArrayresults.get(i)); + } } - - JsonArray jsonArrayresults = jsonObj.getAsJsonArray("results"); - // validate the required field `results` (array) - for (int i = 0; i < jsonArrayresults.size(); i++) { - TagSearchResult.validateJsonElement(jsonArrayresults.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -274,7 +269,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/TagSearchResult.java b/src/main/java/ai/reveng/model/TagSearchResult.java index 52840cd9..ba314826 100644 --- a/src/main/java/ai/reveng/model/TagSearchResult.java +++ b/src/main/java/ai/reveng/model/TagSearchResult.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -182,10 +180,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -209,19 +204,19 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!TagSearchResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in TagSearchResult is not found in the empty JSON string", TagSearchResult.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TagSearchResult is not found in the empty JSON string", TagSearchResult.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TagSearchResult.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("tag").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tag` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tag").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tag` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tag").toString())); } } @@ -282,7 +277,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/TaskResponse.java b/src/main/java/ai/reveng/model/TaskResponse.java index dc3acbb5..932ce9a2 100644 --- a/src/main/java/ai/reveng/model/TaskResponse.java +++ b/src/main/java/ai/reveng/model/TaskResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.TaskStatus; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -56,7 +54,7 @@ public class TaskResponse { public static final String SERIALIZED_NAME_STATUS = "status"; @SerializedName(SERIALIZED_NAME_STATUS) @javax.annotation.Nullable - private TaskStatus status; + private TaskStatus status = TaskStatus.UNINITIALISED; public static final String SERIALIZED_NAME_ERROR_MESSAGE = "error_message"; @SerializedName(SERIALIZED_NAME_ERROR_MESSAGE) @@ -195,10 +193,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -222,7 +217,7 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!TaskResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in TaskResponse is not found in the empty JSON string", TaskResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TaskResponse is not found in the empty JSON string", TaskResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -231,7 +226,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti TaskStatus.validateJsonElement(jsonObj.get("status")); } if ((jsonObj.get("error_message") != null && !jsonObj.get("error_message").isJsonNull()) && !jsonObj.get("error_message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `error_message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error_message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `error_message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error_message").toString())); } } @@ -292,7 +287,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/TaskStatus.java b/src/main/java/ai/reveng/model/TaskStatus.java index 5a78bf0d..b5b0b21b 100644 --- a/src/main/java/ai/reveng/model/TaskStatus.java +++ b/src/main/java/ai/reveng/model/TaskStatus.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/TaskStatusResponse.java b/src/main/java/ai/reveng/model/TaskStatusResponse.java index f8f19cef..c3fc2329 100644 --- a/src/main/java/ai/reveng/model/TaskStatusResponse.java +++ b/src/main/java/ai/reveng/model/TaskStatusResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.BinaryTaskStatus; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -205,10 +203,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -232,14 +227,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!TaskStatusResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in TaskStatusResponse is not found in the empty JSON string", TaskStatusResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TaskStatusResponse is not found in the empty JSON string", TaskStatusResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TaskStatusResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -247,7 +242,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti BinaryTaskStatus.validateJsonElement(jsonObj.get("status")); // ensure the optional json data is an array if present if (jsonObj.get("log_history") != null && !jsonObj.get("log_history").isJsonNull() && !jsonObj.get("log_history").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `log_history` to be an array in the JSON string but got `%s`", jsonObj.get("log_history").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `log_history` to be an array in the JSON string but got `%s`", jsonObj.get("log_history").toString())); } } @@ -308,7 +303,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/TcpCarvedFile.java b/src/main/java/ai/reveng/model/TcpCarvedFile.java new file mode 100644 index 00000000..09dca965 --- /dev/null +++ b/src/main/java/ai/reveng/model/TcpCarvedFile.java @@ -0,0 +1,425 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import ai.reveng.invoker.JSON; + +/** + * TcpCarvedFile + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TcpCarvedFile { + public static final String SERIALIZED_NAME_DIRECTION = "direction"; + @SerializedName(SERIALIZED_NAME_DIRECTION) + @javax.annotation.Nonnull + private String direction; + + public static final String SERIALIZED_NAME_FILENAME = "filename"; + @SerializedName(SERIALIZED_NAME_FILENAME) + @javax.annotation.Nullable + private String filename; + + public static final String SERIALIZED_NAME_IS_PE = "is_pe"; + @SerializedName(SERIALIZED_NAME_IS_PE) + @javax.annotation.Nonnull + private Boolean isPe; + + public static final String SERIALIZED_NAME_MIME_TYPE = "mime_type"; + @SerializedName(SERIALIZED_NAME_MIME_TYPE) + @javax.annotation.Nullable + private String mimeType; + + public static final String SERIALIZED_NAME_OFFSET = "offset"; + @SerializedName(SERIALIZED_NAME_OFFSET) + @javax.annotation.Nonnull + private Long offset; + + public static final String SERIALIZED_NAME_SHA256 = "sha256"; + @SerializedName(SERIALIZED_NAME_SHA256) + @javax.annotation.Nonnull + private String sha256; + + public static final String SERIALIZED_NAME_SIZE = "size"; + @SerializedName(SERIALIZED_NAME_SIZE) + @javax.annotation.Nonnull + private Long size; + + public static final String SERIALIZED_NAME_YARA_HITS = "yara_hits"; + @SerializedName(SERIALIZED_NAME_YARA_HITS) + @javax.annotation.Nullable + private List yaraHits; + + public TcpCarvedFile() { + } + + public TcpCarvedFile direction(@javax.annotation.Nonnull String direction) { + this.direction = direction; + return this; + } + + /** + * Get direction + * @return direction + */ + @javax.annotation.Nonnull + public String getDirection() { + return direction; + } + + public void setDirection(@javax.annotation.Nonnull String direction) { + this.direction = direction; + } + + + public TcpCarvedFile filename(@javax.annotation.Nullable String filename) { + this.filename = filename; + return this; + } + + /** + * Get filename + * @return filename + */ + @javax.annotation.Nullable + public String getFilename() { + return filename; + } + + public void setFilename(@javax.annotation.Nullable String filename) { + this.filename = filename; + } + + + public TcpCarvedFile isPe(@javax.annotation.Nonnull Boolean isPe) { + this.isPe = isPe; + return this; + } + + /** + * Get isPe + * @return isPe + */ + @javax.annotation.Nonnull + public Boolean getIsPe() { + return isPe; + } + + public void setIsPe(@javax.annotation.Nonnull Boolean isPe) { + this.isPe = isPe; + } + + + public TcpCarvedFile mimeType(@javax.annotation.Nullable String mimeType) { + this.mimeType = mimeType; + return this; + } + + /** + * Get mimeType + * @return mimeType + */ + @javax.annotation.Nullable + public String getMimeType() { + return mimeType; + } + + public void setMimeType(@javax.annotation.Nullable String mimeType) { + this.mimeType = mimeType; + } + + + public TcpCarvedFile offset(@javax.annotation.Nonnull Long offset) { + this.offset = offset; + return this; + } + + /** + * Get offset + * @return offset + */ + @javax.annotation.Nonnull + public Long getOffset() { + return offset; + } + + public void setOffset(@javax.annotation.Nonnull Long offset) { + this.offset = offset; + } + + + public TcpCarvedFile sha256(@javax.annotation.Nonnull String sha256) { + this.sha256 = sha256; + return this; + } + + /** + * Get sha256 + * @return sha256 + */ + @javax.annotation.Nonnull + public String getSha256() { + return sha256; + } + + public void setSha256(@javax.annotation.Nonnull String sha256) { + this.sha256 = sha256; + } + + + public TcpCarvedFile size(@javax.annotation.Nonnull Long size) { + this.size = size; + return this; + } + + /** + * Get size + * @return size + */ + @javax.annotation.Nonnull + public Long getSize() { + return size; + } + + public void setSize(@javax.annotation.Nonnull Long size) { + this.size = size; + } + + + public TcpCarvedFile yaraHits(@javax.annotation.Nullable List yaraHits) { + this.yaraHits = yaraHits; + return this; + } + + public TcpCarvedFile addYaraHitsItem(String yaraHitsItem) { + if (this.yaraHits == null) { + this.yaraHits = new ArrayList<>(); + } + this.yaraHits.add(yaraHitsItem); + return this; + } + + /** + * Get yaraHits + * @return yaraHits + */ + @javax.annotation.Nullable + public List getYaraHits() { + return yaraHits; + } + + public void setYaraHits(@javax.annotation.Nullable List yaraHits) { + this.yaraHits = yaraHits; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TcpCarvedFile tcpCarvedFile = (TcpCarvedFile) o; + return Objects.equals(this.direction, tcpCarvedFile.direction) && + Objects.equals(this.filename, tcpCarvedFile.filename) && + Objects.equals(this.isPe, tcpCarvedFile.isPe) && + Objects.equals(this.mimeType, tcpCarvedFile.mimeType) && + Objects.equals(this.offset, tcpCarvedFile.offset) && + Objects.equals(this.sha256, tcpCarvedFile.sha256) && + Objects.equals(this.size, tcpCarvedFile.size) && + Objects.equals(this.yaraHits, tcpCarvedFile.yaraHits); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(direction, filename, isPe, mimeType, offset, sha256, size, yaraHits); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TcpCarvedFile {\n"); + sb.append(" direction: ").append(toIndentedString(direction)).append("\n"); + sb.append(" filename: ").append(toIndentedString(filename)).append("\n"); + sb.append(" isPe: ").append(toIndentedString(isPe)).append("\n"); + sb.append(" mimeType: ").append(toIndentedString(mimeType)).append("\n"); + sb.append(" offset: ").append(toIndentedString(offset)).append("\n"); + sb.append(" sha256: ").append(toIndentedString(sha256)).append("\n"); + sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" yaraHits: ").append(toIndentedString(yaraHits)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("direction", "filename", "is_pe", "mime_type", "offset", "sha256", "size", "yara_hits")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("direction", "is_pe", "offset", "sha256", "size")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to TcpCarvedFile + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!TcpCarvedFile.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TcpCarvedFile is not found in the empty JSON string", TcpCarvedFile.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!TcpCarvedFile.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TcpCarvedFile` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TcpCarvedFile.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("direction").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `direction` to be a primitive type in the JSON string but got `%s`", jsonObj.get("direction").toString())); + } + if ((jsonObj.get("filename") != null && !jsonObj.get("filename").isJsonNull()) && !jsonObj.get("filename").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `filename` to be a primitive type in the JSON string but got `%s`", jsonObj.get("filename").toString())); + } + if ((jsonObj.get("mime_type") != null && !jsonObj.get("mime_type").isJsonNull()) && !jsonObj.get("mime_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `mime_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mime_type").toString())); + } + if (!jsonObj.get("sha256").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha256` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha256").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("yara_hits") != null && !jsonObj.get("yara_hits").isJsonNull() && !jsonObj.get("yara_hits").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `yara_hits` to be an array in the JSON string but got `%s`", jsonObj.get("yara_hits").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TcpCarvedFile.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TcpCarvedFile' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TcpCarvedFile.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TcpCarvedFile value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public TcpCarvedFile read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TcpCarvedFile given an JSON string + * + * @param jsonString JSON string + * @return An instance of TcpCarvedFile + * @throws IOException if the JSON string is invalid with respect to TcpCarvedFile + */ + public static TcpCarvedFile fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TcpCarvedFile.class); + } + + /** + * Convert an instance of TcpCarvedFile to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/ai/reveng/model/TimestampModel.java b/src/main/java/ai/reveng/model/TimestampModel.java index eaa20230..22081d5d 100644 --- a/src/main/java/ai/reveng/model/TimestampModel.java +++ b/src/main/java/ai/reveng/model/TimestampModel.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -208,10 +206,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -235,14 +230,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!TimestampModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in TimestampModel is not found in the empty JSON string", TimestampModel.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TimestampModel is not found in the empty JSON string", TimestampModel.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TimestampModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -305,7 +300,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/TokenisedData.java b/src/main/java/ai/reveng/model/TokenisedData.java index 2df1bd86..25f7b250 100644 --- a/src/main/java/ai/reveng/model/TokenisedData.java +++ b/src/main/java/ai/reveng/model/TokenisedData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AIDecompFunctionMapping; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -210,50 +208,6 @@ public void setTokenisedDecompilation(@javax.annotation.Nullable String tokenise this.tokenisedDecompilation = tokenisedDecompilation; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the TokenisedData instance itself - */ - public TokenisedData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -268,13 +222,12 @@ public boolean equals(Object o) { return Objects.equals(this.functionMapping, tokenisedData.functionMapping) && Objects.equals(this.predictedFunctionName, tokenisedData.predictedFunctionName) && Objects.equals(this.status, tokenisedData.status) && - Objects.equals(this.tokenisedDecompilation, tokenisedData.tokenisedDecompilation)&& - Objects.equals(this.additionalProperties, tokenisedData.additionalProperties); + Objects.equals(this.tokenisedDecompilation, tokenisedData.tokenisedDecompilation); } @Override public int hashCode() { - return Objects.hash(functionMapping, predictedFunctionName, status, tokenisedDecompilation, additionalProperties); + return Objects.hash(functionMapping, predictedFunctionName, status, tokenisedDecompilation); } @Override @@ -285,7 +238,6 @@ public String toString() { sb.append(" predictedFunctionName: ").append(toIndentedString(predictedFunctionName)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" tokenisedDecompilation: ").append(toIndentedString(tokenisedDecompilation)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -295,10 +247,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -322,27 +271,39 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!TokenisedData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in TokenisedData is not found in the empty JSON string", TokenisedData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TokenisedData is not found in the empty JSON string", TokenisedData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!TokenisedData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TokenisedData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TokenisedData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `function_mapping` + if (jsonObj.get("function_mapping") != null && !jsonObj.get("function_mapping").isJsonNull()) { + AIDecompFunctionMapping.validateJsonElement(jsonObj.get("function_mapping")); + } if ((jsonObj.get("predicted_function_name") != null && !jsonObj.get("predicted_function_name").isJsonNull()) && !jsonObj.get("predicted_function_name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `predicted_function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("predicted_function_name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `predicted_function_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("predicted_function_name").toString())); } if (!jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); } // validate the required field `status` StatusEnum.validateJsonElement(jsonObj.get("status")); if ((jsonObj.get("tokenised_decompilation") != null && !jsonObj.get("tokenised_decompilation").isJsonNull()) && !jsonObj.get("tokenised_decompilation").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tokenised_decompilation` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tokenised_decompilation").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tokenised_decompilation` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tokenised_decompilation").toString())); } } @@ -361,28 +322,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TokenisedData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -390,28 +329,7 @@ else if (entry.getValue() instanceof Character) public TokenisedData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - TokenisedData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/TriageFunctionResponse.java b/src/main/java/ai/reveng/model/TriageFunctionResponse.java index 705eaf97..6fc748a5 100644 --- a/src/main/java/ai/reveng/model/TriageFunctionResponse.java +++ b/src/main/java/ai/reveng/model/TriageFunctionResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -345,10 +343,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -372,25 +367,25 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!TriageFunctionResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in TriageFunctionResponse is not found in the empty JSON string", TriageFunctionResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TriageFunctionResponse is not found in the empty JSON string", TriageFunctionResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TriageFunctionResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("summary").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("summary").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("summary").toString())); } // ensure the required json array is present if (jsonObj.get("capabilities") == null) { throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); } else if (!jsonObj.get("capabilities").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `capabilities` to be an array in the JSON string but got `%s`", jsonObj.get("capabilities").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `capabilities` to be an array in the JSON string but got `%s`", jsonObj.get("capabilities").toString())); } } @@ -451,7 +446,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/TriageReportResponse.java b/src/main/java/ai/reveng/model/TriageReportResponse.java index c1a115d2..1ba506d3 100644 --- a/src/main/java/ai/reveng/model/TriageReportResponse.java +++ b/src/main/java/ai/reveng/model/TriageReportResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.TriageFunctionResponse; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -222,10 +220,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -249,30 +244,30 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!TriageReportResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in TriageReportResponse is not found in the empty JSON string", TriageReportResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TriageReportResponse is not found in the empty JSON string", TriageReportResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TriageReportResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("summary").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("summary").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `summary` to be a primitive type in the JSON string but got `%s`", jsonObj.get("summary").toString())); } - // ensure the json data is an array - if (!jsonObj.get("functions").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); + if (jsonObj.get("functions") != null) { + if (!jsonObj.get("functions").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `functions` to be an array in the JSON string but got `%s`", jsonObj.get("functions").toString())); + } + JsonArray jsonArrayfunctions = jsonObj.getAsJsonArray("functions"); + // validate the required field `functions` (array) + for (int i = 0; i < jsonArrayfunctions.size(); i++) { + TriageFunctionResponse.validateJsonElement(jsonArrayfunctions.get(i)); + } } - - JsonArray jsonArrayfunctions = jsonObj.getAsJsonArray("functions"); - // validate the required field `functions` (array) - for (int i = 0; i < jsonArrayfunctions.size(); i++) { - TriageFunctionResponse.validateJsonElement(jsonArrayfunctions.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -332,7 +327,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/Ttp.java b/src/main/java/ai/reveng/model/Ttp.java index 3a2afb6e..4e7c700e 100644 --- a/src/main/java/ai/reveng/model/Ttp.java +++ b/src/main/java/ai/reveng/model/Ttp.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -224,50 +222,6 @@ public void setScore(@javax.annotation.Nonnull Long score) { this.score = score; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the Ttp instance itself - */ - public Ttp putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -284,8 +238,7 @@ public boolean equals(Object o) { Objects.equals(this.name, ttp.name) && Objects.equals(this.namespace, ttp.namespace) && Objects.equals(this.processSeqids, ttp.processSeqids) && - Objects.equals(this.score, ttp.score)&& - Objects.equals(this.additionalProperties, ttp.additionalProperties); + Objects.equals(this.score, ttp.score); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -294,7 +247,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(attAmpersandCk, mbc, name, namespace, processSeqids, score, additionalProperties); + return Objects.hash(attAmpersandCk, mbc, name, namespace, processSeqids, score); } private static int hashCodeNullable(JsonNullable a) { @@ -314,7 +267,6 @@ public String toString() { sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); sb.append(" processSeqids: ").append(toIndentedString(processSeqids)).append("\n"); sb.append(" score: ").append(toIndentedString(score)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -324,10 +276,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -351,34 +300,42 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Ttp.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Ttp is not found in the empty JSON string", Ttp.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Ttp is not found in the empty JSON string", Ttp.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!Ttp.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Ttp` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Ttp.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the optional json data is an array if present if (jsonObj.get("att&ck") != null && !jsonObj.get("att&ck").isJsonNull() && !jsonObj.get("att&ck").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `att&ck` to be an array in the JSON string but got `%s`", jsonObj.get("att&ck").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `att&ck` to be an array in the JSON string but got `%s`", jsonObj.get("att&ck").toString())); } // ensure the optional json data is an array if present if (jsonObj.get("mbc") != null && !jsonObj.get("mbc").isJsonNull() && !jsonObj.get("mbc").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `mbc` to be an array in the JSON string but got `%s`", jsonObj.get("mbc").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `mbc` to be an array in the JSON string but got `%s`", jsonObj.get("mbc").toString())); } if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if ((jsonObj.get("namespace") != null && !jsonObj.get("namespace").isJsonNull()) && !jsonObj.get("namespace").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `namespace` to be a primitive type in the JSON string but got `%s`", jsonObj.get("namespace").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `namespace` to be a primitive type in the JSON string but got `%s`", jsonObj.get("namespace").toString())); } // ensure the optional json data is an array if present if (jsonObj.get("process_seqids") != null && !jsonObj.get("process_seqids").isJsonNull() && !jsonObj.get("process_seqids").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `process_seqids` to be an array in the JSON string but got `%s`", jsonObj.get("process_seqids").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `process_seqids` to be an array in the JSON string but got `%s`", jsonObj.get("process_seqids").toString())); } } @@ -397,28 +354,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Ttp value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -426,28 +361,7 @@ else if (entry.getValue() instanceof Character) public Ttp read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - Ttp instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/TypeDefinition.java b/src/main/java/ai/reveng/model/TypeDefinition.java index 546cf12d..f7e29f5a 100644 --- a/src/main/java/ai/reveng/model/TypeDefinition.java +++ b/src/main/java/ai/reveng/model/TypeDefinition.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -81,7 +79,7 @@ public TypeDefinition lastChange(@javax.annotation.Nullable String lastChange) { } /** - * Get lastChange + * Timestamp of the last change to this type definition * @return lastChange */ @javax.annotation.Nullable @@ -246,10 +244,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -273,28 +268,28 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!TypeDefinition.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in TypeDefinition is not found in the empty JSON string", TypeDefinition.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TypeDefinition is not found in the empty JSON string", TypeDefinition.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TypeDefinition.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("last_change") != null && !jsonObj.get("last_change").isJsonNull()) && !jsonObj.get("last_change").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `last_change` to be a primitive type in the JSON string but got `%s`", jsonObj.get("last_change").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `last_change` to be a primitive type in the JSON string but got `%s`", jsonObj.get("last_change").toString())); } if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } if ((jsonObj.get("artifact_type") != null && !jsonObj.get("artifact_type").isJsonNull()) && !jsonObj.get("artifact_type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `artifact_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("artifact_type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `artifact_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("artifact_type").toString())); } } @@ -355,7 +350,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/UpdateFunctionDataTypes.java b/src/main/java/ai/reveng/model/UpdateFunctionDataTypes.java index ecfbce29..df8d80ca 100644 --- a/src/main/java/ai/reveng/model/UpdateFunctionDataTypes.java +++ b/src/main/java/ai/reveng/model/UpdateFunctionDataTypes.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.FunctionInfoInput; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -183,10 +181,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -210,14 +205,14 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!UpdateFunctionDataTypes.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in UpdateFunctionDataTypes is not found in the empty JSON string", UpdateFunctionDataTypes.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in UpdateFunctionDataTypes is not found in the empty JSON string", UpdateFunctionDataTypes.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateFunctionDataTypes.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -282,7 +277,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/UploadFileType.java b/src/main/java/ai/reveng/model/UploadFileType.java index e7fa96cb..2241000f 100644 --- a/src/main/java/ai/reveng/model/UploadFileType.java +++ b/src/main/java/ai/reveng/model/UploadFileType.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/UploadResponse.java b/src/main/java/ai/reveng/model/UploadResponse.java index e5b4677f..e17fadaa 100644 --- a/src/main/java/ai/reveng/model/UploadResponse.java +++ b/src/main/java/ai/reveng/model/UploadResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.UploadFileType; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -209,10 +207,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -236,24 +231,24 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!UploadResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in UploadResponse is not found in the empty JSON string", UploadResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in UploadResponse is not found in the empty JSON string", UploadResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UploadResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("sha_256_hash").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sha_256_hash` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sha_256_hash").toString())); } // validate the required field `file_type` UploadFileType.validateJsonElement(jsonObj.get("file_type")); if (!jsonObj.get("filename").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `filename` to be a primitive type in the JSON string but got `%s`", jsonObj.get("filename").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `filename` to be a primitive type in the JSON string but got `%s`", jsonObj.get("filename").toString())); } } @@ -314,7 +309,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/UpsertAiDecomplationRatingRequest.java b/src/main/java/ai/reveng/model/UpsertAiDecomplationRatingRequest.java index 750ac539..1c0efd7a 100644 --- a/src/main/java/ai/reveng/model/UpsertAiDecomplationRatingRequest.java +++ b/src/main/java/ai/reveng/model/UpsertAiDecomplationRatingRequest.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.AiDecompilationRating; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -90,7 +88,7 @@ public UpsertAiDecomplationRatingRequest reason(@javax.annotation.Nullable Strin } /** - * Get reason + * An optional reason for the rating * @return reason */ @javax.annotation.Nullable @@ -183,10 +181,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -210,21 +205,21 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!UpsertAiDecomplationRatingRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in UpsertAiDecomplationRatingRequest is not found in the empty JSON string", UpsertAiDecomplationRatingRequest.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in UpsertAiDecomplationRatingRequest is not found in the empty JSON string", UpsertAiDecomplationRatingRequest.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpsertAiDecomplationRatingRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the required field `rating` AiDecompilationRating.validateJsonElement(jsonObj.get("rating")); if ((jsonObj.get("reason") != null && !jsonObj.get("reason").isJsonNull()) && !jsonObj.get("reason").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); } } @@ -285,7 +280,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/UpsertOverridesData.java b/src/main/java/ai/reveng/model/UpsertOverridesData.java index f2605a53..23d90cbb 100644 --- a/src/main/java/ai/reveng/model/UpsertOverridesData.java +++ b/src/main/java/ai/reveng/model/UpsertOverridesData.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -87,50 +85,6 @@ public void setUserOverrideMappings(@javax.annotation.Nonnull Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the UpsertOverridesData instance itself - */ - public UpsertOverridesData putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -142,13 +96,12 @@ public boolean equals(Object o) { return false; } UpsertOverridesData upsertOverridesData = (UpsertOverridesData) o; - return Objects.equals(this.userOverrideMappings, upsertOverridesData.userOverrideMappings)&& - Objects.equals(this.additionalProperties, upsertOverridesData.additionalProperties); + return Objects.equals(this.userOverrideMappings, upsertOverridesData.userOverrideMappings); } @Override public int hashCode() { - return Objects.hash(userOverrideMappings, additionalProperties); + return Objects.hash(userOverrideMappings); } @Override @@ -156,7 +109,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class UpsertOverridesData {\n"); sb.append(" userOverrideMappings: ").append(toIndentedString(userOverrideMappings)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -166,10 +118,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -193,14 +142,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!UpsertOverridesData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in UpsertOverridesData is not found in the empty JSON string", UpsertOverridesData.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in UpsertOverridesData is not found in the empty JSON string", UpsertOverridesData.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!UpsertOverridesData.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpsertOverridesData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpsertOverridesData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -221,28 +178,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpsertOverridesData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -250,28 +185,7 @@ else if (entry.getValue() instanceof Character) public UpsertOverridesData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - UpsertOverridesData instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/UpsertOverridesInputBody.java b/src/main/java/ai/reveng/model/UpsertOverridesInputBody.java index 44bcc966..4f963dca 100644 --- a/src/main/java/ai/reveng/model/UpsertOverridesInputBody.java +++ b/src/main/java/ai/reveng/model/UpsertOverridesInputBody.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -44,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -87,50 +85,6 @@ public void setOverrides(@javax.annotation.Nonnull Map overrides this.overrides = overrides; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the UpsertOverridesInputBody instance itself - */ - public UpsertOverridesInputBody putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -142,13 +96,12 @@ public boolean equals(Object o) { return false; } UpsertOverridesInputBody upsertOverridesInputBody = (UpsertOverridesInputBody) o; - return Objects.equals(this.overrides, upsertOverridesInputBody.overrides)&& - Objects.equals(this.additionalProperties, upsertOverridesInputBody.additionalProperties); + return Objects.equals(this.overrides, upsertOverridesInputBody.overrides); } @Override public int hashCode() { - return Objects.hash(overrides, additionalProperties); + return Objects.hash(overrides); } @Override @@ -156,7 +109,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class UpsertOverridesInputBody {\n"); sb.append(" overrides: ").append(toIndentedString(overrides)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -166,10 +118,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -193,14 +142,22 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!UpsertOverridesInputBody.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in UpsertOverridesInputBody is not found in the empty JSON string", UpsertOverridesInputBody.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in UpsertOverridesInputBody is not found in the empty JSON string", UpsertOverridesInputBody.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!UpsertOverridesInputBody.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpsertOverridesInputBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpsertOverridesInputBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -221,28 +178,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpsertOverridesInputBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -250,28 +185,7 @@ else if (entry.getValue() instanceof Character) public UpsertOverridesInputBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - UpsertOverridesInputBody instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/UserActivityResponse.java b/src/main/java/ai/reveng/model/UserActivityResponse.java index ba40e930..9c013cd8 100644 --- a/src/main/java/ai/reveng/model/UserActivityResponse.java +++ b/src/main/java/ai/reveng/model/UserActivityResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -287,10 +285,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -314,31 +309,31 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!UserActivityResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in UserActivityResponse is not found in the empty JSON string", UserActivityResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in UserActivityResponse is not found in the empty JSON string", UserActivityResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UserActivityResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("actions").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `actions` to be a primitive type in the JSON string but got `%s`", jsonObj.get("actions").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `actions` to be a primitive type in the JSON string but got `%s`", jsonObj.get("actions").toString())); } if (!jsonObj.get("activity_scope").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `activity_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("activity_scope").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `activity_scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("activity_scope").toString())); } if (!jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (!jsonObj.get("sources").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `sources` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sources").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sources` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sources").toString())); } if (!jsonObj.get("username").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); } } @@ -399,7 +394,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/Vulnerabilities.java b/src/main/java/ai/reveng/model/Vulnerabilities.java index bef56fbe..6e2086f8 100644 --- a/src/main/java/ai/reveng/model/Vulnerabilities.java +++ b/src/main/java/ai/reveng/model/Vulnerabilities.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.Vulnerability; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -167,10 +165,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -194,27 +189,27 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Vulnerabilities.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Vulnerabilities is not found in the empty JSON string", Vulnerabilities.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Vulnerabilities is not found in the empty JSON string", Vulnerabilities.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Vulnerabilities.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("vulnerabilities").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `vulnerabilities` to be an array in the JSON string but got `%s`", jsonObj.get("vulnerabilities").toString())); + if (jsonObj.get("vulnerabilities") != null) { + if (!jsonObj.get("vulnerabilities").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `vulnerabilities` to be an array in the JSON string but got `%s`", jsonObj.get("vulnerabilities").toString())); + } + JsonArray jsonArrayvulnerabilities = jsonObj.getAsJsonArray("vulnerabilities"); + // validate the required field `vulnerabilities` (array) + for (int i = 0; i < jsonArrayvulnerabilities.size(); i++) { + Vulnerability.validateJsonElement(jsonArrayvulnerabilities.get(i)); + } } - - JsonArray jsonArrayvulnerabilities = jsonObj.getAsJsonArray("vulnerabilities"); - // validate the required field `vulnerabilities` (array) - for (int i = 0; i < jsonArrayvulnerabilities.size(); i++) { - Vulnerability.validateJsonElement(jsonArrayvulnerabilities.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -274,7 +269,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/Vulnerability.java b/src/main/java/ai/reveng/model/Vulnerability.java index fdafe8aa..9a540ba7 100644 --- a/src/main/java/ai/reveng/model/Vulnerability.java +++ b/src/main/java/ai/reveng/model/Vulnerability.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -43,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -477,10 +475,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -504,45 +499,45 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Vulnerability.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Vulnerability is not found in the empty JSON string", Vulnerability.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in Vulnerability is not found in the empty JSON string", Vulnerability.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Vulnerability.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (!jsonObj.get("vendor").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `vendor` to be a primitive type in the JSON string but got `%s`", jsonObj.get("vendor").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `vendor` to be a primitive type in the JSON string but got `%s`", jsonObj.get("vendor").toString())); } if (!jsonObj.get("product").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `product` to be a primitive type in the JSON string but got `%s`", jsonObj.get("product").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `product` to be a primitive type in the JSON string but got `%s`", jsonObj.get("product").toString())); } if (!jsonObj.get("version").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("version").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("version").toString())); } if (!jsonObj.get("cve_number").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `cve_number` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cve_number").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `cve_number` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cve_number").toString())); } if (!jsonObj.get("severity").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `severity` to be a primitive type in the JSON string but got `%s`", jsonObj.get("severity").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `severity` to be a primitive type in the JSON string but got `%s`", jsonObj.get("severity").toString())); } // validate the required field `severity` SeverityEnum.validateJsonElement(jsonObj.get("severity")); if (!jsonObj.get("source").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `source` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source").toString())); } if (!jsonObj.get("cvss_version").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `cvss_version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cvss_version").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `cvss_version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cvss_version").toString())); } if (!jsonObj.get("cvss_vector").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `cvss_vector` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cvss_vector").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `cvss_vector` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cvss_vector").toString())); } if (!jsonObj.get("remarks").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `remarks` to be a primitive type in the JSON string but got `%s`", jsonObj.get("remarks").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `remarks` to be a primitive type in the JSON string but got `%s`", jsonObj.get("remarks").toString())); } } @@ -603,7 +598,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/WarningEvent.java b/src/main/java/ai/reveng/model/WarningEvent.java index 2bfb0dc3..727dbc21 100644 --- a/src/main/java/ai/reveng/model/WarningEvent.java +++ b/src/main/java/ai/reveng/model/WarningEvent.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -208,50 +206,6 @@ public void setType(@javax.annotation.Nonnull String type) { this.type = type; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the WarningEvent instance itself - */ - public WarningEvent putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -268,8 +222,7 @@ public boolean equals(Object o) { Objects.equals(this.kind, warningEvent.kind) && Objects.equals(this.message, warningEvent.message) && Objects.equals(this.seq, warningEvent.seq) && - Objects.equals(this.type, warningEvent.type)&& - Objects.equals(this.additionalProperties, warningEvent.additionalProperties); + Objects.equals(this.type, warningEvent.type); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -278,7 +231,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(attempt, identifiers, kind, message, seq, type, additionalProperties); + return Objects.hash(attempt, identifiers, kind, message, seq, type); } private static int hashCodeNullable(JsonNullable a) { @@ -298,7 +251,6 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" seq: ").append(toIndentedString(seq)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -308,10 +260,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -335,29 +284,37 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!WarningEvent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in WarningEvent is not found in the empty JSON string", WarningEvent.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in WarningEvent is not found in the empty JSON string", WarningEvent.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!WarningEvent.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `WarningEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : WarningEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the optional json data is an array if present if (jsonObj.get("identifiers") != null && !jsonObj.get("identifiers").isJsonNull() && !jsonObj.get("identifiers").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `identifiers` to be an array in the JSON string but got `%s`", jsonObj.get("identifiers").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `identifiers` to be an array in the JSON string but got `%s`", jsonObj.get("identifiers").toString())); } if (!jsonObj.get("kind").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString())); } if (!jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); } if (!jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); } } @@ -376,28 +333,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, WarningEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -405,28 +340,7 @@ else if (entry.getValue() instanceof Character) public WarningEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - WarningEvent instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/WorkflowProgress.java b/src/main/java/ai/reveng/model/WorkflowProgress.java index 72637c34..17f804a6 100644 --- a/src/main/java/ai/reveng/model/WorkflowProgress.java +++ b/src/main/java/ai/reveng/model/WorkflowProgress.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.ProgressMessage; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -45,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -244,50 +242,6 @@ public void setStepsTotal(@javax.annotation.Nonnull Long stepsTotal) { this.stepsTotal = stepsTotal; } - /** - * A container for additional, undeclared properties. - * This is a holder for any undeclared properties as specified with - * the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. - * If the property does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the WorkflowProgress instance itself - */ - public WorkflowProgress putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; - } - - /** - * Return the additional (undeclared) property. - * - * @return a map of objects - */ - public Map getAdditionalProperties() { - return additionalProperties; - } - - /** - * Return the additional (undeclared) property with the specified name. - * - * @param key name of the property - * @return an object - */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } @Override @@ -303,13 +257,12 @@ public boolean equals(Object o) { Objects.equals(this.status, workflowProgress.status) && Objects.equals(this.step, workflowProgress.step) && Objects.equals(this.stepIndex, workflowProgress.stepIndex) && - Objects.equals(this.stepsTotal, workflowProgress.stepsTotal)&& - Objects.equals(this.additionalProperties, workflowProgress.additionalProperties); + Objects.equals(this.stepsTotal, workflowProgress.stepsTotal); } @Override public int hashCode() { - return Objects.hash(messages, status, step, stepIndex, stepsTotal, additionalProperties); + return Objects.hash(messages, status, step, stepIndex, stepsTotal); } @Override @@ -321,7 +274,6 @@ public String toString() { sb.append(" step: ").append(toIndentedString(step)).append("\n"); sb.append(" stepIndex: ").append(toIndentedString(stepIndex)).append("\n"); sb.append(" stepsTotal: ").append(toIndentedString(stepsTotal)).append("\n"); - sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -331,10 +283,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -358,30 +307,42 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!WorkflowProgress.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in WorkflowProgress is not found in the empty JSON string", WorkflowProgress.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in WorkflowProgress is not found in the empty JSON string", WorkflowProgress.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!WorkflowProgress.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `WorkflowProgress` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : WorkflowProgress.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the required json array is present - if (jsonObj.get("messages") == null) { - throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); - } else if (!jsonObj.get("messages").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `messages` to be an array in the JSON string but got `%s`", jsonObj.get("messages").toString())); + if (jsonObj.get("messages") != null && !jsonObj.get("messages").isJsonNull()) { + if (!jsonObj.get("messages").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `messages` to be an array in the JSON string but got `%s`", jsonObj.get("messages").toString())); + } + JsonArray jsonArraymessages = jsonObj.getAsJsonArray("messages"); + // validate the required field `messages` (array) + for (int i = 0; i < jsonArraymessages.size(); i++) { + ProgressMessage.validateJsonElement(jsonArraymessages.get(i)); + } } if (!jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); } // validate the required field `status` StatusEnum.validateJsonElement(jsonObj.get("status")); if (!jsonObj.get("step").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `step` to be a primitive type in the JSON string but got `%s`", jsonObj.get("step").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `step` to be a primitive type in the JSON string but got `%s`", jsonObj.get("step").toString())); } } @@ -400,28 +361,6 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, WorkflowProgress value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - JsonElement jsonElement = gson.toJsonTree(entry.getValue()); - if (jsonElement.isJsonArray()) { - obj.add(entry.getKey(), jsonElement.getAsJsonArray()); - } else { - obj.add(entry.getKey(), jsonElement.getAsJsonObject()); - } - } - } - } elementAdapter.write(out, obj); } @@ -429,28 +368,7 @@ else if (entry.getValue() instanceof Character) public WorkflowProgress read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - WorkflowProgress instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; + return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); diff --git a/src/main/java/ai/reveng/model/Workspace.java b/src/main/java/ai/reveng/model/Workspace.java index 0aa2257a..86b30154 100644 --- a/src/main/java/ai/reveng/model/Workspace.java +++ b/src/main/java/ai/reveng/model/Workspace.java @@ -13,11 +13,9 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import com.google.gson.annotations.SerializedName; import java.io.IOException; -import java.util.Locale; import com.google.gson.TypeAdapter; import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; diff --git a/src/main/java/ai/reveng/model/XrefFromResponse.java b/src/main/java/ai/reveng/model/XrefFromResponse.java index 9f6e53af..10d0ab96 100644 --- a/src/main/java/ai/reveng/model/XrefFromResponse.java +++ b/src/main/java/ai/reveng/model/XrefFromResponse.java @@ -13,13 +13,13 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SegmentInfo; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import java.io.File; import java.io.IOException; import java.util.Arrays; import org.openapitools.jackson.nullable.JsonNullable; @@ -44,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -81,7 +80,7 @@ public class XrefFromResponse { public static final String SERIALIZED_NAME_RAW_DATA = "raw_data"; @SerializedName(SERIALIZED_NAME_RAW_DATA) @javax.annotation.Nullable - private String rawData; + private File rawData; public static final String SERIALIZED_NAME_SEGMENT = "segment"; @SerializedName(SERIALIZED_NAME_SEGMENT) @@ -196,7 +195,7 @@ public void setIsString(@javax.annotation.Nullable Boolean isString) { } - public XrefFromResponse rawData(@javax.annotation.Nullable String rawData) { + public XrefFromResponse rawData(@javax.annotation.Nullable File rawData) { this.rawData = rawData; return this; } @@ -206,11 +205,11 @@ public XrefFromResponse rawData(@javax.annotation.Nullable String rawData) { * @return rawData */ @javax.annotation.Nullable - public String getRawData() { + public File getRawData() { return rawData; } - public void setRawData(@javax.annotation.Nullable String rawData) { + public void setRawData(@javax.annotation.Nullable File rawData) { this.rawData = rawData; } @@ -377,10 +376,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -404,32 +400,29 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!XrefFromResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in XrefFromResponse is not found in the empty JSON string", XrefFromResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in XrefFromResponse is not found in the empty JSON string", XrefFromResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : XrefFromResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("value") != null && !jsonObj.get("value").isJsonNull()) && !jsonObj.get("value").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); - } - if ((jsonObj.get("raw_data") != null && !jsonObj.get("raw_data").isJsonNull()) && !jsonObj.get("raw_data").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `raw_data` to be a primitive type in the JSON string but got `%s`", jsonObj.get("raw_data").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); } // validate the optional field `segment` if (jsonObj.get("segment") != null && !jsonObj.get("segment").isJsonNull()) { SegmentInfo.validateJsonElement(jsonObj.get("segment")); } if ((jsonObj.get("orig_str_encoding") != null && !jsonObj.get("orig_str_encoding").isJsonNull()) && !jsonObj.get("orig_str_encoding").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `orig_str_encoding` to be a primitive type in the JSON string but got `%s`", jsonObj.get("orig_str_encoding").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `orig_str_encoding` to be a primitive type in the JSON string but got `%s`", jsonObj.get("orig_str_encoding").toString())); } if ((jsonObj.get("xref_to") != null && !jsonObj.get("xref_to").isJsonNull()) && !jsonObj.get("xref_to").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `xref_to` to be a primitive type in the JSON string but got `%s`", jsonObj.get("xref_to").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `xref_to` to be a primitive type in the JSON string but got `%s`", jsonObj.get("xref_to").toString())); } } @@ -490,7 +483,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/XrefResponse.java b/src/main/java/ai/reveng/model/XrefResponse.java index 79b3aaf6..acb029e2 100644 --- a/src/main/java/ai/reveng/model/XrefResponse.java +++ b/src/main/java/ai/reveng/model/XrefResponse.java @@ -13,7 +13,6 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.XrefFromResponse; import ai.reveng.model.XrefToResponse; import com.google.gson.TypeAdapter; @@ -46,7 +45,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -202,10 +200,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -229,37 +224,37 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!XrefResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in XrefResponse is not found in the empty JSON string", XrefResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in XrefResponse is not found in the empty JSON string", XrefResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : XrefResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the json data is an array - if (!jsonObj.get("xref_to_list").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `xref_to_list` to be an array in the JSON string but got `%s`", jsonObj.get("xref_to_list").toString())); + if (jsonObj.get("xref_to_list") != null) { + if (!jsonObj.get("xref_to_list").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `xref_to_list` to be an array in the JSON string but got `%s`", jsonObj.get("xref_to_list").toString())); + } + JsonArray jsonArrayxrefToList = jsonObj.getAsJsonArray("xref_to_list"); + // validate the required field `xref_to_list` (array) + for (int i = 0; i < jsonArrayxrefToList.size(); i++) { + XrefToResponse.validateJsonElement(jsonArrayxrefToList.get(i)); + } } - - JsonArray jsonArrayxrefToList = jsonObj.getAsJsonArray("xref_to_list"); - // validate the required field `xref_to_list` (array) - for (int i = 0; i < jsonArrayxrefToList.size(); i++) { - XrefToResponse.validateJsonElement(jsonArrayxrefToList.get(i)); - }; - // ensure the json data is an array - if (!jsonObj.get("xref_from_list").isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `xref_from_list` to be an array in the JSON string but got `%s`", jsonObj.get("xref_from_list").toString())); + if (jsonObj.get("xref_from_list") != null) { + if (!jsonObj.get("xref_from_list").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `xref_from_list` to be an array in the JSON string but got `%s`", jsonObj.get("xref_from_list").toString())); + } + JsonArray jsonArrayxrefFromList = jsonObj.getAsJsonArray("xref_from_list"); + // validate the required field `xref_from_list` (array) + for (int i = 0; i < jsonArrayxrefFromList.size(); i++) { + XrefFromResponse.validateJsonElement(jsonArrayxrefFromList.get(i)); + } } - - JsonArray jsonArrayxrefFromList = jsonObj.getAsJsonArray("xref_from_list"); - // validate the required field `xref_from_list` (array) - for (int i = 0; i < jsonArrayxrefFromList.size(); i++) { - XrefFromResponse.validateJsonElement(jsonArrayxrefFromList.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -319,7 +314,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object diff --git a/src/main/java/ai/reveng/model/XrefToResponse.java b/src/main/java/ai/reveng/model/XrefToResponse.java index b35dfef5..ead21dae 100644 --- a/src/main/java/ai/reveng/model/XrefToResponse.java +++ b/src/main/java/ai/reveng/model/XrefToResponse.java @@ -13,13 +13,13 @@ package ai.reveng.model; import java.util.Objects; -import java.util.Locale; import ai.reveng.model.SegmentInfo; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import java.io.File; import java.io.IOException; import java.util.Arrays; import org.openapitools.jackson.nullable.JsonNullable; @@ -44,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Locale; import ai.reveng.invoker.JSON; @@ -81,7 +80,7 @@ public class XrefToResponse { public static final String SERIALIZED_NAME_RAW_DATA = "raw_data"; @SerializedName(SERIALIZED_NAME_RAW_DATA) @javax.annotation.Nullable - private String rawData; + private File rawData; public static final String SERIALIZED_NAME_SEGMENT = "segment"; @SerializedName(SERIALIZED_NAME_SEGMENT) @@ -196,7 +195,7 @@ public void setIsString(@javax.annotation.Nullable Boolean isString) { } - public XrefToResponse rawData(@javax.annotation.Nullable String rawData) { + public XrefToResponse rawData(@javax.annotation.Nullable File rawData) { this.rawData = rawData; return this; } @@ -206,11 +205,11 @@ public XrefToResponse rawData(@javax.annotation.Nullable String rawData) { * @return rawData */ @javax.annotation.Nullable - public String getRawData() { + public File getRawData() { return rawData; } - public void setRawData(@javax.annotation.Nullable String rawData) { + public void setRawData(@javax.annotation.Nullable File rawData) { this.rawData = rawData; } @@ -377,10 +376,7 @@ public String toString() { * (except the first line). */ private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + return o == null ? "null" : o.toString().replace("\n", "\n "); } @@ -404,32 +400,29 @@ private String toIndentedString(Object o) { public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!XrefToResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in XrefToResponse is not found in the empty JSON string", XrefToResponse.openapiRequiredFields.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in XrefToResponse is not found in the empty JSON string", XrefToResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : XrefToResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("value") != null && !jsonObj.get("value").isJsonNull()) && !jsonObj.get("value").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); - } - if ((jsonObj.get("raw_data") != null && !jsonObj.get("raw_data").isJsonNull()) && !jsonObj.get("raw_data").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `raw_data` to be a primitive type in the JSON string but got `%s`", jsonObj.get("raw_data").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("value").toString())); } // validate the optional field `segment` if (jsonObj.get("segment") != null && !jsonObj.get("segment").isJsonNull()) { SegmentInfo.validateJsonElement(jsonObj.get("segment")); } if ((jsonObj.get("orig_str_encoding") != null && !jsonObj.get("orig_str_encoding").isJsonNull()) && !jsonObj.get("orig_str_encoding").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `orig_str_encoding` to be a primitive type in the JSON string but got `%s`", jsonObj.get("orig_str_encoding").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `orig_str_encoding` to be a primitive type in the JSON string but got `%s`", jsonObj.get("orig_str_encoding").toString())); } if ((jsonObj.get("xref_from") != null && !jsonObj.get("xref_from").isJsonNull()) && !jsonObj.get("xref_from").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `xref_from` to be a primitive type in the JSON string but got `%s`", jsonObj.get("xref_from").toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `xref_from` to be a primitive type in the JSON string but got `%s`", jsonObj.get("xref_from").toString())); } } @@ -490,7 +483,7 @@ else if (entry.getValue().getAsJsonPrimitive().isNumber()) else if (entry.getValue().getAsJsonPrimitive().isBoolean()) instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); else - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); } else if (entry.getValue().isJsonArray()) { instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); } else { // JSON object