From fdbc62b7c82059da94fe1bd7f95cf17bac4dcf0c Mon Sep 17 00:00:00 2001 From: Karl Rieb Date: Tue, 31 May 2016 17:37:07 -0700 Subject: [PATCH] 2.0.4 release. --- .gitignore | 11 +- ChangeLog.txt | 26 + ReadMe.md | 58 +- build.gradle | 240 +++++++ examples/.gitignore | 4 +- examples/account-info/.gitignore | 3 +- examples/account-info/build.gradle | 2 + examples/account-info/pom.xml | 34 - .../core/examples/account_info/Main.java | 11 +- examples/android/build.gradle | 26 +- examples/android/proguard-rules-debug.pro | 2 + examples/android/proguard-rules.pro | 10 - .../android/DropboxClientFactory.java | 2 +- examples/authorize/.gitignore | 3 +- examples/authorize/build.gradle | 2 + examples/authorize/pom.xml | 34 - .../dropbox/core/examples/authorize/Main.java | 64 +- examples/build.gradle | 60 ++ examples/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 53638 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + examples/gradlew | 160 +++++ examples/gradlew.bat | 90 +++ examples/longpoll/.gitignore | 3 +- examples/longpoll/build.gradle | 2 + examples/longpoll/pom.xml | 34 - .../dropbox/core/examples/longpoll/Main.java | 11 +- examples/pom.xml | 77 -- examples/run | 31 +- examples/settings.gradle | 8 + examples/tutorial/.gitignore | 3 +- examples/tutorial/build.gradle | 2 + examples/tutorial/pom.xml | 34 - .../dropbox/core/examples/tutorial/Main.java | 2 +- examples/upgrade-oauth1-token/.gitignore | 3 +- examples/upgrade-oauth1-token/build.gradle | 2 + examples/upgrade-oauth1-token/pom.xml | 34 - .../examples/upgrade_oauth1_token/Main.java | 6 +- examples/upload-file/.gitignore | 3 +- examples/upload-file/build.gradle | 2 + examples/upload-file/pom.xml | 34 - .../core/examples/upload_file/Main.java | 11 +- examples/web-file-browser/.gitignore | 3 +- examples/web-file-browser/build.gradle | 10 + examples/web-file-browser/pom.xml | 69 -- .../examples/web_file_browser/Common.java | 2 +- .../core/examples/web_file_browser/Main.java | 85 +-- gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 53638 bytes gradle/wrapper/gradle-wrapper.properties | 6 + gradlew | 160 +++++ gradlew.bat | 90 +++ pom.xml | 386 ---------- settings.gradle | 4 + .../com/dropbox/core/ApiErrorResponse.java | 76 ++ .../com/dropbox/core/DbxRequestConfig.java | 101 ++- .../java/com/dropbox/core/DbxRequestUtil.java | 99 +-- .../java/com/dropbox/core/DbxUploader.java | 32 +- .../com/dropbox/core/DbxWrappedException.java | 47 ++ .../java/com/dropbox/core/LocalizedText.java | 60 +- .../dropbox/core/http/OkHttpRequestor.java | 66 +- .../java/com/dropbox/core/http/SSLConfig.java | 98 ++- .../core/json/CompositeJsonDeserializer.java | 195 ------ .../java/com/dropbox/core/json/JsonUtil.java | 113 --- .../core/json/StructJsonDeserializer.java | 57 -- .../core/json/StructJsonSerializer.java | 60 -- .../core/json/UnionJsonDeserializer.java | 65 -- .../core/json/UnionJsonSerializer.java | 64 -- .../core/stone/CompositeSerializer.java | 35 + .../dropbox/core/stone/StoneSerializer.java | 140 ++++ .../dropbox/core/stone/StoneSerializers.java | 272 +++++++ .../dropbox/core/stone/StructSerializer.java | 25 + .../dropbox/core/stone/UnionSerializer.java | 8 + .../java/com/dropbox/core/stone/Util.java | 42 ++ .../dropbox/core/v2/DbxAppClientV2Base.java | 2 +- .../com/dropbox/core/v2/DbxClientV2Base.java | 2 +- .../core/v2/DbxDownloadStyleBuilder.java | 77 ++ .../com/dropbox/core/v2/DbxRawClientV2.java | 83 ++- .../dropbox/core/v2/DbxTeamClientV2Base.java | 2 +- .../core/v2/async/LaunchEmptyResult.java | 126 ++-- .../core/v2/async/LaunchResultBase.java | 117 ++-- .../com/dropbox/core/v2/async/PollArg.java | 128 ++-- .../core/v2/async/PollEmptyResult.java | 92 +-- .../com/dropbox/core/v2/async/PollError.java | 96 ++- .../core/v2/async/PollErrorException.java | 2 +- .../dropbox/core/v2/async/PollResultBase.java | 86 ++- .../dropbox/core/v2/async/package-info.java | 2 +- .../com/dropbox/core/v2/auth/AuthError.java | 108 +-- .../core/v2/auth/DbxUserAuthRequests.java | 17 +- .../dropbox/core/v2/auth/package-info.java | 2 +- .../dropbox/core/v2/common/package-info.java | 2 +- .../com/dropbox/core/v2/files/CommitInfo.java | 186 ++--- .../core/v2/files/CreateFolderArg.java | 132 ++-- .../core/v2/files/CreateFolderError.java | 117 ++-- .../v2/files/CreateFolderErrorException.java | 2 +- .../core/v2/files/DbxUserFilesRequests.java | 461 +++++++----- .../com/dropbox/core/v2/files/DeleteArg.java | 132 ++-- .../dropbox/core/v2/files/DeleteError.java | 145 ++-- .../core/v2/files/DeleteErrorException.java | 2 +- .../core/v2/files/DeletedMetadata.java | 169 ++--- .../com/dropbox/core/v2/files/Dimensions.java | 144 ++-- .../dropbox/core/v2/files/DownloadArg.java | 146 ++-- .../core/v2/files/DownloadBuilder.java | 74 ++ .../dropbox/core/v2/files/DownloadError.java | 123 ++-- .../core/v2/files/DownloadErrorException.java | 2 +- .../dropbox/core/v2/files/FileMetadata.java | 306 ++++---- .../core/v2/files/FileSharingInfo.java | 154 ++-- .../dropbox/core/v2/files/FolderMetadata.java | 229 +++--- .../core/v2/files/FolderSharingInfo.java | 152 ++-- .../core/v2/files/GetCopyReferenceArg.java | 132 ++-- .../core/v2/files/GetCopyReferenceError.java | 123 ++-- .../files/GetCopyReferenceErrorException.java | 2 +- .../core/v2/files/GetCopyReferenceResult.java | 158 ++--- .../dropbox/core/v2/files/GetMetadataArg.java | 177 ++--- .../core/v2/files/GetMetadataBuilder.java | 18 +- .../core/v2/files/GetMetadataError.java | 117 ++-- .../v2/files/GetMetadataErrorException.java | 2 +- .../core/v2/files/GetPreviewBuilder.java | 74 ++ .../core/v2/files/GetTemporaryLinkArg.java | 134 ++-- .../core/v2/files/GetTemporaryLinkError.java | 123 ++-- .../files/GetTemporaryLinkErrorException.java | 2 +- .../core/v2/files/GetTemporaryLinkResult.java | 142 ++-- .../core/v2/files/GetThumbnailBuilder.java | 24 +- .../dropbox/core/v2/files/GpsCoordinates.java | 142 ++-- .../dropbox/core/v2/files/ListFolderArg.java | 186 ++--- .../core/v2/files/ListFolderBuilder.java | 18 +- .../core/v2/files/ListFolderContinueArg.java | 128 ++-- .../v2/files/ListFolderContinueError.java | 133 ++-- .../ListFolderContinueErrorException.java | 2 +- .../core/v2/files/ListFolderError.java | 123 ++-- .../v2/files/ListFolderErrorException.java | 2 +- .../ListFolderGetLatestCursorBuilder.java | 18 +- .../ListFolderGetLatestCursorResult.java | 128 ++-- .../core/v2/files/ListFolderLongpollArg.java | 141 ++-- .../v2/files/ListFolderLongpollError.java | 89 ++- .../ListFolderLongpollErrorException.java | 2 +- .../v2/files/ListFolderLongpollResult.java | 151 ++-- .../core/v2/files/ListFolderResult.java | 164 ++--- .../core/v2/files/ListRevisionsArg.java | 147 ++-- .../core/v2/files/ListRevisionsError.java | 123 ++-- .../v2/files/ListRevisionsErrorException.java | 2 +- .../core/v2/files/ListRevisionsResult.java | 150 ++-- .../dropbox/core/v2/files/LookupError.java | 169 ++--- .../com/dropbox/core/v2/files/MediaInfo.java | 127 ++-- .../dropbox/core/v2/files/MediaMetadata.java | 170 ++--- .../com/dropbox/core/v2/files/Metadata.java | 198 +++--- .../dropbox/core/v2/files/PhotoMetadata.java | 149 ++-- .../com/dropbox/core/v2/files/PreviewArg.java | 146 ++-- .../dropbox/core/v2/files/PreviewError.java | 147 ++-- .../core/v2/files/PreviewErrorException.java | 2 +- .../dropbox/core/v2/files/RelocationArg.java | 150 ++-- .../core/v2/files/RelocationError.java | 207 +++--- .../v2/files/RelocationErrorException.java | 2 +- .../com/dropbox/core/v2/files/RestoreArg.java | 146 ++-- .../dropbox/core/v2/files/RestoreError.java | 155 ++-- .../core/v2/files/RestoreErrorException.java | 2 +- .../core/v2/files/SaveCopyReferenceArg.java | 146 ++-- .../core/v2/files/SaveCopyReferenceError.java | 163 ++--- .../SaveCopyReferenceErrorException.java | 2 +- .../v2/files/SaveCopyReferenceResult.java | 128 ++-- .../com/dropbox/core/v2/files/SaveUrlArg.java | 168 +++++ .../dropbox/core/v2/files/SaveUrlError.java | 331 +++++++++ .../core/v2/files/SaveUrlErrorException.java | 28 + .../core/v2/files/SaveUrlJobStatus.java | 309 ++++++++ .../dropbox/core/v2/files/SaveUrlResult.java | 296 ++++++++ .../com/dropbox/core/v2/files/SearchArg.java | 196 +++--- .../dropbox/core/v2/files/SearchBuilder.java | 18 +- .../dropbox/core/v2/files/SearchError.java | 123 ++-- .../core/v2/files/SearchErrorException.java | 2 +- .../dropbox/core/v2/files/SearchMatch.java | 142 ++-- .../core/v2/files/SearchMatchType.java | 100 +-- .../com/dropbox/core/v2/files/SearchMode.java | 100 +-- .../dropbox/core/v2/files/SearchResult.java | 165 ++--- .../dropbox/core/v2/files/SharingInfo.java | 128 ++-- .../dropbox/core/v2/files/ThumbnailArg.java | 168 ++--- .../dropbox/core/v2/files/ThumbnailError.java | 147 ++-- .../v2/files/ThumbnailErrorException.java | 2 +- .../core/v2/files/ThumbnailFormat.java | 93 ++- .../dropbox/core/v2/files/ThumbnailSize.java | 114 +-- .../dropbox/core/v2/files/UploadBuilder.java | 19 +- .../dropbox/core/v2/files/UploadError.java | 119 ++-- .../core/v2/files/UploadErrorException.java | 2 +- .../core/v2/files/UploadSessionAppendArg.java | 140 ++-- .../v2/files/UploadSessionAppendUploader.java | 15 +- .../files/UploadSessionAppendV2Uploader.java | 15 +- .../core/v2/files/UploadSessionCursor.java | 143 ++-- .../core/v2/files/UploadSessionFinishArg.java | 142 ++-- .../v2/files/UploadSessionFinishError.java | 155 ++-- .../UploadSessionFinishErrorException.java | 2 +- .../v2/files/UploadSessionFinishUploader.java | 15 +- .../v2/files/UploadSessionLookupError.java | 149 ++-- .../UploadSessionLookupErrorException.java | 2 +- .../v2/files/UploadSessionOffsetError.java | 129 ++-- .../core/v2/files/UploadSessionStartArg.java | 126 ++-- .../v2/files/UploadSessionStartResult.java | 128 ++-- .../v2/files/UploadSessionStartUploader.java | 17 +- .../dropbox/core/v2/files/UploadUploader.java | 15 +- .../core/v2/files/UploadWriteFailed.java | 142 ++-- .../dropbox/core/v2/files/VideoMetadata.java | 162 ++--- .../core/v2/files/WriteConflictError.java | 103 ++- .../com/dropbox/core/v2/files/WriteError.java | 181 +++-- .../com/dropbox/core/v2/files/WriteMode.java | 137 ++-- .../dropbox/core/v2/files/package-info.java | 2 +- .../v2/properties/GetPropertyTemplateArg.java | 128 ++-- .../properties/GetPropertyTemplateResult.java | 166 ++--- .../properties/ListPropertyTemplateIds.java | 134 ++-- .../ModifyPropertyTemplateError.java | 174 +++-- .../ModifyPropertyTemplateErrorException.java | 29 - .../core/v2/properties/PropertyField.java | 142 ++-- .../v2/properties/PropertyFieldTemplate.java | 158 ++--- .../core/v2/properties/PropertyGroup.java | 150 ++-- .../v2/properties/PropertyGroupTemplate.java | 166 ++--- .../v2/properties/PropertyTemplateError.java | 133 ++-- .../PropertyTemplateErrorException.java | 29 - .../core/v2/properties/PropertyType.java | 89 ++- .../core/v2/properties/package-info.java | 2 +- .../dropbox/core/v2/sharing/AccessLevel.java | 115 +-- .../core/v2/sharing/AclUpdatePolicy.java | 96 ++- .../core/v2/sharing/AddFolderMemberArg.java | 172 ++--- .../v2/sharing/AddFolderMemberBuilder.java | 18 +- .../core/v2/sharing/AddFolderMemberError.java | 251 +++---- .../AddFolderMemberErrorException.java | 2 +- .../dropbox/core/v2/sharing/AddMember.java | 140 ++-- .../v2/sharing/AddMemberSelectorError.java | 187 +++-- .../v2/sharing/CollectionLinkMetadata.java | 153 ++-- .../core/v2/sharing/CreateSharedLinkArg.java | 152 ++-- .../v2/sharing/CreateSharedLinkBuilder.java | 19 +- .../v2/sharing/CreateSharedLinkError.java | 123 ++-- .../CreateSharedLinkErrorException.java | 2 +- .../CreateSharedLinkWithSettingsArg.java | 148 ++-- .../CreateSharedLinkWithSettingsError.java | 169 ++--- ...eSharedLinkWithSettingsErrorException.java | 2 +- .../v2/sharing/DbxUserSharingRequests.java | 380 +++++----- .../core/v2/sharing/FileLinkMetadata.java | 282 ++++---- .../dropbox/core/v2/sharing/FolderAction.java | 138 ++-- .../core/v2/sharing/FolderLinkMetadata.java | 217 +++--- .../core/v2/sharing/FolderPermission.java | 154 ++-- .../dropbox/core/v2/sharing/FolderPolicy.java | 166 ++--- .../core/v2/sharing/GetMetadataArgs.java | 146 ++-- .../v2/sharing/GetSharedLinkFileBuilder.java | 26 +- .../v2/sharing/GetSharedLinkFileError.java | 104 +-- .../GetSharedLinkFileErrorException.java | 2 +- .../v2/sharing/GetSharedLinkMetadataArg.java | 160 ++--- .../sharing/GetSharedLinkMetadataBuilder.java | 20 +- .../core/v2/sharing/GetSharedLinksArg.java | 126 ++-- .../core/v2/sharing/GetSharedLinksError.java | 131 ++-- .../sharing/GetSharedLinksErrorException.java | 2 +- .../core/v2/sharing/GetSharedLinksResult.java | 134 ++-- .../dropbox/core/v2/sharing/GroupInfo.java | 245 +++---- .../core/v2/sharing/GroupMembershipInfo.java | 184 ++--- .../dropbox/core/v2/sharing/InviteeInfo.java | 123 ++-- .../v2/sharing/InviteeMembershipInfo.java | 196 ++---- .../com/dropbox/core/v2/sharing/JobError.java | 232 +++--- .../dropbox/core/v2/sharing/JobStatus.java | 136 ++-- .../dropbox/core/v2/sharing/LinkMetadata.java | 174 +++-- .../core/v2/sharing/LinkPermissions.java | 164 ++--- .../v2/sharing/ListFolderMembersArgs.java | 160 ++--- .../v2/sharing/ListFolderMembersBuilder.java | 18 +- .../sharing/ListFolderMembersContinueArg.java | 128 ++-- .../ListFolderMembersContinueError.java | 133 ++-- ...stFolderMembersContinueErrorException.java | 2 +- .../sharing/ListFolderMembersCursorArg.java | 146 ++-- .../core/v2/sharing/ListFoldersArgs.java | 146 ++-- .../core/v2/sharing/ListFoldersBuilder.java | 18 +- .../v2/sharing/ListFoldersContinueArg.java | 128 ++-- .../v2/sharing/ListFoldersContinueError.java | 89 ++- .../ListFoldersContinueErrorException.java | 2 +- .../core/v2/sharing/ListFoldersResult.java | 146 ++-- .../sharing/ListMountableFoldersBuilder.java | 18 +- .../core/v2/sharing/ListSharedLinksArg.java | 158 ++--- .../v2/sharing/ListSharedLinksBuilder.java | 20 +- .../core/v2/sharing/ListSharedLinksError.java | 133 ++-- .../ListSharedLinksErrorException.java | 2 +- .../v2/sharing/ListSharedLinksResult.java | 160 ++--- .../dropbox/core/v2/sharing/MemberAction.java | 110 +-- .../core/v2/sharing/MemberPermission.java | 154 ++-- .../dropbox/core/v2/sharing/MemberPolicy.java | 96 ++- .../core/v2/sharing/MemberSelector.java | 145 ++-- .../core/v2/sharing/MembershipInfo.java | 170 ++--- .../sharing/ModifySharedLinkSettingsArgs.java | 154 ++-- .../ModifySharedLinkSettingsError.java | 154 ++-- ...odifySharedLinkSettingsErrorException.java | 2 +- .../core/v2/sharing/MountFolderArg.java | 128 ++-- .../core/v2/sharing/MountFolderError.java | 173 ++--- .../v2/sharing/MountFolderErrorException.java | 2 +- .../core/v2/sharing/PathLinkMetadata.java | 169 ++--- .../core/v2/sharing/PendingUploadMode.java | 93 ++- .../v2/sharing/PermissionDeniedReason.java | 124 ++-- .../RelinquishFolderMembershipArg.java | 170 ++--- .../RelinquishFolderMembershipError.java | 173 ++--- ...inquishFolderMembershipErrorException.java | 2 +- .../v2/sharing/RemoveFolderMemberArg.java | 158 ++--- .../v2/sharing/RemoveFolderMemberError.java | 185 +++-- .../RemoveFolderMemberErrorException.java | 2 +- .../core/v2/sharing/RequestedVisibility.java | 100 +-- .../core/v2/sharing/ResolvedVisibility.java | 114 +-- .../core/v2/sharing/RevokeSharedLinkArg.java | 128 ++-- .../v2/sharing/RevokeSharedLinkError.java | 104 +-- .../RevokeSharedLinkErrorException.java | 2 +- .../core/v2/sharing/ShareFolderArg.java | 192 +++-- .../core/v2/sharing/ShareFolderBuilder.java | 18 +- .../core/v2/sharing/ShareFolderError.java | 163 ++--- .../v2/sharing/ShareFolderErrorException.java | 2 +- .../core/v2/sharing/ShareFolderJobStatus.java | 144 ++-- .../core/v2/sharing/ShareFolderLaunch.java | 134 ++-- .../core/v2/sharing/SharePathError.java | 534 +++++++++++--- .../v2/sharing/SharedFolderAccessError.java | 110 +-- .../SharedFolderAccessErrorException.java | 2 +- .../v2/sharing/SharedFolderMemberError.java | 96 ++- .../core/v2/sharing/SharedFolderMembers.java | 190 ++--- .../core/v2/sharing/SharedFolderMetadata.java | 262 +++---- .../v2/sharing/SharedFolderMetadataBase.java | 182 ++--- .../SharedLinkAccessFailureReason.java | 117 ++-- .../core/v2/sharing/SharedLinkError.java | 96 ++- .../v2/sharing/SharedLinkErrorException.java | 2 +- .../core/v2/sharing/SharedLinkMetadata.java | 236 +++---- .../core/v2/sharing/SharedLinkPolicy.java | 96 ++- .../core/v2/sharing/SharedLinkSettings.java | 150 ++-- .../v2/sharing/SharedLinkSettingsError.java | 93 ++- .../core/v2/sharing/TeamMemberInfo.java | 154 ++-- .../core/v2/sharing/TransferFolderArg.java | 142 ++-- .../core/v2/sharing/TransferFolderError.java | 187 +++-- .../sharing/TransferFolderErrorException.java | 2 +- .../core/v2/sharing/UnmountFolderArg.java | 128 ++-- .../core/v2/sharing/UnmountFolderError.java | 143 ++-- .../sharing/UnmountFolderErrorException.java | 2 +- .../core/v2/sharing/UnshareFolderArg.java | 140 ++-- .../core/v2/sharing/UnshareFolderError.java | 143 ++-- .../sharing/UnshareFolderErrorException.java | 2 +- .../v2/sharing/UpdateFolderMemberArg.java | 158 ++--- .../v2/sharing/UpdateFolderMemberError.java | 165 ++--- .../UpdateFolderMemberErrorException.java | 2 +- .../v2/sharing/UpdateFolderPolicyArg.java | 164 ++--- .../v2/sharing/UpdateFolderPolicyBuilder.java | 18 +- .../v2/sharing/UpdateFolderPolicyError.java | 153 ++-- .../UpdateFolderPolicyErrorException.java | 2 +- .../com/dropbox/core/v2/sharing/UserInfo.java | 154 ++-- .../core/v2/sharing/UserMembershipInfo.java | 184 ++--- .../dropbox/core/v2/sharing/Visibility.java | 117 ++-- .../dropbox/core/v2/sharing/package-info.java | 2 +- .../core/v2/team/ActiveWebSession.java | 222 +++--- .../core/v2/team/AddPropertyTemplateArg.java | 168 ++--- .../v2/team/AddPropertyTemplateResult.java | 139 ++-- .../com/dropbox/core/v2/team/AdminTier.java | 107 +-- .../core/v2/team/AlphaGroupCreateArg.java | 254 +++++++ .../core/v2/team/AlphaGroupFullInfo.java | 320 +++++++++ .../core/v2/team/AlphaGroupUpdateArgs.java | 247 +++++++ .../core/v2/team/AlphaGroupsGetInfoItem.java | 290 ++++++++ .../core/v2/team/AlphaGroupsListResult.java | 199 ++++++ .../java/com/dropbox/core/v2/team/ApiApp.java | 194 +++-- .../dropbox/core/v2/team/BaseDfbReport.java | 128 ++-- .../com/dropbox/core/v2/team/DateRange.java | 138 ++-- .../dropbox/core/v2/team/DateRangeError.java | 82 +-- .../core/v2/team/DateRangeErrorException.java | 2 +- .../core/v2/team/DbxTeamTeamRequests.java | 663 +++++++++--------- .../core/v2/team/DesktopClientSession.java | 254 +++---- .../dropbox/core/v2/team/DesktopPlatform.java | 103 ++- .../dropbox/core/v2/team/DeviceSession.java | 176 ++--- .../core/v2/team/DeviceSessionArg.java | 142 ++-- .../dropbox/core/v2/team/DevicesActive.java | 290 +++----- .../team/DevicesListMemberDevicesBuilder.java | 18 +- .../DevicesListMembersDevicesBuilder.java | 18 +- .../team/DevicesListTeamDevicesBuilder.java | 19 +- .../core/v2/team/GetActivityReport.java | 490 +++++-------- .../core/v2/team/GetDevicesReport.java | 174 ++--- .../core/v2/team/GetMembershipReport.java | 256 +++---- .../core/v2/team/GetStorageReport.java | 262 +++---- .../dropbox/core/v2/team/GroupAccessType.java | 95 ++- .../dropbox/core/v2/team/GroupCreateArg.java | 150 ++-- .../core/v2/team/GroupCreateError.java | 103 ++- .../v2/team/GroupCreateErrorException.java | 2 +- .../core/v2/team/GroupDeleteError.java | 98 +-- .../v2/team/GroupDeleteErrorException.java | 2 +- .../dropbox/core/v2/team/GroupFullInfo.java | 208 +++--- .../dropbox/core/v2/team/GroupMemberInfo.java | 142 ++-- .../core/v2/team/GroupMemberSelector.java | 142 ++-- .../v2/team/GroupMemberSelectorError.java | 98 +-- .../team/GroupMemberSetAccessTypeError.java | 104 +-- ...roupMemberSetAccessTypeErrorException.java | 2 +- .../core/v2/team/GroupMembersAddArg.java | 160 ++--- .../core/v2/team/GroupMembersAddError.java | 239 +++---- .../team/GroupMembersAddErrorException.java | 2 +- .../v2/team/GroupMembersChangeResult.java | 142 ++-- .../core/v2/team/GroupMembersRemoveArg.java | 160 ++--- .../core/v2/team/GroupMembersRemoveError.java | 104 +-- .../GroupMembersRemoveErrorException.java | 2 +- .../core/v2/team/GroupMembersSelector.java | 142 ++-- .../v2/team/GroupMembersSelectorError.java | 98 +-- .../v2/team/GroupMembersSetAccessTypeArg.java | 170 ++--- .../dropbox/core/v2/team/GroupSelector.java | 139 ++-- .../core/v2/team/GroupSelectorError.java | 89 ++- .../v2/team/GroupSelectorErrorException.java | 29 + .../com/dropbox/core/v2/team/GroupType.java | 101 --- .../dropbox/core/v2/team/GroupUpdateArgs.java | 166 ++--- .../core/v2/team/GroupUpdateError.java | 98 +-- .../v2/team/GroupUpdateErrorException.java | 2 +- .../core/v2/team/GroupsGetInfoError.java | 89 ++- .../v2/team/GroupsGetInfoErrorException.java | 2 +- .../core/v2/team/GroupsGetInfoItem.java | 135 ++-- .../dropbox/core/v2/team/GroupsListArg.java | 128 ++-- .../core/v2/team/GroupsListContinueArg.java | 128 ++-- .../core/v2/team/GroupsListContinueError.java | 89 ++- .../GroupsListContinueErrorException.java | 2 +- .../core/v2/team/GroupsListResult.java | 165 ++--- .../core/v2/team/GroupsMembersListArg.java | 180 +++++ .../v2/team/GroupsMembersListContinueArg.java | 138 ++++ .../team/GroupsMembersListContinueError.java | 78 +++ ...oupsMembersListContinueErrorException.java | 29 + .../core/v2/team/GroupsMembersListResult.java | 202 ++++++ .../dropbox/core/v2/team/GroupsPollError.java | 104 +-- .../v2/team/GroupsPollErrorException.java | 2 +- .../dropbox/core/v2/team/GroupsSelector.java | 155 ++-- .../core/v2/team/GroupsUpdateBuilder.java | 18 +- .../core/v2/team/IncludeMembersArg.java | 126 ++-- .../core/v2/team/ListMemberAppsArg.java | 128 ++-- .../core/v2/team/ListMemberAppsError.java | 89 ++- .../v2/team/ListMemberAppsErrorException.java | 2 +- .../core/v2/team/ListMemberAppsResult.java | 134 ++-- .../core/v2/team/ListMemberDevicesArg.java | 164 ++--- .../core/v2/team/ListMemberDevicesError.java | 89 ++- .../team/ListMemberDevicesErrorException.java | 2 +- .../core/v2/team/ListMemberDevicesResult.java | 168 ++--- .../core/v2/team/ListMembersAppsArg.java | 126 ++-- .../core/v2/team/ListMembersAppsError.java | 89 ++- .../team/ListMembersAppsErrorException.java | 2 +- .../core/v2/team/ListMembersAppsResult.java | 160 ++--- .../core/v2/team/ListMembersDevicesArg.java | 162 ++--- .../core/v2/team/ListMembersDevicesError.java | 89 ++- .../ListMembersDevicesErrorException.java | 2 +- .../v2/team/ListMembersDevicesResult.java | 160 ++--- .../dropbox/core/v2/team/ListTeamAppsArg.java | 126 ++-- .../core/v2/team/ListTeamAppsError.java | 89 ++- .../v2/team/ListTeamAppsErrorException.java | 2 +- .../core/v2/team/ListTeamAppsResult.java | 160 ++--- .../core/v2/team/ListTeamDevicesArg.java | 162 ++--- .../core/v2/team/ListTeamDevicesError.java | 89 ++- .../team/ListTeamDevicesErrorException.java | 2 +- .../core/v2/team/ListTeamDevicesResult.java | 160 ++--- .../dropbox/core/v2/team/MemberAccess.java | 142 ++-- .../dropbox/core/v2/team/MemberAddArg.java | 194 +++-- .../dropbox/core/v2/team/MemberAddResult.java | 289 ++++---- .../dropbox/core/v2/team/MemberDevices.java | 182 ++--- .../core/v2/team/MemberLinkedApps.java | 150 ++-- .../dropbox/core/v2/team/MemberProfile.java | 240 ++++--- .../core/v2/team/MemberSelectorError.java | 92 +-- .../dropbox/core/v2/team/MembersAddArg.java | 146 ++-- .../core/v2/team/MembersAddJobStatus.java | 156 ++--- .../core/v2/team/MembersAddLaunch.java | 146 ++-- .../core/v2/team/MembersDeactivateArg.java | 140 ++-- .../core/v2/team/MembersDeactivateError.java | 95 ++- .../core/v2/team/MembersGetInfoArgs.java | 134 ++-- .../core/v2/team/MembersGetInfoError.java | 82 +-- .../v2/team/MembersGetInfoErrorException.java | 2 +- .../core/v2/team/MembersGetInfoItem.java | 135 ++-- .../dropbox/core/v2/team/MembersListArg.java | 128 ++-- .../core/v2/team/MembersListContinueArg.java | 128 ++-- .../v2/team/MembersListContinueError.java | 89 ++- .../MembersListContinueErrorException.java | 2 +- .../core/v2/team/MembersListError.java | 82 +-- .../v2/team/MembersListErrorException.java | 2 +- .../core/v2/team/MembersListResult.java | 164 ++--- .../core/v2/team/MembersRemoveArg.java | 222 +++--- .../core/v2/team/MembersRemoveBuilder.java | 35 +- .../core/v2/team/MembersRemoveError.java | 185 +++-- .../v2/team/MembersRemoveErrorException.java | 2 +- .../core/v2/team/MembersSendWelcomeError.java | 94 ++- .../MembersSendWelcomeErrorException.java | 2 +- .../v2/team/MembersSetPermissionsArg.java | 142 ++-- .../v2/team/MembersSetPermissionsError.java | 116 +-- .../MembersSetPermissionsErrorException.java | 2 +- .../v2/team/MembersSetPermissionsResult.java | 142 ++-- .../core/v2/team/MembersSetProfileArg.java | 176 ++--- .../v2/team/MembersSetProfileBuilder.java | 18 +- .../core/v2/team/MembersSetProfileError.java | 136 ++-- .../team/MembersSetProfileErrorException.java | 2 +- .../core/v2/team/MembersSuspendError.java | 118 ++-- .../v2/team/MembersSuspendErrorException.java | 2 +- .../core/v2/team/MembersUnsuspendArg.java | 128 ++-- .../core/v2/team/MembersUnsuspendError.java | 111 +-- .../team/MembersUnsuspendErrorException.java | 2 +- .../core/v2/team/MobileClientPlatform.java | 117 ++-- .../core/v2/team/MobileClientSession.java | 242 +++---- .../team/PropertiesTemplateUpdateBuilder.java | 93 --- .../v2/team/ReportsGetActivityBuilder.java | 18 +- .../v2/team/ReportsGetDevicesBuilder.java | 18 +- .../v2/team/ReportsGetMembershipBuilder.java | 18 +- .../v2/team/ReportsGetStorageBuilder.java | 18 +- .../core/v2/team/RevokeDesktopClientArg.java | 154 ++-- .../core/v2/team/RevokeDeviceSessionArg.java | 149 ++-- .../v2/team/RevokeDeviceSessionBatchArg.java | 134 ++-- .../team/RevokeDeviceSessionBatchError.java | 82 +-- ...evokeDeviceSessionBatchErrorException.java | 2 +- .../team/RevokeDeviceSessionBatchResult.java | 134 ++-- .../v2/team/RevokeDeviceSessionError.java | 96 ++- .../RevokeDeviceSessionErrorException.java | 2 +- .../v2/team/RevokeDeviceSessionStatus.java | 140 ++-- .../core/v2/team/RevokeLinkedApiAppArg.java | 154 ++-- .../v2/team/RevokeLinkedApiAppBatchArg.java | 134 ++-- .../v2/team/RevokeLinkedAppBatchError.java | 82 +-- .../RevokeLinkedAppBatchErrorException.java | 2 +- .../v2/team/RevokeLinkedAppBatchResult.java | 134 ++-- .../core/v2/team/RevokeLinkedAppError.java | 96 ++- .../team/RevokeLinkedAppErrorException.java | 2 +- .../core/v2/team/RevokeLinkedAppStatus.java | 140 ++-- .../dropbox/core/v2/team/StorageBucket.java | 143 ++-- .../core/v2/team/TeamGetInfoResult.java | 198 ++---- .../dropbox/core/v2/team/TeamMemberInfo.java | 142 ++-- .../core/v2/team/TeamMemberProfile.java | 248 +++---- .../core/v2/team/TeamMemberStatus.java | 100 +-- .../core/v2/team/TeamMembershipType.java | 86 +++ .../v2/team/UpdatePropertyTemplateArg.java | 197 ++---- .../v2/team/UpdatePropertyTemplateResult.java | 139 ++-- .../dropbox/core/v2/team/UserSelectorArg.java | 161 ++--- .../core/v2/team/UserSelectorError.java | 86 ++- .../core/v2/team/UsersSelectorArg.java | 185 ++--- .../dropbox/core/v2/team/package-info.java | 2 +- .../core/v2/teamcommon/AlphaGroupSummary.java | 250 +++++++ .../v2/teamcommon/GroupManagementType.java | 96 +++ .../v2/{team => teamcommon}/GroupSummary.java | 172 ++--- .../dropbox/core/v2/teamcommon/GroupType.java | 97 +++ .../core/v2/teamcommon/package-info.java | 7 + .../core/v2/teampolicies/EmmState.java | 103 ++- .../teampolicies/SharedFolderJoinPolicy.java | 96 ++- .../SharedFolderMemberPolicy.java | 96 ++- .../teampolicies/SharedLinkCreatePolicy.java | 103 ++- .../core/v2/teampolicies/TeamPolicies.java | 142 ++-- .../v2/teampolicies/TeamSharingPolicies.java | 158 ++--- .../core/v2/teampolicies/package-info.java | 2 +- .../com/dropbox/core/v2/users/Account.java | 202 +++--- .../dropbox/core/v2/users/AccountType.java | 100 +-- .../dropbox/core/v2/users/BasicAccount.java | 230 +++--- .../core/v2/users/DbxUserUsersRequests.java | 44 +- .../dropbox/core/v2/users/FullAccount.java | 302 ++++---- .../com/dropbox/core/v2/users/FullTeam.java | 158 ++--- .../dropbox/core/v2/users/GetAccountArg.java | 128 ++-- .../core/v2/users/GetAccountBatchArg.java | 134 ++-- .../core/v2/users/GetAccountBatchError.java | 123 ++-- .../users/GetAccountBatchErrorException.java | 2 +- .../core/v2/users/GetAccountError.java | 89 ++- .../v2/users/GetAccountErrorException.java | 2 +- .../v2/users/IndividualSpaceAllocation.java | 129 ++-- .../java/com/dropbox/core/v2/users/Name.java | 174 ++--- .../core/v2/users/SpaceAllocation.java | 137 ++-- .../com/dropbox/core/v2/users/SpaceUsage.java | 143 ++-- .../java/com/dropbox/core/v2/users/Team.java | 142 ++-- .../core/v2/users/TeamSpaceAllocation.java | 144 ++-- .../dropbox/core/v2/users/package-info.java | 2 +- src/test/java/com/dropbox/core/ITUtil.java | 173 +++++ .../StoneSerializersTest.java} | 28 +- .../com/dropbox/core/v1/DbxClientV1IT.java | 101 +-- .../core/v2/DataTypeSerializationTest.java | 150 ---- .../com/dropbox/core/v2/DbxClientV2IT.java | 276 ++++++++ .../com/dropbox/core/v2/DbxClientV2Test.java | 15 +- .../v2/files/DataTypeSerializationTest.java | 196 ++++++ .../core/v2/files/FilesSerializers.java | 21 + 553 files changed, 27653 insertions(+), 31394 deletions(-) create mode 100644 build.gradle create mode 100644 examples/account-info/build.gradle delete mode 100644 examples/account-info/pom.xml create mode 100644 examples/android/proguard-rules-debug.pro create mode 100644 examples/authorize/build.gradle delete mode 100644 examples/authorize/pom.xml create mode 100644 examples/build.gradle create mode 100644 examples/gradle/wrapper/gradle-wrapper.jar create mode 100644 examples/gradle/wrapper/gradle-wrapper.properties create mode 100755 examples/gradlew create mode 100644 examples/gradlew.bat create mode 100644 examples/longpoll/build.gradle delete mode 100644 examples/longpoll/pom.xml delete mode 100644 examples/pom.xml create mode 100644 examples/settings.gradle create mode 100644 examples/tutorial/build.gradle delete mode 100644 examples/tutorial/pom.xml create mode 100644 examples/upgrade-oauth1-token/build.gradle delete mode 100644 examples/upgrade-oauth1-token/pom.xml create mode 100644 examples/upload-file/build.gradle delete mode 100644 examples/upload-file/pom.xml create mode 100644 examples/web-file-browser/build.gradle delete mode 100644 examples/web-file-browser/pom.xml create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100755 gradlew create mode 100644 gradlew.bat delete mode 100644 pom.xml create mode 100644 settings.gradle create mode 100644 src/main/java/com/dropbox/core/ApiErrorResponse.java create mode 100644 src/main/java/com/dropbox/core/DbxWrappedException.java delete mode 100644 src/main/java/com/dropbox/core/json/CompositeJsonDeserializer.java delete mode 100644 src/main/java/com/dropbox/core/json/JsonUtil.java delete mode 100644 src/main/java/com/dropbox/core/json/StructJsonDeserializer.java delete mode 100644 src/main/java/com/dropbox/core/json/StructJsonSerializer.java delete mode 100644 src/main/java/com/dropbox/core/json/UnionJsonDeserializer.java delete mode 100644 src/main/java/com/dropbox/core/json/UnionJsonSerializer.java create mode 100644 src/main/java/com/dropbox/core/stone/CompositeSerializer.java create mode 100644 src/main/java/com/dropbox/core/stone/StoneSerializer.java create mode 100644 src/main/java/com/dropbox/core/stone/StoneSerializers.java create mode 100644 src/main/java/com/dropbox/core/stone/StructSerializer.java create mode 100644 src/main/java/com/dropbox/core/stone/UnionSerializer.java create mode 100644 src/main/java/com/dropbox/core/stone/Util.java create mode 100644 src/main/java/com/dropbox/core/v2/files/DownloadBuilder.java create mode 100644 src/main/java/com/dropbox/core/v2/files/GetPreviewBuilder.java create mode 100644 src/main/java/com/dropbox/core/v2/files/SaveUrlArg.java create mode 100644 src/main/java/com/dropbox/core/v2/files/SaveUrlError.java create mode 100644 src/main/java/com/dropbox/core/v2/files/SaveUrlErrorException.java create mode 100644 src/main/java/com/dropbox/core/v2/files/SaveUrlJobStatus.java create mode 100644 src/main/java/com/dropbox/core/v2/files/SaveUrlResult.java delete mode 100644 src/main/java/com/dropbox/core/v2/properties/ModifyPropertyTemplateErrorException.java delete mode 100644 src/main/java/com/dropbox/core/v2/properties/PropertyTemplateErrorException.java create mode 100644 src/main/java/com/dropbox/core/v2/team/AlphaGroupCreateArg.java create mode 100644 src/main/java/com/dropbox/core/v2/team/AlphaGroupFullInfo.java create mode 100644 src/main/java/com/dropbox/core/v2/team/AlphaGroupUpdateArgs.java create mode 100644 src/main/java/com/dropbox/core/v2/team/AlphaGroupsGetInfoItem.java create mode 100644 src/main/java/com/dropbox/core/v2/team/AlphaGroupsListResult.java create mode 100644 src/main/java/com/dropbox/core/v2/team/GroupSelectorErrorException.java delete mode 100644 src/main/java/com/dropbox/core/v2/team/GroupType.java create mode 100644 src/main/java/com/dropbox/core/v2/team/GroupsMembersListArg.java create mode 100644 src/main/java/com/dropbox/core/v2/team/GroupsMembersListContinueArg.java create mode 100644 src/main/java/com/dropbox/core/v2/team/GroupsMembersListContinueError.java create mode 100644 src/main/java/com/dropbox/core/v2/team/GroupsMembersListContinueErrorException.java create mode 100644 src/main/java/com/dropbox/core/v2/team/GroupsMembersListResult.java delete mode 100644 src/main/java/com/dropbox/core/v2/team/PropertiesTemplateUpdateBuilder.java create mode 100644 src/main/java/com/dropbox/core/v2/team/TeamMembershipType.java create mode 100644 src/main/java/com/dropbox/core/v2/teamcommon/AlphaGroupSummary.java create mode 100644 src/main/java/com/dropbox/core/v2/teamcommon/GroupManagementType.java rename src/main/java/com/dropbox/core/v2/{team => teamcommon}/GroupSummary.java (60%) create mode 100644 src/main/java/com/dropbox/core/v2/teamcommon/GroupType.java create mode 100644 src/main/java/com/dropbox/core/v2/teamcommon/package-info.java create mode 100644 src/test/java/com/dropbox/core/ITUtil.java rename src/test/java/com/dropbox/core/{json/JsonUtilTest.java => stone/StoneSerializersTest.java} (74%) delete mode 100644 src/test/java/com/dropbox/core/v2/DataTypeSerializationTest.java create mode 100644 src/test/java/com/dropbox/core/v2/DbxClientV2IT.java create mode 100644 src/test/java/com/dropbox/core/v2/files/DataTypeSerializationTest.java create mode 100644 src/test/java/com/dropbox/core/v2/files/FilesSerializers.java diff --git a/.gitignore b/.gitignore index 13985cb7f..c60485dba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,15 @@ +# Gradle +.gradle/ +build/ + # Maven build output folder -/target +/target/ # IntelliJ project folder -/intellij +intellij/ +.idea/ +*.iml +local.properties # Output file when rendering ReadMe.md locally. /ReadMe.html diff --git a/ChangeLog.txt b/ChangeLog.txt index 19f8efb5f..a8162987b 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,29 @@ +2.0.4 (2016-05-31) +--------------------------------------------- +- Update to latest API specs: + - Files (DbxUserFilesRequests) + - Add saveUrl(..) saving online content to your Dropbox. + - Shared folders (DbxUserSharingRequests) + - Add AccessLevel.VIEWER_NO_COMMENT. + - Add GroupInfo.getIsOwner(). + - Change return type of SharePathError.Tag.ALREADY_SHARED from Void to SharedFolderMetadata. + - Add leaveACopy argument to relinquishFolderMembership(..). + - Change relinquishFolderMembership(..) to return async job ID when leaving a copy. + - Add JobError.Tag.RELINQUISH_FOLDER_MEMBERSHIP_ERROR. + - Business endpoints (DbxTeamTeamRequests) + - Add MemberProfiler.getMembershipType(). + - Add keepAccount argument to membersRemove(..). + - Add CANNOT_KEEP_ACCOUNT_AND_TRANSFER and CANNOT_KEEP_ACCOUNT_AND_DELETE_DATA to MembersRemoveError. +- Migrate build from maven to gradle. +- Improve code shrinking when using ProGuard. + - Response/request serialization updated to be better optimized by ProGuard. +- Properly support multidex builds. + - Response/request objects should no longer always be kept in primary dex. +- Add partial download support through range requests. +- Fix deserialization bug when handling new server responses that were previously void. +- Fix bug where user locale is ignored for APIv2 requests. +- Fix bug where filenames containing line feeds were rejected as bad requests. + --------------------------------------------- 2.0.3 (2016-05-07) - Fix Bad JSON error on ProGuard optimized APKs when deserializing error responses. diff --git a/ReadMe.md b/ReadMe.md index c7b1fa8fb..ac0e07547 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -14,7 +14,7 @@ If you're using Maven, then edit your project's "pom.xml" and add this to the `< com.dropbox.core dropbox-core-sdk - 2.0.3 + 2.0.4 ``` @@ -23,10 +23,12 @@ If you are using Gradle, then edit your project's "build.gradle" and add this to ```groovy dependencies { // ... - compile 'com.dropbox.core:dropbox-core-sdk:2.0.3' + compile 'com.dropbox.core:dropbox-core-sdk:2.0.4' } ``` +You can also download the Java SDK JAR and and its dependencies directly from the [latest release page](https://github.com/dropbox/dropbox-sdk-java/releases/latest). + ## Get a Dropbox API key You need a Dropbox API key to make API requests. @@ -46,9 +48,9 @@ Save the API key to a JSON file called, say, "test.app": ## Using the Dropbox API Before your app can access a Dropbox user's files, the user must authorize your application using OAuth 2. Successfully completing this authorization flow gives you an _access token_ for the user's Dropbox account, which grants you the ability to make Dropbox API calls to access their files. - * Example for a simple web app: [Web File Browser example](examples/web-file-browser/src/com/dropbox/core/examples/web_file_browser/DropboxAuth.java) + * Example for a simple web app: [Web File Browser example](examples/web-file-browser/src/main/java/com/dropbox/core/examples/web_file_browser/DropboxAuth.java) * Example for an Android app: [Android example](examples/android/src/main/java/com/dropbox/core/examples/android/UserActivity.java) - * Example for a command-line tool: [Command-Line Authorization example](examples/authorize/src/com/dropbox/core/examples/authorize/Main.java) + * Example for a command-line tool: [Command-Line Authorization example](examples/authorize/src/main/java/com/dropbox/core/examples/authorize/Main.java) Once you have an access token, create a [`DbxClientV2`](https://dropbox.github.io/dropbox-sdk-java/api-docs/v2.0.x/com/dropbox/core/v2/DbxClientV2.html) and start making API calls. @@ -56,13 +58,11 @@ You only need to perform the authorization process once per user. Once you have ## Running the examples -Prerequisites: Apache Maven - 1. Download this repository. 2. Save your Dropbox API key in a file called "test.app". See: [Get a Dropbox API key](#get-a-dropbox-api-key), above. -3. `mvn install` -4. To compile all the examples: `mvn -f examples/pom.xml compile` -5. To compile just one example: `mvn -f examples//pom.xml compile`. +3. Compile and install the SDK into your local maven repo: `./gradlew install` +4. To compile all the examples: `(cd examples/ && ./gradlew classes` +5. To compile just one example: `(cd examples/ && ./gradlew ::classes` ### authorize @@ -126,23 +126,12 @@ cd examples ## Running the integration tests 1. Run through the `authorize` example above to get a "test.auth" file. -2. `./run-integration-tests ` - -Run `./run-integration-tests` with no arguments to see how to run individual tests. +2. `./gradlew -Pcom.dropbox.test.authInfoFile= integrationTest` -## Loading the project in IntelliJ 14 - -Assume "{sdk}" represents the top-level folder of this SDK. - -1. Click *Import Project*, select "{sdk}/pom.xml". -2. You'll see the *Import Project From Maven* dialog. - - Check *Search for projects recursively* - - Check *Keep project files in*, set it to "{sdk}/intellij" - - Check *Import Maven projects automatically* - - Uncheck *Use Maven output directories* - - Click *Next* -3. Clicking *Next* on the rest of the dialogs. -4. On the last dialog, you can change *Project name* if you want **but make sure** you set *Project file location* back to "{sdk}/intellij". +To run individual tests, use the `--tests` gradle test filter: +``` +./gradlew -Pcom.dropbox.test.authInfoFile= integrationTest --tests '*.DbxClientV1IT.testAccountInfo' +``` ## FAQ @@ -159,8 +148,8 @@ OSGi containers running on Java 1.6 or above should provide this capability. Un As a workaround, you can build your own version of the JAR that omits the "osgi.ee" capability by running: ``` -mvn clean -mvn package -Dosgi.bnd.noee=true +./gradlew clean +./gradlew -Posgi.bnd.noee=true jar ``` (This is equivalent to passing the "-noee" option to the OSGi "bnd" tool.) @@ -169,19 +158,6 @@ Another workaround is to tell your OSGi container to provide that requirement: [ ### Does this SDK require any special ProGuard rules for shrink optimizations? -Yes. This SDK uses Jackson JSON libraries for serialization. Specifically: - - * [Jackson Core](https://github.com/FasterXML/jackson-core) - * [Jackson Annotations](https://github.com/FasterXML/jackson-annotations) - * [Jackson Databind](https://github.com/FasterXML/jackson-databind) - -Jackson Databind makes use of reflection and annotations to map Java objects to JSON. Your ProGuard configuration should ensure Jackson annotations and Object mapping classes are kept. An example configuration is shown below: - -``` --keepattributes *Annotation*,EnclosingMethod,InnerClasses,Signature --keepnames class com.fasterxml.jackson.** { *; } --dontwarn com.fasterxml.jackson.databind.** --adaptresourcefilenames com/dropbox/core/http/trusted-certs.raw -``` +Versions 2.0.0-2.0.3 of this SDK require specific ProGuard rules to work with shrinking enabled. However, since version **2.0.4**, the SDK no longer needs special ProGuard directives. **IMPORTANT: If you are running version 2.0.x before 2.0.3, you should update to the latest Dropbox SDK version to avoid a deserialization bug that can cause Android apps that use ProGuard to crash.** \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 000000000..47d7aa54d --- /dev/null +++ b/build.gradle @@ -0,0 +1,240 @@ +apply plugin: 'java' +apply plugin: 'osgi' +apply plugin: 'maven' + +description = 'Official Java client library for the Dropbox API.' +group = 'com.dropbox.core' +archivesBaseName = 'dropbox-core-sdk' +version = '0-SNAPSHOT' +sourceCompatibility = JavaVersion.VERSION_1_6 +targetCompatibility = JavaVersion.VERSION_1_6 + +// needed before we define the pom +conf2ScopeMappings.addMapping(1, configurations.compileOnly, 'provided') + +ext { + generatedSources = file("$buildDir/generated-sources") + generatedResources = file("$buildDir/generated-resources") + authInfoPropertyName = 'com.dropbox.test.authInfoFile' + basePom = pom { + name = 'Official Dropbox Java SDK' + artifactId = archivesBaseName + project { + packaging 'jar' + url 'https://www.dropbox.com/developers/core' + + scm { + connection 'scm:git:git@github.com:dropbox/dropbox-sdk-java.git' + developerConnection 'scm:git:git@github.com:dropbox/dropbox-sdk-java.git' + url 'https://github.com/dropbox/dropbox-sdk-java' + } + + developers { + developer { + id 'dropbox-api-team' + name 'Dropbox API Team' + email 'api-support@dropbox.com' + organization = 'Dropbox' + } + } + + licenses { + license { + name 'MIT' + url 'http://opensource.org/licenses/MIT' + distribution 'repo' + } + } + } + } +} + +buildscript { + repositories { + jcenter() + mavenCentral() + } + dependencies { + classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0' + } +} + +repositories { + mavenCentral() +} + +dependencies { + // Important: Jackson 2.8+ will be free to use JDK7 features and no longer guarantees JDK6 + // compatibility + compile 'com.fasterxml.jackson.core:jackson-core:2.7.4' + + compileOnly 'javax.servlet:servlet-api:2.5' + compileOnly 'com.squareup.okhttp:okhttp:2.7.5' + compileOnly 'com.google.android:android:4.1.1.4' + + testCompile 'org.testng:testng:6.9.10' + testCompile 'org.mockito:mockito-core:1.10.19' + testCompile 'org.openjdk.jmh:jmh-core:1.12' + testCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.12' + testCompile 'com.squareup.okhttp:okhttp:2.7.5' +} + +processResources { + filesMatching('**/sdk-version.txt') { + expand project.properties + } +} + +compileJava { + options.compilerArgs << '-Xlint:all' + options.warnings = true + options.deprecation = true + options.encoding = 'utf-8' +} + +test { + useTestNG() + + // TestNG specific options + options.parallel 'classesAndMethods' + options.preserveOrder true + options.threadCount 4 + + // exclude integration tests + exclude '**/IT*.class' + exclude '**/*IT.class' + exclude '**/*IT$*.class' + + testLogging { + events "skipped", "failed" + info { + events "passed", "skipped", "failed" + } + } +} + +def getAuthInfoFile() { + if (!project.hasProperty(authInfoPropertyName)) { + throw new GradleException('' + + "These tests require the \"${authInfoPropertyName}\" " + + "project property be set to point to an authorization JSON file " + + "(e.g. ./gradlew integrationTest -P${authInfoPropertyName}=auth.json)." + ) + } + + def authInfoFile = file(project.property(authInfoPropertyName)) + if (!authInfoFile.exists()) { + throw new GradleException('' + + "The test auth info file does not exist: \"${authInfoFile.absolutePath}\". " + + "Please ensure the \"${authInfoPropertyName}\" project property is set to point to " + + "the correct authorization JSON file." + ) + } + return authInfoFile +} + + +task integrationTest(type: Test) { + description 'Runs integration tests against Production or Dev servers.' + + useTestNG() + + // TestNG specific options + options.preserveOrder true + + // only select integration tests (similar to maven-failsafe-plugin rules) + include '**/IT*.class' + include '**/*IT.class' + include '**/*IT$*.class' + + testLogging { + events "skipped", "failed" + info { + events "passed", "skipped", "failed" + } + } + + reports { + html { + destination = file("${buildDir}/reports/integration-tests") + } + } + + ext { + authInfoPropertyName = 'com.dropbox.test.authInfoFile' + okHttpPropertyName = 'com.dropbox.test.okHttp' + } + + doFirst { + systemProperty authInfoPropertyName, getAuthInfoFile().absolutePath + if (project.hasProperty(okHttpPropertyName)) { + systemProperty okHttpPropertyName, project.property(okHttpPropertyName) + } + } +} + +javadoc { + title "${project.name} ${project.version} API" + failOnError true + + // JDK 8's javadoc has an on-by-default lint called "missing", which requires that everything + // be documented. Disable this lint because we intentionally don't document some things. + // + // NOTE: ugly hack to set our doclint settings due to strange handling of string options by the + // javadoc task. + options.addBooleanOption "Xdoclint:all,-missing", true + options.addStringOption "link", "http://docs.oracle.com/javase/6/docs/api/" +} + +jar { + // OsgiManifest since we import 'osgi' plugin + manifest { + name project.name + description project.description + license project.basePom.getModel().getLicenses()[0].url + + def noeeProp = 'osgi.bnd.noee' + def noee = project.properties.get(noeeProp, System.properties.get(noeeProp, 'false')) + instruction '-noee', noee + } +} + +task sourcesJar(type: Jar, dependsOn: classes) { + classifier = 'sources' + from sourceSets.main.allSource +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} + +artifacts { + archives sourcesJar + archives javadocJar +} + +install { + repositories.mavenInstaller { + pom = project.basePom + } +} + +// To avoid cross-compilation surprises, add JDK6 libs to the boot classpath. This prevents issues +// where we depend on a JDK7 interface that did not exist in JDK6. +if (project.sourceCompatibility == JavaVersion.VERSION_1_6) { + if (System.env.JDK6_HOME == null) { + logger.warn("Set JDK6_HOME environment to disable boot classpath warnings.") + } else { + def jdkHome = System.env.JDK6_HOME + def sep = File.pathSeparator + + logger.info("Setting JVM boot classpath to use ${jdkHome}") + project.tasks.withType(JavaCompile) { + options.bootClasspath = "${jdkHome}/jre/lib/rt.jar" + options.bootClasspath += "${sep}${jdkHome}/jre/lib/jsse.jar" + options.bootClasspath += "${sep}${jdkHome}/jre/lib/jce.jar" + } + } +} + diff --git a/examples/.gitignore b/examples/.gitignore index b0bdbcd66..438a85544 100644 --- a/examples/.gitignore +++ b/examples/.gitignore @@ -1,4 +1,6 @@ # Example app/auth config (used with example). +/.gradle/ +/.idea/ /*.app /*.auth -/web-file-browser.db +*.db diff --git a/examples/account-info/.gitignore b/examples/account-info/.gitignore index ea8c4bf7f..76daa494e 100644 --- a/examples/account-info/.gitignore +++ b/examples/account-info/.gitignore @@ -1 +1,2 @@ -/target +/build/ +/target/ diff --git a/examples/account-info/build.gradle b/examples/account-info/build.gradle new file mode 100644 index 000000000..f0f5749fc --- /dev/null +++ b/examples/account-info/build.gradle @@ -0,0 +1,2 @@ + +description = 'Account Info Example (Dropbox Core API SDK)' diff --git a/examples/account-info/pom.xml b/examples/account-info/pom.xml deleted file mode 100644 index 5017bbef1..000000000 --- a/examples/account-info/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - 4.0.0 - - Account Info Example (Dropbox Core API SDK) - examples-account-info - jar - - - com.dropbox.core - examples - 0-SNAPSHOT - ../pom.xml - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - compile - - build-classpath - - - - - - - diff --git a/examples/account-info/src/main/java/com/dropbox/core/examples/account_info/Main.java b/examples/account-info/src/main/java/com/dropbox/core/examples/account_info/Main.java index b31b56cc3..4630e7e03 100644 --- a/examples/account-info/src/main/java/com/dropbox/core/examples/account_info/Main.java +++ b/examples/account-info/src/main/java/com/dropbox/core/examples/account_info/Main.java @@ -25,7 +25,7 @@ public static void main(String[] args) // Only display important log messages. Logger.getLogger("").setLevel(Level.WARNING); - if (args.length == 0) { + if (args.length != 1) { System.out.println(""); System.out.println("Usage: COMMAND "); System.out.println(""); @@ -33,15 +33,10 @@ public static void main(String[] args) System.out.println(" an authorized Dropbox API request. Generate this file using the \"authorize\""); System.out.println(" example program."); System.out.println(""); + System.exit(1); return; } - if (args.length != 1) { - System.err.println("Expecting exactly 1 argument, got " + args.length + "."); - System.err.println("Run with no arguments for help."); - System.exit(1); return; - } - String argAuthFile = args[0]; // Read auth info file. @@ -55,7 +50,7 @@ public static void main(String[] args) } // Create a DbxClientV1, which is what you use to make API calls. - String userLocale = Locale.getDefault().toString(); + String userLocale = Locale.getDefault().toLanguageTag(); DbxRequestConfig requestConfig = new DbxRequestConfig("examples-account-info", userLocale); DbxClientV2 dbxClient = new DbxClientV2(requestConfig, authInfo.getAccessToken(), authInfo.getHost()); diff --git a/examples/android/build.gradle b/examples/android/build.gradle index ed2237254..1299c3b65 100644 --- a/examples/android/build.gradle +++ b/examples/android/build.gradle @@ -6,9 +6,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:2.1.0' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.2' } } @@ -32,6 +30,7 @@ android { versionCode 1 versionName "1.0" } + buildTypes { release { minifyEnabled true @@ -40,9 +39,8 @@ android { } debug { // to debug ProGuard rules - minifyEnabled false - shrinkResources false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-debug.pro' } } @@ -52,6 +50,10 @@ android { exclude 'META-INF/NOTICE' exclude 'META-INF/NOTICE.txt' } + + lintOptions { + disable 'InvalidPackage' + } } dependencies { @@ -59,8 +61,16 @@ dependencies { compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' compile 'com.android.support:recyclerview-v7:23.1.1' - compile 'com.fasterxml.jackson.core:jackson-core:2.7.1' - compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.1' + compile 'com.fasterxml.jackson.core:jackson-core:2.7.4' compile 'com.squareup.picasso:picasso:2.5.2' compile 'com.squareup.okhttp:okhttp:2.4.0' } + +apply plugin: 'com.getkeepsafe.dexcount' + +dexcount { + format = "list" + includeClasses = true + includeFieldCount = false + orderByMethodCount = true +} diff --git a/examples/android/proguard-rules-debug.pro b/examples/android/proguard-rules-debug.pro new file mode 100644 index 000000000..d27c34abd --- /dev/null +++ b/examples/android/proguard-rules-debug.pro @@ -0,0 +1,2 @@ +-dontobfuscate +-include "proguard-rules.pro" diff --git a/examples/android/proguard-rules.pro b/examples/android/proguard-rules.pro index 852d6a581..0438ad43d 100644 --- a/examples/android/proguard-rules.pro +++ b/examples/android/proguard-rules.pro @@ -16,16 +16,6 @@ # public *; #} -# Dropbox SDK Serialization - --keepattributes *Annotation*,EnclosingMethod,InnerClasses,Signature --keepnames class com.fasterxml.jackson.** { *; } --dontwarn com.fasterxml.jackson.databind.** - -# Dropbox SSL trusted certs - --adaptresourcefilenames com/dropbox/core/http/trusted-certs.raw - # OkHttp and Servlet optional dependencies -dontwarn okio.** diff --git a/examples/android/src/main/java/com/dropbox/core/examples/android/DropboxClientFactory.java b/examples/android/src/main/java/com/dropbox/core/examples/android/DropboxClientFactory.java index e88905c41..06cd2b9be 100644 --- a/examples/android/src/main/java/com/dropbox/core/examples/android/DropboxClientFactory.java +++ b/examples/android/src/main/java/com/dropbox/core/examples/android/DropboxClientFactory.java @@ -16,7 +16,7 @@ public class DropboxClientFactory { public static void init(String accessToken) { if (sDbxClient == null) { - String userLocale = Locale.getDefault().toString(); + String userLocale = Locale.getDefault().toLanguageTag(); DbxRequestConfig requestConfig = new DbxRequestConfig( "examples-v2-demo", userLocale, diff --git a/examples/authorize/.gitignore b/examples/authorize/.gitignore index ea8c4bf7f..76daa494e 100644 --- a/examples/authorize/.gitignore +++ b/examples/authorize/.gitignore @@ -1 +1,2 @@ -/target +/build/ +/target/ diff --git a/examples/authorize/build.gradle b/examples/authorize/build.gradle new file mode 100644 index 000000000..57d7b2671 --- /dev/null +++ b/examples/authorize/build.gradle @@ -0,0 +1,2 @@ + +description = 'Authorize Example (Dropbox Core API SDK)' diff --git a/examples/authorize/pom.xml b/examples/authorize/pom.xml deleted file mode 100644 index e4f82e8c7..000000000 --- a/examples/authorize/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - 4.0.0 - - Authorize Example (Dropbox Core API SDK) - examples-authorize - jar - - - com.dropbox.core - examples - 0-SNAPSHOT - ../pom.xml - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - compile - - build-classpath - - - - - - - diff --git a/examples/authorize/src/main/java/com/dropbox/core/examples/authorize/Main.java b/examples/authorize/src/main/java/com/dropbox/core/examples/authorize/Main.java index fd4c1b31f..56d587f87 100644 --- a/examples/authorize/src/main/java/com/dropbox/core/examples/authorize/Main.java +++ b/examples/authorize/src/main/java/com/dropbox/core/examples/authorize/Main.java @@ -21,22 +21,31 @@ * An example command-line application that runs through the web-based OAuth * flow (using {@link DbxWebAuth}). */ -public class Main -{ - public static void main(String[] args) - throws IOException - { +public class Main { + + public static void main(String[] args) throws IOException { // Only display important log messages. Logger.getLogger("").setLevel(Level.WARNING); - if (args.length == 0) { - printHelp(System.out); - return; - } if (args.length != 2) { - System.err.println("Expecting exactly 2 arguments, got " + args.length + "."); - System.err.println("Run with no arguments for help."); - System.exit(1); return; + System.out.println("Usage: COMMAND "); + System.out.println(""); + System.out.println(": a JSON file with information about your API app. Example:"); + System.out.println(""); + System.out.println(" {"); + System.out.println(" \"key\": \"Your Dropbox API app key...\","); + System.out.println(" \"secret\": \"Your Dropbox API app secret...\""); + System.out.println(" }"); + System.out.println(""); + System.out.println(" Get an API app key by registering with Dropbox:"); + System.out.println(" https://dropbox.com/developers/apps"); + System.out.println(""); + System.out.println(": If authorization is successful, the resulting API"); + System.out.println(" access token will be saved to this file, which can then be used with"); + System.out.println(" other example programs, such as the one in \"examples/account-info\"."); + System.out.println(""); + System.exit(1); + return; } String argAppInfoFile = args[0]; @@ -46,14 +55,13 @@ public static void main(String[] args) DbxAppInfo appInfo; try { appInfo = DbxAppInfo.Reader.readFromFile(argAppInfoFile); - } - catch (JsonReader.FileLoadException ex) { + } catch (JsonReader.FileLoadException ex) { System.err.println("Error reading : " + ex.getMessage()); System.exit(1); return; } // Run through Dropbox API authorization process - String userLocale = Locale.getDefault().toString(); + String userLocale = Locale.getDefault().toLanguageTag(); DbxRequestConfig requestConfig = new DbxRequestConfig("examples-authorize", userLocale); DbxWebAuthNoRedirect webAuth = new DbxWebAuthNoRedirect(requestConfig, appInfo); @@ -72,8 +80,7 @@ public static void main(String[] args) DbxAuthFinish authFinish; try { authFinish = webAuth.finish(code); - } - catch (DbxException ex) { + } catch (DbxException ex) { System.err.println("Error in DbxWebAuth.start: " + ex.getMessage()); System.exit(1); return; } @@ -87,32 +94,11 @@ public static void main(String[] args) try { DbxAuthInfo.Writer.writeToFile(authInfo, argAuthFileOutput); System.out.println("Saved authorization information to \"" + argAuthFileOutput + "\"."); - } - catch (IOException ex) { + } catch (IOException ex) { System.err.println("Error saving to : " + ex.getMessage()); System.err.println("Dumping to stderr instead:"); DbxAuthInfo.Writer.writeToStream(authInfo, System.err); System.exit(1); return; } } - - private static void printHelp(PrintStream out) - { - out.println("Usage: COMMAND "); - out.println(""); - out.println(": a JSON file with information about your API app. Example:"); - out.println(""); - out.println(" {"); - out.println(" \"key\": \"Your Dropbox API app key...\","); - out.println(" \"secret\": \"Your Dropbox API app secret...\""); - out.println(" }"); - out.println(""); - out.println(" Get an API app key by registering with Dropbox:"); - out.println(" https://dropbox.com/developers/apps"); - out.println(""); - out.println(": If authorization is successful, the resulting API"); - out.println(" access token will be saved to this file, which can then be used with"); - out.println(" other example programs, such as the one in \"examples/account-info\"."); - out.println(""); - } } diff --git a/examples/build.gradle b/examples/build.gradle new file mode 100644 index 000000000..b7e9bceef --- /dev/null +++ b/examples/build.gradle @@ -0,0 +1,60 @@ +allprojects { + apply plugin: 'maven' + group = 'com.dropbox.core' + version = '0-SNAPSHOT' +} + +subprojects { + apply plugin: 'java' + + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + + repositories { + jcenter() + mavenLocal() + mavenCentral() + + // Release Staging Testing + // maven { url "..." } + } + + dependencies { + compile group: 'com.dropbox.core', name: 'dropbox-core-sdk', version: '0-SNAPSHOT', changing: true + } + + compileJava { + options.compilerArgs << '-Xlint:all' + options.warnings = true + options.deprecation = true + options.encoding = 'utf-8' + } + + // allow subprojects to run with arbitrary number of arguments specified through project properties: + // + // -Parg0=... -Parg1=... -Parg2=... + // + // This is intended to be used by the ./run script and not through gradle directly + task run(type: JavaExec) { + classpath = sourceSets.main.runtimeClasspath + main = "com.dropbox.core.examples.${project.name.replace('-','_')}.Main" + ignoreExitValue true + + // convenience for not having to always specify the auth file + def useAuthInfoFileProp = project.properties.get('useAuthInfoFileProp', 'false') == 'true' + if (useAuthInfoFileProp && project.hasProperty('com.dropbox.test.authInfoFile')) { + args project.property('com.dropbox.test.authInfoFile') + } + + def argi = 0 + while (true) { + def prop = "arg${argi}" + if (project.hasProperty(prop)) { + args project.property(prop) + } else { + break + } + ++argi + } + } +} diff --git a/examples/gradle/wrapper/gradle-wrapper.jar b/examples/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..5ccda13e9cb94678ba179b32452cf3d60dc36353 GIT binary patch literal 53638 zcmafaW0a=B^559DjdyI@wr$%scWm3Xy<^+Pj_sKpY&N+!|K#4>Bz;ajPk*RBjZ;RV75EK*;j-;d{(BB5~-#>pF^k0$_Qx&35mhPeng zP5V`%P1S)(UiPcRczm!G=Nud7!TH`9_!bdReTmO0lO(Zfn zfMqP~+s2VTE#?sl=$9e(CuBOAH2n}=c4idsipAKKQIO=pSsMiScd0TvKs^d1xMCym`IZxg&Xd3ii(^3$M#K)myV2qM z{o5&z?1rtP{gnX6zegV2 z$03xe*g2pGA^BqfBE}XDD-CN?H&?w?kE0wG3~``ie?T+IRmsT;*cpLZ)OnaXBtFzX zMcc97L%tQqGz+E@0i)gy&0g_7PV@3~zaE{g-2zQ|T9d>EL&JiD+E8t?H^#-Hv8!mV z-r%F^bl8v}j19B}`M^zJ>hD+Tg?Fg%no2GYmKkbR`2=|`@o`~1&VbKUJ@ZSojd|ihP|{9&8F<6 zcAvtwl6yo{Js7UQ{l~MjA7Rz8(sYEcRXX(n*(Mp75OBEijo(25zwC)pc=#%f_xV93 z`&d+DI*TAtd3KBd(^964h=X;uks5gf3MU}cR#X_wnk6_crcAVLsTV2SzsGM$h~aq~ z6oX|v?jSq%txd-SHwHy`7x4*jJqH^;0*1`Sztp*aYi4tRMBD|Ryyl%F{IC{(=Y{Y5 zhSQPvqZN~4uvCi*h``E|llqjfc4rnRQPs3@(MnB9jto`dtz!CB-ojaReyN}7BwMp! zU@jEkH2hS%NUB|wE0d;=hS4^M^dTz`r=^`7LNsQkU26nlt4o?Ki13cwDXkQH+)w#uNVQo2o@pEJOAZV3Uf z8WWqpN|lDuGdkokHkKLwmo@qCdV6}M=~DGq+P3}@$$yqQssE{3|BxxM*q?tD3oiW6 z^!W)Iau1CDv+;dTH4Lbb;*)+mGrKg;g)4tHB;h~=3QsCF)I|E{`=jp;ArQuy&zUzA zlz$NoIhz7h@;Sw+#%u~;!w56XV3JkGLOHaVlvs1eSSck_-2#zs%EynXvEnsUsO3{@ z=2B!(Gdra;oKm@A@~#LeoDFC2&V->;dgCP}x`Qm{yZA&ULeNnWvNIGzcgjx2?Rx#m z_I4lu^j~)hR_VQ?`&Yk|{^}Rqf8MFY|1el;E@sY>4t8d;4h}YMj{n$ntcs2Tju6_n zc%t6wvvLifwar=wOlL#;T5V}~s_KU-6cMz7X&7`JeYdHW?WaaBnYH!e82^(58{d#J z&3H)nMCXi0pUcVg^sRt^KZxdFRj|_ZglEw{Ri0EN6_laAxbE8zB=H8KgU;Xtpk5?z zC2?g-xj`9d8MtJf-!H#~s0}tJ>Ksa+7KP;J(%hHwUBewO);ZZ&ry8oYXI%5+YQgNQeyS*ViKL>Yy2`MsK? zB7Y$Zk@YAy#-Kwyo5KSK$lcvER(OV>qrW1VXPo7Ih%dEJZ<|5sEmeC)do0(dJ;7Fc z#v{T#df-92-StcUzRO7OjZ?g-Ik?9eGEDWsUL(f2jUmS9_ajH?wV&{0Aj)-0IP36} z4!4}CW2D{v(ZmPjB$#&;fps(Hvph<>^IORq|0^=eDhYiA%W5!rM_K_y(bsu@*)m3P++I=?)h!HA@uUc{zxJ0ibvxU%Ke8OQ+KDRndS#XDA4T zto-I$zC-%q0v8ZL`!Z;MMK0`Irsn?gZwiTbsJAr&4g~c3FEn8J&tfX(X=3ZOyEhpng#DDSOc6XLr%uGtB2|0=_Au$%heH3&*ID*ZPhs8iJyw{$c z)`ySqPVndS_Rnv2f$xtMcp${1WTLjhW)S3(;l*PK4#cXz09;@vNj*6?$Q>%5jIboV2fgAyb?c(W#K{@rj#6OKF&J#QQ9 zboB4HeJ?hXrHp)H9rx@Rta#*PdvkHJ<<2Asc#ClKA;st5qadT0NZHEA111(&qsaLb zkeTH_h(yr92XkyqqslQgTo(|RN$hhQ*IL7<12W?$+q6R2jtnWadKrIyeA>bj=;9mM zaPK&0{1#djnc2d@4fR{7K872i*IvH0mK#eqf4=iu8F5=2P#fG-GBZ|`J2MyJ(^^*5 z$tQaAS;Y(2k!j10=adaH9^!>^k+iBMVWD9#+F=&Q(yZ5NVJ>A}t>1R@32TZ0JTMas z%42sos08y0NMkb$BsDnQo8nVhd#ksaq8UyBjAO1FHRfW*u`ojc^y3)=(f&PTM`k@F zMoZFS>HCeNX1c@G{<=x`IQr>{11kPK#7AZWy_q&GQYwk*t|uTE9H*TVi|@g8P95wBlwf};`RANPqd z@rf3B=~Q8%Wgl5i2t$W?Ns1WgZ1t0sFVJF73Rc!d@X---3W@e+Dbvpj;l~8r`F9Sc zKd8G>dR2>61(|Bw&XdTlG}}fnu~6{2xsz6Efmc;nRDupK!KI-q=^*h{`b$W=VCBWe|mhK3YN$PO28ZaH@2V;Nbgpwl8Fig6xxkWN7UhWjM%G z<^O`4VX45jgsIIO-R$7F$`uCa6O>(WOZ>i>Gor3X^yySAwSB;0*X`pWy<(jya4!HO zYDvrso1n6V3G<>TnrSv{+unA;cSAWuH!9k`z#^j306@cy?0{jP-p4NUCSRP<_wNHG6^axCR zMECIg`Vz^ja7F}a@eRp)X%2>D5;2HR8kL?^&npLgqU9<#pY)7;V<(`jjbZL5j>8!3 zLF`9aB2GDCO#Q|6P6_x!My0QO@k9M-2f2-|AF33CZ))eL<;OOi;76DiE|3}S)dWs znAG6VC4EKe9MedTp6d0%J409Iu^T12e)n(N?^s^DlM+cUS5h4SEqq4NjK+%c6KPr%EUeiN1v_&WkfIr9Do+Q{2=Ap?{FS|6D&*Au8=PW}~Rt~+3EJpNK(;7R!k z%&9kpQ;0c6#VF?+W0D~mUp&bc96HK5g~~9ch$%)z5Z@Wq`!V zLK|>+`YZuZ?H_46y1zmqL~@TLC0lsiaSZzy-7!W4m2VsY*S@u zW}zeWzr7N1oL)qzKa8J;I?@RxaLmPEowX2BlSD2hnYW}WyvQ$FK%;PTPl4|ftNkVB-&5MvFWP;Yx2`zBS8o_7QfB#MLS!;fRlOU$t z%iCYD|0>%`e)v|$e?d9+U&O=spApZ$`@51x_J1P_|AafS>X$C4YG{A#vQ3BFr-~J& zrNf{=tbRuZqT9ky&r6pgk}1*#cgZ;@Dve26=%&Eu887bdn12Lfj~ET zV5IjzrKV8JQNK?MSC0X660d`nnw55z4~eTJnzix7U0S>nhTZ)+f}uOuozz3gz(ZMj zYs1J$Dy2L`8>*UTBLriGUKTY410qsp)+K??D$!Mr_7=C*Ec`Q^X$b{2>?+1_7Ka7f zd2{rtBr%g2PbF_kHb0yF5ypGWmJ(ftYt&YJ_ynIc9aWyTF~dXbrN!iNKZ_(_u>s(I z2*X|;szamJz{2dl(P2I;%foJLF51)WO50&h!EXP{5|gzy^b(4+nn<;j$NCt?UP_cL zEU1-XN`f*1Gl}Fht4&Pn5xo)Ma$kZyBt2qju1yuSTysFNG^pi%vvU=hqPhQ-Cpl`! zSt+cpY2TVYkvTflcqwieu*7MHVIVSQSivl850|@O!h+yWxUM;@nYhP*y8k$MMX>^Vzs= zqdctvR$e(}|H4~b=2=Dszgy^xqjuY6alG6sJ&J~#*>K6$Dl|Pf&Y~sh$@07*amh*T z_wIHl$BbJK)7B2V0P=;_iRjD@X9TGO4h+mK7laU=qy zmy|9(xNb7=49$9mLHL1jK#9O+t+CJ;3IDtkK4I0H_{C zMZMuxRK)|E4155y$!RGIcAVHwpQK;2>ssTa8^Y0_8A*sk}a3gZD5Il8pD}4GR1;_@6*%Y^za=h*V zu5|)zJI%1zR^G!TWc5ioA9xPwtfcqbul(N(r%J#%9D&&zkuV4xj0VXfymNc> zXa2;S1FBKAgNu0n(1&iyT^XFajIG9aRR$`eVEejDBr(KR%NpK5M4^XoP2r^{5!QII z=({hFfVnU7w+W~i2BF-t(|u6~1LVuM`kfH|v*hfA+X=o<%CrInhQid%%Pn@a#zcB{ z^o7+|r0o0_JFn1}AG;)N{NfS8LI&fnSX*e@KcPEe6OV6U-=oiHjXw;D&;Ui32rr=^ zeI$9fsv_3NJU2zXlqE0HwYjRkF^(*=dmpb#bAGI-iGF7mAYYyfIwG8Z;|+==LK(t5 z=LlsTsJKX@6c-VZ+w{_}$Z-T9i*wIN-d5;hIXRENbV;h#&hIG%+U%XScSeP_M`St_ zW*|AQg18~yjh5x7_;)cRFt3fbcf={_ULTh(DfkEq%mVu$EcpgdN}OOAmZBAc2`mzY-_S)k2M=`*UssiSqyy?xVKo=MbGuFS6XRVx2Djkn-AEcIgSQvVAF zfc`p)g#X!O$~sv5mqQqq{Nb>uh&I-rK1N;7H0mguftm{=rV;MIL=kQZjZ6q_PVrHj zl3gcbRfrb*Cn_KeXJnZ06ZEq<=ClnSMYA~}FVE$cEB}!?;QRYG{63OGvgE!wNV+3U z&{hS7QV6Z6UL=q3cB&(hP~yB{WPCY<2lhJj&?d_e^Y$rRxGZ6c1-iXZdJo;c_d!-U7axq4RNZah&+JQde7@OZf;An_X_9 z;&omnq3Vb#o!)t8oY6U5q9V@2gy>2y91VhMexMd;_^7e(hpL;mFYj^Ms7`BGG-h5q zK%Q)s!X(^S6HkOCW#c?l`3P0RZTN{hKdkGb8X4YR z`Q>!^OJIGZmB9N^htzi$VRW^@G$NKIzjI7BcO^B;MhbLW^3e|uMwSeIP|Zs8x`x5{ zeL>F`oNu5Vl>~_AJi)C>nNM&Fhx!XDe?wEG`x8B+)*W-m%b^U0@g03H+h=q%dPTeRj5TVw;2U@yvqaijNc-yOdE0sdE!oOQm8LWcwb zvPS>{qWI4usc7VCDdgf}W@r3gcXz7#y9ura^7ra0x>qu1l*@W+h%sd>?FNRF3P1|= zZbh`V{x`M!W`~UpsRQ+GS9kSrxHBr?)ej6Lo3uG_H zt<~-{2g_b|`=9T*FAm_G(f&ius6m395oJ6G`(dhHA`zwVV}R^Nn`tA;NVLNfW^Hs9AWg~k&`b-e$0W2lP^ww;)sP<7yihp z>9;T5*j*ExLF8eyk}p*_!`MPt{qUWd(sve|0cQ3d(s?$MugrLsb=F0U=Z>3QNKb~xQiuR|wEjrfU z+ zcuJ(5)AJajIhR#qf<4<5IRe+i9ySGsxMdU+)OPV`G3%LV?Y&rh6sS?3B$pjiq)Tp> z7}ce0mnh`&H|iOQ1Gb0uRJX^%qxxmUZ=$BivYy9aXQU8){*Y>2BZ9l-I9bd_Cb^=f%{ zmiWjT=K4anJYD<1{Uv&xtE!H~-PThqR_6Xk6JGHrBqqGQKH?tN;Y{bu{vvRtU8UsW z(llN(rJar!7lEQU6Og+kl{x(`fYfSOcD-A(iW^ymja51?n_e*XdzPU6$KMxkZcJK` zJda&tRCKm42Sb&*e*F*DU{{L^KV#|D}q2fz@SkOgh!`P8>llzU)uQmjI>w+ojmYH8DUYso9od6~Q z;4`O#*N}<@^x4|bmeg+8V z#FzePXp9j-$0LxzgYFM1c8Sfb>{Ps6=4+{2OSxf{aUT^)eNk{Itv=A6UH-NWAk zbZSac^MG}0zqXgc*4EY)bsLAv>)zhim))%o>em2scaCgRq(g@OFY^hHi1@3ZH?0RyOJwn?nXpt|EK zC7C$;BzYJGJRO=@=P;0~`pP4Xo506(sb4GFpOQ5bebMSZAyb9jZC0r^8@4#6@ zN1(csX24ZP&hIq|Wy)DqPP#K}FbsE(!eN*bF(bfPb223XmHFutE}fA+X)(F@1;%yH zk1$?!wEHfeYJqddk074aDxPkEX(5=S7o}DSWlDe=WSG+rui7V8D&L^N{0Eoj{52^F znZVhj=S5qnyRaUmgH@o~<9q*IvbmW>Rd7#O2emhnur1TYHlW(mYhdexX!Kp=0`-Hf z!SuIx<@XNREb6dlpjM~u!9pOrQ+I)gFWa|Hkzd!e`}FK$)l*+RDtXAr6jhG2g7^(& zS#O*-Cp0BefE>7adHa;nq#sma9#q??1@@V^r}|p+lu`QF`_*sO?>*YP{B-=C+6Oin z!SJy*7wjAkT`h%`ZcC$OE7=@uwGN%GB0FWRvSBmnm)%cUkp!1DR;?)JH7?*wZ@)ch ztfdr-ApH==lQ4l~Yl$%t!PHH1zsCEliydl^cX*{BK4Bwl&; zJx=3~4w4j}SylJRk^&{HD^znI={^oh5?NHd2d1H_jh;qml_=-(7Web$GL)idHHN(A!9a;z33kdFv;y;z&UxF)%AeR4wcX*@Dd`TbAx)+%j<6 z7<;WW)i;(q6bO+@sG3~TKii83s*~Hn6H8`K%#A+`Q1P~mlINmHgw45@lEne3jJ17P zZh;hz8;0&UQZnl9P!Lf~yjjLORIsk_d{Ii_YQEQ%aR@^GyDuwHeJ}ihLhY_)AdGHg zhFSd5RVy#l^BEgfnr@AE7^Ft-Psf|qCcFrebXbLZme1nEm7HrU@Z!uVjNSN%-b3af z7qZUkhP=v4wwvDaxCFp{JDGra@o7D-oGogt?x{pR{FrAwaZ3wj-{uzAmKMqt2&XDh ze1?H=?{VpKPF0hrr{{u7|~@}3h?pBn#AQcs3}tn(ld_+ zqfibU?{%p}DH=QlEiIzWnzdn6rJbfL=v^pfoHN&UQod6xHxUy033s>27|xW2!iAIt zRMTOs@W ztWJX=uuAhKLfXd7Xin6FH>PB>VwRXl4F(L&>kRYIq}#{TDkrvZbm;tKBkE*r5OWJg ze$J|ti%j?`N}(DXhW1uC21DuyX5QdoV|XVRKtk$BO(Z z!r{tOk9B6*;^R}Wbbq0T8n^5h^;eF6;UW=V@uJ%kc4}Rrjhc5Tf!euvA3@BRs^etQ zTvbc9z2dp|@0!7GwZ0$+)pv^B;=9vdN9L&x2Rdrsyn9jC@59nFpfyrwenQ6#59tMB zbxBZXtF3No6)I@oO_M(F>|pLUp*fD=$lgK+TWWnF{Y4KN@A9dy_j=>>H)bJ&9@U?0 z-(8chcmAoj#}1M%`IE2FD2NrGL|<^YKj#l)D>KZ*V{He`yRLk7DCyeO=TFkfPHhf4 z5|@pgWJH9l&&_3*O#Cv^2K;f;@ziVC$~X*WqHORbe`PI1`*AOp(@oD_R*Ppc4F~vr z9G|JbXZs4my(CQT9e&C3$OA;PJWyy4wV#ru3Lb_&?NV=uGtP(tB#tEv(Qle)=vYk4 z_2_mBJ16D~hlCE6WQ@rh*$0;0&BE>^ZBhShUv^)=m zh*`f{oNA2|<*ho;N|huZ(U*r;ql>cY94QNLs#2$sN*iX*R7#Fg49~f#84)>us9SYM z8@F_Gk7c(OJeB~Djj!~LB-D6=PR&OfBRuiHS{2D`rca#zAoHu@6%XY^snOZ`Pe{_!OQ!llj z(vX$_-^MCRyV?lYDAQT~lA!9eCC;-*J^9Q>{{U0rLXqySl({*)}PenaIaXeRr|kqvv>R|%fO}InxZ~VOfnRIr--(j~C;1hh zD*m7*eDdTK57}_}{UZVr*caO06;H%}gb&))zDo;^G(P1=7mFuZQv=`$A05DWSR}Yj zz8ZepdD~0R;-d)k(Aaw^lnN|J!2D4^-n)OM?w|7@Y0vZ25q!@+PfU=QX}7$BJdUxj zdp&-GJ8nv;ER~ac$O(wj00ZDTP2$N1C|hle^8}xhQXJzom#1|R)U+mBjk=y|-iY!q z#0nokHC_*isP`5cvj%!?Ooi>_cRXO*x2mYm_L4oGpC8HQUTzGFv%d@~!e9%SuPlpj z{+Ksf!<#*U0k`m-)`OUxR@_@EbDXB26M2=)J>8l$jiL)8FEthy`J}zQnE^>+4bdYbk){#$Ae;MY{p}>NLh`~ z%kMR=#_oMtE+mw(R^lc%8j^q`_5VQoF zdsg1*Je;fRn1)0{M!eq2XZ@bD?`m0tNP`8$^5dk~b~$&7lVu};YMm&UAe?26^F0+) zQ#M%s*_)O?gbLFsB}@In8QSnvrhwl_hj}eQ#Dg$d!fkT2Bpahm|HITp`fg&o5lq3; zIhE8y*U&7&SRM}j)U^6QBW7u5?zLzorLgcxF7fF%IbQblWkITm@JWRX`9%5#5AFm3 z?qVtRQf9en5;}Gc7cg0+4t*tiyZN8fM3#oZS>Ty_0y23t91&jU(~bv4MIo%-OCEV7 zdAXNo%|)mFOFE?n)-|vp2eT+$NF-%FZ)ZJTBUbSk05b~^3%&W1_W4{Qt~t9odd5QM z`Gc4TcYEVcVve}3n#zgRpAFF!s0U_MxOA0)q)trM{)o)oLggxismMzF;OEj^Q5kik z8U%h>Fvp&;ufkk5TM9Wz*OYP7p7KApanC7QeD2)v0iO3c8vKIb$02BzG$mvFyE6cnmvjQ_D+w=-K2%xW?Oqod6 zB7Pl(^a*8csuMhcKhn@tK~z-am+?uA#K$Hy!*QpDIFp;!7GbNxPhhS)*SU3=9qWo2 zlrRVt`EqCX$@&P93(B0audju)9=r1FK+l*9&iT1wn$MJGx^nFLKC#uj7$2`SLY%5e z5ZVhH0FiQ_$qNYobPI9S))@hsvAm~!l+P2Ld$W0r?(zDtGFM~l&o`%k#PGW1`c9uT z>??a$mVcqFF?ro?X7rTop_TB;- z-W57af`0;N3i0G!+UI{3p4KevSam`(@cxay(;!sWX!1I>p<3VQ>!lK81nJ%b+ zaC{l?Bb+#xHQjN8jlax_iYvts#}cHKzm8Gms}{A*qiP!gaY6SXmN-qK^hnk2{Y7k zpFB~8I{Ao7f!d|!hCoNV8t=r5DH_O%vQ-`O3Ij(>ItU^Rdpg~c^&*XyHm`-oj#j$< zs@56Irzq;y_xL50pG(TO$lB~^%`SH3y71v^^PHT<)Fe!in!K<@`4L#QKo1UWCIb=t zsSrf|{N{PF6+M&c%}mwiq0W$O579{QuZikvDg70zm`~43QGO-r5Pk{^lf0W@cj{ei)J8*ALTs_Cpj#}WC zi~dg`S)L3Gmwe@?Qcu2X?ANb%K6(0%i&Xuf^x$WIkRrJ)2)z*Dm7R3N4yu5;J@DJ% z7QO8HEGp|}R620#Xlf#k_WQ$EfvsI1ws3xNbliM)pTUuFnkB3bYRZLSJ}s3GFL*ww zxCqqp2--kYmf9t(woiP*gSs97*`>%XM1f~pqciQDv}yl|R>f0=Y3Ec#{H^n0b*cUf zT?z`b6|cYwVav`F|FlPc8)QB8n0b#WsS^%EKR8`vz8C8L6UjM}H(wCJX}}#Cy?6)l zat}6oCqnMj-)GcV)Q|4apKY~;bkGOsbd9*rK}hyiVwg7);0g8OkJUmj^nu#&Wb_FS z5;q1k>;crXcO>Jx1@HJmgwwCUFnFk!9`{KFcT?=lYbe}3PuIMZW7h5sWj$Zr^BlSB z%4zYVvbVE{aarM@2NJO7Gw;HP>m9}(Upz3!lm*cu2Wc%DVucXK>X1q?uj8(HJQ3!V zH5Zbg+|b!G7#Cs98{?Lz)=b?9ouh9*RPDS7)fF4rXSx;gGFo9;pdPe&uUvoVIw}%D(mbE03&j@<0#ahS#Y}6C zzg;$sg8j!*_paDJnNWjA0=H@ZrE9_p`T0i5lkMTLb2za(w`2TOvGGEQGJny0X}+=G zIc^9V2J;y%k<5M`x8M=}etGa@Bj}g|W?6U1l0!fE*BF9O zF}^F8q0pPw3rnD`Cu$zYPicTy1ByF1g1U6(!G#XLV)}q zAn5=>`!7;UzfkT=LZNd~RiuDfibAh->%HQ=!8V?TnQw$@@{!w_O(zDwgk8>;;Hm+8 zl#60Sp%qZH%iosK?uTL>B>OK|n=X$T9`1z&gVyfS11B_L)WxTSP-; z**~VIOErBGO|wcRK?Z##|U}R@;6~V7UR}1!CHv0ERDFhD zS$yjwLc7+Zqang$sdZ(wtE9>m%h$g6=5H?YkXxGFY|&C@Bekzio2iik-la8wIYYD? zd07T!tEv{~#%ZUUkyPkHnTeUT;?8!xt5DA(X<25(AnGPQoq;pz{QFozFr->fl}l7KL=wwU0c$$0u6|Tn_0ut2k%t6$hP)9U8FA)$YI>KADk7I00%L1I zYcZ~iyUCV8VSB-!$*VTizC66F^K@f~Y^$AZX_?R=SDnRP}HCj$}I|n5d4*6S5u5RX2efSh`aD zC&D6%JG$k1@||c5Ek6vkOqA2j_uxgC>~=dUOb!t z)k|iO1Ez1pL-pzrsG4hNmHDd15X9VKIwubXrwo6&@`@dHvzzuz84AM>0`s;8f~^=J zZ-p?3-Hb z(WDr+^=6inA%7u{Z#8R-&)(D^n&^RbVqjksyK+cLGE`Td?i{WWKzBukjHI{d0YW$L zyP0A~m8zHpd!;NwkYLNY^aUAtn~9FOib#_*o((EbtnS?Eao=%w;f3qjtYqG!g$ZI3`1M80Xw1433 zYDuT%h~5S7xgT!7BmQdwUvjmbZ0T*t0K%+9$P9QPGmyEzXEd?WB=Pso;#S*e+%jtxnvqYOP;|Zfp=h!2kf%MR+7= zqGGk}Lgx^XfkhZ2xVInt_k*Agcds+D?9E$t@BvrZuf4Cmw{L!9J|Dka5Cvcidr=;a z==`^l2XsOJKXd)J(M7QlAPV>GwK~V*+rb^{2^|m*@jWe&&^s6+rSYDQ^n_H848ghf z=!SeuImw26j-NhEJ^LGci2@NPUqzZ8j57Vm05goac}pbcX)}pAEqx_0{oc6 z8=P1J$q!$?Kn76z(ZIe`fees$sX%?yQws0*twdd+*Ow1p;cyCShuLpwlJ9MVd(cIg zd+6kQu!kRSK^ZSYME;?KkoTyctbzGd6?==g_}DksIQZxIc{ObIb|s5xX-)2y6ESs$W_f{ivzGA^!rv!~r{nB%Cs92! zXKk}PxU;-A98m+b+z6F5D3dnrRIuE_ACKCfjd-^`g|YBr=)6-s`VJpTJ3e+`EkKEw^^iEn=}HPap7lN6VM~4Fn$X zutC%X2g+Hcm1c95+mf}-GN=fN`3h;OEzTc`$%qs~2*Wfado zPzd<{tWY>h!$b`Jnc73EI=}cSth`#km4MnUlg+@_MUIxdOhZSKN!zt%hJ|sxRQADk zFUbNBn_vbW%%oMMYqxL88&xk7gJTD!|rdWQ_?n zcG*h4WcftfU7B*^ zyY;4$6>n_*L)?0fo}9@|C@S7{4d^Xh>|vOp5wG(Zj!RjtDxCHSve@dHdvl9c7BjTt zIC$wdXJZa(ys>*f2KSn+F}3)p-H*(uM;l~DN0mvWTB$P3 z9XjJ@R28*M3U$A7Ej1-T2Hh0_%c#3^9?yo^x6^+>DLZe~#MnLu0&OP8>q;|((mR>R zJ5cfFwZus71_JM?CeQoIW7#+QSWIP;)}&MK$|`$1RpSAHhAU^P*K_W9S6MzDu-kVT zwS%Q3g^RFVH76n$0&tc#C0D&$Z+A zV)?!i&p;#EX1K%24(pd_RiUjSdzbcw@h>av$Iixg@X}!=hrvzbITP@5uTpmfYx5M$ zw!ElwFZ1IsSS{^@hZh-XZWfVM-KSj3Q?*2R5HuMal(y6{efA5~ z1T&LnfJ0_jz-Suospc$;Ad73` zU*~dB@=2(oS@R*|EEY{oBTPB27Hv@+i<{SaOLxumq#~@R6R&mBJr8g+X={q1hNdUC zK#4cHD0yiVNLDS5+pk?E@ zs=i@E$z?;yV`F6OE{##0JED?1BA)FO+uXLQWz)2lg;;1*JQq%SIIuwCxcp(h@UZ^n zY65>V$ftP<()hOq-99k>a)lGWl`}+10G0B9wk{_GYL>hexp!TZlYMB|s{{B{MVzu! zH_*q4xaq77m^Wm8JNmc-E?tE{NEk(hJ*AnwB8o2=j=IqT#DVJ67uz|dV$@6i1qWKw zhEU1Y2jtoPgf}pYcC&NwC*0&=OJ-V_VYscGPURO#MT;vN{XJOALTgdXJ6|k~Wti0D zm_ycwy8NrV4?NPkNa3@VEoX443umrYw?Br(^x-tNwwt;U0=&|(d)ZlJt+JbF2X${0 zGnd#L^TzQnc*+lx=$3y}1#1QCo}v;{Hbov+$L zIy3nf)T*-#h8F%Tu{n9=)>ZZ12n>H{ z(3K&i=jM(hT8Ctl@Z;WeeO)<+kv*udON*kb5&nl;GdIaQ@E2TNIO#j zqsR@_F$d5C4A3F=bZla?E@R9+-RvJahY`JR_;wm_TQV@7nv_1ub8HLY{L)Q zX?Jd&ASuon4BbfjVo&Hk?tG-m#&h~1YY(;w=6jNgzFa_L|BbP?ii^9;wzUba!QCOa zyF+ky*Wm8%5TtN-cXxMpcc*Z73l<0;Z+Gu=y5GIe_uChBR~IE~t^b%~jrq(!ZybBv zwQF=k-wQqN&xDpW!dg-ze)0}Ndum9c=kfnMg6BR7Wx#%)c>UctYj zI2usyXd~!5>?j;+R ztcEQ})Fp88$?c(Ka#E~?%U+;S$hmo5Pn~x0yqLMUa0BUtesm*FU3PlBcX?bR$n)Rd z6o4#8L{T^I(xcH;(AOy3NTEZZ==iHsaqf>)yt_wjcBu`W+qV!tJ>Pml*eNKI z*NxwZdAQevbL>vRZsq6Cf9X*j`r0Xb=iQ;RMV#VR-immwbYlx~eY@`q<5?4a=$;es zRG|@!SgHYNfF)2+ByHOaL8N|;B}6PQ9STt`WFqb%KfH_8A$T+zkBKS0*+*{kQ|aSE zCmb@OCKwq}@y5$hxRvD1+fjz)uQFuGR=LIYUXGcOOrQCE3jy&XG3Q5oi2T?9gS6PE zSVkW^sqpod?OQ3La~nIv_1&cR>p2~1QSrvzR=m*_=%xtkso8^i&eQQN+#7ig3(wgz zgY~V>N9;i=UH8as>Z;hc_p=-MInd$R&hz!@;{5z#jRxt2yEtcdfQgSE<*Er~?s*jB zXFNMgcH=`UTkePw;5%hZXIDW@Q$s}o-#|&f=-T%7+FZ&{`V5FEQtC~dDDf&AP`L9m zC~$9^BgUd67t#IUt;JPj(zz1CFl;4Bmi!UO&x_(K-P{?RC~}Bp*R-&>8wnx8Xzbkt z7$5IVi6FQ24MDS&D)D{RagO01KgnD|?qr*b&cl%JDsDJ26m+LMeg%Cm3q)oc;K^qS zEGgQDNeEF}l#mMbk7tyv;FH?yci@X-eXiryo{^x%v1J(biDGOz?kqhSM%{&MD zndH(?z~n^%R>5tE7o~oXyK+427*`?N9C_Ey%POchfv>+=+y4&5?Ik}#_pTylu=i{v zqy3U4iH)h+K9A0#|1F+f?65I1v%2HdqAsWG-Q+euLw=j1&}Gw<{nbQ#C)@@tgk>w_iX~Pb z9ggj=EKc+;xmp37?l**~E?XzxBBq@n zX%vahMtu8cBAEVr71W(-rG;b!E_RNdbW0Sv5UqZ>NeR@H3uT7cc)oFm0y4iWTBwjL zWn}4%GMi%1hK5+RK`Sa7=+N3XA@remIit2z`6zXfFmfr;G?H<)Itg$z#k?@7It^rL zRzeg1}G&58g5hLuSGb5qO?ncqDnuu71PVYObpw4o7wpYII3oA1>GW< zkcHw>vt^n91MdgI}HISUKD#lo8X7i21k*=5)OK@xmFYr4YvPm1^qRo|t zx#WkfD8|}opr-7wi&myQ?PGB7b`FUs*~MNGW3b3Sj@X6X<2=Z4M5VXCzOZfyEi64b z&fMyM#o$|TagMHE+-GJWSW2i0i(5=ZZlN#K0@P%}M2m?l!RS@8d6;l)W3Ao6UX&Si zFS|!WXd1iD8PVV{RbEtU@B!=Ypdf~_jKHhY#S2FF`o~*~_{|tXN)wl;EA(>dF;j-C zyKg83O*}B6oOn8vt6aV0keW}c24fH>JQg}K4&`YZE~idCU+QiML@^J)QU&R9P#D#y zF#*5w%A2YBYWo|ms?8FIbk+|m2Q5VL&UCg1(;e^KckoO=AP~?xbzIYvE698mMW396 zlLx$bn3y$Y@7Opq=TSDK&@I+Jo;eyXq71vsq!dVzj0H})+`|^EFskziD5d{k2eV1I z9IT65*0e^dgu5)hPuJx0fl7$fC9%xA2*QeXOK)D{_9F{9SqA4o`w9F|sZ!aA8%&;S;<%gqRHjwi^5O`VaVmhQ${Rk#EYrMQY_K^ z$?dT~5p2_3S8Al!U=54VTFhN%3^oz&%cr6}#?fF3OG1T~HCR%Z75KS?+UgF=cF;r~ z)x?r~E#`lY!|h3DQ&lu@rWg!KD^5y3#C;*e^0;85Zp7EsfDD;eQVY{!$YLuFrx#Gg z8Ax-BrDby+#X~@{rO4wQbH~Lc6@#%$Eb>Aod`Co>T%aMr^|TK;7}`WQ!UW*#^5yHY zjh80o(vda?g*9n%pu`W(nPeLv7l+_JiN|kNl*UtQjg#vA!)=ONG>%zMbHmKh5I$Bt z_u|G*(Zk(vSF!pCH@bHOAEAa>Gp@!N(Rp~L+1SKCEX#u>g}(q`i_+9 z1kda0UH~h5v4aIpN>QD~j1T2$djC=0FpQ2vG_w|{_WY_RVmTS3ebF_tHLlj`EKk@a zs{1mRdfGCKj>~egs@%5Dm1TVZv%g+HB=n^)*=rhipiF*+haaM8r}|hdF#I^SJ5%yr zhd0K)$D6LBoqq}mgP18t6NRR@G2?O z^5vnT`obE9M@V}>x0BaJLs#bs-|?sqS@Ue){Fu!nLv7aB_S7}-vBqcy@)h-sI{%1_ z_KT`aVUo-cPO%fI4{mWvjs9W_qm3Jj!4soqQ4~Vrtc0{($z{D%(;kF7@h%OF4|0MA zQbQ_%dmVnkw=4V0Ewd8(_f;fHDWh#*sdIc%#=8YxEPsy3wah`*MI$9~aFNVM8oY+V z58N?ee-{1I6#dgY)kB;G44F)>07s1NZ^+iBk==7Yi35$FJzf7V zIMhF*=l?}r%Tl*;!(BoLuHa~f^Gf1<`JxyC&PYVFDg_VoO-=}v$6t_%SZ;4vR(p7! zD263lQJj<_4>7m1pL7bH>~;r@K{pX^^}#0*UZVccJSZb%W1~@CEky_9hCkeNP29gY8&>G4bZb>-K0PgFCJ8gq8z{Hv{Z% z&;l5@_GmGouX9+w0V9U)I(w0OVU*dCdsL^{NVkoXe&k|}Gh#P7;1s0pdU-zMwLCT) zR;vYSyK)ok=xWB~kyNBMZ5G&1RE=S>)6}nE$tCuhHV2wUWZRBeVA*^eV@&T4KYao- z8>J@etM7A@7(4*0RL&+k3^~(YV$bu9)@#Rx?= ze3jW(AYMZ^vk}*kf`#Mc!y~SdQi!|QxZ~^%Ew*}6dZp4A*w@^B#sC|%2y(WS&wldh zD4iBDGg=j|`ii=4Cck<{^>+oi@J&M(Y8?VB=HITKvm9-(E2#I913ZSFKVKY2Se=Hx zJe3-Ch{*{?p`=}7FdrpaBru39>m8F11i)gUN8&E9PYLndHdk*H#r-vY296s+4#_nZCzlQW4W3f}v`#qflyLh3FkP(s)bMd@6~${pwe2gSWmhZr**B{T z5En}1-PoKH;=5FCS$31_wiaX0pv?A7=y5rlOxGN88=X>E^ zQwDj#0*=q0i%R{1f3Rp(89KMi@xGG>xVdzOD06R(Kq0@Wja=V&;S=s5a{mckK=v-& zmw$EwCp=F@7BIOuHel3WFJ_RFz$IV&6}ID?EB&ThJKvZ1~x6MmPge5 zt(SYdXt(59X5{!;Xk>fv(4V&5h>9RVHi}I}qrn&%#?f~i&jPKw+a51q%CmSk1MDEX zKe-r6bb+qh+%7o2ekA2s)~|-R7IaU9lYp6gN^E_a&~$HO*Y`}0or?{lth{q)u=E;| zI`}+cO0H^nzhsK~>!OtU&k2N0OLVYInlPthjkzZ2?zWYiku)sQ47LbfGme|WDV;l* zb>mOd&2kDRZSsW(mrUaRVkLmJONrT*|Hs&Hz=dkdo6?%J&MdaFQHRVK`qY_&J%MA* z_bu1cSSTyp`fE@g{Xd~mM@Q{e2?*+Q0g zVIH8a>a3_Qfq!l3jX8{A+0iQ!cZm2NOV?bksI0G3Rp0dotW5Q7al~fl7a-JGHl9n% z;oE>%4dION#<$t49%%DllWnO8T5z?RpbziccFCUVExL|4hwyOGgT(ixrM1zBV+8!d z^X4{oDIEy<8`?G=1FBkjj!DT+Iz@+~qsPvnA3m$YYa44D5f~z?Td7(CU`g#BkaT5N z*g;A#HjrA>$k~FNN#(p?3L%cbt2&LNuOsx5&k0 zi`vIXe2K4EbSAVsA**>T=5S)3*c1CSl;av6fEaX3VUx=A;q+f7gC%w8uw>&q111fv zZ_bP?e{e|Fsm${(@fT7x=0DJ#{)DtoXz-Enn>m;)G5VqlC>JHg<*H(Yt{#e#jGs(-y04=5aS>Vo$1;BY%!$&ez*ZtGli<{b0rA5}r9)af6 z>H94&tGZUGoI89eu}dOeSbH=dzRfAM3u-hI)p$zs?nqeek+n_bh1t+8m z)Hb4(LrOb-pe5*2>HcVG!fJtDU#w>qFKY3{eoZdw1yHgW!0E(yWylc8FqYQA1TEXD zbf~B#yG!7!%30~Ut7m9o(CKG@2tdj|R&9;>!RGlD3(LDB$M;FGK#^s$JHht}O6NdN z5j`8AY_jR?2}2T60dlmdKv23$I4Du{j`3BsJ8Ex32ISc(jt3{Hr{-@x%a%l+Y?3b^ zAZlPBAe{fRv-2N4%im<|j0~(rEIuP47KSeW7qFA0q%Dp6Ne7%Z1ui*PI5ah{Yd3m? zTAi=&X-f;DfD<Q_M{%F8}X;?4MUJ}8nu+pvwssN^tipM>X-sA+cApuG5Qmea`I+!?Wz zULdjKq+Jc-)2)X^`dQ3fOXK??zua!=6M0RESPpv-s+8Zw1a+M~+)B=kS>MO*EY~-G zqh(d07C`WlE$e}SMClh>Mj6YS9Y5I5w~9o;u&J4TY_k07lvEV7LnK>NO%_n(VeD4k zG){-&tGycc@kilbQR7!qRoa)@uMNncI^CHCej*vD~KpBG?G4FFP`b=h3c<5 zL3cO5n2TX8Ns;w10gjIPBve?{hVeUA_R9O5-CF_W@8-PrpMl)(WyZAYU+qv3Uowv` zc<@@i8N{_o6&`Tq9z27D9!$ZXBG12K(1xTbPA-}(BGM8IhS8Xq8qs3B1V%+B8<7^+ zHWC<^RHEO@de4X)Q)d1leX>^6?%(m$myvMyrdaKQ;co-G*a_oPU!!}z9L&OeLum*7 zPmeF&ND3Dl8U#cd5d?(ze_jdyNx=+O5A#Da!}c|8=wRW2=fXhIpo}d>u)ZRJjc;81 z7VEmf+D8kctKd-2vqlS?v^Fz^QL*VN|7F`mpjxPht{s!yY)v`4r>erMRi&o=hWUoM zc$@*eKvtV%c!_@cy|wR^bL@3Ik>r=-2hr>LrfgyqTnolEx5{gqRP6DN}YZqiH^9hZ1}POOQ87awyCk^DBpT` z3l3r4lFjkr7P(P=KPd$5rY|V&t1lX0jgKn$b(q*dDD$8`!MP{PJ zE5l~1+~7lOtKRTIY^&dZLCB9i=Y=mk$3>Qy@RIJ2pb!a0q!k;)n7WKG;lbeFqDEWM zUbIwY8gyU}?4CS_?RN6mrP`90btKc}IeaW0;4A;$yCp4flat@16AYKs;ImANuE@Ch zgjeDskVwH)h!u|vKg!~VjeNZ*;rLlKir#Nb$sHWzp0HE zKRf85#yP2R6x6LR0UblQ6mtru36wz`)a5ZMZllv_vKg+$cXf8K8lG(R`W7itv%jz9 zv?A4R`t4b~3Ju5+WhP@p(!*%A3iYs7i5Z);*uc`Bg?t}Bdp&KIIwJcE@45+Nsj^<}B6FhfzPXOMZwm$|zrP`#no437g$~jT=c@NXr4r3@7zb;@7=b}XQ@+T0An$s3 zy-I}GgwuAIcFneODJl1gC!5vLa4zl^6=rI})~MKOwK&^^*Mp~{|Avzd_dePHu_OxR zWb)10*H+H|oQJnRcJi%1k+|P(d`(SDgv0VMSW)SSUaRS@I;h!^H^GA=#VyTK_(!gb zfYYG+%8EPLgbXQFz~R>)fb%Mo_f*X)0&>nVZ#B25(?d$K$|%>Rf;cJv@dw2r0QP_k zOmz*loRlwq%RV0tfGOWV zh1Ja{Gc3yusN*N6APmm1UxMQcFeAHY`&woD=fh3C)mv^D8)0T20-M2-Ga>*$mbt(f z1%u6C!5IU0aO@~2&ig$|g^hi%FkNU#y1!3!u9J2j9UkFJap6$er-4nKm)0;T+aZzzSI<)c~I+d3DgJ zBgQ(WOG%eh-479Awz40?Ic#qbcB9V~pVpl$g5StF&L3iwtG-RYO7M2I^rT*EYB@}5 zlr_g!Sw!cg0-U<5zV5mO>=Wnpf~@J-rwvuM1B40%d&fu0Q`&tx1iO7|^cpZmgR%yk z3R=5%0-k1ulIeTxr1o<2aCk%Rd4Trb91M(hfeW=!m(`+T%a$6+4Xmp63wOl+%y~JpiZ=VoB60)9h8{km2x5%$kR_#)es^mlcUlVs=*0cHly>6$+gT)P zh0gTZSy#^7GE9M#%m)`!ff}C}tp13BHR<3_=&N zhGv3Ic(b|b)`N`6#z8|8f5>iIN_kVdk@>3U3O0t2@!QapkmnpkH*md(+p zeb;W_Ru~AoJ_jTh!CuE~h&ESGm1Q@S!L83OCoMmdp1|3!FIQ_3KGq|gPHihQzCKSV zg;&`PH!e@vqQY+5n$J|QnYWd|K3A{+YYvAe)1X?2DDx2HFN^FgdwCser(jP74#!{E&2X00Yr`cdQbzgR(vimiMd zNA_!FBf*@-xW%lsWt^?AddX)l4RS4u`z}JI?_+2-`t*%_hFGZ=Kr#Eu%MP%k)L($G zmJ4d3&3jkMSjX|y*e+@=vvSxMI=NLgzw|}!zLAC4^qxh<=~(Ozou9>_&b@!|%YIaA z!KkG}X@w_4p(I*&!v^|5IA;yZ25P;#XjY0hN}IVag2>$kgZ$Bbcr_#;B*Go^li_D( z@pm&ocQqt+jYGXAm+EL^9-TvKv&W6w9thfs2KUHIKz)is_}cbNwDt_G{6cBKDQU_p zYRfCknnMP{ps>$tQlsP=T)#r;6N26xZw zKx7F=It;ntA6NaNhJ93Fl3J6j|F}!XFB~2F72h3((74h!`%-q2WUMX!@V^_rJG`Nz?Eck!gZGL3RRbAlc8PT{kyZ{bF%57iM2edLIrX5&C?+2PYI%I zXt99XAiTJJm?DmB^RJI}#5Q}!H_^xAW!E=&)3di-GJ>FVyjz|GE^vr#Nh25g#3JFv z;XjkU;_aN_Dfh|qxh!lASsQ>JbwyBB+W|-gsv>tNKR_GVL`ua{xA-x#D^v6cF*-SA zgy^IqVrH*F($Qbn1$&o1{-!ImiF^qZKJ|p$=j$(U{XdcTbZ-A-HPZcqRB!)@#i6(V zKP-3U=_z@tDM?icN!f|X3EHvAnSG_lsTpN^X;~%4S_Q`1MrOuZW_AU8R|G{yW=7V1 zYRd5$DOq}|W?2R)nK8*F+3B$ZYU(MPu}RscL(qSt34nd_zT?-~nPxse2;Qgc{k+cv zF?6x8Hl}klF*32RcmB6e!51TFH$Vg*eEpVG2E70o50kTr=lIgy6AqZLFN$?e<0)rt9fNOYGuj}+R!Ob5B z>a#gOe&>t)>d!@gDVMA8>96f(EjrrupF#rtS)(#1^q9F`VLKt~oQ}h(Ntw*GrQ*F% zNmvfD^=MC8BKh2eqbIo0+itJM@4)_GFL%kHP=t&qL%JK4{a!*JA}6P=Na=+yHxCHF zt^HMZU`>NPwoAy1&-40ky8o{q;q!a{pIHl^g6|gNK(z{uL-Kc)}-_4e4&hh*MQ z+LrPsZHwu@zg^JquZXyjv#_0w%_o;o#=_R*6T<2GN#_5ruy~S+?k9#HjSmbif~Gmt zrfPc@@vy*ogFj730(#C|s2q8IaKr?A#YR5`Ubw)oe>1R7IIWHU2UEG)%1~beL^mhq*kFr#ttMPg&%1fPIIwM)17ddY(dM{ zm|$7$c*Jfo;UWY`M3CXl*Efd-R7=iV(J%4Qjz&GvG3^8xSn2gn_H9Ekp>>@kCSg}n z1)p>MY^Jm@X4Lbk^Z3!;%`sayVqbB}olO=JP<^3q!Ja=3Qe-KJ z<-$Q;E<*?*5BcqYTTs~5X=TR$b>6UVlCe{Vv+>0vo~VIESk&zgxe7I2)8d1b<}1y& z??NZr$i&i9d2Es$IGSSYYONr@1?AA(%%h<6acCOJN4{u?hF<`sCDLgNrmGaQ^M8w} zk#@Ym#l>KTW}``wng=U61g&mC-(D}k(ijVRz*H{yl9sAq9m`Qu*=23j_IAk22jwff z`-db}Ovk}+vQr#mjR>R<3lu+799RYM4mEuD1Z3Bx45{h2{5xgqucgTR!z8Boa|xb& zzWx@{{cGj^+Y(eTaQx)h|CcWt94YwMGz`%X^Cm4g*TeQuE8!UhG;q;A)Irx$Itx(A zU-tC8{vjyJI_>uS_X32bTj%fYprc43(83}?C)T#jJ2q9RwWG2dQo2`GQxq2X8!n{R z@t^gm5VrdHSub!Yk=Qh-s4l6rk`_HeXld`*BMJF?sGC;9RFZQvKJjUskfd(de$j3| zY2k;2JDsw?cv(JVNXOn*=F_LuU7xd9aK4#e4tImyciMp9F6T66vLjC>80~na( zSo`z?)DbJw*nrCO7~2e;x5K#aM0yhWq__QuJ0Z;3C3H@>(!;e}M3E zgV52L4pavfLlaoZmMW-GQj^U@sis7jaEI6+ht^#Xq(zuU7#~&>a_l$eE)h~XxC0-* zLj(0#+V)Sr4(P1aR}7U;(G=@#GDYpBt5!HDQsD|cy^}|OPo^3VCx(B*7!YbE{BD~- zTyLsMnImY?+O58^d|BeXQJAn>-!w2KYm2Ld_?7euE^r>-!mplJ zT%MXtb>FVVW!`$lPh7G7Fy#%MAzeo$0=HV$cA||Az}Qm3+(XKM9iMD2XzlXd+5d6n zJ&0_X&H;;hj(K}YuFVZ`0f)#Wj69(uU#Q8@Oq5)or#TL_8c_TdK4ZYQo3WW5gdX+fWum-4aLQo-t7dCMT!enzWjL%H7HNP zV3~Z}`VNqJa%GeuFyizrFakKW3YT--=qjfenAY<#M4mMn))d2~5Cf;MEnfYHh}A7L z8h zh^<&eLd+I{lpnykh;*~L!yYL4S?^IILpVG5|M0g3-6@kH%*Em-Y)v#}nB>gs0ggx-FUGem-(sOAidI2#zY zh&d;jIr0lCjRE)_rdq$~Jj;U!_2a)q^8ecHot3i8e^H+UKOa1N|C=4~&!w;YX;0aj zeeMr?gHH_ff6ao)QknUrK%@OJZ8tHn$-67iZwk=LQ!u6?`iz(qhQZV!qr!)66<-#^ zYr2kIB|q2nj%7f3-GYXZ4>$NF-cGqz30YZkI&Wn>b$eWI*lj(G%rI<&pxsXPA{`-M zS!^k>IyfreOR5+j~VywzG;xQb0w z%vugs{rpJTD!(a9AwuTOB(Af-=UpDbhvy*Y&(y(tt2UUPr6OTg*NX)iA>l947mYoQfXk^i!S#*U@1J@ z2QxQ8j~Mw)cm)o6Wb1vaQpc)Mov+?fu#6`k=k{qr-AjZkiMVJ53n}^h_sdXxd(h?w z2sYr+WB^%EIjsH{L;2MA^&>*EmiFM)Vx{5kjR(tRxH4Nd;F7H*z7)|SOkwfFzHwu zjyQb=&j52A)7Pv%WBN0lYwa?HW( zarYIRMDIjG1c=2P^h@kN8wb9$KO$>cd);0G+mrbMnewtor?uCd4zr1?o4SR(Cg_nF zkUVpjEWC662=|IJO^(DK?x!B2j^0b6y`ZUikbi4jw#7kK+WJ;36wlKtOhDmSF}g!P zH$f8Obzo73Pm&!K+EXYKY3-PIga1nMPS3b{_VSCxM!!Teo>DGkDn2nojggH_aaXpU zH$LH4G7AvW8Fsi#Kl+Y|_v>v#Dx3|0kueJzq0pCt13sdNMIxa77x~y1i2v)r{k7Il zND=PDKSinZ=X(DiMApBZ_Ma!ai_Pbtqt7uICjU6<|9QkG#Z5_pF`)&^zp@lGHEY?> zob_KdszR+K1%w7Lw$>K?cE%}=OA}#cIkRe`ZoT>9P01uFjZPP!xp|Pi`5TCO_viK% zatD421$LF$U_%rr8raKq98kg+@S5i*PgsVji0t{U;(+WL0{{<}<}w9W&4F{x7$Pl( zbVjo%I-2ko6E1HZJ2oWFx(V7DOrd@d5*` z$^w|?A0wYs&yY_5+5hSUlD7Sv!}ZT&=${JY-yXt14J&uFLv-IB;{;7|FhDTKPqmWt zSYs!|FA=ki#QBAQ@3=CNjq3((GLRfB8)<9c7ei9omq5K)b~Ud$=ylJZQYb>5i+Z*B zzn1gmKOQ|^d3|2DbE^2vOkEo?fVE))zmGHSv#vM0oqkVW4Si($efiF_l~f1eR-H>m zT!3nXB7;q=5h;0h=b>ki`3J>AN^bpM0t?`p#cS6RwMP{$3 zf5YpWx9YH`H(#WeiS>XF^CvIoZmh-lGlgi-e+{_h8{Yi!^Lihu^G%^Y=J}bEP=IJ3 ziy-mF2-~H${~5-Q!o!0yGUx8e06S*KOy>7J>>KEl^fOt7hf06Vr(Ld4S!ktk$I!o38En7`E1Gm*Q%|uEZ}mZi#3G(m+FYjfWOvb#E__Z- z@(F2jsA4hk!V}px!d;J|`8r=x_bYB$J1ll8Ve2jmxjaLGP=xs4h~P@22`UkOuxu$Wok0kqIKZY z7v{k&6b-io3)$3e)lbt}Z_~fO@<4lyx#RLPgJs(e+HrP2uvELL0%L{k5$EjyTCw_+ ze))JVuA@XZtJY(UUm@n~7IQSIt*5nZU*U$mCqwT1D3z8{4@xE$)w^EVdEw%s?L;?S z2|Izmbm=3AO)bgLcxt0pe<;d7iUbn__kCyk1MyTdvmGeC8&7J}*?2$SH-VwY?XfoQ zqYq<9sSl<$9(~Gzm3ef2XRgI*4*Qs^-iOc{mq!7#_VR<*pu?P9q(kH6HYv$S-z zs5+&xfW0mB?!dqQgwI_$GFrdABguYE1tGtW{WA+#TpmLPEWl=W5pr5Aw28uX;H%y; zShKW7UZO*hqu~tPrf!AcpmE0#hMhK)=uhlz&ZpnD;{0lol*8qGnCqv4KG-m|@U3b4 zl?Xtc+Q$Xc06T3Y*XQIe)_)JH*Bb%rJJNTuo*~r=xnwEUULbeU+->~Au=|AaCwC|2 zB2ZvgDEj*SPVt7h<9)_mv`@5?y4II?s5&t&^ql?IDp)~#`3~D#aLNhVyyKm%5s< zL&hyL{c)Pza*a=VISCsC*4=Tp=uQtG2X4&bwB(@~G@9X0<6#s;1YfU8ceDfM>1HP@ zBy+SOJ62?4+$-QM&((;$^prmdeX|xh66wMGkkKp(BhH)FWT^D$W>Xk4W6R9ON7z@% zVRY~IWw$uox{cpl(D*&pG(%7Kh}q0AA?!&l`stAjp6n;qfF)3#d6PKfdL*zVS>}wq z$k(Z_&pyty-RR4EK022?p=*_MgQjvXnxjs<8w|nxC^pBs8a0=({ZRGv?T7#LmUdbo z5r#Hl!!S!-O;@J)d>IFHl5f20y!@7DrF^ z_z?7%h9EOc?w4A3|Xj1uxkVSJ`K>#xa_TW471++r*d$j(!vspAXkqQ`^ zoZD|(BIil5=7YRnGxHTWM533mjo-NK;i4vPo| zn?ra*s~AYnANQ59amix31-PTaLuxI)j@uiXoOo2?&_`tlv)X@EpUk}*8n&pEBNV@j zfuXm{97;!lkNX6+v9zp?5+KP7qR1!wDyh@V6iji)=-R7v3v}szoJ4rNwSbSc0fn-6 z(%(nYl;3B!l$3VIQB5c{^=Z(cU<^xg(h!)O2HJD0|Dx{h)-S(T7;?(y9>PQ`{RE6a zN^$cR<(fZBWlxS$nRU8TMF?c>_K?{Wy8Giv%3+vXj7lz=Xr6dgwdby=-Tc90f7Rmn z^RwmZ}Z^0gA} zpDV7;h)ustN7vN)e6%NhRNEoJ_;&(`T^2pSMT}J*hGEJ`LU99Th$e4vERN_Cl7g#1fFt#NO)B_sw+ciHwEO-DTLU;d;C;dye z;aOqSO?_&%jn68b<9}bH{JlC!Qnis^P(bswU71tl#@~x8%r(>Y)Y<4)?fVX?&>J1e zdSv`?r;hj;u^UCIqcnnP3%jix85v47(NBMO6yqQ~NFgO$8%!~D(h#Rsy^ znD7kV2Yq1PEh7pH_)>|VT8Le`$~LvRf){u#Ty)~YrURJVsxwRhFE305zP=MK(trR9WN;qn5XYoiV7$sVI!-sf{?Fc5ip&cf@ zGudnOY3pS~zMc(WnAgRHe8MTkv!F<~v{cir@{BfEiuf5tq};~7zttC~cORaG;|u%A z8FeY29j1eTQTh7pT&GEc=CMS64QhN+jpHJHpUzv5^nu@Wie3C#1CM*Fx&F-9i<)v5-{o*hh{<{gKx zd=UIIR`8%zBdo!+hVyj&mt4`*Z~b^{sH4B1EheAOX$fYz1wCYxsp=EgFdIn{NTQ?! z>J?uF%QS{ge*9-;b6~hcvHQ70Y(I6h!2f24sM=cn|ETCL)d{7~I-ZYj?3)4ecW9*B z;84mjBN46j zdtzrh_wdA5IPhahW^WKPnw#v7R@qkTkoZGzAsT?)f=Pb)y67CDIEV%IE>TE6pUgTg zL9ZdRW$gY5xw!Ci462Hx`Qj`7ql{#Fy#ut?rfFT}i$MKVFUxodF!_t)=KFcy*2A>u z_moV!M0=Ff>}`{iEgwBS$0#Yu7Ct48thL-)BjwNg@UxAr_*gIIEQ=QTa3jL`EsI>+ zjYuZFeNxBqt$JrBLk_Ion==8{S`XJPyZS~xDjB_0DuZHdF|98P6U&+5+OyYb`R`>$ zT&R0d)Shz`lbzwV-&7um%7g?{!VTcX>T>tUF$!9T7@uYq`WTncHb52^h>~r@jbC@! zF~bd5ftDhUhb}_yZU8OJ2*Xn2&1ia$Rn;Sm7sb%p)Pb+^?Qaz*iRYMB z{HOnwh5+*Sxe|YKy#HBs{>$%G({@@=L;915HBl#u0zbG*K;&xLx*mU+% zHqg$khwqNi@8cEMKjqd2kB5=Wh&!5H#zmiJ>!cUnH29&|eUi)`>>g%wknYx9dUyk7 z6F_YwD8?T>eO49_%SzluTA1%nJDfXWFHX4~)rVA0=CF*0C@m&A?1f@nad48XnLNwp zE8bOcL>+B=P|RwkAvBVx$EsRlXod2)+=E|ci?Bp{RE($15ivmFA*6U|Xd=mybqYmB zu#QxV!?x&{MxKG=LW=FctT;RFq3zZuAprm?YtBkFC#wgKRa#~&N`;=AcGrK;T9x2{ zZa3FXnyoEKCn}04|aPM{QB&kb#R?2`EaZAdyVs z4NDNhxCE(jNZ3uV>6F;=aw^FftX^83sJ&I4mXoE;^pDxhmL3*Or|-UBbQG$UN9wWJ z_Gr&8`m-^ODr@p$q=n>t?3;VRW@%$E@F%O+)E0^L7Bk0GL2V=ugD4wo6jw;B4HfBf z9$QHbDDg?Ad$rCSd7b5Atz^Z2FIX`vgL0-hQrrvRe!D7O@;)!aZEA8H(l^x>vYSzH zF35#}be?z1YA86ZtzpZPL0PsKsJ()yYc7G}B+!0WSBI8hz}D*h*3E68CD?Du(Q-3L zwfLiSYE_|iz$(4oxcw(>fV}v^$3TkoAXSCoanpT!u9y7iS?o>u4w3bIBgSsNmYy*h z1W%o`nC8#GF4)IVaWQjh*sHzl$ltI8`Z9gLpT7&a8Oa-am+p{yPkvq2i8(iE=2^<$ zfPFOR36Q@j3jh;(h0lq&#C%}-VI{P!Psq@u4Lgsezk6)uhVSyjP^C}(S*wqO#C1D@ zS~bMmaW^{IO-E_6a?kb0qz1PaVOn;FXEYz|4+s>)b~lTLRcW%R!an^43kyD5MPZhRfWFGU)S%1LxsUp2 zE;Us$5)4>8;;&AzRRzfgNC~-xa1+bPl^r;)_xBxv+pm=I0VetdtyTryvPe_gPxm>Q z_J?3wcRi!xZ1W~0RUF-rRWG7hZKtOXPpeMOs9HYA}f$?TK=>Aff z@~*63NyAagJAJClb{y!OE`fH6#4%WiTMHeu%x(UjE6ke>r+;+=D#;049D6mD``YoG z&czj|I5U=`*T2rGnx~>8-_;gEt>-kGvt!5mgZR9IqqNN_j4}M1cGl@?_vG#0PW6A?WBxxZ#Uv%&zmm6n4Vn$Eva*fodv1|bVpO(hKfaNee@6>|jpKc0 zmjqmnnyQ&nkbM;N6v_wlKZCs%guAhSL58z%C790YIL@BnbNlo5{tmx`^uyb@_HUue}m7G$vd zI5w&QbjX4RGH=e-Y&Izgagbzx3!ogC(g+bO^w;IE3jJuu$#Z`eX#9;(yw!S zpqe!4ErF|esQfMRrgi`X06a6k9B2myu~agt{0Whb(z^ZbHdNFoP1U`Rw+iEw`Z*Lh zc-Q<@l@U!(xBZegoF3uD1t$e-JVD%mQkJBR%(I{VA|=?!j6|KU9U{n>$@I~$??v)w z;98=w&&N+hv|};w=V$2FMt0i5)=+sWdIPSZ{3%RYClgv0faav`D_>A_k9tv--8&ZBr9J#qbF7|M*D%$3JfTZ-)QB{C)K` zKU{V6KVloB^CESsBhf%|)dkLE6E48FS@*JteR5g64Jrpodo5U0D-!uwv&6a4Fl{O6 zyxHKQB8c>4AC`!pg{&~-0?8cDx6`0ER% z(2ZLil$_5P#|*_SXgAVG1ao)lP8|c;Y;=mTH`h;FEC+AV&L7eH=(oPA=AGnnzHDJN zyY(8rx**=d!{-j2ao-WU(*`r#rBA%2dAsQd?8cs>gDy?imSqbZjXjo|oeM^@$|BC< zxiy-8&F?g75yZ_hS70J6RcoaOB}DxY2bxH-g$L62jwV{5Lq#NOQCbAvllj~@ER~xF z!#Fu8vcW31=Vdw4Mn@uZsWvx;o337|70o?Ynkpam4QGJ_evK`nOPAK_gOajPx0c3l z311T3b1G>1Y9>_!ebR;7%-$Crbq27Fkvy4Prpl~klji#|FZMbu5h{}kA?rSKV_F_@ z%ytfQD=XwVo~bTvrXr1LW!Ertm`NTalpqU3>{Ao;$bF4x)NFB^q2&7P43-oNqy|O~ zJWOA#xsyxq7&4qBfdI+9&&Exo9v_JS-<(9XP-HJzQOdHAaG)7)hIn4(~N< z(mX#}|4=|llvZ6>9**iSEQ8ArOdxb-R=bTgQ7?tQs&H+yls>WKwl6GCflZgFs#K3Y zRSVXd=Zag)y#b|hcAjYe`KOt-G)ar^a+KZbVJ>4CVyU8S!L}rhhya%(*@~j0-UWik zAX#d?bD)K@tIHUpq>-%Z;K@w9wmwK_Cqx#M5V{!~@3jp<mvau-CC&*inT)s~J(4bQwef5NKwgT8Q!5-TWq+{Q14#0wUy=9Y&Ypv{g%UCpcdp)X5E#mp<_EW} z=2<&j9^Fa z3EXedVfxY5Pe70wdS^%p+8aT|)B!sa1#u?2OPp=CV&*`*TT`71PI~dxxHQMLqlV+_ zWUMw+Ruw)|rszJSTi7>|fUNVG>}E*etC>g}1Y86wHL@tqh2Qqg*qt5}vw^D+3tB2+ zOlY&s^1h6tuT%NS6X}W?gx*ns*7yHkXhnJ+UWZ{Ae>r|Qbk_)fB06SPL%>VMWpwm+x zP?NliTb!q@+a~(@Q&ktpE>{)L@>Q;Wgg8=R663fb>J2Q!78L#C@8y9LY2?-4vk z_VD8&5wvW2OdCi?KW4s%6jHk~mEnZx$`Hrv=UxVFN3|Te!P+28e*l_yVLT?&m0tzF zmVCLhb12&m4(bWEq&P>sQiougHCV+$&>Ci9;0S1h?h-E;Zi(Cvg;uYtg2|5aE7~sA zlE;v1(-5Hja}8O%R<7?(FE7NU;?vf~)EeP)K62hF4l^F`dlP53jXB(ANaPMf(LA zfmVcBTft7P)(yoHv{zG1JXx74PpyZbHDuCh3Mb>T=t*v!oOq@r?DC-d_s}%(rFs^^ zZ%d6I;6Giz^0sukzltv_A#7%@4AKf&qE=|ox(x0C`?lw{Z^gvhO?*eU;u_V^d6E9W zaC>^PN#!|DT>$3Zp&}#PJ}eydoid0XvIwPB3pE)2kBgEmre!NXABiU*HxMV7`Uz$yH)SRse@1O zoS+s^kzqW=Bmk$B17sAN(<_%zh&u=%w9Bp3=QzeRq`5~r^rb{D=12B3v5=xPUc1&8 zCLh@^od>R{eDUR3l*po`zs;uh_X)JBHCGHG)wgq$QMZp10IY zY2=XbVB_DLnONUkW5OQ*=0V-wY%*MU)o$!<{o_(bY2-BxVcMdMSYM5)5F15&N}G z|I&m%7V5&f_J#mGGD9nSQwLKg!{7TN=Bk*{ZvfixElr(VcAT1vR{dY%M0Tljq9WV}=Z$6IiTT;#oFAJFftdiMJ#wEMeD@ z51w^Pmnw7ll|jVNT-J<1oIp)}pY^abX z$(&%+DJ@cldZ?NZnM|!;*O=buWpVUW))kWmtz4NgS%^jN&Ywi!&&4)DLbp!JEbFytdRjmC-honQklfu%p{-bM^z#od$M*bQzSw5j zX3^Lp$w2swMHoF}`Z9WIzG8}u;B1R!=LYOf1}#jITe~~nQ;Uw&c+fa3Lgwn6)nstW z)1$tR#Q}yfd>bWF+Ob&g+BT(j=L_^e7|fj#j6cl=k0M`f(ftD-n>(#4Nl@}rN~tYS`Skee3!%|*_nJ(j6D=FB{b~2vk%t2&mxW2z+zjLWk+q27P_>9h-);iNanhX7PBDbcujL#~5 z&?(YirpKTZD!9x6l*G3Iph2-*)mo%M7O15Y?K^}Ss$rFWCN3IIg9>mn9T@G zzu)<~9Bo<%^_osbyA{t=qjdLDcdWLqyImc2r20f(BX$ETg5YLvVam~48XGJG7W5fN zeWs9lWApcxW-#tWmXVqY?yLp20j9M$T>My(y|^v)LKO%s%ODWLrLz*#LpXDdEQUUd z+D6kuG2t%RG2}8P=+solX{al2{qh6tDmV_>7 zZ>CY~Nt`JNL&QdxG8121=3=w47?gNkfrjE=GvVnB4cFHzeYMiDr zF5_|pv(dl>#!gc}Y4?VQ?1O6TUQNUqR0*hUlY5Q4E~dlc>lW+{v_{@P5fZYFa1c#X z=!TAp#_q{|jfLfaxnemk*gTcZFm4I4BIwKCaX7oX z6_wEK72gdI5+u7z4z_teh3zKKJ{7F9Y3tIuRr_Ri@Bvf7W=@p9;Bjmp&Ktwe1go@g z{G?eWDaFAruknsF)IB5n9^l#&E2dmJK4$G4!9U`y0i_Q|(feC(gNFEr!T9rk;$TvS zqh@V8#8Bth!us%G-sNs{bO&Os3lgsVUB}zcmS08vt@n65^4Xp|reP<{!%*rXNk~aK)LSlNoJNI(_qdG2Jodh6AlOv+{ z;JW)ApZ^)A@XJnTtgl4;2A{h<2G$v-cp><^qRl*d)+?YIEFckv*!>B&DkwlnP&>%I z+A}uR>lB9l{8NnJYkY7UV&6}?r1g&u1J2qohUe>(H(k~rmv5R|-%=k|EDZVRiDG+tP<5~o z(OJW^xW0D_;s0>w3YAjcdIyc7-{DI_UM2>*Sf4_S)}oEi zS*jSwX~y7w)XP%PZ-fS^-)jT~H9o1m>_H)Z8@SZ+!=i9q?d)pND0RQcBS}y7^0)A!t86RLC=*8Zt!3gCklci zCWm;JEelpqZpMib)>0@$T6o&hMwL;38r(T`wNj0t*bXH`>4`_=8;)Ce1p}eMf_!&& zM;&EckhL~k#kMf|v|%ZDuXyBE#h?gsErc=rIFo@re{kVy&K2n{o6VKG3}4gh!VYnG z$T0Z}F(zjh8}9uHtKO4jLFt|bESh#3O@;GbEg3M*LBwNyi14t_fM>W zCHt(icYV<*C*4#5LG4lqo|u{WdFTkUAXiF^wuX?kMivYwG;cUv&>EMm`fy5DY_GEY znMK9$!aj|hES+Z<83-j~skhCI;Pu%H%+>^Bz%{6~ z>}YpJ(w89-R@khjmJ>;l(@rr{&Ut7oxQ4ROI#n&FwiPsAf@tHpW)*0}`|%SE1dzds@`VuDdk_DPCuFR*g))jsMvKP(mSkc zWo>iNM5cWmg-V{(>-AG8A$LSX1>5fmn2oSeZn%(_a0~7T8&|LOPYoH6-pY3oV-UAG z>$w!2>A-)ojaB{TUre9i&ZqFm*+jc}1Bec>7Hc z)^d17RH6xWWS;#2-z8jH`e`9#2wDjwYAJiX_=FtYQNC8?RGJ(08CKIcTk6nC8|x<4 zInb7n1cgS>8AxTxduWGD6vjTII3%LBmVM%od2z(4Bqn3?jQ1bxhKHi31_*Gjl)}nX z4;pA9m94^*U+@Y=>peo zNo?*$Q9)7N$K6y$*p)D{cc%Zu`DTK%K-lB8n^%GL_$`in;M$b1F~KI~*UTFnhF5T3{g*2a#kgwo$-jYFM0vcd$qn9xB+JyI$&7jpv=+%4#Xh0b<3g`3 zhdF_vA*~t{>b+!2>!`@0Elcl!sxDEbBBGAVD}8c_0)Eg^8|ej6d_yHd_!=@JmoYjU zDmq^-Q-Y^4Iaf={Hd9=CS%Sxv^kma=dNjj<{4BrZ7U*O{+?0VoYOUXdkY9f8yred3 ztpN8Hv^myWp5ub>K;@BkrH^pxge&e5<$+hC(#oJ)^}zggRWkm-)(xahJjQ~#K#-+7 zGw=m_285~N{?R4b0iN&}e;|6(xLHZ+m7tYXuBueU)KvCVwtw4faK<;_SvQmp^E)m# z2wuc@7d(|cOp;f4&di7t?qK&Dvz;BHR`}wHayxGn2zepXZYY_=6nL{@%h-F`d>*0Q zn0&eInMklJ-Zc>ySO7s;tT*FI;YoqMpa<82%uwHk)3aqzTi)x`BaHh-o(A5M(-c%C z>xbJ`o88`;vnf)yqQ#QGGlmJtz6c!pA6!rAUmxa%Af&ZuA6pl#o} zi;9zZ1L7ofenGj%Fj-a-nA*sqtn6mXc1h9sIIkyAemj!SNmgZ#+E!dS6+GY#zxqki zb%?-K82eoIzTOgfj^;CH>KDy#wY5d9Nn_w1vmh!-Y{1}0ZU?PFVQB5w6L!hDS!2Nm zFFx3+QkhQ!b)#H!Qnv*Nwz8+e29Cm1DoBJxbWja$>oKZ_j?7xTXnI@*OLCl)7N~te z^!mihr{LC84r@yM>a9}%1)_{R)=SSrg^r5K4bCz@v=5aU^X*cuVK=&yFmrD^Pd;58 zc{+qj?;Dd4ZD*S#@P<3-KttrOkR6cMPKCYnlb`7~wXB2OAeMfC-YoxO7+49pwP7q54W_vapya&dxE)%o2JOs4eiSpYf}8%s{8$4xxWR-`$?m$BIN3E zQoj|Q14<@0uqS?Ca)WJUljz837q%vSxmIWj)I!Phz!PwNGaWWFenr)_BF$zXoB&x3 z5AKB{|Ju|RZhRi1@rkc3yozo8Lm%0PcvIh1fczcQot9UMmk7TY%I%%{Jv6J$ghe~# z;;NX{@iF*)kraz$Dwl~RuXp0)#U7Bd<}3rF(S-|X?-p-f{tJfT(EGh4lN?CxX?fMo z6r(nG$vg9Hdaau3(&+jEObS+Bh2&`$3W9=Vps}yJSHN7y8hLvl)nB19>mWMwUr(xB z`cjbCljUKIR{#?{A!NG}3S4ASfj_~%Te3Fc^2~0n0$T)oW%Z5r8}9Y4I6v?`CyjTc zW1ibtcRdK^@IHShDdckCr;LN_ihXbY*`Rwwplb1h2Iv^eU_*mB%Aq4r%EZRv717gB z#EEi&Sa+vLapDq6h49;lqPn6=`dFaMzOCt1X+b5q=+_c-Qxn1)-O#BL z?4w>BKo5Oh8p~w)#te?LkZ8AgTQ_-ON;EC+bWR0OfLCGR@EB%TLDu*uOzv5Tz6qzw zd;41Q!&&Wk=*46P=F>+7yRpw?PlVqlbeRx^nUAjur^`NQj3Pzy`#W8}LQ^~C z6SA6PQBuL;kvli0x~wfGh6oEV+a7p%`B+Nk8B&T7fhVfnSP`m+nY$9nqsg%d@Wc~# zM_=SMx$)~a9@i=R+US4X?quG8RXz`Q(BSkHT zzZL%YCBF43|FhH0ZxHz=-vbP*)PRj}mVaTYA`>(M#1r_#4Z{8pyH(k{|M*PzKQ-VU z?L**Fg?xhb6M#*~$qivr@PHZ=L3IdiWpXyhpDAZ^7Ck4u)%G9`mC6kz>_jwt*--Mn zI@XU#*6kD5&GH)8-m3jlR!93cpjUli5a?4l)yW5xlB!H4#F4J>6c|bg%5==zhh8;< zyd|41?AFey>+YZ$aGVh4n4mH6TB)adN zYK+1QTX*9O8#m{gG5r@PhWvu{NdH>wcM?lXya3nbw$IihoXQR|ZpYSOOQuu&(b}=T@mEqbXCPJXqLOIyr3b!WAfOaIeN;` z-7LGUIB@FC#~qNa$tcN zX5}GhmZSvke@P$`rZPL;e>k2T2(loybV{`eh9reDyw4RH3)L+0{_^!}LY`8%ZSv(X zrUV3G;^Cqgrl1<+E#$K7eJT&}`=%UkF)5?@n**RqY!GS7IfP0i;CzQDvcT<&My#AO zF*fr!GY?U*wL&wyAZP=1+Qi~nVslG71q?od^V8Vqh^&c7-pUnF?Di1DTMGeFr%jIJnq3Q=CtEJBZ_*;5gE(xykw7*}hyR9nX9@#V3r8;{bg= z9k7}3uloES-TjX}gdbiYiYId4y`QHL>l5m+*$u)umJtKqa7I!B zrxZZFnHOBz$eMEvzmLF>{uWRmRIz35G5{1bhdJrWmsOl9dOYRFs%(mZ4TJfS3GUoY z8%!{#xmMt_#(CV~1B|S-+k=;OYwgZ>zdOx{bV!sg7PlQ%>~3rn9h{y{k%j&?l)QCzmpt zHxxOZhMRAamdjbDet~6M;}H_T<)05-)m@PTUhZTgox1US@22rBt{ z-J$qMz3nMW5lg-gSZYiiq_NTjy6dn7UP4QJVp2i=3C6W}#NW{4pV))OEIfENSc%N5 zbbE!*rXyV#@6d8HG0N;1ObGGvQsuc!K@Wsp*` zj5Feo3Uo)L`d(V)_%z0LSuP*wifuNhm>MU`mP|5@&}jDLHOFDCobqak;&7M-#@@sJ zeFwsYVpHiYKvWb576^#v*J1t7STX-*6BG~_&>2S=?GXV^hB;-|FNckyOcD+q1iq}^ zl%7>;YWnSDtZ(>_2##64LRp>! z*9*pH*4_{4p0`^SZ@eLG!1*OOgO^AW$vzk|~XXb*oA8s&FrVSWL}fi3lc5@!SyzO+s%&`?Oe4 zkR;*QmG35AhhA2SfnDHMst&Gbu8v2CbziPhoC3y$#s^&wx>%s65fF~LQNgVrv@mxR zUq4}YMRP*IJc$7-3xj3VGR{d6j^BbJ%WPJ!5>-JxBeLC-&aBEt1x+U_>6S}iMZJ^S z{JJ8w*pMp*q;3Av#JW3}di-p3a0qT$C*YE=iO|fgLuudeK7z#s& zNv`(!Jnv6-HodjGbW|B!i*4|(Ys5zBJ~*>wcA0o%dipNK0kmzf#N-#>oxdnB9C@qJ zqmO+ij2xS!AfV7k_eP~hiZHVz>MJGKryBS=Jt9|x%z6QXsaUE)u?4@0oV~6XtKPH!#1vpK* z)jy-Us#vP8CUT(F$k5$gTT-(9BIt=Sr2MEW=D5G!{LNB#?;~qb<#@@alHw*Y(rGCW z_UNXnRikDXV|HCJ)w{NGc>Ec*^~BeMOa69Pq~D7xb5A}Z)SD|_#A(FgMFKXqvAD$jkUTW(k@wWxE*Am-Wev1Tj7 zx-)GB`2%V-{OznB{Oz0`D>^RL{NtQC5J+7-m_u0m9x_QZ-baTi4OCwin2G4vRVd|b z#uKAfml%wjM@rWl#jJ3<4tO|rB7EHt-EWh~20>YsLjEjp3>!_lsi{&A`x9vIP&8bv0rcuU>SbE>yjv-bF98a?n5Z z<&ufd_I~;=Do5YX@x^DfqPGI(W+K4cO!w=+^@~&HUr$>^Dr){Gv`Bpe{Rv6F7MdUx zW)A&O7-s9M5-=uW)1EvCe`{eL^`P&QGCi_4%qNQW+w4%O7!gmvmj0*X7x`$C9w`}I z4;g13Yg{ZHPaaReZ;@%K4PL!ckRkRHLcC|p%H0VHOOvF_i}A_qqo<>=)$}_1&`8^H zvt6CH*&YT7gW^77VXG=wP(6H|y!s`eNHySyo_4s*1 z=f!O8)JUBi;6FWAAFRSw+n8{(KDOC1urUIu`~PH6oZe|(s}4- zFv%F83l3UnrivGQB0Y$6A3I}%UjsuSS5lrv!I7+fmE1qKI@|b3G{lEhwV^4k#)6@t z``RT+{ekO=nQlNxk%qv`1uX6*PM4%>`2;iX1goo$1GGk$e)G!}Iktpzk#0q5lk2BG z*C0cE_oTTG!AWCLL8l?KtKe;#h3|rB#j94i?up(xh?~CE_J?^IY%l53HfL?~l$lH$ z9QV)l9egqA>?4N^MgwjDis2eFsWsyx@54jl)hHan_28D?XK6RS)qj$rJ24+Lc?&)l__&M~~Eks$7NHRVjM8kB= zM2*Q*(ao%}v5^$}0_WY+$FEo4Abng*DPwxz;km27m4?S>tJ|l^o=!_A>N7_qX-!bEf>kUTDZId`-pC}2>~VC`+6y6aEnRr{w%^6Ww_2d$q?v1ErT)c*nRj2k zD4R5}HmXK#oGFBb+e%-lH#dr$u0(C3DvT{C@YPPFaXWQA-NxOH3Y!EA+zqUB9S+RLG+TB1#P43ER_cn=mVZa!pWn!m&=jF`ZEUFd8K z)@|48>!9(1S2XvPNpz4&_1*w2GKmzsrOcT>_AxDqm>1!MydeFD#4mJ+k)uStModCg za62D@jzzP-k+G5VxI(`NzJR$yL1!uG5V#xP2p23@t_r7|-3Z-aE`OD|LDL74$qQGj zAiBkpE5as_=qY@R&kXs>IiHec+Vv~%Ye

i1O>I_eGKr^&y;^hm-V94&lC5U~@}s zTa5yXP^(8uV=BE6Dt+3? zLaE_7J031uGhDE7|b&w1(^tMyMTy4Ezl&wqN)pF3smtPe#|`O&uE&FOFx;Lv>2r%dWXcsINN|d3 zzSwY&aG}}M#$$|eJ8DI()+D|nV{jSt3X)A(IZ~?lt!A^rpo2z1YmxIU1%lU1G1LL~ z*NFxe{FkBI2+QE9yNI%iZ4g#m1ZMFxYZ10u>`lpV;=aIeh-*?bt~GKz2fOafq^Y$g zM%cM+$NDj_M%^@usUdiHr=2peP3Y;}A%428!?wZ1t|ZvKyDc#F=ivQGFk$n$Auf_1 z)(P76l5Zj$=3GpYqa$Aox}1I>2ghWjQ1cu{;^*$HRyLhx?bh*pJ)4^KC^Ti5mx3`! zvq54tCQ8wFggOQH(f{j65`l?f+7=HujTDJq%0}^CEPFKPxXlgtM$%#TJB|{_HY7WM zd$9`r31iNC3?q53j|V!gg-2DPTYgyV?leMeIyCC^Np)_#+#JG5N3RiYT!$iODzD5A z6YnL^J_$q67@&_DHO|XTjV7qNFUdl}?SlKC>tG$*#ANykA3n~@zH4~pwrK89kqYs~ zSO`7+bxlDW-G#QxDvwT)N*#jp0`2Cv3kbvct-1AYh_@X*vgtjvB$wGRQ#=vi{<*DF z1Bh84t}k!gqK!CAPYZQId%Xi0FyxOvKCz5?x@0X*=|yS_6KV?iX!k=J;1;lT=_hz} zV=L5=<93TT&R^bhK#YsG)gu;R$yf4TTK0PRo?+jke){Nn3knK58FEQES$;Py4-j^G z(PxSif~@1(9Q{#mzxI-64DH)s7Yo=8Z4%`WBkwkcvPME0UF!K%y(a+o`}UBc@#`*3by8Z}nAp3?M6pH77=*ri%#`G z1QtkLqKP)tWpQF`2<_A6X&3Kj6}edvVlZF^2D?8dS3ObqWNwC zOIenicvYA65wda#o|w6m)lF2wmrdDsn*hSj7*D6e69S?j~z zk(0vUKo34jm&;RR0=U1()qpAHGe6dN0{eTD(xaRBK?0hy1z;><{QXNjG8ek|8)3)_iqnw}LZMK$v> zcP>Dw%~pt!=i@kesT1!3flkCj`90M=pS#q`TcWS1IWH~c(~TT<0|S<;Ugeay#fHqM zJQ3xWaJNGVCn0LC2t=mGq6n`!LbUHW_?@c_v%j(>0%{`@K^ll2$dZF9Bt}qbpR27XI#7 z;U+c(3^sbw9~!92lm}5O2ccjQ zWP+fnk`Y);H#FHdqQ1i4ozrAYV;T`diRyj;tH8UHfkT-Ix!6wNNo0_jkx3`w-eb56PVT}m! z1Lohml~_I04KHA|F$Dcv`{S?O>Ob2`|7Edp^m^(Q(xaRvR35Mtcn^=BVK#j&IC7;6 zwepMCRBECVZ*qEYsG#E^&e1)9)tfu>s&RL^@i2C- zY2oU4^msrZ3KB&g4Pl)`L7(sok*F4A2(ppxtn^vZVxbZ0O!nac=@WIal@ADc03m>q zV4O~~o)#h+8qb)F)FLw;C~+l^8!d^=Yp)_UFQHae#4vcDjb&R+pvpGW+Rr$1Wbs%L zNUlR)6%L3w?Gkri+%?_>exZp=8+NXwGZ^2KHCbclCCRST&H%%^tQ}O}W3I?Vq5S@> zQN2o74BTWy0ks%2111cNdL-vP7AHdR=A{uLeYB*kD;b<@b0U*rw~TdaaXGXEbM0cQ zCpxukm)k;`M*P}PY-{Nb3HH>hI;~c%$-QG&Z1%hL#7I1OEo=f$u9a%aLMb6>Ov9P> zHcM2@&oRJoN5)?^GP=XndpF!Lccdd2{Na2x#+X8|J%iMsr zBE*WMg3U}K_*z&RWY`E(;yLc7IZ3h+#;7TT>kAZAX&28F;W7`=bw*n`uO3woyC?-kF~99-?(=qf@bQg@*mw8t;f@}$ zFUn4>$|}JG@pYra1v+m$O1NV#np*C1*N1RlgXts+LJo3Eh+lI?hx_zS7?5Chqc@L= zee;2E38C=ITE7R8zok9Yy7j%kd(8TLCa8uGTR=SEG|^ZCX`8Zi^05UECSKxjO_luw zuW@tF=a@@l0k*cr5Nw`yI3wG0!j}hHOPr(WV-s#q6V*NyNF#JZ^!rN;Z5c(AuX%5K zM-cSO_ktIMpc`#~USvnFC-;Jvec-|rnjbRj2xRhs6``a89lhK}}SIMA??Kul-qE0}hn{(s5eKb02g3JKp&&xim%gn-Wv834dh_x}$G z07k`MB>;B*7Wf|+1Pv4*Tn+^Vgafef0eJr}>OEj|_;Dctod|yaDl4iaNG~ZT1~{ny z_hiPcx7GrHe^3T|&;Xx5uRP!HZ;StzOjb}%QcP4)>4mJ=Ul9kQyS`Xl-G zTdglXVEy$yuRoao1o%@H>d#2)&vVqf8aRsvnCEQ(CI8<1e_pk|z<|I06X5ez9bkRu z;wtFqU;>DJYpVYkP=lZx|*2EW;l!na}aSiriMT z0C`maq^AEHo-V*v{2M%RJ6!_{LuEktc?oMvLm6vpb4Q!sL*s2~FZBXI?g72@`-bqJ zSFJCg&;AY?5cAi<(H?NFOw826P*7jr(B58F*Gkv;Po;(Dc^`q-5&IrN`wn2w`+MFA z0Gg)1$-C+w${YYwhmonVBOrV>Ae8*?^RD2DZ@L4h5^O-;8UM^U;9l!{kMvvU=j|y0 z5R0(*ZyC>bWo%XfWE==kJKsl)Kd)L}dW_$q%UB!#*IF2}I|@Sw_?cJ%%KZIU)Sp+a zZzn(l@aFu)k;e_Z9J6 za`#W@THgeKhRkm&;zzaqx8dix#Nkgo2f%>-8@#_Y{eKfYd|n&R<@0{Bc&YxD<)25K z=c+kB;b!0b-{kpY0RHU+`q%t@-`skxdh-*|`0an!z@pBQGKad+*WUQO z-kwWv{6s}D{1>SIAjt7N|Ieikelnq%{0pYPItl?wXY*I#gXdJwBhCM$0y6(6s{ayq z{yF^fkm*0+6D|G;{zpsvQvmhnRL^6t{-kPj_!m@vRNDWluIJ$^f08UZ{|l0T4rckh zM9-uB{UpP3|0lA)?nXbyd>(7+C+4ZoKVkl8kUyaR`0*sP<1z(dhrp`TODO zxlip+%+ERh8}m0Fw$C&D+=1~Y!FJxiAo%Mj_4^V$cOUyn&|mlq!Jo6lzcKtiFUfOv zkDo+7rN0pU(p~@QaeKan{u4Q<;uqv!JJTP~zu!=QUWn&gmp`dotN)4Wf6S%NckF(` zF4X)J?2iHCANKE_7vQ;F|0ffE<1b9l-yi-`cmJb6&uz^=X+AgoLh~2c9|ij3_77v< zbED%=eDT(Qf&br4kk9MuxgF&v(F(vY@W-1uU_tnMtI8{BaKKyOcXb&iAS6KOxwoC) GfBiq \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/examples/gradlew.bat b/examples/gradlew.bat new file mode 100644 index 000000000..72d362daf --- /dev/null +++ b/examples/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/examples/longpoll/.gitignore b/examples/longpoll/.gitignore index ea8c4bf7f..76daa494e 100644 --- a/examples/longpoll/.gitignore +++ b/examples/longpoll/.gitignore @@ -1 +1,2 @@ -/target +/build/ +/target/ diff --git a/examples/longpoll/build.gradle b/examples/longpoll/build.gradle new file mode 100644 index 000000000..14a786261 --- /dev/null +++ b/examples/longpoll/build.gradle @@ -0,0 +1,2 @@ + +description = 'List Folder Longpoll Example (Dropbox Core API SDK)' diff --git a/examples/longpoll/pom.xml b/examples/longpoll/pom.xml deleted file mode 100644 index 66b372148..000000000 --- a/examples/longpoll/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - 4.0.0 - - List Folder Longpoll Example (Dropbox Core API SDK) - examples-longpoll - jar - - - com.dropbox.core - examples - 0-SNAPSHOT - ../pom.xml - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - compile - - build-classpath - - - - - - - diff --git a/examples/longpoll/src/main/java/com/dropbox/core/examples/longpoll/Main.java b/examples/longpoll/src/main/java/com/dropbox/core/examples/longpoll/Main.java index 424b12367..4ec21ab89 100644 --- a/examples/longpoll/src/main/java/com/dropbox/core/examples/longpoll/Main.java +++ b/examples/longpoll/src/main/java/com/dropbox/core/examples/longpoll/Main.java @@ -110,7 +110,7 @@ public static void longpoll(DbxAuthInfo auth, String path) throws IOException { */ private static DbxClientV2 createClient(DbxAuthInfo auth, StandardHttpRequestor.Config config) { String clientUserAgentId = "examples-longpoll"; - String userLocale = Locale.getDefault().toString(); + String userLocale = Locale.getDefault().toLanguageTag(); StandardHttpRequestor requestor = new StandardHttpRequestor(config); DbxRequestConfig requestConfig = new DbxRequestConfig(clientUserAgentId, userLocale, requestor); @@ -187,7 +187,7 @@ public static void main(String[] args) throws IOException { // Only display important log messages. Logger.getLogger("").setLevel(Level.WARNING); - if (args.length == 0) { + if (args.length != 2) { System.out.println(""); System.out.println("Usage: COMMAND "); System.out.println(""); @@ -197,15 +197,10 @@ public static void main(String[] args) throws IOException { System.out.println(""); System.out.println(" : The path on Dropbox to watch for changes."); System.out.println(""); + System.exit(1); return; } - if (args.length != 2) { - System.err.println("Expecting exactly 2 arguments, got " + args.length + "."); - System.err.println("Run with no arguments for help."); - System.exit(1); return; - } - String authFile = args[0]; String path = args[1]; diff --git a/examples/pom.xml b/examples/pom.xml deleted file mode 100644 index 0083d3a0c..000000000 --- a/examples/pom.xml +++ /dev/null @@ -1,77 +0,0 @@ - - 4.0.0 - - Dropbox Core API SDK Examples - com.dropbox.core - examples - 0-SNAPSHOT - - pom - - - account-info - authorize - longpoll - tutorial - upgrade-oauth1-token - upload-file - web-file-browser - - - - - com.dropbox.core - dropbox-core-sdk - 0-SNAPSHOT - - - - - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - ${project.build.directory}/runtime-classpath - runtime - - - - compile - - build-classpath - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 8 - 8 - UTF-8 - true - - - - - - - - UTF-8 - - diff --git a/examples/run b/examples/run index cc5fc09d8..bebfa2f08 100755 --- a/examples/run +++ b/examples/run @@ -33,31 +33,26 @@ if [ $# -eq 0 ]; then die "" \ "Usage: run example-args..." \ "" \ - "For example: run web-file-browser ..." \ + "For example: run upload-file ..." \ "" fi +declare -a project_properties +if [ "${1}" == '--use-auth-prop' ] ; then + project_properties+=("-PuseAuthInfoFileProp=true") + shift +fi + example_name="$1" ; shift example_name="$(echo "$example_name" | sed 's|/*$||')" # Remove trailing slashes, since shell tab completion will usually add one. -example_folder=${example_name//_/-} -example_package=${example_name//-/_} - -if [ ! -f "$base_dir/$example_folder/pom.xml" ]; then - die "Invalid example \"$example_name\"." \ - "(Couldn't find \"pom.xml\" in \"$base_dir/$example_folder\".)" -fi - -if [ ! -f "$base_dir/$example_folder/target/runtime-classpath" ]; then - die "Unable to run example \"$example_name\"." \ - "Couldn't find \"target/runtime-classpath\" in \"$base_dir/$example_folder\"." \ - "\"ReadMe.md\" at the top level has instructions for running the examples." -fi - base_dir=`dirname "$loc"` -classpath="$base_dir/$example_folder/target/classes:$(cat $base_dir/$example_folder/target/runtime-classpath)" -main_class=com.dropbox.core.examples."$example_package".Main +i=0 +for arg in "${@}" ; do + project_properties+=("-Parg${i}=${arg}") + i=$((i+1)) +done -exec java -ea -cp "$classpath" "$main_class" "$@" +exec "${base_dir}/gradlew" -b "${base_dir}/build.gradle" --console plain --quiet ":${example_name}:run" "${project_properties[@]}" diff --git a/examples/settings.gradle b/examples/settings.gradle new file mode 100644 index 000000000..0faeda68e --- /dev/null +++ b/examples/settings.gradle @@ -0,0 +1,8 @@ +rootProject.name = 'examples' +include ':account-info' +include ':authorize' +include ':longpoll' +include ':tutorial' +include ':upgrade-oauth1-token' +include ':upload-file' +include ':web-file-browser' diff --git a/examples/tutorial/.gitignore b/examples/tutorial/.gitignore index ea8c4bf7f..76daa494e 100644 --- a/examples/tutorial/.gitignore +++ b/examples/tutorial/.gitignore @@ -1 +1,2 @@ -/target +/build/ +/target/ diff --git a/examples/tutorial/build.gradle b/examples/tutorial/build.gradle new file mode 100644 index 000000000..5d87f1467 --- /dev/null +++ b/examples/tutorial/build.gradle @@ -0,0 +1,2 @@ + +description = 'Tutorial Example (Dropbox Core API SDK)' diff --git a/examples/tutorial/pom.xml b/examples/tutorial/pom.xml deleted file mode 100644 index f39ad98bb..000000000 --- a/examples/tutorial/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - 4.0.0 - - Tutorial Example (Dropbox Core API SDK) - examples-tutorial - jar - - - com.dropbox.core - examples - 0-SNAPSHOT - ../pom.xml - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - compile - - build-classpath - - - - - - - diff --git a/examples/tutorial/src/main/java/com/dropbox/core/examples/tutorial/Main.java b/examples/tutorial/src/main/java/com/dropbox/core/examples/tutorial/Main.java index 06f4f3598..577fe2e23 100644 --- a/examples/tutorial/src/main/java/com/dropbox/core/examples/tutorial/Main.java +++ b/examples/tutorial/src/main/java/com/dropbox/core/examples/tutorial/Main.java @@ -19,7 +19,7 @@ public class Main { public static void main(String args[]) throws DbxException, IOException { // Create Dropbox client - DbxRequestConfig config = new DbxRequestConfig("dropbox/java-tutorial", "en_US"); + DbxRequestConfig config = new DbxRequestConfig("dropbox/java-tutorial"); DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN); // Get current account info diff --git a/examples/upgrade-oauth1-token/.gitignore b/examples/upgrade-oauth1-token/.gitignore index ea8c4bf7f..76daa494e 100644 --- a/examples/upgrade-oauth1-token/.gitignore +++ b/examples/upgrade-oauth1-token/.gitignore @@ -1 +1,2 @@ -/target +/build/ +/target/ diff --git a/examples/upgrade-oauth1-token/build.gradle b/examples/upgrade-oauth1-token/build.gradle new file mode 100644 index 000000000..2978f5a1d --- /dev/null +++ b/examples/upgrade-oauth1-token/build.gradle @@ -0,0 +1,2 @@ + +description = 'Upgrade OAuth 1 Token Example (Dropbox Core API SDK)' diff --git a/examples/upgrade-oauth1-token/pom.xml b/examples/upgrade-oauth1-token/pom.xml deleted file mode 100644 index 02697568c..000000000 --- a/examples/upgrade-oauth1-token/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - 4.0.0 - - Upgrade OAuth 1 Token Example (Dropbox Core API SDK) - examples-upgrade-oauth1-token - jar - - - com.dropbox.core - examples - 0-SNAPSHOT - ../pom.xml - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - compile - - build-classpath - - - - - - - diff --git a/examples/upgrade-oauth1-token/src/main/java/com/dropbox/core/examples/upgrade_oauth1_token/Main.java b/examples/upgrade-oauth1-token/src/main/java/com/dropbox/core/examples/upgrade_oauth1_token/Main.java index d66210d24..15216db98 100644 --- a/examples/upgrade-oauth1-token/src/main/java/com/dropbox/core/examples/upgrade_oauth1_token/Main.java +++ b/examples/upgrade-oauth1-token/src/main/java/com/dropbox/core/examples/upgrade_oauth1_token/Main.java @@ -47,7 +47,7 @@ public static void main(String[] args) new DbxOAuth1AccessToken(cfg.accessTokenKey, cfg.accessTokenSecret); // Get an OAuth 2 access token. - String userLocale = Locale.getDefault().toString(); + String userLocale = Locale.getDefault().toLanguageTag(); DbxRequestConfig requestConfig = new DbxRequestConfig("examples-authorize", userLocale); DbxOAuth1Upgrader upgrader = new DbxOAuth1Upgrader(requestConfig, appInfo); @@ -143,8 +143,8 @@ private static Config parseArgs(String[] args) disable = true; } else { + printHelp(System.out); System.err.println("Unrecognized option \"" + arg + "\"."); - System.err.println("Run with no arguments for help."); return null; } } @@ -154,8 +154,8 @@ private static Config parseArgs(String[] args) } if (remainingArgs.size() != 3) { + printHelp(System.out); System.err.println("Expecting at least 3 non-option arguments, got " + remainingArgs.size() + "."); - System.err.println("Run with no arguments for help."); return null; } diff --git a/examples/upload-file/.gitignore b/examples/upload-file/.gitignore index ea8c4bf7f..76daa494e 100644 --- a/examples/upload-file/.gitignore +++ b/examples/upload-file/.gitignore @@ -1 +1,2 @@ -/target +/build/ +/target/ diff --git a/examples/upload-file/build.gradle b/examples/upload-file/build.gradle new file mode 100644 index 000000000..d057734f8 --- /dev/null +++ b/examples/upload-file/build.gradle @@ -0,0 +1,2 @@ + +description = 'Upload File Example (Dropbox Core API SDK)' diff --git a/examples/upload-file/pom.xml b/examples/upload-file/pom.xml deleted file mode 100644 index 6ea66765c..000000000 --- a/examples/upload-file/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - 4.0.0 - - Upload File Example (Dropbox Core API SDK) - examples-upload-file - jar - - - com.dropbox.core - examples - 0-SNAPSHOT - ../pom.xml - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - compile - - build-classpath - - - - - - - diff --git a/examples/upload-file/src/main/java/com/dropbox/core/examples/upload_file/Main.java b/examples/upload-file/src/main/java/com/dropbox/core/examples/upload_file/Main.java index 2791f5d6f..df166e4c6 100644 --- a/examples/upload-file/src/main/java/com/dropbox/core/examples/upload_file/Main.java +++ b/examples/upload-file/src/main/java/com/dropbox/core/examples/upload_file/Main.java @@ -213,7 +213,7 @@ public static void main(String[] args) throws IOException { // Only display important log messages. Logger.getLogger("").setLevel(Level.WARNING); - if (args.length == 0) { + if (args.length != 3) { System.out.println(""); System.out.println("Usage: COMMAND "); System.out.println(""); @@ -226,12 +226,7 @@ public static void main(String[] args) throws IOException { System.out.println(" : The path on Dropbox to save the file to."); System.out.println(""); System.exit(1); - } - - if (args.length != 3) { - System.err.println("Expecting exactly 3 arguments, got " + args.length + "."); - System.err.println("Run with no arguments for help."); - System.exit(1); + return; } String argAuthFile = args[0]; @@ -270,7 +265,7 @@ public static void main(String[] args) throws IOException { // Create a DbxClientV2, which is what you use to make API calls. - String userLocale = Locale.getDefault().toString(); + String userLocale = Locale.getDefault().toLanguageTag(); DbxRequestConfig requestConfig = new DbxRequestConfig("examples-upload-file", userLocale); DbxClientV2 dbxClient = new DbxClientV2(requestConfig, authInfo.getAccessToken(), authInfo.getHost()); diff --git a/examples/web-file-browser/.gitignore b/examples/web-file-browser/.gitignore index ea8c4bf7f..76daa494e 100644 --- a/examples/web-file-browser/.gitignore +++ b/examples/web-file-browser/.gitignore @@ -1 +1,2 @@ -/target +/build/ +/target/ diff --git a/examples/web-file-browser/build.gradle b/examples/web-file-browser/build.gradle new file mode 100644 index 000000000..04ec1c587 --- /dev/null +++ b/examples/web-file-browser/build.gradle @@ -0,0 +1,10 @@ + +description = 'Web File Browser Example (Dropbox Core API SDK)' + +dependencies { + compile 'org.eclipse.jetty.aggregate:jetty-server:8.1.18.v20150929' + compile 'javax.servlet:javax.servlet-api:3.1.0' + compile 'org.apache.commons:commons-lang3:3.4' + compile 'com.fasterxml.jackson.core:jackson-core:2.7.4' + compile 'com.fasterxml.jackson.core:jackson-databind:2.7.4' +} diff --git a/examples/web-file-browser/pom.xml b/examples/web-file-browser/pom.xml deleted file mode 100644 index 939dce387..000000000 --- a/examples/web-file-browser/pom.xml +++ /dev/null @@ -1,69 +0,0 @@ - - 4.0.0 - - Web File Browser Example (Dropbox Core API SDK) - examples-web-file-browser - jar - - - com.dropbox.core - examples - 0-SNAPSHOT - ../pom.xml - - - - - org.eclipse.jetty.aggregate - jetty-server - 8.1.18.v20150929 - - - javax.servlet - javax.servlet-api - 3.1.0 - - - org.apache.commons - commons-lang3 - 3.4 - - - com.fasterxml.jackson.core - jackson-core - 2.7.1 - - - com.fasterxml.jackson.core - jackson-databind - 2.7.1-1 - - - - - - java.net - http://download.java.net/maven/2 - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - compile - - build-classpath - - - - - - - diff --git a/examples/web-file-browser/src/main/java/com/dropbox/core/examples/web_file_browser/Common.java b/examples/web-file-browser/src/main/java/com/dropbox/core/examples/web_file_browser/Common.java index b524f52e6..79cc58336 100644 --- a/examples/web-file-browser/src/main/java/com/dropbox/core/examples/web_file_browser/Common.java +++ b/examples/web-file-browser/src/main/java/com/dropbox/core/examples/web_file_browser/Common.java @@ -144,7 +144,7 @@ public User requireLoggedInUser(HttpServletRequest request, HttpServletResponse public DbxRequestConfig getRequestConfig(HttpServletRequest request) { - return new DbxRequestConfig("example-web-file-browser", request.getLocale().toString()); + return new DbxRequestConfig("example-web-file-browser", request.getLocale().toLanguageTag()); } public void handleDbxException(HttpServletResponse response, User user, DbxException ex, String action) diff --git a/examples/web-file-browser/src/main/java/com/dropbox/core/examples/web_file_browser/Main.java b/examples/web-file-browser/src/main/java/com/dropbox/core/examples/web_file_browser/Main.java index f08c3b458..fc93d69c9 100644 --- a/examples/web-file-browser/src/main/java/com/dropbox/core/examples/web_file_browser/Main.java +++ b/examples/web-file-browser/src/main/java/com/dropbox/core/examples/web_file_browser/Main.java @@ -24,15 +24,12 @@ * An example web application that uses the Dropbox API to let users browse * their Dropbox folder. */ -public class Main extends AbstractHandler -{ +public class Main extends AbstractHandler { private final Common common; private final DropboxAuth dropboxAuth; private final DropboxBrowse dropboxBrowse; - private Main(PrintWriter log, DbxAppInfo dbxAppInfo, File userDbFile) - throws IOException, Common.DatabaseException - { + private Main(PrintWriter log, DbxAppInfo dbxAppInfo, File userDbFile) throws IOException, Common.DatabaseException { this.common = new Common(log, dbxAppInfo, userDbFile); this.dropboxAuth = new DropboxAuth(common); this.dropboxBrowse = new DropboxBrowse(common); @@ -43,8 +40,7 @@ private Main(PrintWriter log, DbxAppInfo dbxAppInfo, File userDbFile) // ------------------------------------------------------------------------------------------- public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { + throws IOException, ServletException { // Don't pollute the logging with the favicon.ico requests that browsers issue. if (target.equals("/favicon.ico")) { response.sendError(404); @@ -60,34 +56,25 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques if (target.equals("/")) { doIndex(request, response); - } - else if (target.equals("/login")) { + } else if (target.equals("/login")) { doLogin(request, response); - } - else if (target.equals("/home")) { + } else if (target.equals("/home")) { doHome(request, response); - } - else if (target.equals("/logout")) { + } else if (target.equals("/logout")) { doLogout(request, response); - } - // Dropbox authorization routes. - else if (target.equals("/dropbox-auth-start")) { + // Dropbox authorize routes + } else if (target.equals("/dropbox-auth-start")) { dropboxAuth.doStart(request, response); - } - else if (target.equals("/dropbox-auth-finish")) { + } else if (target.equals("/dropbox-auth-finish")) { dropboxAuth.doFinish(request, response); - } - else if (target.equals("/dropbox-unlink")) { + } else if (target.equals("/dropbox-unlink")) { dropboxAuth.doUnlink(request, response); - } // Dropbox file browsing routes. - else if (target.equals("/browse")) { + } else if (target.equals("/browse")) { dropboxBrowse.doBrowse(request, response); - } - else if (target.equals("/upload")) { + } else if (target.equals("/upload")) { dropboxBrowse.doUpload(request, response); - } - else { + } else { response.sendError(404); } } @@ -98,9 +85,7 @@ else if (target.equals("/upload")) { // The front page with a login form. If there's already a user logged in, they get // redirected to "/home". - public void doIndex(HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { + public void doIndex(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (!common.checkGet(request, response)) return; // If there's a user logged in, send them to "/home". @@ -140,9 +125,7 @@ public void doIndex(HttpServletRequest request, HttpServletResponse response) // ------------------------------------------------------------------------------------------- // Login form handler. - public void doLogin(HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { + public void doLogin(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (!common.checkPost(request, response)) return; String username = request.getParameter("username"); @@ -176,14 +159,13 @@ public void doLogin(HttpServletRequest request, HttpServletResponse response) } // Returns 'null' if the username is ok. - private static String checkUsername(String username) - { + private static String checkUsername(String username) { if (username.length() < 3) { return "too short (minimum: 3 characters)"; - } - else if (username.length() > 64) { + } else if (username.length() > 64) { return "too long (maximum: 64 characters)"; } + for (int i = 0; i < username.length(); i++) { char c = username.charAt(i); if (c >= 'A' && c <= 'Z') continue; @@ -192,6 +174,7 @@ else if (username.length() > 64) { if (c == '_') continue; return "invalid character at position " + (i+1) + ": " + jq(""+c); } + return null; } @@ -201,9 +184,7 @@ else if (username.length() > 64) { // If a user is logged in, show them information about their account and let them connect their // account to their Dropbox account. If nobody is logged in, redirect to "/". - public void doHome(HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { + public void doHome(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (!common.checkGet(request, response)) return; // If nobody's logged in, send the browser to "/". @@ -259,9 +240,7 @@ public void doHome(HttpServletRequest request, HttpServletResponse response) // ------------------------------------------------------------------------------------------- // Logout form handler. - public void doLogout(HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { + public void doLogout(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (!common.checkPost(request, response)) return; request.getSession().removeAttribute("logged-in-username"); response.sendRedirect("/"); @@ -272,10 +251,8 @@ public void doLogout(HttpServletRequest request, HttpServletResponse response) // ------------------------------------------------------------------------------------------- // Parse command-line arguments and start server. - public static void main(String[] args) - throws IOException - { - if (args.length == 0) { + public static void main(String[] args) throws IOException { + if (args.length != 3) { System.out.println(""); System.out.println("Usage: COMMAND "); System.out.println(""); @@ -293,15 +270,10 @@ public static void main(String[] args) System.out.println(" : Where you want this program to store its database. For"); System.out.println(" example, \"web-file-browser.db\"."); System.out.println(""); + System.exit(1); return; } - if (args.length != 3) { - System.err.println("Expecting exactly 3 arguments, got " + args.length + "."); - System.err.println("Run with no arguments for help."); - System.exit(1); return; - } - String argPort = args[0]; String argAppInfo = args[1]; String argDatabase = args[2]; @@ -314,8 +286,7 @@ public static void main(String[] args) System.err.println("Expecting to be a number from 1 to 65535. Got: " + port + "."); System.exit(1); return; } - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { System.err.println("Expecting to be a number from 1 to 65535. Got: " + jq(argPort) + "."); System.exit(1); return; } @@ -324,8 +295,7 @@ public static void main(String[] args) DbxAppInfo dbxAppInfo; try { dbxAppInfo = DbxAppInfo.Reader.readFromFile(argAppInfo); - } - catch (JsonReader.FileLoadException ex) { + } catch (JsonReader.FileLoadException ex) { System.err.println("Error loading : " + ex.getMessage()); System.exit(1); return; } @@ -347,8 +317,7 @@ public static void main(String[] args) System.out.println("Server running: http://localhost:" + port + "/"); server.join(); - } - catch (Exception ex) { + } catch (Exception ex) { System.err.println("Error running server: " + ex.getMessage()); System.exit(1); } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..5ccda13e9cb94678ba179b32452cf3d60dc36353 GIT binary patch literal 53638 zcmafaW0a=B^559DjdyI@wr$%scWm3Xy<^+Pj_sKpY&N+!|K#4>Bz;ajPk*RBjZ;RV75EK*;j-;d{(BB5~-#>pF^k0$_Qx&35mhPeng zP5V`%P1S)(UiPcRczm!G=Nud7!TH`9_!bdReTmO0lO(Zfn zfMqP~+s2VTE#?sl=$9e(CuBOAH2n}=c4idsipAKKQIO=pSsMiScd0TvKs^d1xMCym`IZxg&Xd3ii(^3$M#K)myV2qM z{o5&z?1rtP{gnX6zegV2 z$03xe*g2pGA^BqfBE}XDD-CN?H&?w?kE0wG3~``ie?T+IRmsT;*cpLZ)OnaXBtFzX zMcc97L%tQqGz+E@0i)gy&0g_7PV@3~zaE{g-2zQ|T9d>EL&JiD+E8t?H^#-Hv8!mV z-r%F^bl8v}j19B}`M^zJ>hD+Tg?Fg%no2GYmKkbR`2=|`@o`~1&VbKUJ@ZSojd|ihP|{9&8F<6 zcAvtwl6yo{Js7UQ{l~MjA7Rz8(sYEcRXX(n*(Mp75OBEijo(25zwC)pc=#%f_xV93 z`&d+DI*TAtd3KBd(^964h=X;uks5gf3MU}cR#X_wnk6_crcAVLsTV2SzsGM$h~aq~ z6oX|v?jSq%txd-SHwHy`7x4*jJqH^;0*1`Sztp*aYi4tRMBD|Ryyl%F{IC{(=Y{Y5 zhSQPvqZN~4uvCi*h``E|llqjfc4rnRQPs3@(MnB9jto`dtz!CB-ojaReyN}7BwMp! zU@jEkH2hS%NUB|wE0d;=hS4^M^dTz`r=^`7LNsQkU26nlt4o?Ki13cwDXkQH+)w#uNVQo2o@pEJOAZV3Uf z8WWqpN|lDuGdkokHkKLwmo@qCdV6}M=~DGq+P3}@$$yqQssE{3|BxxM*q?tD3oiW6 z^!W)Iau1CDv+;dTH4Lbb;*)+mGrKg;g)4tHB;h~=3QsCF)I|E{`=jp;ArQuy&zUzA zlz$NoIhz7h@;Sw+#%u~;!w56XV3JkGLOHaVlvs1eSSck_-2#zs%EynXvEnsUsO3{@ z=2B!(Gdra;oKm@A@~#LeoDFC2&V->;dgCP}x`Qm{yZA&ULeNnWvNIGzcgjx2?Rx#m z_I4lu^j~)hR_VQ?`&Yk|{^}Rqf8MFY|1el;E@sY>4t8d;4h}YMj{n$ntcs2Tju6_n zc%t6wvvLifwar=wOlL#;T5V}~s_KU-6cMz7X&7`JeYdHW?WaaBnYH!e82^(58{d#J z&3H)nMCXi0pUcVg^sRt^KZxdFRj|_ZglEw{Ri0EN6_laAxbE8zB=H8KgU;Xtpk5?z zC2?g-xj`9d8MtJf-!H#~s0}tJ>Ksa+7KP;J(%hHwUBewO);ZZ&ry8oYXI%5+YQgNQeyS*ViKL>Yy2`MsK? zB7Y$Zk@YAy#-Kwyo5KSK$lcvER(OV>qrW1VXPo7Ih%dEJZ<|5sEmeC)do0(dJ;7Fc z#v{T#df-92-StcUzRO7OjZ?g-Ik?9eGEDWsUL(f2jUmS9_ajH?wV&{0Aj)-0IP36} z4!4}CW2D{v(ZmPjB$#&;fps(Hvph<>^IORq|0^=eDhYiA%W5!rM_K_y(bsu@*)m3P++I=?)h!HA@uUc{zxJ0ibvxU%Ke8OQ+KDRndS#XDA4T zto-I$zC-%q0v8ZL`!Z;MMK0`Irsn?gZwiTbsJAr&4g~c3FEn8J&tfX(X=3ZOyEhpng#DDSOc6XLr%uGtB2|0=_Au$%heH3&*ID*ZPhs8iJyw{$c z)`ySqPVndS_Rnv2f$xtMcp${1WTLjhW)S3(;l*PK4#cXz09;@vNj*6?$Q>%5jIboV2fgAyb?c(W#K{@rj#6OKF&J#QQ9 zboB4HeJ?hXrHp)H9rx@Rta#*PdvkHJ<<2Asc#ClKA;st5qadT0NZHEA111(&qsaLb zkeTH_h(yr92XkyqqslQgTo(|RN$hhQ*IL7<12W?$+q6R2jtnWadKrIyeA>bj=;9mM zaPK&0{1#djnc2d@4fR{7K872i*IvH0mK#eqf4=iu8F5=2P#fG-GBZ|`J2MyJ(^^*5 z$tQaAS;Y(2k!j10=adaH9^!>^k+iBMVWD9#+F=&Q(yZ5NVJ>A}t>1R@32TZ0JTMas z%42sos08y0NMkb$BsDnQo8nVhd#ksaq8UyBjAO1FHRfW*u`ojc^y3)=(f&PTM`k@F zMoZFS>HCeNX1c@G{<=x`IQr>{11kPK#7AZWy_q&GQYwk*t|uTE9H*TVi|@g8P95wBlwf};`RANPqd z@rf3B=~Q8%Wgl5i2t$W?Ns1WgZ1t0sFVJF73Rc!d@X---3W@e+Dbvpj;l~8r`F9Sc zKd8G>dR2>61(|Bw&XdTlG}}fnu~6{2xsz6Efmc;nRDupK!KI-q=^*h{`b$W=VCBWe|mhK3YN$PO28ZaH@2V;Nbgpwl8Fig6xxkWN7UhWjM%G z<^O`4VX45jgsIIO-R$7F$`uCa6O>(WOZ>i>Gor3X^yySAwSB;0*X`pWy<(jya4!HO zYDvrso1n6V3G<>TnrSv{+unA;cSAWuH!9k`z#^j306@cy?0{jP-p4NUCSRP<_wNHG6^axCR zMECIg`Vz^ja7F}a@eRp)X%2>D5;2HR8kL?^&npLgqU9<#pY)7;V<(`jjbZL5j>8!3 zLF`9aB2GDCO#Q|6P6_x!My0QO@k9M-2f2-|AF33CZ))eL<;OOi;76DiE|3}S)dWs znAG6VC4EKe9MedTp6d0%J409Iu^T12e)n(N?^s^DlM+cUS5h4SEqq4NjK+%c6KPr%EUeiN1v_&WkfIr9Do+Q{2=Ap?{FS|6D&*Au8=PW}~Rt~+3EJpNK(;7R!k z%&9kpQ;0c6#VF?+W0D~mUp&bc96HK5g~~9ch$%)z5Z@Wq`!V zLK|>+`YZuZ?H_46y1zmqL~@TLC0lsiaSZzy-7!W4m2VsY*S@u zW}zeWzr7N1oL)qzKa8J;I?@RxaLmPEowX2BlSD2hnYW}WyvQ$FK%;PTPl4|ftNkVB-&5MvFWP;Yx2`zBS8o_7QfB#MLS!;fRlOU$t z%iCYD|0>%`e)v|$e?d9+U&O=spApZ$`@51x_J1P_|AafS>X$C4YG{A#vQ3BFr-~J& zrNf{=tbRuZqT9ky&r6pgk}1*#cgZ;@Dve26=%&Eu887bdn12Lfj~ET zV5IjzrKV8JQNK?MSC0X660d`nnw55z4~eTJnzix7U0S>nhTZ)+f}uOuozz3gz(ZMj zYs1J$Dy2L`8>*UTBLriGUKTY410qsp)+K??D$!Mr_7=C*Ec`Q^X$b{2>?+1_7Ka7f zd2{rtBr%g2PbF_kHb0yF5ypGWmJ(ftYt&YJ_ynIc9aWyTF~dXbrN!iNKZ_(_u>s(I z2*X|;szamJz{2dl(P2I;%foJLF51)WO50&h!EXP{5|gzy^b(4+nn<;j$NCt?UP_cL zEU1-XN`f*1Gl}Fht4&Pn5xo)Ma$kZyBt2qju1yuSTysFNG^pi%vvU=hqPhQ-Cpl`! zSt+cpY2TVYkvTflcqwieu*7MHVIVSQSivl850|@O!h+yWxUM;@nYhP*y8k$MMX>^Vzs= zqdctvR$e(}|H4~b=2=Dszgy^xqjuY6alG6sJ&J~#*>K6$Dl|Pf&Y~sh$@07*amh*T z_wIHl$BbJK)7B2V0P=;_iRjD@X9TGO4h+mK7laU=qy zmy|9(xNb7=49$9mLHL1jK#9O+t+CJ;3IDtkK4I0H_{C zMZMuxRK)|E4155y$!RGIcAVHwpQK;2>ssTa8^Y0_8A*sk}a3gZD5Il8pD}4GR1;_@6*%Y^za=h*V zu5|)zJI%1zR^G!TWc5ioA9xPwtfcqbul(N(r%J#%9D&&zkuV4xj0VXfymNc> zXa2;S1FBKAgNu0n(1&iyT^XFajIG9aRR$`eVEejDBr(KR%NpK5M4^XoP2r^{5!QII z=({hFfVnU7w+W~i2BF-t(|u6~1LVuM`kfH|v*hfA+X=o<%CrInhQid%%Pn@a#zcB{ z^o7+|r0o0_JFn1}AG;)N{NfS8LI&fnSX*e@KcPEe6OV6U-=oiHjXw;D&;Ui32rr=^ zeI$9fsv_3NJU2zXlqE0HwYjRkF^(*=dmpb#bAGI-iGF7mAYYyfIwG8Z;|+==LK(t5 z=LlsTsJKX@6c-VZ+w{_}$Z-T9i*wIN-d5;hIXRENbV;h#&hIG%+U%XScSeP_M`St_ zW*|AQg18~yjh5x7_;)cRFt3fbcf={_ULTh(DfkEq%mVu$EcpgdN}OOAmZBAc2`mzY-_S)k2M=`*UssiSqyy?xVKo=MbGuFS6XRVx2Djkn-AEcIgSQvVAF zfc`p)g#X!O$~sv5mqQqq{Nb>uh&I-rK1N;7H0mguftm{=rV;MIL=kQZjZ6q_PVrHj zl3gcbRfrb*Cn_KeXJnZ06ZEq<=ClnSMYA~}FVE$cEB}!?;QRYG{63OGvgE!wNV+3U z&{hS7QV6Z6UL=q3cB&(hP~yB{WPCY<2lhJj&?d_e^Y$rRxGZ6c1-iXZdJo;c_d!-U7axq4RNZah&+JQde7@OZf;An_X_9 z;&omnq3Vb#o!)t8oY6U5q9V@2gy>2y91VhMexMd;_^7e(hpL;mFYj^Ms7`BGG-h5q zK%Q)s!X(^S6HkOCW#c?l`3P0RZTN{hKdkGb8X4YR z`Q>!^OJIGZmB9N^htzi$VRW^@G$NKIzjI7BcO^B;MhbLW^3e|uMwSeIP|Zs8x`x5{ zeL>F`oNu5Vl>~_AJi)C>nNM&Fhx!XDe?wEG`x8B+)*W-m%b^U0@g03H+h=q%dPTeRj5TVw;2U@yvqaijNc-yOdE0sdE!oOQm8LWcwb zvPS>{qWI4usc7VCDdgf}W@r3gcXz7#y9ura^7ra0x>qu1l*@W+h%sd>?FNRF3P1|= zZbh`V{x`M!W`~UpsRQ+GS9kSrxHBr?)ej6Lo3uG_H zt<~-{2g_b|`=9T*FAm_G(f&ius6m395oJ6G`(dhHA`zwVV}R^Nn`tA;NVLNfW^Hs9AWg~k&`b-e$0W2lP^ww;)sP<7yihp z>9;T5*j*ExLF8eyk}p*_!`MPt{qUWd(sve|0cQ3d(s?$MugrLsb=F0U=Z>3QNKb~xQiuR|wEjrfU z+ zcuJ(5)AJajIhR#qf<4<5IRe+i9ySGsxMdU+)OPV`G3%LV?Y&rh6sS?3B$pjiq)Tp> z7}ce0mnh`&H|iOQ1Gb0uRJX^%qxxmUZ=$BivYy9aXQU8){*Y>2BZ9l-I9bd_Cb^=f%{ zmiWjT=K4anJYD<1{Uv&xtE!H~-PThqR_6Xk6JGHrBqqGQKH?tN;Y{bu{vvRtU8UsW z(llN(rJar!7lEQU6Og+kl{x(`fYfSOcD-A(iW^ymja51?n_e*XdzPU6$KMxkZcJK` zJda&tRCKm42Sb&*e*F*DU{{L^KV#|D}q2fz@SkOgh!`P8>llzU)uQmjI>w+ojmYH8DUYso9od6~Q z;4`O#*N}<@^x4|bmeg+8V z#FzePXp9j-$0LxzgYFM1c8Sfb>{Ps6=4+{2OSxf{aUT^)eNk{Itv=A6UH-NWAk zbZSac^MG}0zqXgc*4EY)bsLAv>)zhim))%o>em2scaCgRq(g@OFY^hHi1@3ZH?0RyOJwn?nXpt|EK zC7C$;BzYJGJRO=@=P;0~`pP4Xo506(sb4GFpOQ5bebMSZAyb9jZC0r^8@4#6@ zN1(csX24ZP&hIq|Wy)DqPP#K}FbsE(!eN*bF(bfPb223XmHFutE}fA+X)(F@1;%yH zk1$?!wEHfeYJqddk074aDxPkEX(5=S7o}DSWlDe=WSG+rui7V8D&L^N{0Eoj{52^F znZVhj=S5qnyRaUmgH@o~<9q*IvbmW>Rd7#O2emhnur1TYHlW(mYhdexX!Kp=0`-Hf z!SuIx<@XNREb6dlpjM~u!9pOrQ+I)gFWa|Hkzd!e`}FK$)l*+RDtXAr6jhG2g7^(& zS#O*-Cp0BefE>7adHa;nq#sma9#q??1@@V^r}|p+lu`QF`_*sO?>*YP{B-=C+6Oin z!SJy*7wjAkT`h%`ZcC$OE7=@uwGN%GB0FWRvSBmnm)%cUkp!1DR;?)JH7?*wZ@)ch ztfdr-ApH==lQ4l~Yl$%t!PHH1zsCEliydl^cX*{BK4Bwl&; zJx=3~4w4j}SylJRk^&{HD^znI={^oh5?NHd2d1H_jh;qml_=-(7Web$GL)idHHN(A!9a;z33kdFv;y;z&UxF)%AeR4wcX*@Dd`TbAx)+%j<6 z7<;WW)i;(q6bO+@sG3~TKii83s*~Hn6H8`K%#A+`Q1P~mlINmHgw45@lEne3jJ17P zZh;hz8;0&UQZnl9P!Lf~yjjLORIsk_d{Ii_YQEQ%aR@^GyDuwHeJ}ihLhY_)AdGHg zhFSd5RVy#l^BEgfnr@AE7^Ft-Psf|qCcFrebXbLZme1nEm7HrU@Z!uVjNSN%-b3af z7qZUkhP=v4wwvDaxCFp{JDGra@o7D-oGogt?x{pR{FrAwaZ3wj-{uzAmKMqt2&XDh ze1?H=?{VpKPF0hrr{{u7|~@}3h?pBn#AQcs3}tn(ld_+ zqfibU?{%p}DH=QlEiIzWnzdn6rJbfL=v^pfoHN&UQod6xHxUy033s>27|xW2!iAIt zRMTOs@W ztWJX=uuAhKLfXd7Xin6FH>PB>VwRXl4F(L&>kRYIq}#{TDkrvZbm;tKBkE*r5OWJg ze$J|ti%j?`N}(DXhW1uC21DuyX5QdoV|XVRKtk$BO(Z z!r{tOk9B6*;^R}Wbbq0T8n^5h^;eF6;UW=V@uJ%kc4}Rrjhc5Tf!euvA3@BRs^etQ zTvbc9z2dp|@0!7GwZ0$+)pv^B;=9vdN9L&x2Rdrsyn9jC@59nFpfyrwenQ6#59tMB zbxBZXtF3No6)I@oO_M(F>|pLUp*fD=$lgK+TWWnF{Y4KN@A9dy_j=>>H)bJ&9@U?0 z-(8chcmAoj#}1M%`IE2FD2NrGL|<^YKj#l)D>KZ*V{He`yRLk7DCyeO=TFkfPHhf4 z5|@pgWJH9l&&_3*O#Cv^2K;f;@ziVC$~X*WqHORbe`PI1`*AOp(@oD_R*Ppc4F~vr z9G|JbXZs4my(CQT9e&C3$OA;PJWyy4wV#ru3Lb_&?NV=uGtP(tB#tEv(Qle)=vYk4 z_2_mBJ16D~hlCE6WQ@rh*$0;0&BE>^ZBhShUv^)=m zh*`f{oNA2|<*ho;N|huZ(U*r;ql>cY94QNLs#2$sN*iX*R7#Fg49~f#84)>us9SYM z8@F_Gk7c(OJeB~Djj!~LB-D6=PR&OfBRuiHS{2D`rca#zAoHu@6%XY^snOZ`Pe{_!OQ!llj z(vX$_-^MCRyV?lYDAQT~lA!9eCC;-*J^9Q>{{U0rLXqySl({*)}PenaIaXeRr|kqvv>R|%fO}InxZ~VOfnRIr--(j~C;1hh zD*m7*eDdTK57}_}{UZVr*caO06;H%}gb&))zDo;^G(P1=7mFuZQv=`$A05DWSR}Yj zz8ZepdD~0R;-d)k(Aaw^lnN|J!2D4^-n)OM?w|7@Y0vZ25q!@+PfU=QX}7$BJdUxj zdp&-GJ8nv;ER~ac$O(wj00ZDTP2$N1C|hle^8}xhQXJzom#1|R)U+mBjk=y|-iY!q z#0nokHC_*isP`5cvj%!?Ooi>_cRXO*x2mYm_L4oGpC8HQUTzGFv%d@~!e9%SuPlpj z{+Ksf!<#*U0k`m-)`OUxR@_@EbDXB26M2=)J>8l$jiL)8FEthy`J}zQnE^>+4bdYbk){#$Ae;MY{p}>NLh`~ z%kMR=#_oMtE+mw(R^lc%8j^q`_5VQoF zdsg1*Je;fRn1)0{M!eq2XZ@bD?`m0tNP`8$^5dk~b~$&7lVu};YMm&UAe?26^F0+) zQ#M%s*_)O?gbLFsB}@In8QSnvrhwl_hj}eQ#Dg$d!fkT2Bpahm|HITp`fg&o5lq3; zIhE8y*U&7&SRM}j)U^6QBW7u5?zLzorLgcxF7fF%IbQblWkITm@JWRX`9%5#5AFm3 z?qVtRQf9en5;}Gc7cg0+4t*tiyZN8fM3#oZS>Ty_0y23t91&jU(~bv4MIo%-OCEV7 zdAXNo%|)mFOFE?n)-|vp2eT+$NF-%FZ)ZJTBUbSk05b~^3%&W1_W4{Qt~t9odd5QM z`Gc4TcYEVcVve}3n#zgRpAFF!s0U_MxOA0)q)trM{)o)oLggxismMzF;OEj^Q5kik z8U%h>Fvp&;ufkk5TM9Wz*OYP7p7KApanC7QeD2)v0iO3c8vKIb$02BzG$mvFyE6cnmvjQ_D+w=-K2%xW?Oqod6 zB7Pl(^a*8csuMhcKhn@tK~z-am+?uA#K$Hy!*QpDIFp;!7GbNxPhhS)*SU3=9qWo2 zlrRVt`EqCX$@&P93(B0audju)9=r1FK+l*9&iT1wn$MJGx^nFLKC#uj7$2`SLY%5e z5ZVhH0FiQ_$qNYobPI9S))@hsvAm~!l+P2Ld$W0r?(zDtGFM~l&o`%k#PGW1`c9uT z>??a$mVcqFF?ro?X7rTop_TB;- z-W57af`0;N3i0G!+UI{3p4KevSam`(@cxay(;!sWX!1I>p<3VQ>!lK81nJ%b+ zaC{l?Bb+#xHQjN8jlax_iYvts#}cHKzm8Gms}{A*qiP!gaY6SXmN-qK^hnk2{Y7k zpFB~8I{Ao7f!d|!hCoNV8t=r5DH_O%vQ-`O3Ij(>ItU^Rdpg~c^&*XyHm`-oj#j$< zs@56Irzq;y_xL50pG(TO$lB~^%`SH3y71v^^PHT<)Fe!in!K<@`4L#QKo1UWCIb=t zsSrf|{N{PF6+M&c%}mwiq0W$O579{QuZikvDg70zm`~43QGO-r5Pk{^lf0W@cj{ei)J8*ALTs_Cpj#}WC zi~dg`S)L3Gmwe@?Qcu2X?ANb%K6(0%i&Xuf^x$WIkRrJ)2)z*Dm7R3N4yu5;J@DJ% z7QO8HEGp|}R620#Xlf#k_WQ$EfvsI1ws3xNbliM)pTUuFnkB3bYRZLSJ}s3GFL*ww zxCqqp2--kYmf9t(woiP*gSs97*`>%XM1f~pqciQDv}yl|R>f0=Y3Ec#{H^n0b*cUf zT?z`b6|cYwVav`F|FlPc8)QB8n0b#WsS^%EKR8`vz8C8L6UjM}H(wCJX}}#Cy?6)l zat}6oCqnMj-)GcV)Q|4apKY~;bkGOsbd9*rK}hyiVwg7);0g8OkJUmj^nu#&Wb_FS z5;q1k>;crXcO>Jx1@HJmgwwCUFnFk!9`{KFcT?=lYbe}3PuIMZW7h5sWj$Zr^BlSB z%4zYVvbVE{aarM@2NJO7Gw;HP>m9}(Upz3!lm*cu2Wc%DVucXK>X1q?uj8(HJQ3!V zH5Zbg+|b!G7#Cs98{?Lz)=b?9ouh9*RPDS7)fF4rXSx;gGFo9;pdPe&uUvoVIw}%D(mbE03&j@<0#ahS#Y}6C zzg;$sg8j!*_paDJnNWjA0=H@ZrE9_p`T0i5lkMTLb2za(w`2TOvGGEQGJny0X}+=G zIc^9V2J;y%k<5M`x8M=}etGa@Bj}g|W?6U1l0!fE*BF9O zF}^F8q0pPw3rnD`Cu$zYPicTy1ByF1g1U6(!G#XLV)}q zAn5=>`!7;UzfkT=LZNd~RiuDfibAh->%HQ=!8V?TnQw$@@{!w_O(zDwgk8>;;Hm+8 zl#60Sp%qZH%iosK?uTL>B>OK|n=X$T9`1z&gVyfS11B_L)WxTSP-; z**~VIOErBGO|wcRK?Z##|U}R@;6~V7UR}1!CHv0ERDFhD zS$yjwLc7+Zqang$sdZ(wtE9>m%h$g6=5H?YkXxGFY|&C@Bekzio2iik-la8wIYYD? zd07T!tEv{~#%ZUUkyPkHnTeUT;?8!xt5DA(X<25(AnGPQoq;pz{QFozFr->fl}l7KL=wwU0c$$0u6|Tn_0ut2k%t6$hP)9U8FA)$YI>KADk7I00%L1I zYcZ~iyUCV8VSB-!$*VTizC66F^K@f~Y^$AZX_?R=SDnRP}HCj$}I|n5d4*6S5u5RX2efSh`aD zC&D6%JG$k1@||c5Ek6vkOqA2j_uxgC>~=dUOb!t z)k|iO1Ez1pL-pzrsG4hNmHDd15X9VKIwubXrwo6&@`@dHvzzuz84AM>0`s;8f~^=J zZ-p?3-Hb z(WDr+^=6inA%7u{Z#8R-&)(D^n&^RbVqjksyK+cLGE`Td?i{WWKzBukjHI{d0YW$L zyP0A~m8zHpd!;NwkYLNY^aUAtn~9FOib#_*o((EbtnS?Eao=%w;f3qjtYqG!g$ZI3`1M80Xw1433 zYDuT%h~5S7xgT!7BmQdwUvjmbZ0T*t0K%+9$P9QPGmyEzXEd?WB=Pso;#S*e+%jtxnvqYOP;|Zfp=h!2kf%MR+7= zqGGk}Lgx^XfkhZ2xVInt_k*Agcds+D?9E$t@BvrZuf4Cmw{L!9J|Dka5Cvcidr=;a z==`^l2XsOJKXd)J(M7QlAPV>GwK~V*+rb^{2^|m*@jWe&&^s6+rSYDQ^n_H848ghf z=!SeuImw26j-NhEJ^LGci2@NPUqzZ8j57Vm05goac}pbcX)}pAEqx_0{oc6 z8=P1J$q!$?Kn76z(ZIe`fees$sX%?yQws0*twdd+*Ow1p;cyCShuLpwlJ9MVd(cIg zd+6kQu!kRSK^ZSYME;?KkoTyctbzGd6?==g_}DksIQZxIc{ObIb|s5xX-)2y6ESs$W_f{ivzGA^!rv!~r{nB%Cs92! zXKk}PxU;-A98m+b+z6F5D3dnrRIuE_ACKCfjd-^`g|YBr=)6-s`VJpTJ3e+`EkKEw^^iEn=}HPap7lN6VM~4Fn$X zutC%X2g+Hcm1c95+mf}-GN=fN`3h;OEzTc`$%qs~2*Wfado zPzd<{tWY>h!$b`Jnc73EI=}cSth`#km4MnUlg+@_MUIxdOhZSKN!zt%hJ|sxRQADk zFUbNBn_vbW%%oMMYqxL88&xk7gJTD!|rdWQ_?n zcG*h4WcftfU7B*^ zyY;4$6>n_*L)?0fo}9@|C@S7{4d^Xh>|vOp5wG(Zj!RjtDxCHSve@dHdvl9c7BjTt zIC$wdXJZa(ys>*f2KSn+F}3)p-H*(uM;l~DN0mvWTB$P3 z9XjJ@R28*M3U$A7Ej1-T2Hh0_%c#3^9?yo^x6^+>DLZe~#MnLu0&OP8>q;|((mR>R zJ5cfFwZus71_JM?CeQoIW7#+QSWIP;)}&MK$|`$1RpSAHhAU^P*K_W9S6MzDu-kVT zwS%Q3g^RFVH76n$0&tc#C0D&$Z+A zV)?!i&p;#EX1K%24(pd_RiUjSdzbcw@h>av$Iixg@X}!=hrvzbITP@5uTpmfYx5M$ zw!ElwFZ1IsSS{^@hZh-XZWfVM-KSj3Q?*2R5HuMal(y6{efA5~ z1T&LnfJ0_jz-Suospc$;Ad73` zU*~dB@=2(oS@R*|EEY{oBTPB27Hv@+i<{SaOLxumq#~@R6R&mBJr8g+X={q1hNdUC zK#4cHD0yiVNLDS5+pk?E@ zs=i@E$z?;yV`F6OE{##0JED?1BA)FO+uXLQWz)2lg;;1*JQq%SIIuwCxcp(h@UZ^n zY65>V$ftP<()hOq-99k>a)lGWl`}+10G0B9wk{_GYL>hexp!TZlYMB|s{{B{MVzu! zH_*q4xaq77m^Wm8JNmc-E?tE{NEk(hJ*AnwB8o2=j=IqT#DVJ67uz|dV$@6i1qWKw zhEU1Y2jtoPgf}pYcC&NwC*0&=OJ-V_VYscGPURO#MT;vN{XJOALTgdXJ6|k~Wti0D zm_ycwy8NrV4?NPkNa3@VEoX443umrYw?Br(^x-tNwwt;U0=&|(d)ZlJt+JbF2X${0 zGnd#L^TzQnc*+lx=$3y}1#1QCo}v;{Hbov+$L zIy3nf)T*-#h8F%Tu{n9=)>ZZ12n>H{ z(3K&i=jM(hT8Ctl@Z;WeeO)<+kv*udON*kb5&nl;GdIaQ@E2TNIO#j zqsR@_F$d5C4A3F=bZla?E@R9+-RvJahY`JR_;wm_TQV@7nv_1ub8HLY{L)Q zX?Jd&ASuon4BbfjVo&Hk?tG-m#&h~1YY(;w=6jNgzFa_L|BbP?ii^9;wzUba!QCOa zyF+ky*Wm8%5TtN-cXxMpcc*Z73l<0;Z+Gu=y5GIe_uChBR~IE~t^b%~jrq(!ZybBv zwQF=k-wQqN&xDpW!dg-ze)0}Ndum9c=kfnMg6BR7Wx#%)c>UctYj zI2usyXd~!5>?j;+R ztcEQ})Fp88$?c(Ka#E~?%U+;S$hmo5Pn~x0yqLMUa0BUtesm*FU3PlBcX?bR$n)Rd z6o4#8L{T^I(xcH;(AOy3NTEZZ==iHsaqf>)yt_wjcBu`W+qV!tJ>Pml*eNKI z*NxwZdAQevbL>vRZsq6Cf9X*j`r0Xb=iQ;RMV#VR-immwbYlx~eY@`q<5?4a=$;es zRG|@!SgHYNfF)2+ByHOaL8N|;B}6PQ9STt`WFqb%KfH_8A$T+zkBKS0*+*{kQ|aSE zCmb@OCKwq}@y5$hxRvD1+fjz)uQFuGR=LIYUXGcOOrQCE3jy&XG3Q5oi2T?9gS6PE zSVkW^sqpod?OQ3La~nIv_1&cR>p2~1QSrvzR=m*_=%xtkso8^i&eQQN+#7ig3(wgz zgY~V>N9;i=UH8as>Z;hc_p=-MInd$R&hz!@;{5z#jRxt2yEtcdfQgSE<*Er~?s*jB zXFNMgcH=`UTkePw;5%hZXIDW@Q$s}o-#|&f=-T%7+FZ&{`V5FEQtC~dDDf&AP`L9m zC~$9^BgUd67t#IUt;JPj(zz1CFl;4Bmi!UO&x_(K-P{?RC~}Bp*R-&>8wnx8Xzbkt z7$5IVi6FQ24MDS&D)D{RagO01KgnD|?qr*b&cl%JDsDJ26m+LMeg%Cm3q)oc;K^qS zEGgQDNeEF}l#mMbk7tyv;FH?yci@X-eXiryo{^x%v1J(biDGOz?kqhSM%{&MD zndH(?z~n^%R>5tE7o~oXyK+427*`?N9C_Ey%POchfv>+=+y4&5?Ik}#_pTylu=i{v zqy3U4iH)h+K9A0#|1F+f?65I1v%2HdqAsWG-Q+euLw=j1&}Gw<{nbQ#C)@@tgk>w_iX~Pb z9ggj=EKc+;xmp37?l**~E?XzxBBq@n zX%vahMtu8cBAEVr71W(-rG;b!E_RNdbW0Sv5UqZ>NeR@H3uT7cc)oFm0y4iWTBwjL zWn}4%GMi%1hK5+RK`Sa7=+N3XA@remIit2z`6zXfFmfr;G?H<)Itg$z#k?@7It^rL zRzeg1}G&58g5hLuSGb5qO?ncqDnuu71PVYObpw4o7wpYII3oA1>GW< zkcHw>vt^n91MdgI}HISUKD#lo8X7i21k*=5)OK@xmFYr4YvPm1^qRo|t zx#WkfD8|}opr-7wi&myQ?PGB7b`FUs*~MNGW3b3Sj@X6X<2=Z4M5VXCzOZfyEi64b z&fMyM#o$|TagMHE+-GJWSW2i0i(5=ZZlN#K0@P%}M2m?l!RS@8d6;l)W3Ao6UX&Si zFS|!WXd1iD8PVV{RbEtU@B!=Ypdf~_jKHhY#S2FF`o~*~_{|tXN)wl;EA(>dF;j-C zyKg83O*}B6oOn8vt6aV0keW}c24fH>JQg}K4&`YZE~idCU+QiML@^J)QU&R9P#D#y zF#*5w%A2YBYWo|ms?8FIbk+|m2Q5VL&UCg1(;e^KckoO=AP~?xbzIYvE698mMW396 zlLx$bn3y$Y@7Opq=TSDK&@I+Jo;eyXq71vsq!dVzj0H})+`|^EFskziD5d{k2eV1I z9IT65*0e^dgu5)hPuJx0fl7$fC9%xA2*QeXOK)D{_9F{9SqA4o`w9F|sZ!aA8%&;S;<%gqRHjwi^5O`VaVmhQ${Rk#EYrMQY_K^ z$?dT~5p2_3S8Al!U=54VTFhN%3^oz&%cr6}#?fF3OG1T~HCR%Z75KS?+UgF=cF;r~ z)x?r~E#`lY!|h3DQ&lu@rWg!KD^5y3#C;*e^0;85Zp7EsfDD;eQVY{!$YLuFrx#Gg z8Ax-BrDby+#X~@{rO4wQbH~Lc6@#%$Eb>Aod`Co>T%aMr^|TK;7}`WQ!UW*#^5yHY zjh80o(vda?g*9n%pu`W(nPeLv7l+_JiN|kNl*UtQjg#vA!)=ONG>%zMbHmKh5I$Bt z_u|G*(Zk(vSF!pCH@bHOAEAa>Gp@!N(Rp~L+1SKCEX#u>g}(q`i_+9 z1kda0UH~h5v4aIpN>QD~j1T2$djC=0FpQ2vG_w|{_WY_RVmTS3ebF_tHLlj`EKk@a zs{1mRdfGCKj>~egs@%5Dm1TVZv%g+HB=n^)*=rhipiF*+haaM8r}|hdF#I^SJ5%yr zhd0K)$D6LBoqq}mgP18t6NRR@G2?O z^5vnT`obE9M@V}>x0BaJLs#bs-|?sqS@Ue){Fu!nLv7aB_S7}-vBqcy@)h-sI{%1_ z_KT`aVUo-cPO%fI4{mWvjs9W_qm3Jj!4soqQ4~Vrtc0{($z{D%(;kF7@h%OF4|0MA zQbQ_%dmVnkw=4V0Ewd8(_f;fHDWh#*sdIc%#=8YxEPsy3wah`*MI$9~aFNVM8oY+V z58N?ee-{1I6#dgY)kB;G44F)>07s1NZ^+iBk==7Yi35$FJzf7V zIMhF*=l?}r%Tl*;!(BoLuHa~f^Gf1<`JxyC&PYVFDg_VoO-=}v$6t_%SZ;4vR(p7! zD263lQJj<_4>7m1pL7bH>~;r@K{pX^^}#0*UZVccJSZb%W1~@CEky_9hCkeNP29gY8&>G4bZb>-K0PgFCJ8gq8z{Hv{Z% z&;l5@_GmGouX9+w0V9U)I(w0OVU*dCdsL^{NVkoXe&k|}Gh#P7;1s0pdU-zMwLCT) zR;vYSyK)ok=xWB~kyNBMZ5G&1RE=S>)6}nE$tCuhHV2wUWZRBeVA*^eV@&T4KYao- z8>J@etM7A@7(4*0RL&+k3^~(YV$bu9)@#Rx?= ze3jW(AYMZ^vk}*kf`#Mc!y~SdQi!|QxZ~^%Ew*}6dZp4A*w@^B#sC|%2y(WS&wldh zD4iBDGg=j|`ii=4Cck<{^>+oi@J&M(Y8?VB=HITKvm9-(E2#I913ZSFKVKY2Se=Hx zJe3-Ch{*{?p`=}7FdrpaBru39>m8F11i)gUN8&E9PYLndHdk*H#r-vY296s+4#_nZCzlQW4W3f}v`#qflyLh3FkP(s)bMd@6~${pwe2gSWmhZr**B{T z5En}1-PoKH;=5FCS$31_wiaX0pv?A7=y5rlOxGN88=X>E^ zQwDj#0*=q0i%R{1f3Rp(89KMi@xGG>xVdzOD06R(Kq0@Wja=V&;S=s5a{mckK=v-& zmw$EwCp=F@7BIOuHel3WFJ_RFz$IV&6}ID?EB&ThJKvZ1~x6MmPge5 zt(SYdXt(59X5{!;Xk>fv(4V&5h>9RVHi}I}qrn&%#?f~i&jPKw+a51q%CmSk1MDEX zKe-r6bb+qh+%7o2ekA2s)~|-R7IaU9lYp6gN^E_a&~$HO*Y`}0or?{lth{q)u=E;| zI`}+cO0H^nzhsK~>!OtU&k2N0OLVYInlPthjkzZ2?zWYiku)sQ47LbfGme|WDV;l* zb>mOd&2kDRZSsW(mrUaRVkLmJONrT*|Hs&Hz=dkdo6?%J&MdaFQHRVK`qY_&J%MA* z_bu1cSSTyp`fE@g{Xd~mM@Q{e2?*+Q0g zVIH8a>a3_Qfq!l3jX8{A+0iQ!cZm2NOV?bksI0G3Rp0dotW5Q7al~fl7a-JGHl9n% z;oE>%4dION#<$t49%%DllWnO8T5z?RpbziccFCUVExL|4hwyOGgT(ixrM1zBV+8!d z^X4{oDIEy<8`?G=1FBkjj!DT+Iz@+~qsPvnA3m$YYa44D5f~z?Td7(CU`g#BkaT5N z*g;A#HjrA>$k~FNN#(p?3L%cbt2&LNuOsx5&k0 zi`vIXe2K4EbSAVsA**>T=5S)3*c1CSl;av6fEaX3VUx=A;q+f7gC%w8uw>&q111fv zZ_bP?e{e|Fsm${(@fT7x=0DJ#{)DtoXz-Enn>m;)G5VqlC>JHg<*H(Yt{#e#jGs(-y04=5aS>Vo$1;BY%!$&ez*ZtGli<{b0rA5}r9)af6 z>H94&tGZUGoI89eu}dOeSbH=dzRfAM3u-hI)p$zs?nqeek+n_bh1t+8m z)Hb4(LrOb-pe5*2>HcVG!fJtDU#w>qFKY3{eoZdw1yHgW!0E(yWylc8FqYQA1TEXD zbf~B#yG!7!%30~Ut7m9o(CKG@2tdj|R&9;>!RGlD3(LDB$M;FGK#^s$JHht}O6NdN z5j`8AY_jR?2}2T60dlmdKv23$I4Du{j`3BsJ8Ex32ISc(jt3{Hr{-@x%a%l+Y?3b^ zAZlPBAe{fRv-2N4%im<|j0~(rEIuP47KSeW7qFA0q%Dp6Ne7%Z1ui*PI5ah{Yd3m? zTAi=&X-f;DfD<Q_M{%F8}X;?4MUJ}8nu+pvwssN^tipM>X-sA+cApuG5Qmea`I+!?Wz zULdjKq+Jc-)2)X^`dQ3fOXK??zua!=6M0RESPpv-s+8Zw1a+M~+)B=kS>MO*EY~-G zqh(d07C`WlE$e}SMClh>Mj6YS9Y5I5w~9o;u&J4TY_k07lvEV7LnK>NO%_n(VeD4k zG){-&tGycc@kilbQR7!qRoa)@uMNncI^CHCej*vD~KpBG?G4FFP`b=h3c<5 zL3cO5n2TX8Ns;w10gjIPBve?{hVeUA_R9O5-CF_W@8-PrpMl)(WyZAYU+qv3Uowv` zc<@@i8N{_o6&`Tq9z27D9!$ZXBG12K(1xTbPA-}(BGM8IhS8Xq8qs3B1V%+B8<7^+ zHWC<^RHEO@de4X)Q)d1leX>^6?%(m$myvMyrdaKQ;co-G*a_oPU!!}z9L&OeLum*7 zPmeF&ND3Dl8U#cd5d?(ze_jdyNx=+O5A#Da!}c|8=wRW2=fXhIpo}d>u)ZRJjc;81 z7VEmf+D8kctKd-2vqlS?v^Fz^QL*VN|7F`mpjxPht{s!yY)v`4r>erMRi&o=hWUoM zc$@*eKvtV%c!_@cy|wR^bL@3Ik>r=-2hr>LrfgyqTnolEx5{gqRP6DN}YZqiH^9hZ1}POOQ87awyCk^DBpT` z3l3r4lFjkr7P(P=KPd$5rY|V&t1lX0jgKn$b(q*dDD$8`!MP{PJ zE5l~1+~7lOtKRTIY^&dZLCB9i=Y=mk$3>Qy@RIJ2pb!a0q!k;)n7WKG;lbeFqDEWM zUbIwY8gyU}?4CS_?RN6mrP`90btKc}IeaW0;4A;$yCp4flat@16AYKs;ImANuE@Ch zgjeDskVwH)h!u|vKg!~VjeNZ*;rLlKir#Nb$sHWzp0HE zKRf85#yP2R6x6LR0UblQ6mtru36wz`)a5ZMZllv_vKg+$cXf8K8lG(R`W7itv%jz9 zv?A4R`t4b~3Ju5+WhP@p(!*%A3iYs7i5Z);*uc`Bg?t}Bdp&KIIwJcE@45+Nsj^<}B6FhfzPXOMZwm$|zrP`#no437g$~jT=c@NXr4r3@7zb;@7=b}XQ@+T0An$s3 zy-I}GgwuAIcFneODJl1gC!5vLa4zl^6=rI})~MKOwK&^^*Mp~{|Avzd_dePHu_OxR zWb)10*H+H|oQJnRcJi%1k+|P(d`(SDgv0VMSW)SSUaRS@I;h!^H^GA=#VyTK_(!gb zfYYG+%8EPLgbXQFz~R>)fb%Mo_f*X)0&>nVZ#B25(?d$K$|%>Rf;cJv@dw2r0QP_k zOmz*loRlwq%RV0tfGOWV zh1Ja{Gc3yusN*N6APmm1UxMQcFeAHY`&woD=fh3C)mv^D8)0T20-M2-Ga>*$mbt(f z1%u6C!5IU0aO@~2&ig$|g^hi%FkNU#y1!3!u9J2j9UkFJap6$er-4nKm)0;T+aZzzSI<)c~I+d3DgJ zBgQ(WOG%eh-479Awz40?Ic#qbcB9V~pVpl$g5StF&L3iwtG-RYO7M2I^rT*EYB@}5 zlr_g!Sw!cg0-U<5zV5mO>=Wnpf~@J-rwvuM1B40%d&fu0Q`&tx1iO7|^cpZmgR%yk z3R=5%0-k1ulIeTxr1o<2aCk%Rd4Trb91M(hfeW=!m(`+T%a$6+4Xmp63wOl+%y~JpiZ=VoB60)9h8{km2x5%$kR_#)es^mlcUlVs=*0cHly>6$+gT)P zh0gTZSy#^7GE9M#%m)`!ff}C}tp13BHR<3_=&N zhGv3Ic(b|b)`N`6#z8|8f5>iIN_kVdk@>3U3O0t2@!QapkmnpkH*md(+p zeb;W_Ru~AoJ_jTh!CuE~h&ESGm1Q@S!L83OCoMmdp1|3!FIQ_3KGq|gPHihQzCKSV zg;&`PH!e@vqQY+5n$J|QnYWd|K3A{+YYvAe)1X?2DDx2HFN^FgdwCser(jP74#!{E&2X00Yr`cdQbzgR(vimiMd zNA_!FBf*@-xW%lsWt^?AddX)l4RS4u`z}JI?_+2-`t*%_hFGZ=Kr#Eu%MP%k)L($G zmJ4d3&3jkMSjX|y*e+@=vvSxMI=NLgzw|}!zLAC4^qxh<=~(Ozou9>_&b@!|%YIaA z!KkG}X@w_4p(I*&!v^|5IA;yZ25P;#XjY0hN}IVag2>$kgZ$Bbcr_#;B*Go^li_D( z@pm&ocQqt+jYGXAm+EL^9-TvKv&W6w9thfs2KUHIKz)is_}cbNwDt_G{6cBKDQU_p zYRfCknnMP{ps>$tQlsP=T)#r;6N26xZw zKx7F=It;ntA6NaNhJ93Fl3J6j|F}!XFB~2F72h3((74h!`%-q2WUMX!@V^_rJG`Nz?Eck!gZGL3RRbAlc8PT{kyZ{bF%57iM2edLIrX5&C?+2PYI%I zXt99XAiTJJm?DmB^RJI}#5Q}!H_^xAW!E=&)3di-GJ>FVyjz|GE^vr#Nh25g#3JFv z;XjkU;_aN_Dfh|qxh!lASsQ>JbwyBB+W|-gsv>tNKR_GVL`ua{xA-x#D^v6cF*-SA zgy^IqVrH*F($Qbn1$&o1{-!ImiF^qZKJ|p$=j$(U{XdcTbZ-A-HPZcqRB!)@#i6(V zKP-3U=_z@tDM?icN!f|X3EHvAnSG_lsTpN^X;~%4S_Q`1MrOuZW_AU8R|G{yW=7V1 zYRd5$DOq}|W?2R)nK8*F+3B$ZYU(MPu}RscL(qSt34nd_zT?-~nPxse2;Qgc{k+cv zF?6x8Hl}klF*32RcmB6e!51TFH$Vg*eEpVG2E70o50kTr=lIgy6AqZLFN$?e<0)rt9fNOYGuj}+R!Ob5B z>a#gOe&>t)>d!@gDVMA8>96f(EjrrupF#rtS)(#1^q9F`VLKt~oQ}h(Ntw*GrQ*F% zNmvfD^=MC8BKh2eqbIo0+itJM@4)_GFL%kHP=t&qL%JK4{a!*JA}6P=Na=+yHxCHF zt^HMZU`>NPwoAy1&-40ky8o{q;q!a{pIHl^g6|gNK(z{uL-Kc)}-_4e4&hh*MQ z+LrPsZHwu@zg^JquZXyjv#_0w%_o;o#=_R*6T<2GN#_5ruy~S+?k9#HjSmbif~Gmt zrfPc@@vy*ogFj730(#C|s2q8IaKr?A#YR5`Ubw)oe>1R7IIWHU2UEG)%1~beL^mhq*kFr#ttMPg&%1fPIIwM)17ddY(dM{ zm|$7$c*Jfo;UWY`M3CXl*Efd-R7=iV(J%4Qjz&GvG3^8xSn2gn_H9Ekp>>@kCSg}n z1)p>MY^Jm@X4Lbk^Z3!;%`sayVqbB}olO=JP<^3q!Ja=3Qe-KJ z<-$Q;E<*?*5BcqYTTs~5X=TR$b>6UVlCe{Vv+>0vo~VIESk&zgxe7I2)8d1b<}1y& z??NZr$i&i9d2Es$IGSSYYONr@1?AA(%%h<6acCOJN4{u?hF<`sCDLgNrmGaQ^M8w} zk#@Ym#l>KTW}``wng=U61g&mC-(D}k(ijVRz*H{yl9sAq9m`Qu*=23j_IAk22jwff z`-db}Ovk}+vQr#mjR>R<3lu+799RYM4mEuD1Z3Bx45{h2{5xgqucgTR!z8Boa|xb& zzWx@{{cGj^+Y(eTaQx)h|CcWt94YwMGz`%X^Cm4g*TeQuE8!UhG;q;A)Irx$Itx(A zU-tC8{vjyJI_>uS_X32bTj%fYprc43(83}?C)T#jJ2q9RwWG2dQo2`GQxq2X8!n{R z@t^gm5VrdHSub!Yk=Qh-s4l6rk`_HeXld`*BMJF?sGC;9RFZQvKJjUskfd(de$j3| zY2k;2JDsw?cv(JVNXOn*=F_LuU7xd9aK4#e4tImyciMp9F6T66vLjC>80~na( zSo`z?)DbJw*nrCO7~2e;x5K#aM0yhWq__QuJ0Z;3C3H@>(!;e}M3E zgV52L4pavfLlaoZmMW-GQj^U@sis7jaEI6+ht^#Xq(zuU7#~&>a_l$eE)h~XxC0-* zLj(0#+V)Sr4(P1aR}7U;(G=@#GDYpBt5!HDQsD|cy^}|OPo^3VCx(B*7!YbE{BD~- zTyLsMnImY?+O58^d|BeXQJAn>-!w2KYm2Ld_?7euE^r>-!mplJ zT%MXtb>FVVW!`$lPh7G7Fy#%MAzeo$0=HV$cA||Az}Qm3+(XKM9iMD2XzlXd+5d6n zJ&0_X&H;;hj(K}YuFVZ`0f)#Wj69(uU#Q8@Oq5)or#TL_8c_TdK4ZYQo3WW5gdX+fWum-4aLQo-t7dCMT!enzWjL%H7HNP zV3~Z}`VNqJa%GeuFyizrFakKW3YT--=qjfenAY<#M4mMn))d2~5Cf;MEnfYHh}A7L z8h zh^<&eLd+I{lpnykh;*~L!yYL4S?^IILpVG5|M0g3-6@kH%*Em-Y)v#}nB>gs0ggx-FUGem-(sOAidI2#zY zh&d;jIr0lCjRE)_rdq$~Jj;U!_2a)q^8ecHot3i8e^H+UKOa1N|C=4~&!w;YX;0aj zeeMr?gHH_ff6ao)QknUrK%@OJZ8tHn$-67iZwk=LQ!u6?`iz(qhQZV!qr!)66<-#^ zYr2kIB|q2nj%7f3-GYXZ4>$NF-cGqz30YZkI&Wn>b$eWI*lj(G%rI<&pxsXPA{`-M zS!^k>IyfreOR5+j~VywzG;xQb0w z%vugs{rpJTD!(a9AwuTOB(Af-=UpDbhvy*Y&(y(tt2UUPr6OTg*NX)iA>l947mYoQfXk^i!S#*U@1J@ z2QxQ8j~Mw)cm)o6Wb1vaQpc)Mov+?fu#6`k=k{qr-AjZkiMVJ53n}^h_sdXxd(h?w z2sYr+WB^%EIjsH{L;2MA^&>*EmiFM)Vx{5kjR(tRxH4Nd;F7H*z7)|SOkwfFzHwu zjyQb=&j52A)7Pv%WBN0lYwa?HW( zarYIRMDIjG1c=2P^h@kN8wb9$KO$>cd);0G+mrbMnewtor?uCd4zr1?o4SR(Cg_nF zkUVpjEWC662=|IJO^(DK?x!B2j^0b6y`ZUikbi4jw#7kK+WJ;36wlKtOhDmSF}g!P zH$f8Obzo73Pm&!K+EXYKY3-PIga1nMPS3b{_VSCxM!!Teo>DGkDn2nojggH_aaXpU zH$LH4G7AvW8Fsi#Kl+Y|_v>v#Dx3|0kueJzq0pCt13sdNMIxa77x~y1i2v)r{k7Il zND=PDKSinZ=X(DiMApBZ_Ma!ai_Pbtqt7uICjU6<|9QkG#Z5_pF`)&^zp@lGHEY?> zob_KdszR+K1%w7Lw$>K?cE%}=OA}#cIkRe`ZoT>9P01uFjZPP!xp|Pi`5TCO_viK% zatD421$LF$U_%rr8raKq98kg+@S5i*PgsVji0t{U;(+WL0{{<}<}w9W&4F{x7$Pl( zbVjo%I-2ko6E1HZJ2oWFx(V7DOrd@d5*` z$^w|?A0wYs&yY_5+5hSUlD7Sv!}ZT&=${JY-yXt14J&uFLv-IB;{;7|FhDTKPqmWt zSYs!|FA=ki#QBAQ@3=CNjq3((GLRfB8)<9c7ei9omq5K)b~Ud$=ylJZQYb>5i+Z*B zzn1gmKOQ|^d3|2DbE^2vOkEo?fVE))zmGHSv#vM0oqkVW4Si($efiF_l~f1eR-H>m zT!3nXB7;q=5h;0h=b>ki`3J>AN^bpM0t?`p#cS6RwMP{$3 zf5YpWx9YH`H(#WeiS>XF^CvIoZmh-lGlgi-e+{_h8{Yi!^Lihu^G%^Y=J}bEP=IJ3 ziy-mF2-~H${~5-Q!o!0yGUx8e06S*KOy>7J>>KEl^fOt7hf06Vr(Ld4S!ktk$I!o38En7`E1Gm*Q%|uEZ}mZi#3G(m+FYjfWOvb#E__Z- z@(F2jsA4hk!V}px!d;J|`8r=x_bYB$J1ll8Ve2jmxjaLGP=xs4h~P@22`UkOuxu$Wok0kqIKZY z7v{k&6b-io3)$3e)lbt}Z_~fO@<4lyx#RLPgJs(e+HrP2uvELL0%L{k5$EjyTCw_+ ze))JVuA@XZtJY(UUm@n~7IQSIt*5nZU*U$mCqwT1D3z8{4@xE$)w^EVdEw%s?L;?S z2|Izmbm=3AO)bgLcxt0pe<;d7iUbn__kCyk1MyTdvmGeC8&7J}*?2$SH-VwY?XfoQ zqYq<9sSl<$9(~Gzm3ef2XRgI*4*Qs^-iOc{mq!7#_VR<*pu?P9q(kH6HYv$S-z zs5+&xfW0mB?!dqQgwI_$GFrdABguYE1tGtW{WA+#TpmLPEWl=W5pr5Aw28uX;H%y; zShKW7UZO*hqu~tPrf!AcpmE0#hMhK)=uhlz&ZpnD;{0lol*8qGnCqv4KG-m|@U3b4 zl?Xtc+Q$Xc06T3Y*XQIe)_)JH*Bb%rJJNTuo*~r=xnwEUULbeU+->~Au=|AaCwC|2 zB2ZvgDEj*SPVt7h<9)_mv`@5?y4II?s5&t&^ql?IDp)~#`3~D#aLNhVyyKm%5s< zL&hyL{c)Pza*a=VISCsC*4=Tp=uQtG2X4&bwB(@~G@9X0<6#s;1YfU8ceDfM>1HP@ zBy+SOJ62?4+$-QM&((;$^prmdeX|xh66wMGkkKp(BhH)FWT^D$W>Xk4W6R9ON7z@% zVRY~IWw$uox{cpl(D*&pG(%7Kh}q0AA?!&l`stAjp6n;qfF)3#d6PKfdL*zVS>}wq z$k(Z_&pyty-RR4EK022?p=*_MgQjvXnxjs<8w|nxC^pBs8a0=({ZRGv?T7#LmUdbo z5r#Hl!!S!-O;@J)d>IFHl5f20y!@7DrF^ z_z?7%h9EOc?w4A3|Xj1uxkVSJ`K>#xa_TW471++r*d$j(!vspAXkqQ`^ zoZD|(BIil5=7YRnGxHTWM533mjo-NK;i4vPo| zn?ra*s~AYnANQ59amix31-PTaLuxI)j@uiXoOo2?&_`tlv)X@EpUk}*8n&pEBNV@j zfuXm{97;!lkNX6+v9zp?5+KP7qR1!wDyh@V6iji)=-R7v3v}szoJ4rNwSbSc0fn-6 z(%(nYl;3B!l$3VIQB5c{^=Z(cU<^xg(h!)O2HJD0|Dx{h)-S(T7;?(y9>PQ`{RE6a zN^$cR<(fZBWlxS$nRU8TMF?c>_K?{Wy8Giv%3+vXj7lz=Xr6dgwdby=-Tc90f7Rmn z^RwmZ}Z^0gA} zpDV7;h)ustN7vN)e6%NhRNEoJ_;&(`T^2pSMT}J*hGEJ`LU99Th$e4vERN_Cl7g#1fFt#NO)B_sw+ciHwEO-DTLU;d;C;dye z;aOqSO?_&%jn68b<9}bH{JlC!Qnis^P(bswU71tl#@~x8%r(>Y)Y<4)?fVX?&>J1e zdSv`?r;hj;u^UCIqcnnP3%jix85v47(NBMO6yqQ~NFgO$8%!~D(h#Rsy^ znD7kV2Yq1PEh7pH_)>|VT8Le`$~LvRf){u#Ty)~YrURJVsxwRhFE305zP=MK(trR9WN;qn5XYoiV7$sVI!-sf{?Fc5ip&cf@ zGudnOY3pS~zMc(WnAgRHe8MTkv!F<~v{cir@{BfEiuf5tq};~7zttC~cORaG;|u%A z8FeY29j1eTQTh7pT&GEc=CMS64QhN+jpHJHpUzv5^nu@Wie3C#1CM*Fx&F-9i<)v5-{o*hh{<{gKx zd=UIIR`8%zBdo!+hVyj&mt4`*Z~b^{sH4B1EheAOX$fYz1wCYxsp=EgFdIn{NTQ?! z>J?uF%QS{ge*9-;b6~hcvHQ70Y(I6h!2f24sM=cn|ETCL)d{7~I-ZYj?3)4ecW9*B z;84mjBN46j zdtzrh_wdA5IPhahW^WKPnw#v7R@qkTkoZGzAsT?)f=Pb)y67CDIEV%IE>TE6pUgTg zL9ZdRW$gY5xw!Ci462Hx`Qj`7ql{#Fy#ut?rfFT}i$MKVFUxodF!_t)=KFcy*2A>u z_moV!M0=Ff>}`{iEgwBS$0#Yu7Ct48thL-)BjwNg@UxAr_*gIIEQ=QTa3jL`EsI>+ zjYuZFeNxBqt$JrBLk_Ion==8{S`XJPyZS~xDjB_0DuZHdF|98P6U&+5+OyYb`R`>$ zT&R0d)Shz`lbzwV-&7um%7g?{!VTcX>T>tUF$!9T7@uYq`WTncHb52^h>~r@jbC@! zF~bd5ftDhUhb}_yZU8OJ2*Xn2&1ia$Rn;Sm7sb%p)Pb+^?Qaz*iRYMB z{HOnwh5+*Sxe|YKy#HBs{>$%G({@@=L;915HBl#u0zbG*K;&xLx*mU+% zHqg$khwqNi@8cEMKjqd2kB5=Wh&!5H#zmiJ>!cUnH29&|eUi)`>>g%wknYx9dUyk7 z6F_YwD8?T>eO49_%SzluTA1%nJDfXWFHX4~)rVA0=CF*0C@m&A?1f@nad48XnLNwp zE8bOcL>+B=P|RwkAvBVx$EsRlXod2)+=E|ci?Bp{RE($15ivmFA*6U|Xd=mybqYmB zu#QxV!?x&{MxKG=LW=FctT;RFq3zZuAprm?YtBkFC#wgKRa#~&N`;=AcGrK;T9x2{ zZa3FXnyoEKCn}04|aPM{QB&kb#R?2`EaZAdyVs z4NDNhxCE(jNZ3uV>6F;=aw^FftX^83sJ&I4mXoE;^pDxhmL3*Or|-UBbQG$UN9wWJ z_Gr&8`m-^ODr@p$q=n>t?3;VRW@%$E@F%O+)E0^L7Bk0GL2V=ugD4wo6jw;B4HfBf z9$QHbDDg?Ad$rCSd7b5Atz^Z2FIX`vgL0-hQrrvRe!D7O@;)!aZEA8H(l^x>vYSzH zF35#}be?z1YA86ZtzpZPL0PsKsJ()yYc7G}B+!0WSBI8hz}D*h*3E68CD?Du(Q-3L zwfLiSYE_|iz$(4oxcw(>fV}v^$3TkoAXSCoanpT!u9y7iS?o>u4w3bIBgSsNmYy*h z1W%o`nC8#GF4)IVaWQjh*sHzl$ltI8`Z9gLpT7&a8Oa-am+p{yPkvq2i8(iE=2^<$ zfPFOR36Q@j3jh;(h0lq&#C%}-VI{P!Psq@u4Lgsezk6)uhVSyjP^C}(S*wqO#C1D@ zS~bMmaW^{IO-E_6a?kb0qz1PaVOn;FXEYz|4+s>)b~lTLRcW%R!an^43kyD5MPZhRfWFGU)S%1LxsUp2 zE;Us$5)4>8;;&AzRRzfgNC~-xa1+bPl^r;)_xBxv+pm=I0VetdtyTryvPe_gPxm>Q z_J?3wcRi!xZ1W~0RUF-rRWG7hZKtOXPpeMOs9HYA}f$?TK=>Aff z@~*63NyAagJAJClb{y!OE`fH6#4%WiTMHeu%x(UjE6ke>r+;+=D#;049D6mD``YoG z&czj|I5U=`*T2rGnx~>8-_;gEt>-kGvt!5mgZR9IqqNN_j4}M1cGl@?_vG#0PW6A?WBxxZ#Uv%&zmm6n4Vn$Eva*fodv1|bVpO(hKfaNee@6>|jpKc0 zmjqmnnyQ&nkbM;N6v_wlKZCs%guAhSL58z%C790YIL@BnbNlo5{tmx`^uyb@_HUue}m7G$vd zI5w&QbjX4RGH=e-Y&Izgagbzx3!ogC(g+bO^w;IE3jJuu$#Z`eX#9;(yw!S zpqe!4ErF|esQfMRrgi`X06a6k9B2myu~agt{0Whb(z^ZbHdNFoP1U`Rw+iEw`Z*Lh zc-Q<@l@U!(xBZegoF3uD1t$e-JVD%mQkJBR%(I{VA|=?!j6|KU9U{n>$@I~$??v)w z;98=w&&N+hv|};w=V$2FMt0i5)=+sWdIPSZ{3%RYClgv0faav`D_>A_k9tv--8&ZBr9J#qbF7|M*D%$3JfTZ-)QB{C)K` zKU{V6KVloB^CESsBhf%|)dkLE6E48FS@*JteR5g64Jrpodo5U0D-!uwv&6a4Fl{O6 zyxHKQB8c>4AC`!pg{&~-0?8cDx6`0ER% z(2ZLil$_5P#|*_SXgAVG1ao)lP8|c;Y;=mTH`h;FEC+AV&L7eH=(oPA=AGnnzHDJN zyY(8rx**=d!{-j2ao-WU(*`r#rBA%2dAsQd?8cs>gDy?imSqbZjXjo|oeM^@$|BC< zxiy-8&F?g75yZ_hS70J6RcoaOB}DxY2bxH-g$L62jwV{5Lq#NOQCbAvllj~@ER~xF z!#Fu8vcW31=Vdw4Mn@uZsWvx;o337|70o?Ynkpam4QGJ_evK`nOPAK_gOajPx0c3l z311T3b1G>1Y9>_!ebR;7%-$Crbq27Fkvy4Prpl~klji#|FZMbu5h{}kA?rSKV_F_@ z%ytfQD=XwVo~bTvrXr1LW!Ertm`NTalpqU3>{Ao;$bF4x)NFB^q2&7P43-oNqy|O~ zJWOA#xsyxq7&4qBfdI+9&&Exo9v_JS-<(9XP-HJzQOdHAaG)7)hIn4(~N< z(mX#}|4=|llvZ6>9**iSEQ8ArOdxb-R=bTgQ7?tQs&H+yls>WKwl6GCflZgFs#K3Y zRSVXd=Zag)y#b|hcAjYe`KOt-G)ar^a+KZbVJ>4CVyU8S!L}rhhya%(*@~j0-UWik zAX#d?bD)K@tIHUpq>-%Z;K@w9wmwK_Cqx#M5V{!~@3jp<mvau-CC&*inT)s~J(4bQwef5NKwgT8Q!5-TWq+{Q14#0wUy=9Y&Ypv{g%UCpcdp)X5E#mp<_EW} z=2<&j9^Fa z3EXedVfxY5Pe70wdS^%p+8aT|)B!sa1#u?2OPp=CV&*`*TT`71PI~dxxHQMLqlV+_ zWUMw+Ruw)|rszJSTi7>|fUNVG>}E*etC>g}1Y86wHL@tqh2Qqg*qt5}vw^D+3tB2+ zOlY&s^1h6tuT%NS6X}W?gx*ns*7yHkXhnJ+UWZ{Ae>r|Qbk_)fB06SPL%>VMWpwm+x zP?NliTb!q@+a~(@Q&ktpE>{)L@>Q;Wgg8=R663fb>J2Q!78L#C@8y9LY2?-4vk z_VD8&5wvW2OdCi?KW4s%6jHk~mEnZx$`Hrv=UxVFN3|Te!P+28e*l_yVLT?&m0tzF zmVCLhb12&m4(bWEq&P>sQiougHCV+$&>Ci9;0S1h?h-E;Zi(Cvg;uYtg2|5aE7~sA zlE;v1(-5Hja}8O%R<7?(FE7NU;?vf~)EeP)K62hF4l^F`dlP53jXB(ANaPMf(LA zfmVcBTft7P)(yoHv{zG1JXx74PpyZbHDuCh3Mb>T=t*v!oOq@r?DC-d_s}%(rFs^^ zZ%d6I;6Giz^0sukzltv_A#7%@4AKf&qE=|ox(x0C`?lw{Z^gvhO?*eU;u_V^d6E9W zaC>^PN#!|DT>$3Zp&}#PJ}eydoid0XvIwPB3pE)2kBgEmre!NXABiU*HxMV7`Uz$yH)SRse@1O zoS+s^kzqW=Bmk$B17sAN(<_%zh&u=%w9Bp3=QzeRq`5~r^rb{D=12B3v5=xPUc1&8 zCLh@^od>R{eDUR3l*po`zs;uh_X)JBHCGHG)wgq$QMZp10IY zY2=XbVB_DLnONUkW5OQ*=0V-wY%*MU)o$!<{o_(bY2-BxVcMdMSYM5)5F15&N}G z|I&m%7V5&f_J#mGGD9nSQwLKg!{7TN=Bk*{ZvfixElr(VcAT1vR{dY%M0Tljq9WV}=Z$6IiTT;#oFAJFftdiMJ#wEMeD@ z51w^Pmnw7ll|jVNT-J<1oIp)}pY^abX z$(&%+DJ@cldZ?NZnM|!;*O=buWpVUW))kWmtz4NgS%^jN&Ywi!&&4)DLbp!JEbFytdRjmC-honQklfu%p{-bM^z#od$M*bQzSw5j zX3^Lp$w2swMHoF}`Z9WIzG8}u;B1R!=LYOf1}#jITe~~nQ;Uw&c+fa3Lgwn6)nstW z)1$tR#Q}yfd>bWF+Ob&g+BT(j=L_^e7|fj#j6cl=k0M`f(ftD-n>(#4Nl@}rN~tYS`Skee3!%|*_nJ(j6D=FB{b~2vk%t2&mxW2z+zjLWk+q27P_>9h-);iNanhX7PBDbcujL#~5 z&?(YirpKTZD!9x6l*G3Iph2-*)mo%M7O15Y?K^}Ss$rFWCN3IIg9>mn9T@G zzu)<~9Bo<%^_osbyA{t=qjdLDcdWLqyImc2r20f(BX$ETg5YLvVam~48XGJG7W5fN zeWs9lWApcxW-#tWmXVqY?yLp20j9M$T>My(y|^v)LKO%s%ODWLrLz*#LpXDdEQUUd z+D6kuG2t%RG2}8P=+solX{al2{qh6tDmV_>7 zZ>CY~Nt`JNL&QdxG8121=3=w47?gNkfrjE=GvVnB4cFHzeYMiDr zF5_|pv(dl>#!gc}Y4?VQ?1O6TUQNUqR0*hUlY5Q4E~dlc>lW+{v_{@P5fZYFa1c#X z=!TAp#_q{|jfLfaxnemk*gTcZFm4I4BIwKCaX7oX z6_wEK72gdI5+u7z4z_teh3zKKJ{7F9Y3tIuRr_Ri@Bvf7W=@p9;Bjmp&Ktwe1go@g z{G?eWDaFAruknsF)IB5n9^l#&E2dmJK4$G4!9U`y0i_Q|(feC(gNFEr!T9rk;$TvS zqh@V8#8Bth!us%G-sNs{bO&Os3lgsVUB}zcmS08vt@n65^4Xp|reP<{!%*rXNk~aK)LSlNoJNI(_qdG2Jodh6AlOv+{ z;JW)ApZ^)A@XJnTtgl4;2A{h<2G$v-cp><^qRl*d)+?YIEFckv*!>B&DkwlnP&>%I z+A}uR>lB9l{8NnJYkY7UV&6}?r1g&u1J2qohUe>(H(k~rmv5R|-%=k|EDZVRiDG+tP<5~o z(OJW^xW0D_;s0>w3YAjcdIyc7-{DI_UM2>*Sf4_S)}oEi zS*jSwX~y7w)XP%PZ-fS^-)jT~H9o1m>_H)Z8@SZ+!=i9q?d)pND0RQcBS}y7^0)A!t86RLC=*8Zt!3gCklci zCWm;JEelpqZpMib)>0@$T6o&hMwL;38r(T`wNj0t*bXH`>4`_=8;)Ce1p}eMf_!&& zM;&EckhL~k#kMf|v|%ZDuXyBE#h?gsErc=rIFo@re{kVy&K2n{o6VKG3}4gh!VYnG z$T0Z}F(zjh8}9uHtKO4jLFt|bESh#3O@;GbEg3M*LBwNyi14t_fM>W zCHt(icYV<*C*4#5LG4lqo|u{WdFTkUAXiF^wuX?kMivYwG;cUv&>EMm`fy5DY_GEY znMK9$!aj|hES+Z<83-j~skhCI;Pu%H%+>^Bz%{6~ z>}YpJ(w89-R@khjmJ>;l(@rr{&Ut7oxQ4ROI#n&FwiPsAf@tHpW)*0}`|%SE1dzds@`VuDdk_DPCuFR*g))jsMvKP(mSkc zWo>iNM5cWmg-V{(>-AG8A$LSX1>5fmn2oSeZn%(_a0~7T8&|LOPYoH6-pY3oV-UAG z>$w!2>A-)ojaB{TUre9i&ZqFm*+jc}1Bec>7Hc z)^d17RH6xWWS;#2-z8jH`e`9#2wDjwYAJiX_=FtYQNC8?RGJ(08CKIcTk6nC8|x<4 zInb7n1cgS>8AxTxduWGD6vjTII3%LBmVM%od2z(4Bqn3?jQ1bxhKHi31_*Gjl)}nX z4;pA9m94^*U+@Y=>peo zNo?*$Q9)7N$K6y$*p)D{cc%Zu`DTK%K-lB8n^%GL_$`in;M$b1F~KI~*UTFnhF5T3{g*2a#kgwo$-jYFM0vcd$qn9xB+JyI$&7jpv=+%4#Xh0b<3g`3 zhdF_vA*~t{>b+!2>!`@0Elcl!sxDEbBBGAVD}8c_0)Eg^8|ej6d_yHd_!=@JmoYjU zDmq^-Q-Y^4Iaf={Hd9=CS%Sxv^kma=dNjj<{4BrZ7U*O{+?0VoYOUXdkY9f8yred3 ztpN8Hv^myWp5ub>K;@BkrH^pxge&e5<$+hC(#oJ)^}zggRWkm-)(xahJjQ~#K#-+7 zGw=m_285~N{?R4b0iN&}e;|6(xLHZ+m7tYXuBueU)KvCVwtw4faK<;_SvQmp^E)m# z2wuc@7d(|cOp;f4&di7t?qK&Dvz;BHR`}wHayxGn2zepXZYY_=6nL{@%h-F`d>*0Q zn0&eInMklJ-Zc>ySO7s;tT*FI;YoqMpa<82%uwHk)3aqzTi)x`BaHh-o(A5M(-c%C z>xbJ`o88`;vnf)yqQ#QGGlmJtz6c!pA6!rAUmxa%Af&ZuA6pl#o} zi;9zZ1L7ofenGj%Fj-a-nA*sqtn6mXc1h9sIIkyAemj!SNmgZ#+E!dS6+GY#zxqki zb%?-K82eoIzTOgfj^;CH>KDy#wY5d9Nn_w1vmh!-Y{1}0ZU?PFVQB5w6L!hDS!2Nm zFFx3+QkhQ!b)#H!Qnv*Nwz8+e29Cm1DoBJxbWja$>oKZ_j?7xTXnI@*OLCl)7N~te z^!mihr{LC84r@yM>a9}%1)_{R)=SSrg^r5K4bCz@v=5aU^X*cuVK=&yFmrD^Pd;58 zc{+qj?;Dd4ZD*S#@P<3-KttrOkR6cMPKCYnlb`7~wXB2OAeMfC-YoxO7+49pwP7q54W_vapya&dxE)%o2JOs4eiSpYf}8%s{8$4xxWR-`$?m$BIN3E zQoj|Q14<@0uqS?Ca)WJUljz837q%vSxmIWj)I!Phz!PwNGaWWFenr)_BF$zXoB&x3 z5AKB{|Ju|RZhRi1@rkc3yozo8Lm%0PcvIh1fczcQot9UMmk7TY%I%%{Jv6J$ghe~# z;;NX{@iF*)kraz$Dwl~RuXp0)#U7Bd<}3rF(S-|X?-p-f{tJfT(EGh4lN?CxX?fMo z6r(nG$vg9Hdaau3(&+jEObS+Bh2&`$3W9=Vps}yJSHN7y8hLvl)nB19>mWMwUr(xB z`cjbCljUKIR{#?{A!NG}3S4ASfj_~%Te3Fc^2~0n0$T)oW%Z5r8}9Y4I6v?`CyjTc zW1ibtcRdK^@IHShDdckCr;LN_ihXbY*`Rwwplb1h2Iv^eU_*mB%Aq4r%EZRv717gB z#EEi&Sa+vLapDq6h49;lqPn6=`dFaMzOCt1X+b5q=+_c-Qxn1)-O#BL z?4w>BKo5Oh8p~w)#te?LkZ8AgTQ_-ON;EC+bWR0OfLCGR@EB%TLDu*uOzv5Tz6qzw zd;41Q!&&Wk=*46P=F>+7yRpw?PlVqlbeRx^nUAjur^`NQj3Pzy`#W8}LQ^~C z6SA6PQBuL;kvli0x~wfGh6oEV+a7p%`B+Nk8B&T7fhVfnSP`m+nY$9nqsg%d@Wc~# zM_=SMx$)~a9@i=R+US4X?quG8RXz`Q(BSkHT zzZL%YCBF43|FhH0ZxHz=-vbP*)PRj}mVaTYA`>(M#1r_#4Z{8pyH(k{|M*PzKQ-VU z?L**Fg?xhb6M#*~$qivr@PHZ=L3IdiWpXyhpDAZ^7Ck4u)%G9`mC6kz>_jwt*--Mn zI@XU#*6kD5&GH)8-m3jlR!93cpjUli5a?4l)yW5xlB!H4#F4J>6c|bg%5==zhh8;< zyd|41?AFey>+YZ$aGVh4n4mH6TB)adN zYK+1QTX*9O8#m{gG5r@PhWvu{NdH>wcM?lXya3nbw$IihoXQR|ZpYSOOQuu&(b}=T@mEqbXCPJXqLOIyr3b!WAfOaIeN;` z-7LGUIB@FC#~qNa$tcN zX5}GhmZSvke@P$`rZPL;e>k2T2(loybV{`eh9reDyw4RH3)L+0{_^!}LY`8%ZSv(X zrUV3G;^Cqgrl1<+E#$K7eJT&}`=%UkF)5?@n**RqY!GS7IfP0i;CzQDvcT<&My#AO zF*fr!GY?U*wL&wyAZP=1+Qi~nVslG71q?od^V8Vqh^&c7-pUnF?Di1DTMGeFr%jIJnq3Q=CtEJBZ_*;5gE(xykw7*}hyR9nX9@#V3r8;{bg= z9k7}3uloES-TjX}gdbiYiYId4y`QHL>l5m+*$u)umJtKqa7I!B zrxZZFnHOBz$eMEvzmLF>{uWRmRIz35G5{1bhdJrWmsOl9dOYRFs%(mZ4TJfS3GUoY z8%!{#xmMt_#(CV~1B|S-+k=;OYwgZ>zdOx{bV!sg7PlQ%>~3rn9h{y{k%j&?l)QCzmpt zHxxOZhMRAamdjbDet~6M;}H_T<)05-)m@PTUhZTgox1US@22rBt{ z-J$qMz3nMW5lg-gSZYiiq_NTjy6dn7UP4QJVp2i=3C6W}#NW{4pV))OEIfENSc%N5 zbbE!*rXyV#@6d8HG0N;1ObGGvQsuc!K@Wsp*` zj5Feo3Uo)L`d(V)_%z0LSuP*wifuNhm>MU`mP|5@&}jDLHOFDCobqak;&7M-#@@sJ zeFwsYVpHiYKvWb576^#v*J1t7STX-*6BG~_&>2S=?GXV^hB;-|FNckyOcD+q1iq}^ zl%7>;YWnSDtZ(>_2##64LRp>! z*9*pH*4_{4p0`^SZ@eLG!1*OOgO^AW$vzk|~XXb*oA8s&FrVSWL}fi3lc5@!SyzO+s%&`?Oe4 zkR;*QmG35AhhA2SfnDHMst&Gbu8v2CbziPhoC3y$#s^&wx>%s65fF~LQNgVrv@mxR zUq4}YMRP*IJc$7-3xj3VGR{d6j^BbJ%WPJ!5>-JxBeLC-&aBEt1x+U_>6S}iMZJ^S z{JJ8w*pMp*q;3Av#JW3}di-p3a0qT$C*YE=iO|fgLuudeK7z#s& zNv`(!Jnv6-HodjGbW|B!i*4|(Ys5zBJ~*>wcA0o%dipNK0kmzf#N-#>oxdnB9C@qJ zqmO+ij2xS!AfV7k_eP~hiZHVz>MJGKryBS=Jt9|x%z6QXsaUE)u?4@0oV~6XtKPH!#1vpK* z)jy-Us#vP8CUT(F$k5$gTT-(9BIt=Sr2MEW=D5G!{LNB#?;~qb<#@@alHw*Y(rGCW z_UNXnRikDXV|HCJ)w{NGc>Ec*^~BeMOa69Pq~D7xb5A}Z)SD|_#A(FgMFKXqvAD$jkUTW(k@wWxE*Am-Wev1Tj7 zx-)GB`2%V-{OznB{Oz0`D>^RL{NtQC5J+7-m_u0m9x_QZ-baTi4OCwin2G4vRVd|b z#uKAfml%wjM@rWl#jJ3<4tO|rB7EHt-EWh~20>YsLjEjp3>!_lsi{&A`x9vIP&8bv0rcuU>SbE>yjv-bF98a?n5Z z<&ufd_I~;=Do5YX@x^DfqPGI(W+K4cO!w=+^@~&HUr$>^Dr){Gv`Bpe{Rv6F7MdUx zW)A&O7-s9M5-=uW)1EvCe`{eL^`P&QGCi_4%qNQW+w4%O7!gmvmj0*X7x`$C9w`}I z4;g13Yg{ZHPaaReZ;@%K4PL!ckRkRHLcC|p%H0VHOOvF_i}A_qqo<>=)$}_1&`8^H zvt6CH*&YT7gW^77VXG=wP(6H|y!s`eNHySyo_4s*1 z=f!O8)JUBi;6FWAAFRSw+n8{(KDOC1urUIu`~PH6oZe|(s}4- zFv%F83l3UnrivGQB0Y$6A3I}%UjsuSS5lrv!I7+fmE1qKI@|b3G{lEhwV^4k#)6@t z``RT+{ekO=nQlNxk%qv`1uX6*PM4%>`2;iX1goo$1GGk$e)G!}Iktpzk#0q5lk2BG z*C0cE_oTTG!AWCLL8l?KtKe;#h3|rB#j94i?up(xh?~CE_J?^IY%l53HfL?~l$lH$ z9QV)l9egqA>?4N^MgwjDis2eFsWsyx@54jl)hHan_28D?XK6RS)qj$rJ24+Lc?&)l__&M~~Eks$7NHRVjM8kB= zM2*Q*(ao%}v5^$}0_WY+$FEo4Abng*DPwxz;km27m4?S>tJ|l^o=!_A>N7_qX-!bEf>kUTDZId`-pC}2>~VC`+6y6aEnRr{w%^6Ww_2d$q?v1ErT)c*nRj2k zD4R5}HmXK#oGFBb+e%-lH#dr$u0(C3DvT{C@YPPFaXWQA-NxOH3Y!EA+zqUB9S+RLG+TB1#P43ER_cn=mVZa!pWn!m&=jF`ZEUFd8K z)@|48>!9(1S2XvPNpz4&_1*w2GKmzsrOcT>_AxDqm>1!MydeFD#4mJ+k)uStModCg za62D@jzzP-k+G5VxI(`NzJR$yL1!uG5V#xP2p23@t_r7|-3Z-aE`OD|LDL74$qQGj zAiBkpE5as_=qY@R&kXs>IiHec+Vv~%Ye

i1O>I_eGKr^&y;^hm-V94&lC5U~@}s zTa5yXP^(8uV=BE6Dt+3? zLaE_7J031uGhDE7|b&w1(^tMyMTy4Ezl&wqN)pF3smtPe#|`O&uE&FOFx;Lv>2r%dWXcsINN|d3 zzSwY&aG}}M#$$|eJ8DI()+D|nV{jSt3X)A(IZ~?lt!A^rpo2z1YmxIU1%lU1G1LL~ z*NFxe{FkBI2+QE9yNI%iZ4g#m1ZMFxYZ10u>`lpV;=aIeh-*?bt~GKz2fOafq^Y$g zM%cM+$NDj_M%^@usUdiHr=2peP3Y;}A%428!?wZ1t|ZvKyDc#F=ivQGFk$n$Auf_1 z)(P76l5Zj$=3GpYqa$Aox}1I>2ghWjQ1cu{;^*$HRyLhx?bh*pJ)4^KC^Ti5mx3`! zvq54tCQ8wFggOQH(f{j65`l?f+7=HujTDJq%0}^CEPFKPxXlgtM$%#TJB|{_HY7WM zd$9`r31iNC3?q53j|V!gg-2DPTYgyV?leMeIyCC^Np)_#+#JG5N3RiYT!$iODzD5A z6YnL^J_$q67@&_DHO|XTjV7qNFUdl}?SlKC>tG$*#ANykA3n~@zH4~pwrK89kqYs~ zSO`7+bxlDW-G#QxDvwT)N*#jp0`2Cv3kbvct-1AYh_@X*vgtjvB$wGRQ#=vi{<*DF z1Bh84t}k!gqK!CAPYZQId%Xi0FyxOvKCz5?x@0X*=|yS_6KV?iX!k=J;1;lT=_hz} zV=L5=<93TT&R^bhK#YsG)gu;R$yf4TTK0PRo?+jke){Nn3knK58FEQES$;Py4-j^G z(PxSif~@1(9Q{#mzxI-64DH)s7Yo=8Z4%`WBkwkcvPME0UF!K%y(a+o`}UBc@#`*3by8Z}nAp3?M6pH77=*ri%#`G z1QtkLqKP)tWpQF`2<_A6X&3Kj6}edvVlZF^2D?8dS3ObqWNwC zOIenicvYA65wda#o|w6m)lF2wmrdDsn*hSj7*D6e69S?j~z zk(0vUKo34jm&;RR0=U1()qpAHGe6dN0{eTD(xaRBK?0hy1z;><{QXNjG8ek|8)3)_iqnw}LZMK$v> zcP>Dw%~pt!=i@kesT1!3flkCj`90M=pS#q`TcWS1IWH~c(~TT<0|S<;Ugeay#fHqM zJQ3xWaJNGVCn0LC2t=mGq6n`!LbUHW_?@c_v%j(>0%{`@K^ll2$dZF9Bt}qbpR27XI#7 z;U+c(3^sbw9~!92lm}5O2ccjQ zWP+fnk`Y);H#FHdqQ1i4ozrAYV;T`diRyj;tH8UHfkT-Ix!6wNNo0_jkx3`w-eb56PVT}m! z1Lohml~_I04KHA|F$Dcv`{S?O>Ob2`|7Edp^m^(Q(xaRvR35Mtcn^=BVK#j&IC7;6 zwepMCRBECVZ*qEYsG#E^&e1)9)tfu>s&RL^@i2C- zY2oU4^msrZ3KB&g4Pl)`L7(sok*F4A2(ppxtn^vZVxbZ0O!nac=@WIal@ADc03m>q zV4O~~o)#h+8qb)F)FLw;C~+l^8!d^=Yp)_UFQHae#4vcDjb&R+pvpGW+Rr$1Wbs%L zNUlR)6%L3w?Gkri+%?_>exZp=8+NXwGZ^2KHCbclCCRST&H%%^tQ}O}W3I?Vq5S@> zQN2o74BTWy0ks%2111cNdL-vP7AHdR=A{uLeYB*kD;b<@b0U*rw~TdaaXGXEbM0cQ zCpxukm)k;`M*P}PY-{Nb3HH>hI;~c%$-QG&Z1%hL#7I1OEo=f$u9a%aLMb6>Ov9P> zHcM2@&oRJoN5)?^GP=XndpF!Lccdd2{Na2x#+X8|J%iMsr zBE*WMg3U}K_*z&RWY`E(;yLc7IZ3h+#;7TT>kAZAX&28F;W7`=bw*n`uO3woyC?-kF~99-?(=qf@bQg@*mw8t;f@}$ zFUn4>$|}JG@pYra1v+m$O1NV#np*C1*N1RlgXts+LJo3Eh+lI?hx_zS7?5Chqc@L= zee;2E38C=ITE7R8zok9Yy7j%kd(8TLCa8uGTR=SEG|^ZCX`8Zi^05UECSKxjO_luw zuW@tF=a@@l0k*cr5Nw`yI3wG0!j}hHOPr(WV-s#q6V*NyNF#JZ^!rN;Z5c(AuX%5K zM-cSO_ktIMpc`#~USvnFC-;Jvec-|rnjbRj2xRhs6``a89lhK}}SIMA??Kul-qE0}hn{(s5eKb02g3JKp&&xim%gn-Wv834dh_x}$G z07k`MB>;B*7Wf|+1Pv4*Tn+^Vgafef0eJr}>OEj|_;Dctod|yaDl4iaNG~ZT1~{ny z_hiPcx7GrHe^3T|&;Xx5uRP!HZ;StzOjb}%QcP4)>4mJ=Ul9kQyS`Xl-G zTdglXVEy$yuRoao1o%@H>d#2)&vVqf8aRsvnCEQ(CI8<1e_pk|z<|I06X5ez9bkRu z;wtFqU;>DJYpVYkP=lZx|*2EW;l!na}aSiriMT z0C`maq^AEHo-V*v{2M%RJ6!_{LuEktc?oMvLm6vpb4Q!sL*s2~FZBXI?g72@`-bqJ zSFJCg&;AY?5cAi<(H?NFOw826P*7jr(B58F*Gkv;Po;(Dc^`q-5&IrN`wn2w`+MFA z0Gg)1$-C+w${YYwhmonVBOrV>Ae8*?^RD2DZ@L4h5^O-;8UM^U;9l!{kMvvU=j|y0 z5R0(*ZyC>bWo%XfWE==kJKsl)Kd)L}dW_$q%UB!#*IF2}I|@Sw_?cJ%%KZIU)Sp+a zZzn(l@aFu)k;e_Z9J6 za`#W@THgeKhRkm&;zzaqx8dix#Nkgo2f%>-8@#_Y{eKfYd|n&R<@0{Bc&YxD<)25K z=c+kB;b!0b-{kpY0RHU+`q%t@-`skxdh-*|`0an!z@pBQGKad+*WUQO z-kwWv{6s}D{1>SIAjt7N|Ieikelnq%{0pYPItl?wXY*I#gXdJwBhCM$0y6(6s{ayq z{yF^fkm*0+6D|G;{zpsvQvmhnRL^6t{-kPj_!m@vRNDWluIJ$^f08UZ{|l0T4rckh zM9-uB{UpP3|0lA)?nXbyd>(7+C+4ZoKVkl8kUyaR`0*sP<1z(dhrp`TODO zxlip+%+ERh8}m0Fw$C&D+=1~Y!FJxiAo%Mj_4^V$cOUyn&|mlq!Jo6lzcKtiFUfOv zkDo+7rN0pU(p~@QaeKan{u4Q<;uqv!JJTP~zu!=QUWn&gmp`dotN)4Wf6S%NckF(` zF4X)J?2iHCANKE_7vQ;F|0ffE<1b9l-yi-`cmJb6&uz^=X+AgoLh~2c9|ij3_77v< zbED%=eDT(Qf&br4kk9MuxgF&v(F(vY@W-1uU_tnMtI8{BaKKyOcXb&iAS6KOxwoC) GfBiq \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 000000000..72d362daf --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 34ff5a389..000000000 --- a/pom.xml +++ /dev/null @@ -1,386 +0,0 @@ - - 4.0.0 - - Dropbox Core API SDK - A client library for Dropbox's HTTP-based "Core API". - - com.dropbox.core - dropbox-core-sdk - 0-SNAPSHOT - - jar - - https://www.dropbox.com/developers/core - - scm:git:git@github.com:dropbox/dropbox-sdk-java.git - scm:git:git@github.com:dropbox/dropbox-sdk-java.git - https://github.com/dropbox/dropbox-sdk-java - - - - - MIT - http://opensource.org/licenses/MIT - repo - - - - - - dropbox-api-team - Dropbox API Team - api-support@dropbox.com - Dropbox - - - - - 3.0.5 - - - - UTF-8 - false - - - - - com.fasterxml.jackson.core - jackson-annotations - 2.7.1 - - - - - com.fasterxml.jackson.core - jackson-core - 2.7.1 - - - - com.fasterxml.jackson.core - jackson-databind - 2.7.1-1 - - - - - javax.servlet - servlet-api - 2.5 - provided - - - - - com.squareup.okhttp - okhttp - 2.7.4 - provided - - - - - com.google.android - android - 4.1.1.4 - provided - - - - org.testng - testng - 6.9.10 - test - - - org.mockito - mockito-core - 1.10.19 - test - - - org.openjdk.jmh - jmh-core - 1.11.3 - test - - - org.openjdk.jmh - jmh-generator-annprocess - 1.11.3 - test - - - - - - - src/main/resources - - sdk-version.txt - - true - - - ${project.build.directory}/generated-resources/certs - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.5.1 - - 1.6 - 1.6 - -Xlint:all - true - true - - - - org.codehaus.mojo - animal-sniffer-maven-plugin - 1.14 - - - org.codehaus.mojo.signature - java16 - 1.0 - - - - - check-java-version-compatibility - test - - check - - - - - - org.apache.maven.plugins - maven-source-plugin - 3.0.0 - - - attach-sources - - jar - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9.1 - - true - - - - attach-javadoc - - jar - - - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.8 - - - copy - package - - run - - - - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.19.1 - - - classesAndMethods - 2 - true - - - - org.apache.maven.plugins - maven-failsafe-plugin - 2.19.1 - - true - false - - - - - - com.dropbox.maven - pem-converter-maven-plugin - 1.0 - - - - src/main/resources/trusted-certs.crt - ${project.build.directory}/generated-resources/certs/com/dropbox/core/http/trusted-certs.raw - - - convert - - - - - - - - - maven-jar-plugin - 2.6 - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - org.apache.felix - maven-bundle-plugin - 3.0.1 - true - - - <_noee>${osgi.bnd.noee} - - - - - bundle-manifest - process-classes - - manifest - - - - - - - - edu.washington.cs.types.checker - checker-maven-plugin - 1.7.5 - - - checkers.nullness.NullnessChecker - - - -AstubWarnIfNotFound -Astubs=support/checker-framework-stubs -AassumeSideEffectFree -AsuppressWarnings=purity.invalid.overriding -AprintErrorStack - - - - - - org.codehaus.mojo - findbugs-maven-plugin - 3.0.3 - - max - low - true - support/findbugs-exclude.xml - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - ${project.build.directory}/test-classpath - test - - - - test-compile - - build-classpath - - - - - - - - - - jdk8 - - [1.8,) - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.3 - - - - -Xdoclint:accessibility - -Xdoclint:html - -Xdoclint:reference - -Xdoclint:syntax - - - - - - - - - diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 000000000..5f5a599f0 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,4 @@ +rootProject.name = 'dropbox-sdk-java' + + + diff --git a/src/main/java/com/dropbox/core/ApiErrorResponse.java b/src/main/java/com/dropbox/core/ApiErrorResponse.java new file mode 100644 index 000000000..0e77a8b58 --- /dev/null +++ b/src/main/java/com/dropbox/core/ApiErrorResponse.java @@ -0,0 +1,76 @@ +package com.dropbox.core; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonToken; + +import com.dropbox.core.stone.StoneSerializer; + +final class ApiErrorResponse { + private final T error; + private LocalizedText userMessage; + + public ApiErrorResponse(T error, LocalizedText userMessage) { + if (error == null) { + throw new NullPointerException("error"); + } + this.error = error; + this.userMessage = userMessage; + } + + public T getError() { + return error; + } + + public LocalizedText getUserMessage() { + return userMessage; + } + + /** + * For internal use only. + */ + static final class Serializer extends StoneSerializer> { + private StoneSerializer errSerializer; + + public Serializer(StoneSerializer errSerializer) { + this.errSerializer = errSerializer; + } + + @Override + public void serialize(ApiErrorResponse value, JsonGenerator g) throws IOException, JsonGenerationException { + throw new UnsupportedOperationException("Error wrapper serialization not supported."); + } + + @Override + public ApiErrorResponse deserialize(JsonParser p) throws IOException, JsonParseException { + T error = null; + LocalizedText userMessage = null; + + expectStartObject(p); + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("error".equals(field)) { + error = errSerializer.deserialize(p); + } else if ("user_message".equals(field)) { + userMessage = LocalizedText.BABEL_SERIALIZER.deserialize(p); + } else { + skipValue(p); + } + } + if (error == null) { + throw new JsonParseException(p, "Required field \"error\" missing."); + } + + ApiErrorResponse value = new ApiErrorResponse(error, userMessage); + expectEndObject(p); + + return value; + } + } +} + diff --git a/src/main/java/com/dropbox/core/DbxRequestConfig.java b/src/main/java/com/dropbox/core/DbxRequestConfig.java index bee6b55bc..9eca79440 100644 --- a/src/main/java/com/dropbox/core/DbxRequestConfig.java +++ b/src/main/java/com/dropbox/core/DbxRequestConfig.java @@ -1,5 +1,7 @@ package com.dropbox.core; +import java.util.Locale; + import com.dropbox.core.http.HttpRequestor; import com.dropbox.core.http.StandardHttpRequestor; @@ -15,7 +17,7 @@ public class DbxRequestConfig { private final HttpRequestor httpRequestor; private final int maxRetries; - private DbxRequestConfig(String clientIdentifier, /*@Nullable*/String userLocale, HttpRequestor httpRequestor, int maxRetries) { + private DbxRequestConfig(String clientIdentifier, /*@Nullable*/ String userLocale, HttpRequestor httpRequestor, int maxRetries) { if (clientIdentifier == null) throw new NullPointerException("clientIdentifier"); if (httpRequestor == null) throw new NullPointerException("httpRequestor"); if (maxRetries < 0) throw new IllegalArgumentException("maxRetries"); @@ -26,11 +28,38 @@ private DbxRequestConfig(String clientIdentifier, /*@Nullable*/String userLocale this.maxRetries = maxRetries; } - public DbxRequestConfig(String clientIdentifier, String userLocale) { + /** + * Creates a new configuration. + * + * @param clientIdentifier client identifier typically in the form "Name/Version" to be used in + * the User-Agent header (see {@link #getClientIdentifier}). + */ + public DbxRequestConfig(String clientIdentifier) { + this(clientIdentifier, null); + } + + /** + * Creates a new configuration. + * + * @param clientIdentifier client identifier typically in the form "Name/Version" to be used in + * the User-Agent header (see {@link #getClientIdentifier}). + * @param userLocale IETF BCP 47 language tag of locale to use for user-visible text in responses, or + * {@code null} to use the user's Dropbox locale preference. + */ + public DbxRequestConfig(String clientIdentifier, /*@Nullable*/ String userLocale) { this(clientIdentifier, userLocale, StandardHttpRequestor.INSTANCE); } - public DbxRequestConfig(String clientIdentifier, /*@Nullable*/String userLocale, HttpRequestor httpRequestor) { + /** + * Creates a new configuration. + * + * @param clientIdentifier client identifier typically in the form "Name/Version" to be used in + * the User-Agent header (see {@link #getClientIdentifier}). + * @param userLocale IETF BCP 47 language tag of locale to use for user-visible text in responses, or + * {@code null} to use the user's Dropbox locale preference. + * @param httpRequestor HTTP client to use for issuing requests. + */ + public DbxRequestConfig(String clientIdentifier, /*@Nullable*/ String userLocale, HttpRequestor httpRequestor) { this(clientIdentifier, userLocale, httpRequestor, 0); } @@ -65,17 +94,15 @@ public String getClientIdentifier() { } /** - * Returns the locale of the user of your app. This is used by the Dropbox server to localize - * user-visible strings returned by API calls. + * Returns the locale of the user of your app as an IETF BCP 47 language tag. This is used by + * the Dropbox server to localize user-visible strings returned by API calls. * - *

- * If the value is {@code null} or some locale that Dropbox doesn't support, the localized - * strings will be in English. - *

+ *

If the value is {@code null} or some locale that Dropbox doesn't support, the strings + * will be localized based on the user's Dropbox locale preference. * *

Defaults to {@code null}. * - * @return locale of app user, or {@code null} if not localized. + * @return locale of app user, or {@code null} to use user's Dropbox locale settings. */ public String getUserLocale() { return userLocale; @@ -156,6 +183,23 @@ public static Builder newBuilder(String clientIdentifier) { return new Builder(clientIdentifier); } + // Available in Java 7, but not in Java 6. Do a hacky version of it here. + private static String toLanguageTag(Locale locale) { + if (locale == null) { + return null; + } + StringBuilder tag = new StringBuilder(); + + tag.append(locale.getLanguage().toLowerCase()); + + if (!locale.getCountry().isEmpty()) { + tag.append("-"); + tag.append(locale.getCountry().toUpperCase()); + } + + return tag.toString(); + } + /** * Builder for {@link DbxRequestConfig}. */ @@ -188,9 +232,12 @@ private Builder(String clientIdentifier) { * Set the locale of the app user. User-visible messages returned by the Dropbox servers * will be localized to this locale. * - *

Defaults to {@code null}, which disables localization (messages will be in English). + *

Defaults to {@code null}, which means strings will be localized according to the + * user's Dropbox locale preference. + * + * @param userLocale locale of app user as an IETF BCP 47 language tag, or {@code null} to + * use the user's Dropbox locale settings. * - * @param userLocale Locale of app user, or {@code null} to disable localization * @return this builder */ public Builder withUserLocale(/*@Nullable*/ String userLocale) { @@ -198,6 +245,36 @@ public Builder withUserLocale(/*@Nullable*/ String userLocale) { return this; } + /** + * Set the locale of user-visible messages returned by the Dropbox servers to the user's + * Dropbox locale. + * + *

User-visible strings will be localized according to the user's Dropbox locale + * preference. + * + * @return this builder + */ + public Builder withUserLocaleFromPreferences() { + this.userLocale = null; + return this; + } + + /** + * Set the locale of the app user. User-visible messages returned by the Dropbox servers + * will be localized to this locale. + * + *

Defaults to {@code null}, which means strings will be localized according to the + * user's Dropbox locale preference. + * + * @param userLocale Locale of app user, or {@code null} to use user's Dropbox locale settings. + * + * @return this builder + */ + public Builder withUserLocaleFrom(/*@Nullable*/ Locale userLocale) { // not named withUserLocale because of ambiguous calls when passing 'null' + this.userLocale = toLanguageTag(userLocale); + return this; + } + /** * Set the HTTP requestor to use for issuing network requests to the Dropbox servers. * diff --git a/src/main/java/com/dropbox/core/DbxRequestUtil.java b/src/main/java/com/dropbox/core/DbxRequestUtil.java index 3784cf1b6..cde826a74 100644 --- a/src/main/java/com/dropbox/core/DbxRequestUtil.java +++ b/src/main/java/com/dropbox/core/DbxRequestUtil.java @@ -13,29 +13,19 @@ import java.util.ArrayList; import java.util.List; +import com.dropbox.core.stone.StoneSerializer; import com.dropbox.core.http.HttpRequestor; import com.dropbox.core.json.JsonReadException; import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; import com.dropbox.core.util.IOUtil; import com.dropbox.core.util.StringUtil; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; - import static com.dropbox.core.util.StringUtil.jq; import static com.dropbox.core.util.LangUtil.mkAssert; /*>>> import checkers.nullness.quals.Nullable; */ public final class DbxRequestUtil { - private static final ObjectMapper JSON = JsonUtil.getMapper(); public static String encodeUrlParam(String s) { try { @@ -129,6 +119,16 @@ public static List addUserAgentHeader( return headers; } + public static List addUserLocaleHeader(/*@Nullable*/List headers, DbxRequestConfig requestConfig) { + if (requestConfig.getUserLocale() == null) { + return headers; + } + + if (headers == null) headers = new ArrayList(); + headers.add(new HttpRequestor.Header("Dropbox-API-User-Locale", requestConfig.getUserLocale())); + return headers; + } + public static HttpRequestor.Header buildUserAgentHeader(DbxRequestConfig requestConfig, String sdkUserAgentIdentifier) { return new HttpRequestor.Header("User-Agent", requestConfig.getClientIdentifier() + " " + sdkUserAgentIdentifier + "/" + DbxSdkVersion.Version); } @@ -236,81 +236,12 @@ private static List copyHeaders(List } } - public static class ErrorWrapper extends Exception { - private static final long serialVersionUID = 0L; - - private final Object errValue; // Really an ErrT instance, but Throwable does not allow generic subclasses. - private final String requestId; - private final LocalizedText userMessage; - - public ErrorWrapper(Object errValue, String requestId, LocalizedText userMessage) { - this.errValue = errValue; - this.requestId = requestId; - this.userMessage = userMessage; - } - - public Object getErrorValue() { - return errValue; - } - - public String getRequestId() { - return requestId; - } - - public LocalizedText getUserMessage() { - return userMessage; - } - - public static ErrorWrapper fromResponse(Type errType, HttpRequestor.Response response) - throws IOException, JsonParseException { - String requestId = DbxRequestUtil.getRequestId(response); - - JavaType type = JSON.getTypeFactory() - .constructParametricType( - ApiErrorResponse.class, - JSON.getTypeFactory().constructType(errType) - ); - ApiErrorResponse apiResponse = JSON.readValue(response.getBody(), type); - - // ProGuard/Dex hack: prevent ProGuard/Dex from optimizing away our @JsonCreator - // constructor. We add this code here instead of updating our rules to allow developers - // to easily fix their broken apps by updating the SDK version (see T94429). - if (errType == null) { - new ApiErrorResponse("impossible", new LocalizedText("impossible", "en_US")); - } - - return new ErrorWrapper(apiResponse.getError(), requestId, apiResponse.getUserMessage()); - } - - @JsonIgnoreProperties(ignoreUnknown=true) - private static final class ApiErrorResponse { - private final T error; - private LocalizedText userMessage; - - @JsonCreator - public ApiErrorResponse( - @JsonProperty(value="error", required=true) T error, - @JsonProperty("user_message") LocalizedText userMessage - ) { - if (error == null) { - throw new NullPointerException("error"); - } - this.error = error; - this.userMessage = userMessage; - } - - public T getError() { - return error; - } - - public LocalizedText getUserMessage() { - return userMessage; - } - } - } - public static byte[] loadErrorBody(HttpRequestor.Response response) throws NetworkIOException { + if (response.getBody() == null) { + return new byte[0]; + } + // Slurp the body into memory (up to 4k; anything past that is probably not useful). try { return IOUtil.slurp(response.getBody(), 4096); diff --git a/src/main/java/com/dropbox/core/DbxUploader.java b/src/main/java/com/dropbox/core/DbxUploader.java index 898642b8c..37c1c4272 100644 --- a/src/main/java/com/dropbox/core/DbxUploader.java +++ b/src/main/java/com/dropbox/core/DbxUploader.java @@ -1,20 +1,16 @@ package com.dropbox.core; -import static com.dropbox.core.DbxRequestUtil.ErrorWrapper; - import java.io.Closeable; import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; -import com.dropbox.core.json.JsonUtil; +import com.fasterxml.jackson.core.JsonProcessingException; + +import com.dropbox.core.stone.StoneSerializer; import com.dropbox.core.http.HttpRequestor; import com.dropbox.core.util.IOUtil; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; - /** * Class for completing upload requests. * @@ -47,27 +43,23 @@ * @param exception type returned by server on request failure */ public abstract class DbxUploader implements Closeable { - protected static final ObjectMapper JSON = JsonUtil.getMapper(); - private final HttpRequestor.Uploader httpUploader; - private final JavaType responseType; - private final JavaType errorType; + private final StoneSerializer responseSerializer; + private final StoneSerializer errorSerializer; private boolean closed; private boolean finished; - protected DbxUploader(HttpRequestor.Uploader httpUploader, - JavaType responseType, - JavaType errorType) { + protected DbxUploader(HttpRequestor.Uploader httpUploader, StoneSerializer responseSerializer, StoneSerializer errorSerializer) { this.httpUploader = httpUploader; - this.responseType = responseType; - this.errorType = errorType; + this.responseSerializer = responseSerializer; + this.errorSerializer = errorSerializer; this.closed = false; this.finished = false; } - protected abstract X newException(DbxRequestUtil.ErrorWrapper error); + protected abstract X newException(DbxWrappedException error); /** * Uploads all bytes read from the given {@link InputStream} and returns the response. @@ -224,11 +216,11 @@ public R finish() throws X, DbxException { try { if (response.getStatusCode() == 200) { - return JSON.readValue(response.getBody(), responseType); + return responseSerializer.deserialize(response.getBody()); } else if (response.getStatusCode() == 409) { - ErrorWrapper wrapper = ErrorWrapper.fromResponse(errorType, response); - throw newException(wrapper); + DbxWrappedException wrapped = DbxWrappedException.fromResponse(errorSerializer, response); + throw newException(wrapped); } else { throw DbxRequestUtil.unexpectedStatus(response); diff --git a/src/main/java/com/dropbox/core/DbxWrappedException.java b/src/main/java/com/dropbox/core/DbxWrappedException.java new file mode 100644 index 000000000..c0b39f7b2 --- /dev/null +++ b/src/main/java/com/dropbox/core/DbxWrappedException.java @@ -0,0 +1,47 @@ +package com.dropbox.core; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonParseException; + +import com.dropbox.core.stone.StoneSerializer; +import com.dropbox.core.http.HttpRequestor; + +/** + * For internal use only. + */ +public final class DbxWrappedException extends Exception { + private static final long serialVersionUID = 0L; + + private final Object errValue; // Really an ErrT instance, but Throwable does not allow generic subclasses. + private final String requestId; + private final LocalizedText userMessage; + + public DbxWrappedException(Object errValue, String requestId, LocalizedText userMessage) { + this.errValue = errValue; + this.requestId = requestId; + this.userMessage = userMessage; + } + + public Object getErrorValue() { + return errValue; + } + + public String getRequestId() { + return requestId; + } + + public LocalizedText getUserMessage() { + return userMessage; + } + + public static DbxWrappedException fromResponse(StoneSerializer errSerializer, HttpRequestor.Response response) + throws IOException, JsonParseException { + String requestId = DbxRequestUtil.getRequestId(response); + + ApiErrorResponse apiResponse = new ApiErrorResponse.Serializer(errSerializer) + .deserialize(response.getBody()); + + return new DbxWrappedException(apiResponse.getError(), requestId, apiResponse.getUserMessage()); + } +} diff --git a/src/main/java/com/dropbox/core/LocalizedText.java b/src/main/java/com/dropbox/core/LocalizedText.java index 7ddf2a2f2..58096862c 100644 --- a/src/main/java/com/dropbox/core/LocalizedText.java +++ b/src/main/java/com/dropbox/core/LocalizedText.java @@ -1,7 +1,15 @@ package com.dropbox.core; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.IOException; + +import com.dropbox.core.stone.StoneSerializer; +import com.dropbox.core.stone.StoneSerializers; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonToken; /** * Human-readable text localized to a specific locale. @@ -17,11 +25,7 @@ public final class LocalizedText { * @param text Localized, human-readable text. Must not be {@code null} * @param locale IETF BCP 47 language tag of text locale. Must not be {@code null} */ - @JsonCreator - public LocalizedText( - @JsonProperty("text") String text, - @JsonProperty("locale") String locale - ) { + public LocalizedText(String text, String locale) { if (text == null) { throw new NullPointerException("text"); } @@ -55,4 +59,46 @@ public String getLocale() { public String toString() { return text; } + + /** + * For internal use only. + */ + static final StoneSerializer BABEL_SERIALIZER = new StoneSerializer() { + @Override + public void serialize(LocalizedText value, JsonGenerator g) throws IOException, JsonGenerationException { + throw new UnsupportedOperationException("Error wrapper serialization not supported."); + } + + @Override + public LocalizedText deserialize(JsonParser p) throws IOException, JsonParseException { + String text = null; + String locale = null; + + expectStartObject(p); + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("text".equals(field)) { + text = StoneSerializers.string().deserialize(p); + } else if ("locale".equals(field)) { + locale = StoneSerializers.string().deserialize(p); + } else { + skipValue(p); + } + } + + if (text == null) { + throw new JsonParseException(p, "Required field \"text\" missing."); + } + + if (locale == null) { + throw new JsonParseException(p, "Required field \"locale\" missing."); + } + + LocalizedText value = new LocalizedText(text, locale); + expectEndObject(p); + + return value; + } + }; } diff --git a/src/main/java/com/dropbox/core/http/OkHttpRequestor.java b/src/main/java/com/dropbox/core/http/OkHttpRequestor.java index 23c68ae22..5b2d7850c 100644 --- a/src/main/java/com/dropbox/core/http/OkHttpRequestor.java +++ b/src/main/java/com/dropbox/core/http/OkHttpRequestor.java @@ -27,8 +27,7 @@ * To use this, pass {@link #INSTANCE} to the {@link com.dropbox.core.DbxRequestConfig} constructor. *

*/ -public class OkHttpRequestor extends HttpRequestor -{ +public class OkHttpRequestor extends HttpRequestor { /** * A thread-safe instance of {@code OkHttpRequestor} that connects directly * (as opposed to using a proxy). @@ -37,8 +36,7 @@ public class OkHttpRequestor extends HttpRequestor private final OkHttpClient client; - private static OkHttpClient defaultOkHttpClient() - { + private static OkHttpClient defaultOkHttpClient() { OkHttpClient client = new OkHttpClient(); client.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); client.setReadTimeout(DEFAULT_READ_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); @@ -46,15 +44,16 @@ private static OkHttpClient defaultOkHttpClient() return client; } - public OkHttpRequestor(OkHttpClient client) - { + public OkHttpRequestor(OkHttpClient client) { this.client = client; } + public OkHttpClient getClient() { + return client; + } + @Override - public Response doGet(String url, Iterable
headers) - throws IOException - { + public Response doGet(String url, Iterable
headers) throws IOException { Request.Builder builder = new Request.Builder().get().url(url); toOkHttpHeaders(headers, builder); com.squareup.okhttp.Response response = client.newCall(builder.build()).execute(); @@ -63,21 +62,16 @@ public Response doGet(String url, Iterable
headers) } @Override - public BufferUploader startPost(String url, Iterable
headers) - throws IOException - { + public BufferUploader startPost(String url, Iterable
headers) throws IOException { return startUpload(url, headers, "POST"); } @Override - public BufferUploader startPut(String url, Iterable
headers) - throws IOException - { + public BufferUploader startPut(String url, Iterable
headers) throws IOException { return startUpload(url, headers, "PUT"); } - private BufferUploader startUpload(String url, Iterable
headers, String method) - { + private BufferUploader startUpload(String url, Iterable
headers, String method) { Buffer requestBuffer = new Buffer(); RequestBody requestBody = new BufferRequestBody(requestBuffer, null); Request.Builder builder = new Request.Builder().method(method, requestBody).url(url); @@ -85,15 +79,13 @@ private BufferUploader startUpload(String url, Iterable
headers, String return new BufferUploader(client.newCall(builder.build()), requestBuffer); } - private static void toOkHttpHeaders(Iterable
headers, Request.Builder builder) - { + private static void toOkHttpHeaders(Iterable
headers, Request.Builder builder) { for (Header header : headers) { builder.addHeader(header.getKey(), header.getValue()); } } - private static Map> fromOkHttpHeaders(Headers headers) - { + private static Map> fromOkHttpHeaders(Headers headers) { Map> responseHeaders = new HashMap>(headers.size()); for (String name : headers.names()) { responseHeaders.put(name, headers.values(name)); @@ -106,34 +98,28 @@ private static Map> fromOkHttpHeaders(Headers headers) * the {@link java.io.OutputStream} from an Okio {@link Buffer} that is connected to an OkHttp * {@link RequestBody}. Calling {@link #finish()} will execute the request with OkHttp */ - private static class BufferUploader extends HttpRequestor.Uploader - { + private static class BufferUploader extends HttpRequestor.Uploader { private final Call call; private final Buffer requestBuffer; - public BufferUploader(Call call, Buffer requestBuffer) - { + public BufferUploader(Call call, Buffer requestBuffer) { super(requestBuffer.outputStream()); this.call = call; this.requestBuffer = requestBuffer; } @Override - public void close() - { + public void close() { requestBuffer.clear(); } @Override - public void abort() - { + public void abort() { call.cancel(); } @Override - public Response finish() - throws IOException - { + public Response finish() throws IOException { com.squareup.okhttp.Response response = call.execute(); Map> responseHeaders = fromOkHttpHeaders(response.headers()); return new Response(response.code(), response.body().byteStream(), responseHeaders); @@ -143,33 +129,27 @@ public Response finish() /** * Implementation of {@link RequestBody} that uses a {@link Buffer} for internal storage */ - private static class BufferRequestBody extends RequestBody - { + private static class BufferRequestBody extends RequestBody { private Buffer buffer; private /*@Nullable*/MediaType mediaType; - private BufferRequestBody(final Buffer buffer, /*@Nullable*/MediaType mediaType) - { + private BufferRequestBody(final Buffer buffer, /*@Nullable*/MediaType mediaType) { this.buffer = buffer; this.mediaType = mediaType; } @Override - public /*@Nullable*/MediaType contentType() - { + public /*@Nullable*/MediaType contentType() { return mediaType; } @Override - public long contentLength() - { + public long contentLength() { return buffer.size(); } @Override - public void writeTo(BufferedSink sink) - throws IOException - { + public void writeTo(BufferedSink sink) throws IOException { try { sink.writeAll(buffer); } finally { diff --git a/src/main/java/com/dropbox/core/http/SSLConfig.java b/src/main/java/com/dropbox/core/http/SSLConfig.java index 649a67a61..7e8586a57 100644 --- a/src/main/java/com/dropbox/core/http/SSLConfig.java +++ b/src/main/java/com/dropbox/core/http/SSLConfig.java @@ -18,6 +18,7 @@ import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.HashSet; import javax.net.ssl.HttpsURLConnection; @@ -53,33 +54,23 @@ * */ public class SSLConfig { - /** - * Apply security settings to an {@link HttpsURLConnection}. Make sure you - * haven't called {@link HttpsURLConnection#connect} yet. - */ - public static void apply(HttpsURLConnection conn) throws SSLException { - conn.setSSLSocketFactory(sslSocketFactory); - } - - public static SSLSocketFactory getSSLSocketFactory() { - return sslSocketFactory; - } - - private static final SSLSocketFactory sslSocketFactory = createSSLSocketFactory(); + private static final SSLSocketFactory SSL_SOCKET_FACTORY = createSSLSocketFactory(); - private static final String[] protocolListTLS_v1_2 = {"TLSv1.2"}; - private static final String[] protocolListTLS_v1_0 = {"TLSv1.0"}; - private static final String[] protocolListTLS_v1 = {"TLSv1"}; + private static final String[] PROTOCOL_LIST_TLS_V1_2 = {"TLSv1.2"}; + private static final String[] PROTOCOL_LIST_TLS_V1_0 = {"TLSv1.0"}; + private static final String[] PROTOCOL_LIST_TLS_V1 = {"TLSv1"}; private static /*@MonotonicNonNull*/CipherSuiteFilterationResults CACHED_CIPHER_SUITE_FILTERATION_RESULTS; + private static final String ROOT_CERTS_RESOURCE = "/trusted-certs.crt"; + // All client ciphersuites allowed by Dropbox. // // Including both RFC and OpenSSL ciphersuite naming conventions to support // all Android API levels: // - API Level >= 10 uses the RFC naming convention // - API Level < 10 uses the OpenSSL naming convention - private static HashSet allowedCipherSuites = new HashSet(Arrays.asList(new String[] { + private static final HashSet ALLOWED_CIPHER_SUITES = new HashSet(Arrays.asList(new String[] { "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", @@ -120,21 +111,33 @@ public static SSLSocketFactory getSSLSocketFactory() { "AES128-SHA", })); + /** + * Apply security settings to an {@link HttpsURLConnection}. Make sure you + * haven't called {@link HttpsURLConnection#connect} yet. + */ + public static void apply(HttpsURLConnection conn) throws SSLException { + conn.setSSLSocketFactory(SSL_SOCKET_FACTORY); + } + + public static SSLSocketFactory getSSLSocketFactory() { + return SSL_SOCKET_FACTORY; + } + private static void limitProtocolsAndCiphers(SSLSocket socket) throws SSLException { // Set TLS protocol version outer: { for (String protocol : socket.getSupportedProtocols()) { if (protocol.equals("TLSv1.2")) { - socket.setEnabledProtocols(protocolListTLS_v1_2); + socket.setEnabledProtocols(PROTOCOL_LIST_TLS_V1_2); break outer; } if (protocol.equals("TLSv1.0")) { - socket.setEnabledProtocols(protocolListTLS_v1_0); + socket.setEnabledProtocols(PROTOCOL_LIST_TLS_V1_0); break outer; } if (protocol.equals("TLSv1")) { - socket.setEnabledProtocols(protocolListTLS_v1); + socket.setEnabledProtocols(PROTOCOL_LIST_TLS_V1); break outer; } } @@ -155,9 +158,9 @@ private static String[] getFilteredCipherSuites(String[] supportedCipherSuites) } // Filter the 'supported' list to yield the 'enabled' list. - ArrayList enabled = new ArrayList(allowedCipherSuites.size()); + ArrayList enabled = new ArrayList(ALLOWED_CIPHER_SUITES.size()); for (String supported : supportedCipherSuites) { - if (allowedCipherSuites.contains(supported)) { + if (ALLOWED_CIPHER_SUITES.contains(supported)) { enabled.add(supported); } } @@ -187,10 +190,8 @@ public CipherSuiteFilterationResults(String[] supported, String[] enabled) { } } - private static final String RootCertsResourceName = "trusted-certs.raw"; - private static SSLSocketFactory createSSLSocketFactory() { - KeyStore trustedCertKeyStore = loadKeyStore(RootCertsResourceName); + KeyStore trustedCertKeyStore = loadKeyStore(ROOT_CERTS_RESOURCE); TrustManager[] trustManagers = createTrustManagers(trustedCertKeyStore); SSLContext sslContext = createSSLContext(trustManagers); return new SSLSocketFactoryWrapper(sslContext.getSocketFactory()); @@ -285,7 +286,7 @@ private static TrustManager[] createTrustManagers(KeyStore trustedCertKeyStore) return tmf.getTrustManagers(); } - private static KeyStore loadKeyStore(String certFileResourceName) { + private static KeyStore loadKeyStore(String certFileResource) { KeyStore keyStore; try { keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); @@ -301,18 +302,18 @@ private static KeyStore loadKeyStore(String certFileResourceName) { throw mkAssert("Couldn't initialize KeyStore", ex); } - InputStream in = SSLConfig.class.getResourceAsStream(certFileResourceName); + InputStream in = SSLConfig.class.getResourceAsStream(certFileResource); if (in == null) { - throw new AssertionError("Couldn't find resource \"" + certFileResourceName + "\""); + throw new AssertionError("Couldn't find resource \"" + certFileResource + "\""); } try { loadKeyStore(keyStore, in); } catch (KeyStoreException ex) { - throw mkAssert("Error loading from \"" + certFileResourceName + "\"", ex); + throw mkAssert("Error loading from \"" + certFileResource + "\"", ex); } catch (LoadException ex) { - throw mkAssert("Error loading from \"" + certFileResourceName + "\"", ex); + throw mkAssert("Error loading from \"" + certFileResource + "\"", ex); } catch (IOException ex) { - throw mkAssert("Error loading from \"" + certFileResourceName + "\"", ex); + throw mkAssert("Error loading from \"" + certFileResource + "\"", ex); } finally { IOUtil.closeInput(in); } @@ -320,16 +321,15 @@ private static KeyStore loadKeyStore(String certFileResourceName) { return keyStore; } - public static final int MaxCertLength = 10 * 1024; - public static final class LoadException extends Exception { private static final long serialVersionUID = 0L; - public LoadException(String message) { - super(message); + public LoadException(String message, Throwable cause) { + super(message, cause); } } + @SuppressWarnings("unchecked") private static void loadKeyStore(KeyStore keyStore, InputStream in) throws IOException, LoadException, KeyStoreException { CertificateFactory x509CertFactory; @@ -339,30 +339,20 @@ private static void loadKeyStore(KeyStore keyStore, InputStream in) throw mkAssert("Couldn't initialize X.509 CertificateFactory", ex); } - DataInputStream din = new DataInputStream(in); - byte[] data = new byte[MaxCertLength]; - while (true) { - int length = din.readUnsignedShort(); - if (length == 0) break; - if (length > MaxCertLength) { - throw new LoadException("Invalid length for certificate entry: " + length); - } - din.readFully(data, 0, length); - X509Certificate cert; - try { - cert = (X509Certificate) x509CertFactory.generateCertificate(new ByteArrayInputStream(data, 0, length)); - } catch (CertificateException ex) { - throw new LoadException("Error loading certificate: " + ex.getMessage()); - } + Collection certs; + try { + certs = (Collection) x509CertFactory.generateCertificates(in); + } catch (CertificateException ex) { + throw new LoadException("Error loading certificate: " + ex.getMessage(), ex); + } + + for (X509Certificate cert : certs) { String alias = cert.getSubjectX500Principal().getName(); try { keyStore.setCertificateEntry(alias, cert); } catch (KeyStoreException ex) { - throw new LoadException("Error loading certificate: " + ex.getMessage()); + throw new LoadException("Error loading certificate: " + ex.getMessage(), ex); } } - if (din.read() >= 0) { - throw new LoadException("Found data after after zero-length header."); - } } } diff --git a/src/main/java/com/dropbox/core/json/CompositeJsonDeserializer.java b/src/main/java/com/dropbox/core/json/CompositeJsonDeserializer.java deleted file mode 100644 index b8f79efdc..000000000 --- a/src/main/java/com/dropbox/core/json/CompositeJsonDeserializer.java +++ /dev/null @@ -1,195 +0,0 @@ -package com.dropbox.core.json; - -import com.fasterxml.jackson.core.JsonLocation; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.fasterxml.jackson.databind.deser.ResolvableDeserializer; -import com.fasterxml.jackson.databind.util.NameTransformer; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonMappingException; - -import java.io.IOException; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -public abstract class CompositeJsonDeserializer extends StdDeserializer - implements ResolvableDeserializer { - private static final long serialVersionUID = 0L; - - private final Map, JsonDeserializer> _deserializers; - - - protected CompositeJsonDeserializer(Class clazz, Class ... unwrappableClasses) { - super(clazz); - - this._deserializers = new HashMap, JsonDeserializer>(); - - for (Class unwrappableClass : unwrappableClasses) { - this._deserializers.put(unwrappableClass, null); - } - } - - @Override - public void resolve(DeserializationContext ctx) { - for (Class clazz : new ArrayList>(_deserializers.keySet())) { - _deserializers.put(clazz, getUnwrappingDeserializer(clazz, ctx)); - } - } - - private JsonDeserializer getUnwrappingDeserializer(Class clazz) { - JsonDeserializer deserializer = _deserializers.get(clazz); - if (deserializer == null) { - throw new IllegalArgumentException("Unwrappable " + clazz + " not resolved."); - } - return deserializer; - } - - protected X readCollapsedStructValue(Class structClass, JsonParser p, DeserializationContext ctx) throws IOException, JsonParseException { - Object obj = getUnwrappingDeserializer(structClass).deserialize(p, ctx); - if (obj == null) { - return null; - } - - if (structClass.isInstance(obj)) { - return structClass.cast(obj); - } - - throw new JsonParseException( - p, - "unexpected type deserialized, expected " + structClass + ", but was " + obj.getClass() - ); - } - - protected static boolean hasTag(JsonParser parser) throws IOException, JsonParseException { - return parser.getCurrentToken() == JsonToken.FIELD_NAME && ".tag".equals(parser.getCurrentName()); - } - - protected static String readTag(JsonParser parser) throws IOException, JsonParseException { - if (!hasTag(parser)) { - throw new JsonParseException(parser, "required tag field \".tag\" missing"); - } - - if (parser.nextToken() != JsonToken.VALUE_STRING) { - throw new JsonParseException(parser, "expected a string value for .tag field"); - } - - String tag = parser.getText(); - parser.nextToken(); - - return tag; - } - - protected static String readEnumeratedSubtypeTag(JsonParser parser, String ... ancestors) throws IOException, JsonParseException { - // nothing to do here, fall back to parsing whatever we can - if (!hasTag(parser)) { - return null; - } - - String tag = readTag(parser); - String [] parts = tag.split("\\."); - - if (parts.length < ancestors.length) { - throw new JsonParseException(parser, "unexpected tag \"" + tag + "\""); - } - - for (int i = 0; i < ancestors.length; ++i) { - if (!parts[i].equals(ancestors[i])) { - throw new JsonParseException(parser, "unexpected tag \"" + tag + "\""); - } - } - - if (parts.length == ancestors.length) { - // this is the end of the ancestor, hiearchy. The caller must be the specific subtype - // that must perform the deserialization. - return null; - } else { - return parts[ancestors.length]; - } - } - - protected static String getStringValue(JsonParser parser) throws IOException, JsonParseException { - if (parser.getCurrentToken() != JsonToken.VALUE_STRING) { - throw new JsonParseException(parser, "expected string value."); - } - return parser.getText(); - } - - protected static void assertUnsigned(JsonParser parser, Number num) throws JsonParseException { - if (num.longValue() < 0) { - throw new JsonParseException(parser, "expected an unsigned number, got: " + num); - } - } - - protected static void expectField(JsonParser parser, String name) throws IOException, JsonParseException { - if (parser.getCurrentToken() != JsonToken.FIELD_NAME) { - throw new JsonParseException(parser, "expected field with name \"" + name + "\""); - } - parser.nextToken(); - } - - protected static void expectObjectStart(JsonParser parser) throws IOException, JsonParseException { - if (!isObjectStart(parser)) { - throw new JsonParseException(parser, "expecting the start of an object (\"{\")"); - } - parser.nextToken(); - } - - protected static void expectObjectEnd(JsonParser parser) throws IOException, JsonParseException { - if (!isObjectEnd(parser)) { - throw new JsonParseException(parser, "expecting the end of an object (\"}\")"); - } - // do not iterate to next token. convention is to leave cursor at end of parsed object. - } - - protected static void expectArrayStart(JsonParser parser) throws IOException, JsonParseException { - if (!isArrayStart(parser)) { - throw new JsonParseException(parser, "expecting the start of an array (\"[\")"); - } - parser.nextToken(); - } - - protected static void expectArrayEnd(JsonParser parser) throws IOException, JsonParseException { - if (!isArrayEnd(parser)) { - throw new JsonParseException(parser, "expecting the end of an array (\"[\")"); - } - // do not iterate to next token. convention is to leave cursor at end of parsed object. - } - - protected static boolean isArrayEnd(JsonParser parser) { - return (parser.getCurrentToken() == JsonToken.END_ARRAY); - } - - protected static boolean isArrayStart(JsonParser parser) { - return (parser.getCurrentToken() == JsonToken.START_ARRAY); - } - - protected static boolean isObjectEnd(JsonParser parser) { - return (parser.getCurrentToken() == JsonToken.END_OBJECT); - } - - protected static boolean isObjectStart(JsonParser parser) { - return (parser.getCurrentToken() == JsonToken.START_OBJECT); - } - - protected static void skipValue(JsonParser parser) throws IOException, JsonParseException { - parser.skipChildren(); - parser.nextToken(); - } - - private static JsonDeserializer getUnwrappingDeserializer(Class clazz, DeserializationContext ctx) { - JsonDeserializer deserializer = null; - try { - deserializer = ctx.findRootValueDeserializer(ctx.constructType(clazz)) - .unwrappingDeserializer(NameTransformer.NOP); - } catch (JsonMappingException ex) { - throw new IllegalArgumentException("Unable to find deserializer for: " + clazz, ex); - } - - return deserializer; - } -} diff --git a/src/main/java/com/dropbox/core/json/JsonUtil.java b/src/main/java/com/dropbox/core/json/JsonUtil.java deleted file mode 100644 index fddcb5dc1..000000000 --- a/src/main/java/com/dropbox/core/json/JsonUtil.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.dropbox.core.json; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.core.Base64Variants; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; - -import java.text.DateFormat; -import java.text.FieldPosition; -import java.text.ParseException; -import java.text.ParsePosition; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.TimeZone; - -public final class JsonUtil { - private static final TimeZone UTC = TimeZone.getTimeZone("UTC"); - private static final String DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; - private static final String DATE_FORMAT = "yyyy-MM-dd"; - - private static final ObjectMapper MAPPER = createMapper(false); - private static final ObjectMapper MAPPER_PRETTY = createMapper(true); - - private static ObjectMapper createMapper(boolean prettyPrint) { - DateFormat df = new BabelDateFormat(); - df.setTimeZone(UTC); - df.setLenient(false); - - ObjectMapper mapper = new ObjectMapper() - .setTimeZone(UTC) - .setDateFormat(df) - .setBase64Variant(Base64Variants.MIME_NO_LINEFEEDS); - - if (prettyPrint) { - mapper.enable(SerializationFeature.INDENT_OUTPUT); - } - - return mapper; - } - - public static ObjectMapper getMapper() { - return getMapper(false); - } - - public static ObjectMapper getMapper(boolean prettyPrint) { - if (prettyPrint) { - return MAPPER_PRETTY; - } else{ - return MAPPER; - } - } - - public static JavaType createType(TypeReference typeReference) { - return MAPPER.getTypeFactory().constructType(typeReference); - } - - public static JavaType createType(Class clazz) { - return MAPPER.getTypeFactory().constructType(clazz); - } - - private static final class BabelDateFormat extends SimpleDateFormat { - private static final long serialVersionUID = 0L; - private static final int LONG_FORMAT_LENGTH = DATE_TIME_FORMAT.replace("'", "").length(); - private static final int SHORT_FORMAT_LENGTH = DATE_FORMAT.replace("'", "").length(); - - private DateFormat shortFormat; - - public BabelDateFormat() { - super(DATE_TIME_FORMAT); - this.shortFormat = new SimpleDateFormat(DATE_FORMAT); - } - - @Override - public Object clone() { - BabelDateFormat other = (BabelDateFormat) super.clone(); - other.shortFormat = (DateFormat) shortFormat.clone(); - return other; - } - - @Override - public Date parse(String source, ParsePosition pos) { - int dateLength = source.length() - pos.getIndex(); - if (dateLength == LONG_FORMAT_LENGTH) { - return super.parse(source, pos); - } else if (dateLength == SHORT_FORMAT_LENGTH) { - return shortFormat.parse(source, pos); - } else { - pos.setErrorIndex(Math.min(source.length(), pos.getIndex() + LONG_FORMAT_LENGTH + 1)); - return null; - } - } - - @Override - public void setCalendar(Calendar newCalendar) { - super.setCalendar(newCalendar); - shortFormat.setCalendar(newCalendar); - } - - @Override - public void setLenient(boolean lenient) { - super.setLenient(lenient); - shortFormat.setLenient(lenient); - } - - @Override - public void setTimeZone(TimeZone zone) { - super.setTimeZone(zone); - shortFormat.setTimeZone(zone); - } - } -} diff --git a/src/main/java/com/dropbox/core/json/StructJsonDeserializer.java b/src/main/java/com/dropbox/core/json/StructJsonDeserializer.java deleted file mode 100644 index b20856d4b..000000000 --- a/src/main/java/com/dropbox/core/json/StructJsonDeserializer.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.dropbox.core.json; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.fasterxml.jackson.databind.util.NameTransformer; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonDeserializer; - -import java.io.IOException; - -public abstract class StructJsonDeserializer extends CompositeJsonDeserializer { - private static final long serialVersionUID = 0L; - - private final boolean unwrapping; - - protected StructJsonDeserializer(Class clazz, Class ... subtypeClasses) { - this(clazz, false, subtypeClasses); - } - - protected StructJsonDeserializer(Class clazz, boolean unwrapping, Class ... subtypeClasses) { - super(clazz, subtypeClasses); - - this.unwrapping = unwrapping; - } - - @Override - public JsonDeserializer unwrappingDeserializer(NameTransformer unwrapper) { - return asUnwrapping(); - } - - /** - * Override this method to support generating unwrapped JSON - * (e.g. JSON not wrapped in object brackets, {}). - */ - protected JsonDeserializer asUnwrapping() { - throw new IllegalStateException(getClass().toString() + " does not support unwrapping."); - } - - @Override - public final T deserialize(JsonParser p, DeserializationContext ctx) throws IOException, JsonParseException { - if (!unwrapping) { - expectObjectStart(p); - } - - T instance = deserializeFields(p, ctx); - - if (!unwrapping) { - expectObjectEnd(p); - } - - return instance; - } - - protected abstract T deserializeFields(JsonParser p, DeserializationContext ctx) throws IOException, JsonParseException; -} diff --git a/src/main/java/com/dropbox/core/json/StructJsonSerializer.java b/src/main/java/com/dropbox/core/json/StructJsonSerializer.java deleted file mode 100644 index 1840f1268..000000000 --- a/src/main/java/com/dropbox/core/json/StructJsonSerializer.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.dropbox.core.json; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; -import com.fasterxml.jackson.databind.util.NameTransformer; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; - -import java.io.IOException; - -public abstract class StructJsonSerializer extends StdSerializer { - private static final long serialVersionUID = 0L; - - private final boolean unwrapping; - - protected StructJsonSerializer(Class clazz) { - this(clazz, false); - } - - protected StructJsonSerializer(Class clazz, boolean unwrapping) { - super(clazz); - - this.unwrapping = unwrapping; - } - - @Override - public boolean isUnwrappingSerializer() { - return unwrapping; - } - - @Override - public JsonSerializer unwrappingSerializer(NameTransformer unwrapper) { - return asUnwrapping(); - } - - /** - * Override this method to support generating unwrapped JSON - * (e.g. JSON not wrapped in object brackets, {}). - */ - protected JsonSerializer asUnwrapping() { - throw new IllegalStateException(getClass().toString() + " does not support unwrapping."); - } - - @Override - public final void serialize(T value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - if (!unwrapping) { - g.writeStartObject(); - } - - serializeFields(value, g, provider); - - if (!unwrapping) { - g.writeEndObject(); - } - } - - protected abstract void serializeFields(T value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException; -} diff --git a/src/main/java/com/dropbox/core/json/UnionJsonDeserializer.java b/src/main/java/com/dropbox/core/json/UnionJsonDeserializer.java deleted file mode 100644 index cc6b3ecb8..000000000 --- a/src/main/java/com/dropbox/core/json/UnionJsonDeserializer.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.dropbox.core.json; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.fasterxml.jackson.databind.DeserializationContext; - -import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -public abstract class UnionJsonDeserializer> extends CompositeJsonDeserializer { - private static final long serialVersionUID = 0L; - - private final Map _tagMapping; - private final T _catchAll; - - protected UnionJsonDeserializer(Class clazz, - Map tagMapping, - T catchAll, - Class ... unwrappableFieldClasses - ) { - super(clazz, unwrappableFieldClasses); - - if (tagMapping == null) { - throw new NullPointerException("tagMapping"); - } - - this._tagMapping = Collections.unmodifiableMap(new HashMap(tagMapping)); - this._catchAll = catchAll; - } - - protected abstract V deserialize(T tag, JsonParser p, DeserializationContext ctx) throws IOException, JsonParseException; - - @Override - public V deserialize(JsonParser p, DeserializationContext ctx) throws IOException, JsonParseException { - V value; - if (p.getCurrentToken() == JsonToken.VALUE_STRING) { - T tag = parseTag(p, p.getText()); - value = deserialize(tag, p, ctx); - } else { - expectObjectStart(p); - T tag = parseTag(p, readTag(p)); - value = deserialize(tag, p, ctx); - expectObjectEnd(p); - } - return value; - } - - private T parseTag(JsonParser p, String value) throws IOException, JsonParseException { - T tag = _tagMapping.get(value); - - if (tag == null) { - if (_catchAll == null) { - throw new JsonParseException(p, "Unanticipated tag " + value + " without catch-all"); - } else { - tag = _catchAll; - } - } - - return tag; - } -} diff --git a/src/main/java/com/dropbox/core/json/UnionJsonSerializer.java b/src/main/java/com/dropbox/core/json/UnionJsonSerializer.java deleted file mode 100644 index 0f3decda0..000000000 --- a/src/main/java/com/dropbox/core/json/UnionJsonSerializer.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.dropbox.core.json; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; -import com.fasterxml.jackson.databind.ser.ResolvableSerializer; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.util.NameTransformer; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -public abstract class UnionJsonSerializer extends StdSerializer implements ResolvableSerializer { - private static final long serialVersionUID = 0L; - - private final Map, JsonSerializer> _serializers; - - protected UnionJsonSerializer(Class clazz, Class ... unwrappableFieldClasses) { - super(clazz); - this._serializers = new HashMap, JsonSerializer>(); - - for (Class fieldClass : unwrappableFieldClasses) { - _serializers.put(fieldClass, null); - } - } - - @Override - public void resolve(SerializerProvider provider) { - for (Class clazz : new ArrayList>(_serializers.keySet())) { - _serializers.put(clazz, getUnwrappingSerializer(clazz, provider)); - } - } - - protected JsonSerializer getUnwrappingSerializer(Class fieldClass) { - JsonSerializer serializer = _serializers.get(fieldClass); - if (serializer == null) { - throw new IllegalArgumentException("Field class " + fieldClass + " not resolved."); - } - return serializer; - } - - @Override - public abstract void serialize(T value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException; - - private static JsonSerializer getUnwrappingSerializer(Class clazz, SerializerProvider provider) { - JsonSerializer serializer = null; - try { - serializer = provider.findValueSerializer(clazz) - .unwrappingSerializer(NameTransformer.NOP); - } catch (JsonMappingException ex) { - throw new IllegalArgumentException("Unable to find serializer for: " + clazz, ex); - } - - if (!serializer.isUnwrappingSerializer()) { - throw new IllegalArgumentException("Serializer for " + clazz + " does not support unwrapping."); - } - - return serializer; - } -} diff --git a/src/main/java/com/dropbox/core/stone/CompositeSerializer.java b/src/main/java/com/dropbox/core/stone/CompositeSerializer.java new file mode 100644 index 000000000..acad464ba --- /dev/null +++ b/src/main/java/com/dropbox/core/stone/CompositeSerializer.java @@ -0,0 +1,35 @@ +package com.dropbox.core.stone; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + +public abstract class CompositeSerializer extends StoneSerializer { + protected static final String TAG_FIELD = ".tag"; + + protected static boolean hasTag(JsonParser p) throws IOException, JsonParseException { + return p.getCurrentToken() == JsonToken.FIELD_NAME && TAG_FIELD.equals(p.getCurrentName()); + } + + protected static String readTag(JsonParser p) throws IOException, JsonParseException { + if (!hasTag(p)) { + return null; + } + p.nextToken(); + String tag = getStringValue(p); + p.nextToken(); + + return tag; + } + + protected void writeTag(String tag, JsonGenerator g) throws IOException, JsonGenerationException { + if (tag != null) { + g.writeStringField(TAG_FIELD, tag); + } + } +} + diff --git a/src/main/java/com/dropbox/core/stone/StoneSerializer.java b/src/main/java/com/dropbox/core/stone/StoneSerializer.java new file mode 100644 index 000000000..cb643f8c9 --- /dev/null +++ b/src/main/java/com/dropbox/core/stone/StoneSerializer.java @@ -0,0 +1,140 @@ +package com.dropbox.core.stone; + +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.charset.Charset; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + +public abstract class StoneSerializer { + private static final Charset UTF8 = Charset.forName("UTF-8"); + + public String serialize(T value) { + return serialize(value, false); + } + + public String serialize(T value, boolean pretty) { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + try { + serialize(value, out, pretty); + } catch (JsonGenerationException ex) { + throw new IllegalStateException("Impossible JSON exception", ex); + } catch (IOException ex) { + throw new IllegalStateException("Impossible I/O exception", ex); + } + return new String(out.toByteArray(), UTF8); + } + + public void serialize(T value, OutputStream out) throws IOException { + serialize(value, out, false); + } + + public void serialize(T value, OutputStream out, boolean pretty) throws IOException { + JsonGenerator g = Util.JSON.createGenerator(out); + if (pretty) { + g.useDefaultPrettyPrinter(); + } + try { + serialize(value, g); + } catch (JsonGenerationException ex) { + throw new IllegalStateException("Impossible JSON generation exception", ex); + } + g.flush(); + } + + public T deserialize(String json) throws JsonParseException { + try { + JsonParser p = Util.JSON.createParser(json); + p.nextToken(); + return deserialize(p); + } catch (JsonParseException ex) { + throw ex; + } catch (IOException ex) { + throw new IllegalStateException("Impossible I/O exception", ex); + } + } + + public T deserialize(InputStream json) throws IOException, JsonParseException { + JsonParser p = Util.JSON.createParser(json); + p.nextToken(); + return deserialize(p); + } + + public abstract void serialize(T value, JsonGenerator g) throws IOException, JsonGenerationException; + public abstract T deserialize(JsonParser p) throws IOException, JsonParseException; + + protected static String getStringValue(JsonParser p) throws IOException, JsonParseException { + if (p.getCurrentToken() != JsonToken.VALUE_STRING) { + throw new JsonParseException(p, "expected string value, but was " + p.getCurrentToken()); + } + return p.getText(); + } + + protected static void expectField(String name, JsonParser p) throws IOException, JsonParseException { + if (p.getCurrentToken() != JsonToken.FIELD_NAME) { + throw new JsonParseException(p, "expected field name, but was: " + p.getCurrentToken()); + } + if (!name.equals(p.getCurrentName())) { + throw new JsonParseException(p, "expected field '" + name + "', but was: '" + p.getCurrentName() + "'"); + } + p.nextToken(); + } + + protected static void expectStartObject(JsonParser p) throws IOException, JsonParseException { + if (p.getCurrentToken() != JsonToken.START_OBJECT) { + throw new JsonParseException(p, "expected object value."); + } + p.nextToken(); + } + + protected static void expectEndObject(JsonParser p) throws IOException, JsonParseException { + if (p.getCurrentToken() != JsonToken.END_OBJECT) { + throw new JsonParseException(p, "expected end of object value."); + } + p.nextToken(); + } + + protected static void expectStartArray(JsonParser p) throws IOException, JsonParseException { + if (p.getCurrentToken() != JsonToken.START_ARRAY) { + throw new JsonParseException(p, "expected array value."); + } + p.nextToken(); + } + + protected static void expectEndArray(JsonParser p) throws IOException, JsonParseException { + if (p.getCurrentToken() != JsonToken.END_ARRAY) { + throw new JsonParseException(p, "expected end of array value."); + } + p.nextToken(); + } + + protected static void skipValue(JsonParser p) throws IOException, JsonParseException { + if (p.getCurrentToken().isStructStart()) { + p.skipChildren(); + } else if (p.getCurrentToken().isScalarValue()) { + p.nextToken(); + } else { + throw new JsonParseException(p, "Can't skip JSON value token: " + p.getCurrentToken()); + } + } + + protected static void skipFields(JsonParser p) throws IOException, JsonParseException { + while (p.getCurrentToken() != null && !p.getCurrentToken().isStructEnd()) { + if (p.getCurrentToken().isStructStart()) { + p.skipChildren(); + } else if (p.getCurrentToken() == JsonToken.FIELD_NAME) { + p.nextToken(); + } else if (p.getCurrentToken().isScalarValue()) { + p.nextToken(); + } else { + throw new JsonParseException(p, "Can't skip token: " + p.getCurrentToken()); + } + } + } +} diff --git a/src/main/java/com/dropbox/core/stone/StoneSerializers.java b/src/main/java/com/dropbox/core/stone/StoneSerializers.java new file mode 100644 index 000000000..1f8c34b1e --- /dev/null +++ b/src/main/java/com/dropbox/core/stone/StoneSerializers.java @@ -0,0 +1,272 @@ +package com.dropbox.core.stone; + +import java.io.IOException; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + +public final class StoneSerializers { + + public static StoneSerializer uInt64() { + return LongSerializer.INSTANCE; + } + + public static StoneSerializer int64() { + return LongSerializer.INSTANCE; + } + + public static StoneSerializer uInt32() { + return LongSerializer.INSTANCE; + } + + public static StoneSerializer int32() { + return IntSerializer.INSTANCE; + } + + public static StoneSerializer float64() { + return DoubleSerializer.INSTANCE; + } + + public static StoneSerializer float32() { + return FloatSerializer.INSTANCE; + } + + public static StoneSerializer boolean_() { + return BooleanSerializer.INSTANCE; + } + + public static StoneSerializer binary() { + return ByteArraySerializer.INSTANCE; + } + + public static StoneSerializer string() { + return StringSerializer.INSTANCE; + } + + public static StoneSerializer timestamp() { + return DateSerializer.INSTANCE; + } + + public static StoneSerializer void_() { + return VoidSerializer.INSTANCE; + } + + public static StoneSerializer nullable(StoneSerializer underlying) { + return new NullableSerializer(underlying); + } + + public static StoneSerializer> list(StoneSerializer underlying) { + return new ListSerializer(underlying); + } + + + private static final class LongSerializer extends StoneSerializer { + public static final LongSerializer INSTANCE = new LongSerializer(); + + @Override + public void serialize(Long value, JsonGenerator g) throws IOException, JsonGenerationException { + g.writeNumber(value); + } + + @Override + public Long deserialize(JsonParser p) throws IOException, JsonParseException { + Long value = p.getLongValue(); + p.nextToken(); + return value; + } + } + + private static final class IntSerializer extends StoneSerializer { + public static final IntSerializer INSTANCE = new IntSerializer(); + + @Override + public void serialize(Integer value, JsonGenerator g) throws IOException, JsonGenerationException { + g.writeNumber(value); + } + + @Override + public Integer deserialize(JsonParser p) throws IOException, JsonParseException { + Integer value = p.getIntValue(); + p.nextToken(); + return value; + } + } + + private static final class DoubleSerializer extends StoneSerializer { + public static final DoubleSerializer INSTANCE = new DoubleSerializer(); + + @Override + public void serialize(Double value, JsonGenerator g) throws IOException, JsonGenerationException { + g.writeNumber(value); + } + + @Override + public Double deserialize(JsonParser p) throws IOException, JsonParseException { + Double value = p.getDoubleValue(); + p.nextToken(); + return value; + } + } + + private static final class FloatSerializer extends StoneSerializer { + public static final FloatSerializer INSTANCE = new FloatSerializer(); + + @Override + public void serialize(Float value, JsonGenerator g) throws IOException, JsonGenerationException { + g.writeNumber(value); + } + + @Override + public Float deserialize(JsonParser p) throws IOException, JsonParseException { + Float value = p.getFloatValue(); + p.nextToken(); + return value; + } + } + + private static final class BooleanSerializer extends StoneSerializer { + public static final BooleanSerializer INSTANCE = new BooleanSerializer(); + + @Override + public void serialize(Boolean value, JsonGenerator g) throws IOException, JsonGenerationException { + g.writeBoolean(value); + } + + @Override + public Boolean deserialize(JsonParser p) throws IOException, JsonParseException { + Boolean value = p.getBooleanValue(); + p.nextToken(); + return value; + } + } + + private static final class ByteArraySerializer extends StoneSerializer { + public static final ByteArraySerializer INSTANCE = new ByteArraySerializer(); + + @Override + public void serialize(byte [] value, JsonGenerator g) throws IOException, JsonGenerationException { + g.writeBinary(value); + } + + @Override + public byte [] deserialize(JsonParser p) throws IOException, JsonParseException { + byte [] value = p.getBinaryValue(); + p.nextToken(); + return value; + } + } + + private static final class StringSerializer extends StoneSerializer { + public static final StringSerializer INSTANCE = new StringSerializer(); + + @Override + public void serialize(String value, JsonGenerator g) throws IOException, JsonGenerationException { + g.writeString(value); + } + + @Override + public String deserialize(JsonParser p) throws IOException, JsonParseException { + String value = getStringValue(p); + p.nextToken(); + return value; + } + } + + private static final class DateSerializer extends StoneSerializer { + public static final DateSerializer INSTANCE = new DateSerializer(); + + @Override + public void serialize(Date value, JsonGenerator g) throws IOException, JsonGenerationException { + g.writeString(Util.formatTimestamp(value)); + } + + @Override + public Date deserialize(JsonParser p) throws IOException, JsonParseException { + String text = getStringValue(p); + p.nextToken(); + try { + return Util.parseTimestamp(text); + } catch (ParseException ex) { + throw new JsonParseException(p, "Malformed timestamp: '" + text + "'", ex); + } + } + } + + private static final class VoidSerializer extends StoneSerializer { + public static final VoidSerializer INSTANCE = new VoidSerializer(); + + @Override + public void serialize(Void value, JsonGenerator g) throws IOException, JsonGenerationException { + g.writeNull(); + } + + @Override + public Void deserialize(JsonParser p) throws IOException, JsonParseException { + skipValue(p); + return null; + } + } + + private static final class NullableSerializer extends StoneSerializer { + private final StoneSerializer underlying; + + public NullableSerializer(StoneSerializer underlying) { + this.underlying = underlying; + } + + @Override + public void serialize(T value, JsonGenerator g) throws IOException, JsonGenerationException { + if (value == null) { + g.writeNull(); + } else { + underlying.serialize(value, g); + } + } + + @Override + public T deserialize(JsonParser p) throws IOException, JsonParseException { + if (p.getCurrentToken() == JsonToken.VALUE_NULL) { + p.nextToken(); + return null; + } else { + return underlying.deserialize(p); + } + } + } + + private static final class ListSerializer extends StoneSerializer> { + private final StoneSerializer underlying; + + public ListSerializer(StoneSerializer underlying) { + this.underlying = underlying; + } + + @Override + public void serialize(List value, JsonGenerator g) throws IOException, JsonGenerationException { + g.writeStartArray(value.size()); + for (T elem : value) { + underlying.serialize(elem, g); + } + g.writeEndArray(); + } + + @Override + public List deserialize(JsonParser p) throws IOException, JsonParseException { + expectStartArray(p); + List list = new ArrayList(); + while (p.getCurrentToken() != JsonToken.END_ARRAY) { + T elem = underlying.deserialize(p); + list.add(elem); + } + expectEndArray(p); + return list; + } + } +} diff --git a/src/main/java/com/dropbox/core/stone/StructSerializer.java b/src/main/java/com/dropbox/core/stone/StructSerializer.java new file mode 100644 index 000000000..279205db6 --- /dev/null +++ b/src/main/java/com/dropbox/core/stone/StructSerializer.java @@ -0,0 +1,25 @@ +package com.dropbox.core.stone; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; + +public abstract class StructSerializer extends CompositeSerializer { + + @Override + public void serialize(T value, JsonGenerator g) throws IOException, JsonGenerationException { + serialize(value, g, false); + } + + public abstract void serialize(T value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException; + + @Override + public T deserialize(JsonParser p) throws IOException, JsonParseException { + return deserialize(p, false); + } + + public abstract T deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException; +} diff --git a/src/main/java/com/dropbox/core/stone/UnionSerializer.java b/src/main/java/com/dropbox/core/stone/UnionSerializer.java new file mode 100644 index 000000000..70702549c --- /dev/null +++ b/src/main/java/com/dropbox/core/stone/UnionSerializer.java @@ -0,0 +1,8 @@ +package com.dropbox.core.stone; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; + +public abstract class UnionSerializer extends CompositeSerializer {} diff --git a/src/main/java/com/dropbox/core/stone/Util.java b/src/main/java/com/dropbox/core/stone/Util.java new file mode 100644 index 000000000..46611a084 --- /dev/null +++ b/src/main/java/com/dropbox/core/stone/Util.java @@ -0,0 +1,42 @@ +package com.dropbox.core.stone; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +import com.fasterxml.jackson.core.JsonFactory; + +final class Util { + public static final JsonFactory JSON = new JsonFactory(); + + private static final TimeZone UTC = TimeZone.getTimeZone("UTC"); + private static final String DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; + private static final String DATE_FORMAT = "yyyy-MM-dd"; + private static final int LONG_FORMAT_LENGTH = DATE_TIME_FORMAT.replace("'", "").length(); + private static final int SHORT_FORMAT_LENGTH = DATE_FORMAT.replace("'", "").length(); + + public static String formatTimestamp(Date timestamp) { + DateFormat format = new SimpleDateFormat(DATE_TIME_FORMAT); + format.setCalendar(new GregorianCalendar(UTC)); + return format.format(timestamp); + } + + public static Date parseTimestamp(String timestamp) throws ParseException { + int length = timestamp.length(); + + DateFormat format = null; + if (length == LONG_FORMAT_LENGTH) { + format = new SimpleDateFormat(DATE_TIME_FORMAT); + } else if (length == SHORT_FORMAT_LENGTH) { + format = new SimpleDateFormat(DATE_FORMAT); + } else { + throw new ParseException("timestamp has unexpected format: '" + timestamp + "'", 0); + } + + format.setCalendar(new GregorianCalendar(UTC)); + return format.parse(timestamp); + } +} diff --git a/src/main/java/com/dropbox/core/v2/DbxAppClientV2Base.java b/src/main/java/com/dropbox/core/v2/DbxAppClientV2Base.java index a4c202d56..aaac5490e 100644 --- a/src/main/java/com/dropbox/core/v2/DbxAppClientV2Base.java +++ b/src/main/java/com/dropbox/core/v2/DbxAppClientV2Base.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated by Babel */ +/* This file was generated by Stone */ package com.dropbox.core.v2; diff --git a/src/main/java/com/dropbox/core/v2/DbxClientV2Base.java b/src/main/java/com/dropbox/core/v2/DbxClientV2Base.java index f0dd3640a..67439d73c 100644 --- a/src/main/java/com/dropbox/core/v2/DbxClientV2Base.java +++ b/src/main/java/com/dropbox/core/v2/DbxClientV2Base.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated by Babel */ +/* This file was generated by Stone */ package com.dropbox.core.v2; diff --git a/src/main/java/com/dropbox/core/v2/DbxDownloadStyleBuilder.java b/src/main/java/com/dropbox/core/v2/DbxDownloadStyleBuilder.java index 0b73234d8..e8cfda33c 100644 --- a/src/main/java/com/dropbox/core/v2/DbxDownloadStyleBuilder.java +++ b/src/main/java/com/dropbox/core/v2/DbxDownloadStyleBuilder.java @@ -1,9 +1,14 @@ package com.dropbox.core.v2; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import com.dropbox.core.DbxException; import com.dropbox.core.DbxDownloader; import com.dropbox.core.DbxStreamReader; import com.dropbox.core.NoThrowInputStream; +import com.dropbox.core.http.HttpRequestor; import com.dropbox.core.util.IOUtil; import java.io.IOException; @@ -52,6 +57,29 @@ * @param The return type of the {@link DbxDownloader} */ public abstract class DbxDownloadStyleBuilder { + private Long start; + private Long length; + + protected DbxDownloadStyleBuilder() { + this.start = null; + this.length = null; + } + + protected List getHeaders() { + if (start == null) { + return Collections.emptyList(); + } + + List headers = new ArrayList(); + String rangeValue = String.format("bytes=%d-", start.longValue()); + if (length != null) { + // Range header is inclusive (e.g. bytes=0-499 means first 500 bytes) + rangeValue += Long.toString(start.longValue() + length.longValue() - 1); + } + headers.add(new HttpRequestor.Header("Range", rangeValue)); + + return headers; + } /** * Issues the download request using this builder's request parameters and returns a {@link @@ -69,6 +97,55 @@ public abstract class DbxDownloadStyleBuilder { */ public abstract DbxDownloader start() throws DbxException; + /** + * Sets the partial byte range to download. + * + * Only the specified bytes of the content will be downloaded. The HTTP Range header will be set + * for this request. If {@code start} is greater than the length of the content, the range + * request will be ignored and server will return the entire contents. If {@code length} extends + * beyond the end of the cont`ent, the server will return all bytes from {@code start} until the + * end of the content. + * + * @param start index of first byte in range (index starts at 0) + * @param length number of bytes to download starting at {@code start} + * + * @return this builder + * + * @throws IllegalArgumentException if {@code start} or {@code length} are negative + */ + public DbxDownloadStyleBuilder range(long start, long length) { + if (start < 0) throw new IllegalArgumentException("start must be non-negative"); + if (length < 1) throw new IllegalArgumentException("length must be positive"); + + this.start = start; + this.length = length; + + return this; + } + + /** + * Sets the partial byte range to download. + * + * Only bytes from {@code start} (inclusive) until the end of the content will be + * downloaded. The HTTP Range header will be set for this request. If {@code start} is greater + * than the length of the content, the range request will be ignored and server will return the + * entire contents. + * + * @param start index of first byte in range (index starts at 0). All following bytes in the + * content will be downloaded. + * + * @return this builder + * + * @throws IllegalArgumentException if {@code start} is negative + */ + public DbxDownloadStyleBuilder range(long start) { + if (start < 0) throw new IllegalArgumentException("start must be non-negative"); + + this.start = start; + this.length = null; + + return this; + } /** * Convenience method for {@link DbxDownloader#download(OutputStream)}: diff --git a/src/main/java/com/dropbox/core/v2/DbxRawClientV2.java b/src/main/java/com/dropbox/core/v2/DbxRawClientV2.java index 159edf15f..65bbe9c0e 100644 --- a/src/main/java/com/dropbox/core/v2/DbxRawClientV2.java +++ b/src/main/java/com/dropbox/core/v2/DbxRawClientV2.java @@ -1,5 +1,7 @@ package com.dropbox.core.v2; +import static com.dropbox.core.DbxRequestUtil.addUserLocaleHeader; + import com.dropbox.core.BadResponseException; import com.dropbox.core.DbxDownloader; import com.dropbox.core.DbxException; @@ -8,17 +10,16 @@ import com.dropbox.core.DbxRequestUtil; import com.dropbox.core.DbxUploader; import com.dropbox.core.DbxWebAuth; +import com.dropbox.core.DbxWrappedException; import com.dropbox.core.NetworkIOException; import com.dropbox.core.RetryException; +import com.dropbox.core.stone.StoneSerializer; import com.dropbox.core.http.HttpRequestor; -import com.dropbox.core.json.JsonUtil; import com.dropbox.core.util.LangUtil; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -43,11 +44,10 @@ *

*/ public abstract class DbxRawClientV2 { - private static final JsonFactory JSON_FACTORY = new JsonFactory(); // The HTTP status codes returned for errors specific to particular API calls. - private final static List FUNCTION_SPECIFIC_ERROR_CODES = Arrays.asList(403, 404, 409); + private static final List FUNCTION_SPECIFIC_ERROR_CODES = Arrays.asList(403, 404, 409); private static final String USER_AGENT_ID = "OfficialDropboxJavaSDKv2"; - private static final ObjectMapper JSON = JsonUtil.getMapper(); + private static final JsonFactory JSON = new JsonFactory(); private final DbxRequestConfig requestConfig; private final DbxHost host; @@ -76,26 +76,32 @@ public ResT rpcStyle(final String host, final String path, final ArgT arg, final boolean noAuth, - final JavaType responseType, - final JavaType errorType) - throws DbxRequestUtil.ErrorWrapper, DbxException { + final StoneSerializer argSerializer, + final StoneSerializer responseSerializer, + final StoneSerializer errorSerializer) + throws DbxWrappedException, DbxException { - final byte [] body = writeAsBytes(arg); + final byte [] body = writeAsBytes(argSerializer, arg); final List headers = new ArrayList(); if (!noAuth) { addAuthHeaders(headers); } + if (!this.host.getNotify().equals(host)) { + // TODO(krieb): fix this ugliness + addUserLocaleHeader(headers, requestConfig); + } + headers.add(new HttpRequestor.Header("Content-Type", "application/json; charset=utf-8")); return executeRetriable(requestConfig.getMaxRetries(), new RetriableExecution () { @Override - public ResT execute() throws DbxRequestUtil.ErrorWrapper, DbxException { + public ResT execute() throws DbxWrappedException, DbxException { HttpRequestor.Response response = DbxRequestUtil.startPostRaw(requestConfig, USER_AGENT_ID, host, path, body, headers); try { if (response.getStatusCode() == 200) { - return JSON.readValue(response.getBody(), responseType); + return responseSerializer.deserialize(response.getBody()); } else if (FUNCTION_SPECIFIC_ERROR_CODES.contains(response.getStatusCode())) { - throw DbxRequestUtil.ErrorWrapper.fromResponse(errorType, response); + throw DbxWrappedException.fromResponse(errorSerializer, response); } else { throw DbxRequestUtil.unexpectedStatus(response); } @@ -113,27 +119,30 @@ public DbxDownloader downloadStyle(final String host, final String path, final ArgT arg, final boolean noAuth, - final JavaType responseType, - final JavaType errorType) - throws DbxRequestUtil.ErrorWrapper, DbxException { + final List extraHeaders, + final StoneSerializer argSerializer, + final StoneSerializer responseSerializer, + final StoneSerializer errorSerializer) + throws DbxWrappedException, DbxException { - final List headers = new ArrayList(); + final List headers = new ArrayList(extraHeaders); if (!noAuth) { addAuthHeaders(headers); } - headers.add(new HttpRequestor.Header("Dropbox-API-Arg", headerSafeJson(arg))); + addUserLocaleHeader(headers, requestConfig); + headers.add(new HttpRequestor.Header("Dropbox-API-Arg", headerSafeJson(argSerializer, arg))); headers.add(new HttpRequestor.Header("Content-Type", "")); final byte[] body = new byte[0]; return executeRetriable(requestConfig.getMaxRetries(), new RetriableExecution>() { @Override - public DbxDownloader execute() throws DbxRequestUtil.ErrorWrapper, DbxException { + public DbxDownloader execute() throws DbxWrappedException, DbxException { HttpRequestor.Response response = DbxRequestUtil.startPostRaw(requestConfig, USER_AGENT_ID, host, path, body, headers); String requestId = DbxRequestUtil.getRequestId(response); try { - if (response.getStatusCode() == 200) { + if (response.getStatusCode() == 200 || response.getStatusCode() == 206) { List resultHeaders = response.getHeaders().get("dropbox-api-result"); if (resultHeaders == null) { throw new BadResponseException(requestId, "Missing Dropbox-API-Result header; " + response.getHeaders()); @@ -146,10 +155,10 @@ public DbxDownloader execute() throws DbxRequestUtil.ErrorWrapper, DbxExce throw new BadResponseException(requestId, "Null Dropbox-API-Result header; " + response.getHeaders()); } - ResT result = JSON.readValue(resultHeader, responseType); + ResT result = responseSerializer.deserialize(resultHeader); return new DbxDownloader(result, response.getBody()); } else if (FUNCTION_SPECIFIC_ERROR_CODES.contains(response.getStatusCode())) { - throw DbxRequestUtil.ErrorWrapper.fromResponse(errorType, response); + throw DbxWrappedException.fromResponse(errorSerializer, response); } else { throw DbxRequestUtil.unexpectedStatus(response); } @@ -162,25 +171,24 @@ public DbxDownloader execute() throws DbxRequestUtil.ErrorWrapper, DbxExce }); } - private static byte [] writeAsBytes(T arg) throws DbxException { + private static byte [] writeAsBytes(StoneSerializer serializer, T arg) throws DbxException { + ByteArrayOutputStream out = new ByteArrayOutputStream(); try { - return JSON.writeValueAsBytes(arg); - } catch (JsonProcessingException ex) { - // should never happen - throw LangUtil.mkAssert("Failed to serialize argument", ex); + serializer.serialize(arg, out); } catch (IOException ex) { - throw new NetworkIOException(ex); + throw LangUtil.mkAssert("Impossible", ex); } + return out.toByteArray(); } - private static String headerSafeJson(T value) { + private static String headerSafeJson(StoneSerializer serializer, T value) { StringWriter out = new StringWriter(); try { - JsonGenerator g = JSON.getFactory().createGenerator(out); + JsonGenerator g = JSON.createGenerator(out); // Escape 0x7F, because it's not allowed in an HTTP header. // Escape all non-ASCII because the new HTTP spec recommends against non-ASCII in headers. g.setHighestNonEscapedChar(0x7E); - JSON.writeValue(g, value); + serializer.serialize(value, g); g.flush(); } catch (IOException ex) { throw LangUtil.mkAssert("Impossible", ex); @@ -188,7 +196,11 @@ private static String headerSafeJson(T value) { return out.toString(); } - public HttpRequestor.Uploader uploadStyle(String host, String path, ArgT arg, boolean noAuth) + public HttpRequestor.Uploader uploadStyle(String host, + String path, + ArgT arg, + boolean noAuth, + StoneSerializer argSerializer) throws DbxException { String uri = DbxRequestUtil.buildUri(host, path); @@ -196,9 +208,10 @@ public HttpRequestor.Uploader uploadStyle(String host, String path, ArgT if (!noAuth) { addAuthHeaders(headers); } + addUserLocaleHeader(headers, requestConfig); headers.add(new HttpRequestor.Header("Content-Type", "application/octet-stream")); headers = DbxRequestUtil.addUserAgentHeader(headers, requestConfig, USER_AGENT_ID); - headers.add(new HttpRequestor.Header("Dropbox-API-Arg", headerSafeJson(arg))); + headers.add(new HttpRequestor.Header("Dropbox-API-Arg", headerSafeJson(argSerializer, arg))); try { return requestConfig.getHttpRequestor().startPost(uri, headers); } @@ -233,7 +246,7 @@ public DbxHost getHost() { * behavior backwards compatibility in v1, we leave the old implementation in {@code * DbxRequestUtil} unchanged. */ - private static T executeRetriable(int maxRetries, RetriableExecution execution) throws DbxRequestUtil.ErrorWrapper, DbxException { + private static T executeRetriable(int maxRetries, RetriableExecution execution) throws DbxWrappedException, DbxException { if (maxRetries == 0) { return execution.execute(); } @@ -267,6 +280,6 @@ private static void sleepQuietly(long millis) { } private interface RetriableExecution { - T execute() throws DbxRequestUtil.ErrorWrapper, DbxException; + T execute() throws DbxWrappedException, DbxException; } } diff --git a/src/main/java/com/dropbox/core/v2/DbxTeamClientV2Base.java b/src/main/java/com/dropbox/core/v2/DbxTeamClientV2Base.java index 3dac02d87..3e66d3192 100644 --- a/src/main/java/com/dropbox/core/v2/DbxTeamClientV2Base.java +++ b/src/main/java/com/dropbox/core/v2/DbxTeamClientV2Base.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated by Babel */ +/* This file was generated by Stone */ package com.dropbox.core.v2; diff --git a/src/main/java/com/dropbox/core/v2/async/LaunchEmptyResult.java b/src/main/java/com/dropbox/core/v2/async/LaunchEmptyResult.java index 4a9ca1798..8d2a219ae 100644 --- a/src/main/java/com/dropbox/core/v2/async/LaunchEmptyResult.java +++ b/src/main/java/com/dropbox/core/v2/async/LaunchEmptyResult.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from async.babel */ +/* This file was generated from async.stone */ package com.dropbox.core.v2.async; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Result returned by methods that may either launch an asynchronous job or @@ -36,15 +24,9 @@ * methods will return {@code true}. You can use {@link #tag()} to determine the * tag associated with this instance.

*/ -@JsonSerialize(using=LaunchEmptyResult.Serializer.class) -@JsonDeserialize(using=LaunchEmptyResult.Deserializer.class) public final class LaunchEmptyResult { // union LaunchEmptyResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link LaunchEmptyResult}. */ @@ -198,7 +180,7 @@ else if (obj instanceof LaunchEmptyResult) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -210,70 +192,70 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(LaunchEmptyResult.class); - } + /** + * For internal use only. + */ + public static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(LaunchEmptyResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case ASYNC_JOB_ID: + public void serialize(LaunchEmptyResult value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case ASYNC_JOB_ID: { g.writeStartObject(); - g.writeStringField(".tag", "async_job_id"); - g.writeObjectField("async_job_id", value.asyncJobIdValue); + writeTag("async_job_id", g); + g.writeFieldName("async_job_id"); + StoneSerializers.string().serialize(value.asyncJobIdValue, g); g.writeEndObject(); break; - case COMPLETE: + } + case COMPLETE: { g.writeString("complete"); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(LaunchEmptyResult.class, getTagMapping(), null); - } - - @Override - public LaunchEmptyResult deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case ASYNC_JOB_ID: { - String value = null; - expectField(_p, "async_job_id"); - value = getStringValue(_p); - _p.nextToken(); - return LaunchEmptyResult.asyncJobId(value); } - case COMPLETE: { - return LaunchEmptyResult.COMPLETE; + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("complete", LaunchEmptyResult.Tag.COMPLETE); - return Collections.unmodifiableMap(values); + @Override + public LaunchEmptyResult deserialize(JsonParser p) throws IOException, JsonParseException { + LaunchEmptyResult value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("async_job_id".equals(tag)) { + String fieldValue = null; + expectField("async_job_id", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = LaunchEmptyResult.asyncJobId(fieldValue); + } + else if ("complete".equals(tag)) { + value = LaunchEmptyResult.COMPLETE; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/async/LaunchResultBase.java b/src/main/java/com/dropbox/core/v2/async/LaunchResultBase.java index 68e1970d4..707ed6d3a 100644 --- a/src/main/java/com/dropbox/core/v2/async/LaunchResultBase.java +++ b/src/main/java/com/dropbox/core/v2/async/LaunchResultBase.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from async.babel */ +/* This file was generated from async.stone */ package com.dropbox.core.v2.async; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Result returned by methods that launch an asynchronous job. A method who may @@ -37,15 +25,9 @@ * methods will return {@code true}. You can use {@link #tag()} to determine the * tag associated with this instance.

*/ -@JsonSerialize(using=LaunchResultBase.Serializer.class) -@JsonDeserialize(using=LaunchResultBase.Deserializer.class) public final class LaunchResultBase { // union LaunchResultBase - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link LaunchResultBase}. */ @@ -178,7 +160,7 @@ else if (obj instanceof LaunchResultBase) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -190,64 +172,63 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); + return Serializer.INSTANCE.serialize(this, true); } - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(LaunchResultBase.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(LaunchResultBase value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case ASYNC_JOB_ID: + public void serialize(LaunchResultBase value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case ASYNC_JOB_ID: { g.writeStartObject(); - g.writeStringField(".tag", "async_job_id"); - g.writeObjectField("async_job_id", value.asyncJobIdValue); + writeTag("async_job_id", g); + g.writeFieldName("async_job_id"); + StoneSerializers.string().serialize(value.asyncJobIdValue, g); g.writeEndObject(); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(LaunchResultBase.class, getTagMapping(), null); - } @Override - public LaunchResultBase deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case ASYNC_JOB_ID: { - String value = null; - expectField(_p, "async_job_id"); - value = getStringValue(_p); - _p.nextToken(); - return LaunchResultBase.asyncJobId(value); - } + public LaunchResultBase deserialize(JsonParser p) throws IOException, JsonParseException { + LaunchResultBase value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("async_job_id", LaunchResultBase.Tag.ASYNC_JOB_ID); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("async_job_id".equals(tag)) { + String fieldValue = null; + expectField("async_job_id", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = LaunchResultBase.asyncJobId(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/async/PollArg.java b/src/main/java/com/dropbox/core/v2/async/PollArg.java index dad5c7a40..0273ee1e6 100644 --- a/src/main/java/com/dropbox/core/v2/async/PollArg.java +++ b/src/main/java/com/dropbox/core/v2/async/PollArg.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from async.babel */ +/* This file was generated from async.stone */ package com.dropbox.core.v2.async; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Arguments for methods that poll the status of an asynchronous job. */ -@JsonSerialize(using=PollArg.Serializer.class) -@JsonDeserialize(using=PollArg.Deserializer.class) public class PollArg { // struct PollArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String asyncJobId; /** @@ -94,7 +77,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -106,78 +89,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(PollArg.class); - } - - public Serializer(boolean unwrapping) { - super(PollArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(PollArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("async_job_id", value.asyncJobId); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(PollArg.class); - } - - public Deserializer(boolean unwrapping) { - super(PollArg.class, unwrapping); - } + /** + * For internal use only. + */ + public static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(PollArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("async_job_id"); + StoneSerializers.string().serialize(value.asyncJobId, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public PollArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String asyncJobId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("async_job_id".equals(_field)) { - asyncJobId = getStringValue(_p); - _p.nextToken(); + public PollArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + PollArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_asyncJobId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("async_job_id".equals(field)) { + f_asyncJobId = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_asyncJobId == null) { + throw new JsonParseException(p, "Required field \"async_job_id\" missing."); } + value = new PollArg(f_asyncJobId); } - - if (asyncJobId == null) { - throw new JsonParseException(_p, "Required field \"async_job_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new PollArg(asyncJobId); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/async/PollEmptyResult.java b/src/main/java/com/dropbox/core/v2/async/PollEmptyResult.java index 424c13317..a689d533b 100644 --- a/src/main/java/com/dropbox/core/v2/async/PollEmptyResult.java +++ b/src/main/java/com/dropbox/core/v2/async/PollEmptyResult.java @@ -1,37 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from async.babel */ +/* This file was generated from async.stone */ package com.dropbox.core.v2.async; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Result returned by methods that poll for the status of an asynchronous job. * Upon completion of the job, no additional information is returned. */ -@JsonSerialize(using=PollEmptyResult.Serializer.class) -@JsonDeserialize(using=PollEmptyResult.Deserializer.class) public enum PollEmptyResult { // union PollEmptyResult /** @@ -43,46 +29,60 @@ public enum PollEmptyResult { */ COMPLETE; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(PollEmptyResult.class); - } + /** + * For internal use only. + */ + public static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(PollEmptyResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(PollEmptyResult value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case IN_PROGRESS: + case IN_PROGRESS: { g.writeString("in_progress"); break; - case COMPLETE: + } + case COMPLETE: { g.writeString("complete"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(PollEmptyResult.class, getTagMapping(), null); - } @Override - public PollEmptyResult deserialize(PollEmptyResult _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("complete", PollEmptyResult.COMPLETE); - return Collections.unmodifiableMap(values); + public PollEmptyResult deserialize(JsonParser p) throws IOException, JsonParseException { + PollEmptyResult value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("in_progress".equals(tag)) { + value = PollEmptyResult.IN_PROGRESS; + } + else if ("complete".equals(tag)) { + value = PollEmptyResult.COMPLETE; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/async/PollError.java b/src/main/java/com/dropbox/core/v2/async/PollError.java index 52cf412a5..6df367d54 100644 --- a/src/main/java/com/dropbox/core/v2/async/PollError.java +++ b/src/main/java/com/dropbox/core/v2/async/PollError.java @@ -1,36 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from async.babel */ +/* This file was generated from async.stone */ package com.dropbox.core.v2.async; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Error returned by methods for polling the status of asynchronous job. */ -@JsonSerialize(using=PollError.Serializer.class) -@JsonDeserialize(using=PollError.Deserializer.class) public enum PollError { // union PollError /** @@ -48,51 +34,61 @@ public enum PollError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(PollError.class); - } + /** + * For internal use only. + */ + public static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(PollError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(PollError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case INVALID_ASYNC_JOB_ID: + case INVALID_ASYNC_JOB_ID: { g.writeString("invalid_async_job_id"); break; - case INTERNAL_ERROR: + } + case INTERNAL_ERROR: { g.writeString("internal_error"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(PollError.class, getTagMapping(), PollError.OTHER); - } @Override - public PollError deserialize(PollError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("invalid_async_job_id", PollError.INVALID_ASYNC_JOB_ID); - values.put("internal_error", PollError.INTERNAL_ERROR); - values.put("other", PollError.OTHER); - return Collections.unmodifiableMap(values); + public PollError deserialize(JsonParser p) throws IOException, JsonParseException { + PollError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("invalid_async_job_id".equals(tag)) { + value = PollError.INVALID_ASYNC_JOB_ID; + } + else if ("internal_error".equals(tag)) { + value = PollError.INTERNAL_ERROR; + } + else { + value = PollError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/async/PollErrorException.java b/src/main/java/com/dropbox/core/v2/async/PollErrorException.java index 99f8a21dc..8394bf68a 100644 --- a/src/main/java/com/dropbox/core/v2/async/PollErrorException.java +++ b/src/main/java/com/dropbox/core/v2/async/PollErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from async.babel */ +/* This file was generated from async.stone */ package com.dropbox.core.v2.async; diff --git a/src/main/java/com/dropbox/core/v2/async/PollResultBase.java b/src/main/java/com/dropbox/core/v2/async/PollResultBase.java index 3f8c47831..05164f1ea 100644 --- a/src/main/java/com/dropbox/core/v2/async/PollResultBase.java +++ b/src/main/java/com/dropbox/core/v2/async/PollResultBase.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from async.babel */ +/* This file was generated from async.stone */ package com.dropbox.core.v2.async; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Result returned by methods that poll for the status of an asynchronous job. @@ -32,8 +20,6 @@ * the information returned upon job completion. See {@link PollEmptyResult} for * an example. */ -@JsonSerialize(using=PollResultBase.Serializer.class) -@JsonDeserialize(using=PollResultBase.Deserializer.class) public enum PollResultBase { // union PollResultBase /** @@ -41,43 +27,53 @@ public enum PollResultBase { */ IN_PROGRESS; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(PollResultBase.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(PollResultBase value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(PollResultBase value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case IN_PROGRESS: + case IN_PROGRESS: { g.writeString("in_progress"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(PollResultBase.class, getTagMapping(), null); - } @Override - public PollResultBase deserialize(PollResultBase _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("in_progress", PollResultBase.IN_PROGRESS); - return Collections.unmodifiableMap(values); + public PollResultBase deserialize(JsonParser p) throws IOException, JsonParseException { + PollResultBase value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("in_progress".equals(tag)) { + value = PollResultBase.IN_PROGRESS; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/async/package-info.java b/src/main/java/com/dropbox/core/v2/async/package-info.java index 4282e29d1..a242ac0bb 100644 --- a/src/main/java/com/dropbox/core/v2/async/package-info.java +++ b/src/main/java/com/dropbox/core/v2/async/package-info.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from async.babel */ +/* This file was generated from async.stone */ /** * See None for a list of possible requests for this namespace. diff --git a/src/main/java/com/dropbox/core/v2/auth/AuthError.java b/src/main/java/com/dropbox/core/v2/auth/AuthError.java index 432051a0f..2a10c0a30 100644 --- a/src/main/java/com/dropbox/core/v2/auth/AuthError.java +++ b/src/main/java/com/dropbox/core/v2/auth/AuthError.java @@ -1,36 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from auth.babel */ +/* This file was generated from auth.stone */ package com.dropbox.core.v2.auth; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Errors occurred during authentication. */ -@JsonSerialize(using=AuthError.Serializer.class) -@JsonDeserialize(using=AuthError.Deserializer.class) public enum AuthError { // union AuthError /** @@ -41,56 +27,78 @@ public enum AuthError { * The user specified in 'Dropbox-API-Select-User' is no longer on the team. */ INVALID_SELECT_USER, + /** + * The user specified in 'Dropbox-API-Select-Admin' is not a Dropbox + * Business team admin. + */ + INVALID_SELECT_ADMIN, /** * An unspecified error. */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(AuthError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(AuthError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(AuthError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case INVALID_ACCESS_TOKEN: + case INVALID_ACCESS_TOKEN: { g.writeString("invalid_access_token"); break; - case INVALID_SELECT_USER: + } + case INVALID_SELECT_USER: { g.writeString("invalid_select_user"); break; - case OTHER: - g.writeString("other"); + } + case INVALID_SELECT_ADMIN: { + g.writeString("invalid_select_admin"); break; + } + default: { + g.writeString("other"); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(AuthError.class, getTagMapping(), AuthError.OTHER); - } @Override - public AuthError deserialize(AuthError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("invalid_access_token", AuthError.INVALID_ACCESS_TOKEN); - values.put("invalid_select_user", AuthError.INVALID_SELECT_USER); - values.put("other", AuthError.OTHER); - return Collections.unmodifiableMap(values); + public AuthError deserialize(JsonParser p) throws IOException, JsonParseException { + AuthError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("invalid_access_token".equals(tag)) { + value = AuthError.INVALID_ACCESS_TOKEN; + } + else if ("invalid_select_user".equals(tag)) { + value = AuthError.INVALID_SELECT_USER; + } + else if ("invalid_select_admin".equals(tag)) { + value = AuthError.INVALID_SELECT_ADMIN; + } + else { + value = AuthError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/auth/DbxUserAuthRequests.java b/src/main/java/com/dropbox/core/v2/auth/DbxUserAuthRequests.java index fbfeb700d..2cc8d0e7a 100644 --- a/src/main/java/com/dropbox/core/v2/auth/DbxUserAuthRequests.java +++ b/src/main/java/com/dropbox/core/v2/auth/DbxUserAuthRequests.java @@ -1,18 +1,14 @@ /* DO NOT EDIT */ -/* This file was generated from auth.babel */ +/* This file was generated from auth.stone */ package com.dropbox.core.v2.auth; import com.dropbox.core.DbxApiException; import com.dropbox.core.DbxException; -import com.dropbox.core.DbxRequestUtil; +import com.dropbox.core.DbxWrappedException; import com.dropbox.core.http.HttpRequestor; -import com.dropbox.core.json.JsonUtil; import com.dropbox.core.v2.DbxRawClientV2; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JavaType; - import java.util.HashMap; import java.util.Map; @@ -41,11 +37,12 @@ public void tokenRevoke() throws DbxException { "2/auth/token/revoke", null, false, - JsonUtil.createType(Void.class), - JsonUtil.createType(Void.class)); + com.dropbox.core.stone.StoneSerializers.void_(), + com.dropbox.core.stone.StoneSerializers.void_(), + com.dropbox.core.stone.StoneSerializers.void_()); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new DbxApiException(ew.getRequestId(), ew.getUserMessage(), "Unexpected error response for \"token/revoke\": ew.errValue"); + catch (DbxWrappedException ex) { + throw new DbxApiException(ex.getRequestId(), ex.getUserMessage(), "Unexpected error response for \"token/revoke\":" + ex.getErrorValue()); } } } diff --git a/src/main/java/com/dropbox/core/v2/auth/package-info.java b/src/main/java/com/dropbox/core/v2/auth/package-info.java index fb5269523..b37a3e6ee 100644 --- a/src/main/java/com/dropbox/core/v2/auth/package-info.java +++ b/src/main/java/com/dropbox/core/v2/auth/package-info.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from auth.babel */ +/* This file was generated from auth.stone */ /** * See {@link com.dropbox.core.v2.auth.DbxUserAuthRequests} for a list of diff --git a/src/main/java/com/dropbox/core/v2/common/package-info.java b/src/main/java/com/dropbox/core/v2/common/package-info.java index b68deb72c..ac96d6ca2 100644 --- a/src/main/java/com/dropbox/core/v2/common/package-info.java +++ b/src/main/java/com/dropbox/core/v2/common/package-info.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated by Babel */ +/* This file was generated by Stone */ /** * See None for a list of possible requests for this namespace. diff --git a/src/main/java/com/dropbox/core/v2/files/CommitInfo.java b/src/main/java/com/dropbox/core/v2/files/CommitInfo.java index f30986088..da1d87704 100644 --- a/src/main/java/com/dropbox/core/v2/files/CommitInfo.java +++ b/src/main/java/com/dropbox/core/v2/files/CommitInfo.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.Date; -@JsonSerialize(using=CommitInfo.Serializer.class) -@JsonDeserialize(using=CommitInfo.Deserializer.class) public class CommitInfo { // struct CommitInfo - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String path; protected final WriteMode mode; protected final boolean autorename; @@ -46,7 +29,7 @@ public class CommitInfo { * specifying values for all optional fields. * * @param path Path in the user's Dropbox to save the file. Must match - * pattern "{@code /.*}" and not be {@code null}. + * pattern "{@code /(.|[\\r\\n])*}" and not be {@code null}. * @param mode Selects what to do if the file already exists. * @param autorename If there's a conflict, as determined by the {@code * mode} argument to {@link DbxUserFilesRequests#upload(String)}, have @@ -70,7 +53,7 @@ public CommitInfo(String path, WriteMode mode, boolean autorename, Date clientMo if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("/.*", path)) { + if (!java.util.regex.Pattern.matches("/(.|[\\r\\n])*", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -87,7 +70,7 @@ public CommitInfo(String path, WriteMode mode, boolean autorename, Date clientMo * The default values for unset fields will be used. * * @param path Path in the user's Dropbox to save the file. Must match - * pattern "{@code /.*}" and not be {@code null}. + * pattern "{@code /(.|[\\r\\n])*}" and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -158,7 +141,7 @@ public boolean getMute() { * Returns a new builder for creating an instance of this class. * * @param path Path in the user's Dropbox to save the file. Must match - * pattern "{@code /.*}" and not be {@code null}. + * pattern "{@code /(.|[\\r\\n])*}" and not be {@code null}. * * @return builder for this class. * @@ -184,7 +167,7 @@ protected Builder(String path) { if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("/.*", path)) { + if (!java.util.regex.Pattern.matches("/(.|[\\r\\n])*", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -325,7 +308,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -337,104 +320,85 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(CommitInfo.class); - } - - public Serializer(boolean unwrapping) { - super(CommitInfo.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(CommitInfo value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("path", value.path); - g.writeObjectField("mode", value.mode); - g.writeObjectField("autorename", value.autorename); + public void serialize(CommitInfo value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("path"); + StoneSerializers.string().serialize(value.path, g); + g.writeFieldName("mode"); + WriteMode.Serializer.INSTANCE.serialize(value.mode, g); + g.writeFieldName("autorename"); + StoneSerializers.boolean_().serialize(value.autorename, g); if (value.clientModified != null) { - g.writeObjectField("client_modified", value.clientModified); + g.writeFieldName("client_modified"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.clientModified, g); + } + g.writeFieldName("mute"); + StoneSerializers.boolean_().serialize(value.mute, g); + if (!collapse) { + g.writeEndObject(); } - g.writeObjectField("mute", value.mute); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(CommitInfo.class); - } - - public Deserializer(boolean unwrapping) { - super(CommitInfo.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public CommitInfo deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String path = null; - WriteMode mode = WriteMode.ADD; - boolean autorename = false; - Date clientModified = null; - boolean mute = false; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); - } - else if ("mode".equals(_field)) { - mode = _p.readValueAs(WriteMode.class); - _p.nextToken(); - } - else if ("autorename".equals(_field)) { - autorename = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("client_modified".equals(_field)) { - clientModified = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); - } - else if ("mute".equals(_field)) { - mute = _p.getValueAsBoolean(); - _p.nextToken(); + public CommitInfo deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + CommitInfo value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_path = null; + WriteMode f_mode = WriteMode.ADD; + Boolean f_autorename = false; + Date f_clientModified = null; + Boolean f_mute = false; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("path".equals(field)) { + f_path = StoneSerializers.string().deserialize(p); + } + else if ("mode".equals(field)) { + f_mode = WriteMode.Serializer.INSTANCE.deserialize(p); + } + else if ("autorename".equals(field)) { + f_autorename = StoneSerializers.boolean_().deserialize(p); + } + else if ("client_modified".equals(field)) { + f_clientModified = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else if ("mute".equals(field)) { + f_mute = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_path == null) { + throw new JsonParseException(p, "Required field \"path\" missing."); } + value = new CommitInfo(f_path, f_mode, f_autorename, f_clientModified, f_mute); } - - if (path == null) { - throw new JsonParseException(_p, "Required field \"path\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new CommitInfo(path, mode, autorename, clientModified, mute); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/CreateFolderArg.java b/src/main/java/com/dropbox/core/v2/files/CreateFolderArg.java index b8f2e4d82..19038f2de 100644 --- a/src/main/java/com/dropbox/core/v2/files/CreateFolderArg.java +++ b/src/main/java/com/dropbox/core/v2/files/CreateFolderArg.java @@ -1,45 +1,28 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=CreateFolderArg.Serializer.class) -@JsonDeserialize(using=CreateFolderArg.Deserializer.class) class CreateFolderArg { // struct CreateFolderArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String path; /** * * @param path Path in the user's Dropbox to create. Must match pattern - * "{@code /.*}" and not be {@code null}. + * "{@code /(.|[\\r\\n])*}" and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -48,7 +31,7 @@ public CreateFolderArg(String path) { if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("/.*", path)) { + if (!java.util.regex.Pattern.matches("/(.|[\\r\\n])*", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -88,7 +71,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -100,78 +83,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(CreateFolderArg.class); - } - - public Serializer(boolean unwrapping) { - super(CreateFolderArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(CreateFolderArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("path", value.path); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(CreateFolderArg.class); - } - - public Deserializer(boolean unwrapping) { - super(CreateFolderArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(CreateFolderArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("path"); + StoneSerializers.string().serialize(value.path, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public CreateFolderArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String path = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); + public CreateFolderArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + CreateFolderArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_path = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("path".equals(field)) { + f_path = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_path == null) { + throw new JsonParseException(p, "Required field \"path\" missing."); } + value = new CreateFolderArg(f_path); } - - if (path == null) { - throw new JsonParseException(_p, "Required field \"path\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new CreateFolderArg(path); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/CreateFolderError.java b/src/main/java/com/dropbox/core/v2/files/CreateFolderError.java index f9f2df8fa..af191a81b 100644 --- a/src/main/java/com/dropbox/core/v2/files/CreateFolderError.java +++ b/src/main/java/com/dropbox/core/v2/files/CreateFolderError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is a tagged union. Tagged unions instances are always associated @@ -32,15 +20,9 @@ * return {@code true}. You can use {@link #tag()} to determine the tag * associated with this instance. */ -@JsonSerialize(using=CreateFolderError.Serializer.class) -@JsonDeserialize(using=CreateFolderError.Deserializer.class) public final class CreateFolderError { // union CreateFolderError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link CreateFolderError}. */ @@ -152,7 +134,7 @@ else if (obj instanceof CreateFolderError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -164,64 +146,63 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); + return Serializer.INSTANCE.serialize(this, true); } - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(CreateFolderError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(CreateFolderError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case PATH: + public void serialize(CreateFolderError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PATH: { g.writeStartObject(); - g.writeStringField(".tag", "path"); - g.writeObjectField("path", value.pathValue); + writeTag("path", g); + g.writeFieldName("path"); + WriteError.Serializer.INSTANCE.serialize(value.pathValue, g); g.writeEndObject(); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(CreateFolderError.class, getTagMapping(), null); - } @Override - public CreateFolderError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case PATH: { - WriteError value = null; - expectField(_p, "path"); - value = _p.readValueAs(WriteError.class); - _p.nextToken(); - return CreateFolderError.path(value); - } + public CreateFolderError deserialize(JsonParser p) throws IOException, JsonParseException { + CreateFolderError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("path", CreateFolderError.Tag.PATH); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("path".equals(tag)) { + WriteError fieldValue = null; + expectField("path", p); + fieldValue = WriteError.Serializer.INSTANCE.deserialize(p); + value = CreateFolderError.path(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/CreateFolderErrorException.java b/src/main/java/com/dropbox/core/v2/files/CreateFolderErrorException.java index ed648e7ba..fecc61fd9 100644 --- a/src/main/java/com/dropbox/core/v2/files/CreateFolderErrorException.java +++ b/src/main/java/com/dropbox/core/v2/files/CreateFolderErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; diff --git a/src/main/java/com/dropbox/core/v2/files/DbxUserFilesRequests.java b/src/main/java/com/dropbox/core/v2/files/DbxUserFilesRequests.java index 2fc19da4c..b7e4b507c 100644 --- a/src/main/java/com/dropbox/core/v2/files/DbxUserFilesRequests.java +++ b/src/main/java/com/dropbox/core/v2/files/DbxUserFilesRequests.java @@ -1,23 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; import com.dropbox.core.DbxApiException; import com.dropbox.core.DbxDownloader; import com.dropbox.core.DbxException; -import com.dropbox.core.DbxRequestUtil; import com.dropbox.core.DbxUploader; +import com.dropbox.core.DbxWrappedException; import com.dropbox.core.http.HttpRequestor; -import com.dropbox.core.json.JsonUtil; import com.dropbox.core.v2.DbxDownloadStyleBuilder; import com.dropbox.core.v2.DbxRawClientV2; import com.dropbox.core.v2.DbxUploadStyleBuilder; +import com.dropbox.core.v2.async.PollArg; +import com.dropbox.core.v2.async.PollErrorException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JavaType; - +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -49,11 +49,12 @@ Metadata copy(RelocationArg relocationArg) throws RelocationErrorException, DbxE "2/files/copy", relocationArg, false, - JsonUtil.createType(Metadata.class), - JsonUtil.createType(RelocationError.class)); + RelocationArg.Serializer.INSTANCE, + Metadata.Serializer.INSTANCE, + RelocationError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new RelocationErrorException(ew.getRequestId(), ew.getUserMessage(), (RelocationError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new RelocationErrorException(ex.getRequestId(), ex.getUserMessage(), (RelocationError) ex.getErrorValue()); } } @@ -62,9 +63,9 @@ Metadata copy(RelocationArg relocationArg) throws RelocationErrorException, DbxE * the source path is a folder all its contents will be copied. * * @param fromPath Path in the user's Dropbox to be copied or moved. Must - * match pattern "{@code /.*}" and not be {@code null}. + * match pattern "{@code /(.|[\\r\\n])*}" and not be {@code null}. * @param toPath Path in the user's Dropbox that is the destination. Must - * match pattern "{@code /.*}" and not be {@code null}. + * match pattern "{@code /(.|[\\r\\n])*}" and not be {@code null}. * * @return Metadata for a file or folder. * @@ -92,11 +93,12 @@ GetCopyReferenceResult copyReferenceGet(GetCopyReferenceArg getCopyReferenceArg) "2/files/copy_reference/get", getCopyReferenceArg, false, - JsonUtil.createType(GetCopyReferenceResult.class), - JsonUtil.createType(GetCopyReferenceError.class)); + GetCopyReferenceArg.Serializer.INSTANCE, + GetCopyReferenceResult.Serializer.INSTANCE, + GetCopyReferenceError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new GetCopyReferenceErrorException(ew.getRequestId(), ew.getUserMessage(), (GetCopyReferenceError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new GetCopyReferenceErrorException(ex.getRequestId(), ex.getUserMessage(), (GetCopyReferenceError) ex.getErrorValue()); } } @@ -107,7 +109,7 @@ GetCopyReferenceResult copyReferenceGet(GetCopyReferenceArg getCopyReferenceArg) * * @param path The path to the file or folder you want to get a copy * reference to. Must match pattern "{@code - * ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -132,11 +134,12 @@ SaveCopyReferenceResult copyReferenceSave(SaveCopyReferenceArg saveCopyReference "2/files/copy_reference/save", saveCopyReferenceArg, false, - JsonUtil.createType(SaveCopyReferenceResult.class), - JsonUtil.createType(SaveCopyReferenceError.class)); + SaveCopyReferenceArg.Serializer.INSTANCE, + SaveCopyReferenceResult.Serializer.INSTANCE, + SaveCopyReferenceError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new SaveCopyReferenceErrorException(ew.getRequestId(), ew.getUserMessage(), (SaveCopyReferenceError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new SaveCopyReferenceErrorException(ex.getRequestId(), ex.getUserMessage(), (SaveCopyReferenceError) ex.getErrorValue()); } } @@ -148,7 +151,7 @@ SaveCopyReferenceResult copyReferenceSave(SaveCopyReferenceArg saveCopyReference * DbxUserFilesRequests#copyReferenceGet(String)}. Must not be {@code * null}. * @param path Path in the user's Dropbox that is the destination. Must - * match pattern "{@code /.*}" and not be {@code null}. + * match pattern "{@code /(.|[\\r\\n])*}" and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -172,11 +175,12 @@ FolderMetadata createFolder(CreateFolderArg createFolderArg) throws CreateFolder "2/files/create_folder", createFolderArg, false, - JsonUtil.createType(FolderMetadata.class), - JsonUtil.createType(CreateFolderError.class)); + CreateFolderArg.Serializer.INSTANCE, + FolderMetadata.Serializer.INSTANCE, + CreateFolderError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new CreateFolderErrorException(ew.getRequestId(), ew.getUserMessage(), (CreateFolderError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new CreateFolderErrorException(ex.getRequestId(), ex.getUserMessage(), (CreateFolderError) ex.getErrorValue()); } } @@ -184,7 +188,7 @@ FolderMetadata createFolder(CreateFolderArg createFolderArg) throws CreateFolder * Create a folder at a given path. * * @param path Path in the user's Dropbox to create. Must match pattern - * "{@code /.*}" and not be {@code null}. + * "{@code /(.|[\\r\\n])*}" and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -214,11 +218,12 @@ Metadata delete(DeleteArg deleteArg) throws DeleteErrorException, DbxException { "2/files/delete", deleteArg, false, - JsonUtil.createType(Metadata.class), - JsonUtil.createType(DeleteError.class)); + DeleteArg.Serializer.INSTANCE, + Metadata.Serializer.INSTANCE, + DeleteError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new DeleteErrorException(ew.getRequestId(), ew.getUserMessage(), (DeleteError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new DeleteErrorException(ex.getRequestId(), ex.getUserMessage(), (DeleteError) ex.getErrorValue()); } } @@ -230,7 +235,7 @@ Metadata delete(DeleteArg deleteArg) throws DeleteErrorException, DbxException { * at time of deletion, and not a {@link DeletedMetadata} object. * * @param path Path in the user's Dropbox to delete. Must match pattern - * "{@code /.*}" and not be {@code null}. + * "{@code /(.|[\\r\\n])*}" and not be {@code null}. * * @return Metadata for a file or folder. * @@ -253,17 +258,19 @@ public Metadata delete(String path) throws DeleteErrorException, DbxException { * @return Downloader used to download the response body and view the server * response. */ - DbxDownloader download(DownloadArg downloadArg) throws DownloadErrorException, DbxException { + DbxDownloader download(DownloadArg downloadArg, List headers_) throws DownloadErrorException, DbxException { try { return client.downloadStyle(client.getHost().getContent(), "2/files/download", downloadArg, false, - JsonUtil.createType(FileMetadata.class), - JsonUtil.createType(DownloadError.class)); + headers_, + DownloadArg.Serializer.INSTANCE, + FileMetadata.Serializer.INSTANCE, + DownloadError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new DownloadErrorException(ew.getRequestId(), ew.getUserMessage(), (DownloadError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new DownloadErrorException(ex.getRequestId(), ex.getUserMessage(), (DownloadError) ex.getErrorValue()); } } @@ -271,7 +278,7 @@ DbxDownloader download(DownloadArg downloadArg) throws DownloadErr * Download a file from a user's Dropbox. * * @param path The path of the file to download. Must match pattern "{@code - * ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. * * @return Downloader used to download the response body and view the server * response. @@ -281,14 +288,14 @@ DbxDownloader download(DownloadArg downloadArg) throws DownloadErr */ public DbxDownloader download(String path) throws DownloadErrorException, DbxException { DownloadArg arg = new DownloadArg(path); - return download(arg); + return download(arg, Collections.emptyList()); } /** * Download a file from a user's Dropbox. * * @param path The path of the file to download. Must match pattern "{@code - * ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. * @param rev Deprecated. Please specify revision in the {@code path} * argument to {@link DbxUserFilesRequests#download(String)} instead. * Must have length of at least 9 and match pattern "{@code [0-9a-f]+}". @@ -309,7 +316,24 @@ public DbxDownloader download(String path, String rev) throws Down } } DownloadArg arg = new DownloadArg(path, rev); - return download(arg); + return download(arg, Collections.emptyList()); + } + + /** + * Download a file from a user's Dropbox. + * + * @param path The path of the file to download. Must match pattern "{@code + * (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * + * @return Downloader builder for configuring the request parameters and + * instantiating a downloader. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public DownloadBuilder downloadBuilder(String path) { + DownloadArg arg_ = new DownloadArg(path); + return new DownloadBuilder(this, path); } // @@ -329,11 +353,12 @@ Metadata getMetadata(GetMetadataArg getMetadataArg) throws GetMetadataErrorExcep "2/files/get_metadata", getMetadataArg, false, - JsonUtil.createType(Metadata.class), - JsonUtil.createType(GetMetadataError.class)); + GetMetadataArg.Serializer.INSTANCE, + Metadata.Serializer.INSTANCE, + GetMetadataError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new GetMetadataErrorException(ew.getRequestId(), ew.getUserMessage(), (GetMetadataError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new GetMetadataErrorException(ex.getRequestId(), ex.getUserMessage(), (GetMetadataError) ex.getErrorValue()); } } @@ -345,7 +370,8 @@ Metadata getMetadata(GetMetadataArg getMetadataArg) throws GetMetadataErrorExcep * See {@link GetMetadataBuilder} for more details.

* * @param path The path of a file or folder on Dropbox. Must match pattern - * "{@code ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * "{@code (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code + * null}. * * @return Metadata for a file or folder. * @@ -362,7 +388,8 @@ public Metadata getMetadata(String path) throws GetMetadataErrorException, DbxEx * folder is unsupported. * * @param path The path of a file or folder on Dropbox. Must match pattern - * "{@code ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * "{@code (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code + * null}. * * @return Request builder for configuring request parameters and completing * the request. @@ -371,8 +398,8 @@ public Metadata getMetadata(String path) throws GetMetadataErrorException, DbxEx * preconditions. */ public GetMetadataBuilder getMetadataBuilder(String path) { - GetMetadataArg.Builder argBuilder = GetMetadataArg.newBuilder(path); - return new GetMetadataBuilder(this, argBuilder); + GetMetadataArg.Builder argBuilder_ = GetMetadataArg.newBuilder(path); + return new GetMetadataBuilder(this, argBuilder_); } // @@ -388,17 +415,19 @@ public GetMetadataBuilder getMetadataBuilder(String path) { * @return Downloader used to download the response body and view the server * response. */ - DbxDownloader getPreview(PreviewArg previewArg) throws PreviewErrorException, DbxException { + DbxDownloader getPreview(PreviewArg previewArg, List headers_) throws PreviewErrorException, DbxException { try { return client.downloadStyle(client.getHost().getContent(), "2/files/get_preview", previewArg, false, - JsonUtil.createType(FileMetadata.class), - JsonUtil.createType(PreviewError.class)); + headers_, + PreviewArg.Serializer.INSTANCE, + FileMetadata.Serializer.INSTANCE, + PreviewError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new PreviewErrorException(ew.getRequestId(), ew.getUserMessage(), (PreviewError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new PreviewErrorException(ex.getRequestId(), ex.getUserMessage(), (PreviewError) ex.getErrorValue()); } } @@ -408,7 +437,7 @@ DbxDownloader getPreview(PreviewArg previewArg) throws PreviewErro * .ppsx, .ppsm, .pptx, .pptm, .xls, .xlsx, .xlsm, .rtf * * @param path The path of the file to preview. Must match pattern "{@code - * ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. * * @return Downloader used to download the response body and view the server * response. @@ -418,7 +447,7 @@ DbxDownloader getPreview(PreviewArg previewArg) throws PreviewErro */ public DbxDownloader getPreview(String path) throws PreviewErrorException, DbxException { PreviewArg arg = new PreviewArg(path); - return getPreview(arg); + return getPreview(arg, Collections.emptyList()); } /** @@ -427,7 +456,7 @@ public DbxDownloader getPreview(String path) throws PreviewErrorEx * .ppsx, .ppsm, .pptx, .pptm, .xls, .xlsx, .xlsm, .rtf * * @param path The path of the file to preview. Must match pattern "{@code - * ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. * @param rev Deprecated. Please specify revision in the {@code path} * argument to {@link DbxUserFilesRequests#getPreview(String)} instead. * Must have length of at least 9 and match pattern "{@code [0-9a-f]+}". @@ -448,7 +477,26 @@ public DbxDownloader getPreview(String path, String rev) throws Pr } } PreviewArg arg = new PreviewArg(path, rev); - return getPreview(arg); + return getPreview(arg, Collections.emptyList()); + } + + /** + * Get a preview for a file. Currently previews are only generated for the + * files with the following extensions: .doc, .docx, .docm, .ppt, .pps, + * .ppsx, .ppsm, .pptx, .pptm, .xls, .xlsx, .xlsm, .rtf + * + * @param path The path of the file to preview. Must match pattern "{@code + * (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * + * @return Downloader builder for configuring the request parameters and + * instantiating a downloader. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public GetPreviewBuilder getPreviewBuilder(String path) { + PreviewArg arg_ = new PreviewArg(path); + return new GetPreviewBuilder(this, path); } // @@ -467,11 +515,12 @@ GetTemporaryLinkResult getTemporaryLink(GetTemporaryLinkArg getTemporaryLinkArg) "2/files/get_temporary_link", getTemporaryLinkArg, false, - JsonUtil.createType(GetTemporaryLinkResult.class), - JsonUtil.createType(GetTemporaryLinkError.class)); + GetTemporaryLinkArg.Serializer.INSTANCE, + GetTemporaryLinkResult.Serializer.INSTANCE, + GetTemporaryLinkError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new GetTemporaryLinkErrorException(ew.getRequestId(), ew.getUserMessage(), (GetTemporaryLinkError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new GetTemporaryLinkErrorException(ex.getRequestId(), ex.getUserMessage(), (GetTemporaryLinkError) ex.getErrorValue()); } } @@ -481,8 +530,8 @@ GetTemporaryLinkResult getTemporaryLink(GetTemporaryLinkArg getTemporaryLinkArg) * link is determined automatically by the file's mime type. * * @param path The path to the file you want a temporary link to. Must - * match pattern "{@code ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be - * {@code null}. + * match pattern "{@code (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and + * not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -506,17 +555,19 @@ public GetTemporaryLinkResult getTemporaryLink(String path) throws GetTemporaryL * @return Downloader used to download the response body and view the server * response. */ - DbxDownloader getThumbnail(ThumbnailArg thumbnailArg) throws ThumbnailErrorException, DbxException { + DbxDownloader getThumbnail(ThumbnailArg thumbnailArg, List headers_) throws ThumbnailErrorException, DbxException { try { return client.downloadStyle(client.getHost().getContent(), "2/files/get_thumbnail", thumbnailArg, false, - JsonUtil.createType(FileMetadata.class), - JsonUtil.createType(ThumbnailError.class)); + headers_, + ThumbnailArg.Serializer.INSTANCE, + FileMetadata.Serializer.INSTANCE, + ThumbnailError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new ThumbnailErrorException(ew.getRequestId(), ew.getUserMessage(), (ThumbnailError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new ThumbnailErrorException(ex.getRequestId(), ex.getUserMessage(), (ThumbnailError) ex.getErrorValue()); } } @@ -530,8 +581,8 @@ DbxDownloader getThumbnail(ThumbnailArg thumbnailArg) throws Thumb * See {@link GetThumbnailBuilder} for more details.

* * @param path The path to the image file you want to thumbnail. Must match - * pattern "{@code ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code - * null}. + * pattern "{@code (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not + * be {@code null}. * * @return Downloader used to download the response body and view the server * response. @@ -541,7 +592,7 @@ DbxDownloader getThumbnail(ThumbnailArg thumbnailArg) throws Thumb */ public DbxDownloader getThumbnail(String path) throws ThumbnailErrorException, DbxException { ThumbnailArg arg = new ThumbnailArg(path); - return getThumbnail(arg); + return getThumbnail(arg, Collections.emptyList()); } /** @@ -551,8 +602,8 @@ public DbxDownloader getThumbnail(String path) throws ThumbnailErr * thumbnail. * * @param path The path to the image file you want to thumbnail. Must match - * pattern "{@code ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code - * null}. + * pattern "{@code (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not + * be {@code null}. * * @return Downloader builder for configuring the request parameters and * instantiating a downloader. @@ -561,8 +612,8 @@ public DbxDownloader getThumbnail(String path) throws ThumbnailErr * preconditions. */ public GetThumbnailBuilder getThumbnailBuilder(String path) { - ThumbnailArg.Builder argBuilder = ThumbnailArg.newBuilder(path); - return new GetThumbnailBuilder(this, argBuilder); + ThumbnailArg.Builder argBuilder_ = ThumbnailArg.newBuilder(path); + return new GetThumbnailBuilder(this, argBuilder_); } // @@ -579,11 +630,12 @@ ListFolderResult listFolder(ListFolderArg listFolderArg) throws ListFolderErrorE "2/files/list_folder", listFolderArg, false, - JsonUtil.createType(ListFolderResult.class), - JsonUtil.createType(ListFolderError.class)); + ListFolderArg.Serializer.INSTANCE, + ListFolderResult.Serializer.INSTANCE, + ListFolderError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new ListFolderErrorException(ew.getRequestId(), ew.getUserMessage(), (ListFolderError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new ListFolderErrorException(ex.getRequestId(), ex.getUserMessage(), (ListFolderError) ex.getErrorValue()); } } @@ -594,7 +646,7 @@ ListFolderResult listFolder(ListFolderArg listFolderArg) throws ListFolderErrorE * See {@link ListFolderBuilder} for more details.

* * @param path The path to the folder you want to see the contents of. Must - * match pattern "{@code (/.*)?}" and not be {@code null}. + * match pattern "{@code (/(.|[\\r\\n])*)?}" and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -608,7 +660,7 @@ public ListFolderResult listFolder(String path) throws ListFolderErrorException, * Returns the contents of a folder. * * @param path The path to the folder you want to see the contents of. Must - * match pattern "{@code (/.*)?}" and not be {@code null}. + * match pattern "{@code (/(.|[\\r\\n])*)?}" and not be {@code null}. * * @return Request builder for configuring request parameters and completing * the request. @@ -617,8 +669,8 @@ public ListFolderResult listFolder(String path) throws ListFolderErrorException, * preconditions. */ public ListFolderBuilder listFolderBuilder(String path) { - ListFolderArg.Builder argBuilder = ListFolderArg.newBuilder(path); - return new ListFolderBuilder(this, argBuilder); + ListFolderArg.Builder argBuilder_ = ListFolderArg.newBuilder(path); + return new ListFolderBuilder(this, argBuilder_); } // @@ -637,11 +689,12 @@ ListFolderResult listFolderContinue(ListFolderContinueArg listFolderContinueArg) "2/files/list_folder/continue", listFolderContinueArg, false, - JsonUtil.createType(ListFolderResult.class), - JsonUtil.createType(ListFolderContinueError.class)); + ListFolderContinueArg.Serializer.INSTANCE, + ListFolderResult.Serializer.INSTANCE, + ListFolderContinueError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new ListFolderContinueErrorException(ew.getRequestId(), ew.getUserMessage(), (ListFolderContinueError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new ListFolderContinueErrorException(ex.getRequestId(), ex.getUserMessage(), (ListFolderContinueError) ex.getErrorValue()); } } @@ -682,11 +735,12 @@ ListFolderGetLatestCursorResult listFolderGetLatestCursor(ListFolderArg listFold "2/files/list_folder/get_latest_cursor", listFolderArg, false, - JsonUtil.createType(ListFolderGetLatestCursorResult.class), - JsonUtil.createType(ListFolderError.class)); + ListFolderArg.Serializer.INSTANCE, + ListFolderGetLatestCursorResult.Serializer.INSTANCE, + ListFolderError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new ListFolderErrorException(ew.getRequestId(), ew.getUserMessage(), (ListFolderError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new ListFolderErrorException(ex.getRequestId(), ex.getUserMessage(), (ListFolderError) ex.getErrorValue()); } } @@ -702,7 +756,7 @@ ListFolderGetLatestCursorResult listFolderGetLatestCursor(ListFolderArg listFold * See {@link ListFolderGetLatestCursorBuilder} for more details.

* * @param path The path to the folder you want to see the contents of. Must - * match pattern "{@code (/.*)?}" and not be {@code null}. + * match pattern "{@code (/(.|[\\r\\n])*)?}" and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -721,7 +775,7 @@ public ListFolderGetLatestCursorResult listFolderGetLatestCursor(String path) th * exist in Dropbox. * * @param path The path to the folder you want to see the contents of. Must - * match pattern "{@code (/.*)?}" and not be {@code null}. + * match pattern "{@code (/(.|[\\r\\n])*)?}" and not be {@code null}. * * @return Request builder for configuring request parameters and completing * the request. @@ -730,8 +784,8 @@ public ListFolderGetLatestCursorResult listFolderGetLatestCursor(String path) th * preconditions. */ public ListFolderGetLatestCursorBuilder listFolderGetLatestCursorBuilder(String path) { - ListFolderArg.Builder argBuilder = ListFolderArg.newBuilder(path); - return new ListFolderGetLatestCursorBuilder(this, argBuilder); + ListFolderArg.Builder argBuilder_ = ListFolderArg.newBuilder(path); + return new ListFolderGetLatestCursorBuilder(this, argBuilder_); } // @@ -740,11 +794,11 @@ public ListFolderGetLatestCursorBuilder listFolderGetLatestCursorBuilder(String /** * A longpoll endpoint to wait for changes on an account. In conjunction - * with {@link DbxUserFilesRequests#listFolder(String)}, this call gives you - * a low-latency way to monitor an account for file changes. The connection - * will block until there are changes available or a timeout occurs. This - * endpoint is useful mostly for client-side apps. If you're looking for - * server-side notifications, check out our webhooks * documentation. * @@ -755,21 +809,22 @@ ListFolderLongpollResult listFolderLongpoll(ListFolderLongpollArg listFolderLong "2/files/list_folder/longpoll", listFolderLongpollArg, true, - JsonUtil.createType(ListFolderLongpollResult.class), - JsonUtil.createType(ListFolderLongpollError.class)); + ListFolderLongpollArg.Serializer.INSTANCE, + ListFolderLongpollResult.Serializer.INSTANCE, + ListFolderLongpollError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new ListFolderLongpollErrorException(ew.getRequestId(), ew.getUserMessage(), (ListFolderLongpollError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new ListFolderLongpollErrorException(ex.getRequestId(), ex.getUserMessage(), (ListFolderLongpollError) ex.getErrorValue()); } } /** * A longpoll endpoint to wait for changes on an account. In conjunction - * with {@link DbxUserFilesRequests#listFolder(String)}, this call gives you - * a low-latency way to monitor an account for file changes. The connection - * will block until there are changes available or a timeout occurs. This - * endpoint is useful mostly for client-side apps. If you're looking for - * server-side notifications, check out our webhooks * documentation. * @@ -793,11 +848,11 @@ public ListFolderLongpollResult listFolderLongpoll(String cursor) throws ListFol /** * A longpoll endpoint to wait for changes on an account. In conjunction - * with {@link DbxUserFilesRequests#listFolder(String)}, this call gives you - * a low-latency way to monitor an account for file changes. The connection - * will block until there are changes available or a timeout occurs. This - * endpoint is useful mostly for client-side apps. If you're looking for - * server-side notifications, check out our webhooks * documentation. * @@ -842,11 +897,12 @@ ListRevisionsResult listRevisions(ListRevisionsArg listRevisionsArg) throws List "2/files/list_revisions", listRevisionsArg, false, - JsonUtil.createType(ListRevisionsResult.class), - JsonUtil.createType(ListRevisionsError.class)); + ListRevisionsArg.Serializer.INSTANCE, + ListRevisionsResult.Serializer.INSTANCE, + ListRevisionsError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new ListRevisionsErrorException(ew.getRequestId(), ew.getUserMessage(), (ListRevisionsError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new ListRevisionsErrorException(ex.getRequestId(), ex.getUserMessage(), (ListRevisionsError) ex.getErrorValue()); } } @@ -857,7 +913,7 @@ ListRevisionsResult listRevisions(ListRevisionsArg listRevisionsArg) throws List * {@link #listRevisions(String,long)}).

* * @param path The path to the file you want to see the revisions of. Must - * match pattern "{@code /.*}" and not be {@code null}. + * match pattern "{@code /(.|[\\r\\n])*}" and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -871,7 +927,7 @@ public ListRevisionsResult listRevisions(String path) throws ListRevisionsErrorE * Return revisions of a file * * @param path The path to the file you want to see the revisions of. Must - * match pattern "{@code /.*}" and not be {@code null}. + * match pattern "{@code /(.|[\\r\\n])*}" and not be {@code null}. * @param limit The maximum number of revision entries returned. Must be * greater than or equal to 1 and be less than or equal to 100. * @@ -906,11 +962,12 @@ Metadata move(RelocationArg relocationArg) throws RelocationErrorException, DbxE "2/files/move", relocationArg, false, - JsonUtil.createType(Metadata.class), - JsonUtil.createType(RelocationError.class)); + RelocationArg.Serializer.INSTANCE, + Metadata.Serializer.INSTANCE, + RelocationError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new RelocationErrorException(ew.getRequestId(), ew.getUserMessage(), (RelocationError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new RelocationErrorException(ex.getRequestId(), ex.getUserMessage(), (RelocationError) ex.getErrorValue()); } } @@ -919,9 +976,9 @@ Metadata move(RelocationArg relocationArg) throws RelocationErrorException, DbxE * the source path is a folder all its contents will be moved. * * @param fromPath Path in the user's Dropbox to be copied or moved. Must - * match pattern "{@code /.*}" and not be {@code null}. + * match pattern "{@code /(.|[\\r\\n])*}" and not be {@code null}. * @param toPath Path in the user's Dropbox that is the destination. Must - * match pattern "{@code /.*}" and not be {@code null}. + * match pattern "{@code /(.|[\\r\\n])*}" and not be {@code null}. * * @return Metadata for a file or folder. * @@ -949,11 +1006,12 @@ void permanentlyDelete(DeleteArg deleteArg) throws DeleteErrorException, DbxExce "2/files/permanently_delete", deleteArg, false, - JsonUtil.createType(Void.class), - JsonUtil.createType(DeleteError.class)); + DeleteArg.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.void_(), + DeleteError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new DeleteErrorException(ew.getRequestId(), ew.getUserMessage(), (DeleteError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new DeleteErrorException(ex.getRequestId(), ex.getUserMessage(), (DeleteError) ex.getErrorValue()); } } @@ -963,7 +1021,7 @@ void permanentlyDelete(DeleteArg deleteArg) throws DeleteErrorException, DbxExce * available for Dropbox Business apps. * * @param path Path in the user's Dropbox to delete. Must match pattern - * "{@code /.*}" and not be {@code null}. + * "{@code /(.|[\\r\\n])*}" and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -987,11 +1045,12 @@ FileMetadata restore(RestoreArg restoreArg) throws RestoreErrorException, DbxExc "2/files/restore", restoreArg, false, - JsonUtil.createType(FileMetadata.class), - JsonUtil.createType(RestoreError.class)); + RestoreArg.Serializer.INSTANCE, + FileMetadata.Serializer.INSTANCE, + RestoreError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new RestoreErrorException(ew.getRequestId(), ew.getUserMessage(), (RestoreError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new RestoreErrorException(ex.getRequestId(), ex.getUserMessage(), (RestoreError) ex.getErrorValue()); } } @@ -999,7 +1058,7 @@ FileMetadata restore(RestoreArg restoreArg) throws RestoreErrorException, DbxExc * Restore a file to a specific revision * * @param path The path to the file you want to restore. Must match pattern - * "{@code /.*}" and not be {@code null}. + * "{@code /(.|[\\r\\n])*}" and not be {@code null}. * @param rev The revision to restore for the file. Must have length of at * least 9, match pattern "{@code [0-9a-f]+}", and not be {@code null}. * @@ -1011,6 +1070,90 @@ public FileMetadata restore(String path, String rev) throws RestoreErrorExceptio return restore(arg); } + // + // route files/save_url + // + + /** + * Save a specified URL into a file in user's Dropbox. If the given path + * already exists, the file will be renamed to avoid the conflict (e.g. + * myfile (1).txt). + * + */ + SaveUrlResult saveUrl(SaveUrlArg saveUrlArg) throws SaveUrlErrorException, DbxException { + try { + return client.rpcStyle(client.getHost().getApi(), + "2/files/save_url", + saveUrlArg, + false, + SaveUrlArg.Serializer.INSTANCE, + SaveUrlResult.Serializer.INSTANCE, + SaveUrlError.Serializer.INSTANCE); + } + catch (DbxWrappedException ex) { + throw new SaveUrlErrorException(ex.getRequestId(), ex.getUserMessage(), (SaveUrlError) ex.getErrorValue()); + } + } + + /** + * Save a specified URL into a file in user's Dropbox. If the given path + * already exists, the file will be renamed to avoid the conflict (e.g. + * myfile (1).txt). + * + * @param path The path in Dropbox where the URL will be saved to. Must + * match pattern "{@code /(.|[\\r\\n])*}" and not be {@code null}. + * @param url The URL to be saved. Must not be {@code null}. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public SaveUrlResult saveUrl(String path, String url) throws SaveUrlErrorException, DbxException { + SaveUrlArg arg = new SaveUrlArg(path, url); + return saveUrl(arg); + } + + // + // route files/save_url/check_job_status + // + + /** + * Check the status of a {@link DbxUserFilesRequests#saveUrl(String,String)} + * job. + * + * @param pollArg Arguments for methods that poll the status of an + * asynchronous job. + */ + SaveUrlJobStatus saveUrlCheckJobStatus(PollArg pollArg) throws PollErrorException, DbxException { + try { + return client.rpcStyle(client.getHost().getApi(), + "2/files/save_url/check_job_status", + pollArg, + false, + PollArg.Serializer.INSTANCE, + SaveUrlJobStatus.Serializer.INSTANCE, + com.dropbox.core.v2.async.PollError.Serializer.INSTANCE); + } + catch (DbxWrappedException ex) { + throw new PollErrorException(ex.getRequestId(), ex.getUserMessage(), (com.dropbox.core.v2.async.PollError) ex.getErrorValue()); + } + } + + /** + * Check the status of a {@link DbxUserFilesRequests#saveUrl(String,String)} + * job. + * + * @param asyncJobId Id of the asynchronous job. This is the value of a + * response returned from the method that launched the job. Must have + * length of at least 1 and not be {@code null}. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public SaveUrlJobStatus saveUrlCheckJobStatus(String asyncJobId) throws PollErrorException, DbxException { + PollArg arg = new PollArg(asyncJobId); + return saveUrlCheckJobStatus(arg); + } + // // route files/search // @@ -1026,11 +1169,12 @@ SearchResult search(SearchArg searchArg) throws SearchErrorException, DbxExcepti "2/files/search", searchArg, false, - JsonUtil.createType(SearchResult.class), - JsonUtil.createType(SearchError.class)); + SearchArg.Serializer.INSTANCE, + SearchResult.Serializer.INSTANCE, + SearchError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new SearchErrorException(ew.getRequestId(), ew.getUserMessage(), (SearchError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new SearchErrorException(ex.getRequestId(), ex.getUserMessage(), (SearchError) ex.getErrorValue()); } } @@ -1042,8 +1186,8 @@ SearchResult search(SearchArg searchArg) throws SearchErrorException, DbxExcepti * See {@link SearchBuilder} for more details.

* * @param path The path in the user's Dropbox to search. Should probably be - * a folder. Must match pattern "{@code (/.*)?}" and not be {@code - * null}. + * a folder. Must match pattern "{@code (/(.|[\\r\\n])*)?}" and not be + * {@code null}. * @param query The string to search for. The search string is split on * spaces into multiple tokens. For file name searching, the last token * is used for prefix matching (i.e. "bat c" matches "bat cave" but not @@ -1062,8 +1206,8 @@ public SearchResult search(String path, String query) throws SearchErrorExceptio * be reflected in search results due to a short delay in indexing. * * @param path The path in the user's Dropbox to search. Should probably be - * a folder. Must match pattern "{@code (/.*)?}" and not be {@code - * null}. + * a folder. Must match pattern "{@code (/(.|[\\r\\n])*)?}" and not be + * {@code null}. * @param query The string to search for. The search string is split on * spaces into multiple tokens. For file name searching, the last token * is used for prefix matching (i.e. "bat c" matches "bat cave" but not @@ -1076,8 +1220,8 @@ public SearchResult search(String path, String query) throws SearchErrorExceptio * preconditions. */ public SearchBuilder searchBuilder(String path, String query) { - SearchArg.Builder argBuilder = SearchArg.newBuilder(path, query); - return new SearchBuilder(this, argBuilder); + SearchArg.Builder argBuilder_ = SearchArg.newBuilder(path, query); + return new SearchBuilder(this, argBuilder_); } // @@ -1096,7 +1240,8 @@ UploadUploader upload(CommitInfo commitInfo) throws DbxException { HttpRequestor.Uploader uploader = client.uploadStyle(client.getHost().getContent(), "2/files/upload", commitInfo, - false); + false, + CommitInfo.Serializer.INSTANCE); return new UploadUploader(uploader); } @@ -1109,7 +1254,7 @@ UploadUploader upload(CommitInfo commitInfo) throws DbxException { * See {@link UploadBuilder} for more details.

* * @param path Path in the user's Dropbox to save the file. Must match - * pattern "{@code /.*}" and not be {@code null}. + * pattern "{@code /(.|[\\r\\n])*}" and not be {@code null}. * * @return Uploader used to upload the request body and finish request. * @@ -1127,7 +1272,7 @@ public UploadUploader upload(String path) throws DbxException { * session with {@link DbxUserFilesRequests#uploadSessionStart()}. * * @param path Path in the user's Dropbox to save the file. Must match - * pattern "{@code /.*}" and not be {@code null}. + * pattern "{@code /(.|[\\r\\n])*}" and not be {@code null}. * * @return Uploader builder for configuring request parameters and * instantiating an uploader. @@ -1136,8 +1281,8 @@ public UploadUploader upload(String path) throws DbxException { * preconditions. */ public UploadBuilder uploadBuilder(String path) { - CommitInfo.Builder argBuilder = CommitInfo.newBuilder(path); - return new UploadBuilder(this, argBuilder); + CommitInfo.Builder argBuilder_ = CommitInfo.newBuilder(path); + return new UploadBuilder(this, argBuilder_); } // @@ -1160,7 +1305,8 @@ UploadSessionAppendUploader uploadSessionAppend(UploadSessionCursor uploadSessio HttpRequestor.Uploader uploader = client.uploadStyle(client.getHost().getContent(), "2/files/upload_session/append", uploadSessionCursor, - false); + false, + UploadSessionCursor.Serializer.INSTANCE); return new UploadSessionAppendUploader(uploader); } @@ -1206,7 +1352,8 @@ UploadSessionAppendV2Uploader uploadSessionAppendV2(UploadSessionAppendArg uploa HttpRequestor.Uploader uploader = client.uploadStyle(client.getHost().getContent(), "2/files/upload_session/append_v2", uploadSessionAppendArg, - false); + false, + UploadSessionAppendArg.Serializer.INSTANCE); return new UploadSessionAppendV2Uploader(uploader); } @@ -1268,7 +1415,8 @@ UploadSessionFinishUploader uploadSessionFinish(UploadSessionFinishArg uploadSes HttpRequestor.Uploader uploader = client.uploadStyle(client.getHost().getContent(), "2/files/upload_session/finish", uploadSessionFinishArg, - false); + false, + UploadSessionFinishArg.Serializer.INSTANCE); return new UploadSessionFinishUploader(uploader); } @@ -1313,7 +1461,8 @@ UploadSessionStartUploader uploadSessionStart(UploadSessionStartArg uploadSessio HttpRequestor.Uploader uploader = client.uploadStyle(client.getHost().getContent(), "2/files/upload_session/start", uploadSessionStartArg, - false); + false, + UploadSessionStartArg.Serializer.INSTANCE); return new UploadSessionStartUploader(uploader); } diff --git a/src/main/java/com/dropbox/core/v2/files/DeleteArg.java b/src/main/java/com/dropbox/core/v2/files/DeleteArg.java index ec1e5a0cb..c4ab75e32 100644 --- a/src/main/java/com/dropbox/core/v2/files/DeleteArg.java +++ b/src/main/java/com/dropbox/core/v2/files/DeleteArg.java @@ -1,45 +1,28 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=DeleteArg.Serializer.class) -@JsonDeserialize(using=DeleteArg.Deserializer.class) public class DeleteArg { // struct DeleteArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String path; /** * * @param path Path in the user's Dropbox to delete. Must match pattern - * "{@code /.*}" and not be {@code null}. + * "{@code /(.|[\\r\\n])*}" and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -48,7 +31,7 @@ public DeleteArg(String path) { if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("/.*", path)) { + if (!java.util.regex.Pattern.matches("/(.|[\\r\\n])*", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -88,7 +71,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -100,78 +83,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(DeleteArg.class); - } - - public Serializer(boolean unwrapping) { - super(DeleteArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(DeleteArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("path", value.path); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(DeleteArg.class); - } - - public Deserializer(boolean unwrapping) { - super(DeleteArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(DeleteArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("path"); + StoneSerializers.string().serialize(value.path, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public DeleteArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String path = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); + public DeleteArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + DeleteArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_path = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("path".equals(field)) { + f_path = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_path == null) { + throw new JsonParseException(p, "Required field \"path\" missing."); } + value = new DeleteArg(f_path); } - - if (path == null) { - throw new JsonParseException(_p, "Required field \"path\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new DeleteArg(path); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/DeleteError.java b/src/main/java/com/dropbox/core/v2/files/DeleteError.java index 5f5b4ce65..a95dd9777 100644 --- a/src/main/java/com/dropbox/core/v2/files/DeleteError.java +++ b/src/main/java/com/dropbox/core/v2/files/DeleteError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=DeleteError.Serializer.class) -@JsonDeserialize(using=DeleteError.Deserializer.class) public final class DeleteError { // union DeleteError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link DeleteError}. */ @@ -240,7 +222,7 @@ else if (obj instanceof DeleteError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -252,85 +234,78 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(DeleteError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(DeleteError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case PATH_LOOKUP: + public void serialize(DeleteError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PATH_LOOKUP: { g.writeStartObject(); - g.writeStringField(".tag", "path_lookup"); - g.writeObjectField("path_lookup", value.pathLookupValue); + writeTag("path_lookup", g); + g.writeFieldName("path_lookup"); + LookupError.Serializer.INSTANCE.serialize(value.pathLookupValue, g); g.writeEndObject(); break; - case PATH_WRITE: + } + case PATH_WRITE: { g.writeStartObject(); - g.writeStringField(".tag", "path_write"); - g.writeObjectField("path_write", value.pathWriteValue); + writeTag("path_write", g); + g.writeFieldName("path_write"); + WriteError.Serializer.INSTANCE.serialize(value.pathWriteValue, g); g.writeEndObject(); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(DeleteError.class, getTagMapping(), Tag.OTHER); - } @Override - public DeleteError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case PATH_LOOKUP: { - LookupError value = null; - expectField(_p, "path_lookup"); - value = _p.readValueAs(LookupError.class); - _p.nextToken(); - return DeleteError.pathLookup(value); - } - case PATH_WRITE: { - WriteError value = null; - expectField(_p, "path_write"); - value = _p.readValueAs(WriteError.class); - _p.nextToken(); - return DeleteError.pathWrite(value); - } - case OTHER: { - return DeleteError.OTHER; - } + public DeleteError deserialize(JsonParser p) throws IOException, JsonParseException { + DeleteError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("path_lookup", DeleteError.Tag.PATH_LOOKUP); - values.put("path_write", DeleteError.Tag.PATH_WRITE); - values.put("other", DeleteError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("path_lookup".equals(tag)) { + LookupError fieldValue = null; + expectField("path_lookup", p); + fieldValue = LookupError.Serializer.INSTANCE.deserialize(p); + value = DeleteError.pathLookup(fieldValue); + } + else if ("path_write".equals(tag)) { + WriteError fieldValue = null; + expectField("path_write", p); + fieldValue = WriteError.Serializer.INSTANCE.deserialize(p); + value = DeleteError.pathWrite(fieldValue); + } + else { + value = DeleteError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/DeleteErrorException.java b/src/main/java/com/dropbox/core/v2/files/DeleteErrorException.java index 051269ed9..b9a49282f 100644 --- a/src/main/java/com/dropbox/core/v2/files/DeleteErrorException.java +++ b/src/main/java/com/dropbox/core/v2/files/DeleteErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; diff --git a/src/main/java/com/dropbox/core/v2/files/DeletedMetadata.java b/src/main/java/com/dropbox/core/v2/files/DeletedMetadata.java index b99f26231..2f3526a24 100644 --- a/src/main/java/com/dropbox/core/v2/files/DeletedMetadata.java +++ b/src/main/java/com/dropbox/core/v2/files/DeletedMetadata.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; @@ -29,15 +18,9 @@ * Indicates that there used to be a file or folder at this path, but it no * longer exists. */ -@JsonSerialize(using=DeletedMetadata.Serializer.class) -@JsonDeserialize(using=DeletedMetadata.Deserializer.class) public class DeletedMetadata extends Metadata { // struct DeletedMetadata - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Indicates that there used to be a file or folder at this path, but it no @@ -116,7 +99,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -128,101 +111,89 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); + return Serializer.INSTANCE.serialize(this, true); } - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(DeletedMetadata.class); - } - - public Serializer(boolean unwrapping) { - super(DeletedMetadata.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(DeletedMetadata value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeStringField(".tag", "deleted"); - g.writeObjectField("name", value.name); - g.writeObjectField("path_lower", value.pathLower); - g.writeObjectField("path_display", value.pathDisplay); + public void serialize(DeletedMetadata value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + writeTag("deleted", g); + g.writeFieldName("name"); + StoneSerializers.string().serialize(value.name, g); + g.writeFieldName("path_lower"); + StoneSerializers.string().serialize(value.pathLower, g); + g.writeFieldName("path_display"); + StoneSerializers.string().serialize(value.pathDisplay, g); if (value.parentSharedFolderId != null) { - g.writeObjectField("parent_shared_folder_id", value.parentSharedFolderId); + g.writeFieldName("parent_shared_folder_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.parentSharedFolderId, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(DeletedMetadata.class); - } - - public Deserializer(boolean unwrapping) { - super(DeletedMetadata.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public DeletedMetadata deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - String _subtype_tag = readEnumeratedSubtypeTag(_p, "deleted"); - - String name = null; - String pathLower = null; - String pathDisplay = null; - String parentSharedFolderId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("name".equals(_field)) { - name = getStringValue(_p); - _p.nextToken(); + public DeletedMetadata deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + DeletedMetadata value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + if ("deleted".equals(tag)) { + tag = null; } - else if ("path_lower".equals(_field)) { - pathLower = getStringValue(_p); - _p.nextToken(); + } + if (tag == null) { + String f_name = null; + String f_pathLower = null; + String f_pathDisplay = null; + String f_parentSharedFolderId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("name".equals(field)) { + f_name = StoneSerializers.string().deserialize(p); + } + else if ("path_lower".equals(field)) { + f_pathLower = StoneSerializers.string().deserialize(p); + } + else if ("path_display".equals(field)) { + f_pathDisplay = StoneSerializers.string().deserialize(p); + } + else if ("parent_shared_folder_id".equals(field)) { + f_parentSharedFolderId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } - else if ("path_display".equals(_field)) { - pathDisplay = getStringValue(_p); - _p.nextToken(); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } - else if ("parent_shared_folder_id".equals(_field)) { - parentSharedFolderId = getStringValue(_p); - _p.nextToken(); + if (f_pathLower == null) { + throw new JsonParseException(p, "Required field \"path_lower\" missing."); } - else { - skipValue(_p); + if (f_pathDisplay == null) { + throw new JsonParseException(p, "Required field \"path_display\" missing."); } + value = new DeletedMetadata(f_name, f_pathLower, f_pathDisplay, f_parentSharedFolderId); } - - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); - } - if (pathLower == null) { - throw new JsonParseException(_p, "Required field \"path_lower\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (pathDisplay == null) { - throw new JsonParseException(_p, "Required field \"path_display\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new DeletedMetadata(name, pathLower, pathDisplay, parentSharedFolderId); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/Dimensions.java b/src/main/java/com/dropbox/core/v2/files/Dimensions.java index fb33c57a1..e84cffefc 100644 --- a/src/main/java/com/dropbox/core/v2/files/Dimensions.java +++ b/src/main/java/com/dropbox/core/v2/files/Dimensions.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Dimensions for a photo or video. */ -@JsonSerialize(using=Dimensions.Serializer.class) -@JsonDeserialize(using=Dimensions.Deserializer.class) public class Dimensions { // struct Dimensions - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final long height; protected final long width; @@ -97,7 +80,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -109,89 +92,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(Dimensions.class); - } - - public Serializer(boolean unwrapping) { - super(Dimensions.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(Dimensions value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("height", value.height); - g.writeObjectField("width", value.width); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(Dimensions.class); - } - - public Deserializer(boolean unwrapping) { - super(Dimensions.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(Dimensions value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("height"); + StoneSerializers.uInt64().serialize(value.height, g); + g.writeFieldName("width"); + StoneSerializers.uInt64().serialize(value.width, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public Dimensions deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - Long height = null; - Long width = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("height".equals(_field)) { - height = _p.getLongValue(); - assertUnsigned(_p, height); - _p.nextToken(); + public Dimensions deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + Dimensions value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Long f_height = null; + Long f_width = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("height".equals(field)) { + f_height = StoneSerializers.uInt64().deserialize(p); + } + else if ("width".equals(field)) { + f_width = StoneSerializers.uInt64().deserialize(p); + } + else { + skipValue(p); + } } - else if ("width".equals(_field)) { - width = _p.getLongValue(); - assertUnsigned(_p, width); - _p.nextToken(); + if (f_height == null) { + throw new JsonParseException(p, "Required field \"height\" missing."); } - else { - skipValue(_p); + if (f_width == null) { + throw new JsonParseException(p, "Required field \"width\" missing."); } + value = new Dimensions(f_height, f_width); } - - if (height == null) { - throw new JsonParseException(_p, "Required field \"height\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (width == null) { - throw new JsonParseException(_p, "Required field \"width\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new Dimensions(height, width); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/DownloadArg.java b/src/main/java/com/dropbox/core/v2/files/DownloadArg.java index e25b75b2f..2452f0465 100644 --- a/src/main/java/com/dropbox/core/v2/files/DownloadArg.java +++ b/src/main/java/com/dropbox/core/v2/files/DownloadArg.java @@ -1,46 +1,29 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=DownloadArg.Serializer.class) -@JsonDeserialize(using=DownloadArg.Deserializer.class) class DownloadArg { // struct DownloadArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String path; protected final String rev; /** * * @param path The path of the file to download. Must match pattern "{@code - * ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. * @param rev Deprecated. Please specify revision in the {@code path} * argument to {@link DbxUserFilesRequests#download(String)} instead. * Must have length of at least 9 and match pattern "{@code [0-9a-f]+}". @@ -52,7 +35,7 @@ public DownloadArg(String path, String rev) { if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("((/|id:).*)|(rev:[0-9a-f]{9,})", path)) { + if (!java.util.regex.Pattern.matches("(/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -71,7 +54,7 @@ public DownloadArg(String path, String rev) { * The default values for unset fields will be used. * * @param path The path of the file to download. Must match pattern "{@code - * ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -127,7 +110,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -139,86 +122,67 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(DownloadArg.class); - } - - public Serializer(boolean unwrapping) { - super(DownloadArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(DownloadArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("path", value.path); + public void serialize(DownloadArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("path"); + StoneSerializers.string().serialize(value.path, g); if (value.rev != null) { - g.writeObjectField("rev", value.rev); + g.writeFieldName("rev"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.rev, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(DownloadArg.class); - } - - public Deserializer(boolean unwrapping) { - super(DownloadArg.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public DownloadArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String path = null; - String rev = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); - } - else if ("rev".equals(_field)) { - rev = getStringValue(_p); - _p.nextToken(); + public DownloadArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + DownloadArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_path = null; + String f_rev = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("path".equals(field)) { + f_path = StoneSerializers.string().deserialize(p); + } + else if ("rev".equals(field)) { + f_rev = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_path == null) { + throw new JsonParseException(p, "Required field \"path\" missing."); } + value = new DownloadArg(f_path, f_rev); } - - if (path == null) { - throw new JsonParseException(_p, "Required field \"path\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new DownloadArg(path, rev); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/DownloadBuilder.java b/src/main/java/com/dropbox/core/v2/files/DownloadBuilder.java new file mode 100644 index 000000000..4f1690fe1 --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/files/DownloadBuilder.java @@ -0,0 +1,74 @@ +/* DO NOT EDIT */ +/* This file was generated from files.stone */ + +package com.dropbox.core.v2.files; + +import com.dropbox.core.DbxDownloader; +import com.dropbox.core.DbxException; +import com.dropbox.core.v2.DbxDownloadStyleBuilder; + +/** + * The request builder returned by {@link + * DbxUserFilesRequests#download(String)}. + * + *

Use this class to set optional request parameters and complete the + * request.

+ */ +public class DownloadBuilder extends DbxDownloadStyleBuilder { + private final DbxUserFilesRequests files_; + private final String path; + private String rev; + + /** + * Creates a new instance of this builder. + * + * @param path The path of the file to download. Must match pattern "{@code + * (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * @param files_ Dropbox namespace-specific client used to issue files + * requests. + * + * @return instsance of this builder + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + DownloadBuilder(DbxUserFilesRequests files_, String path) { + if (files_ == null) { + throw new NullPointerException("files_"); + } + this.files_ = files_; + this.path = path; + this.rev = null; + } + + /** + * Set value for optional field. + * + * @param rev Deprecated. Please specify revision in the {@code path} + * argument to {@link DbxUserFilesRequests#download(String)} instead. + * Must have length of at least 9 and match pattern "{@code [0-9a-f]+}". + * + * @return this builder + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public DownloadBuilder withRev(String rev) { + if (rev != null) { + if (rev.length() < 9) { + throw new IllegalArgumentException("String 'rev' is shorter than 9"); + } + if (!java.util.regex.Pattern.matches("[0-9a-f]+", rev)) { + throw new IllegalArgumentException("String 'rev' does not match pattern"); + } + } + this.rev = rev; + return this; + } + + @Override + public DbxDownloader start() throws DownloadErrorException, DbxException { + DownloadArg arg_ = new DownloadArg(path, rev); + return files_.download(arg_, getHeaders()); + } +} diff --git a/src/main/java/com/dropbox/core/v2/files/DownloadError.java b/src/main/java/com/dropbox/core/v2/files/DownloadError.java index d0b456a92..15c160e68 100644 --- a/src/main/java/com/dropbox/core/v2/files/DownloadError.java +++ b/src/main/java/com/dropbox/core/v2/files/DownloadError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=DownloadError.Serializer.class) -@JsonDeserialize(using=DownloadError.Deserializer.class) public final class DownloadError { // union DownloadError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link DownloadError}. */ @@ -181,7 +163,7 @@ else if (obj instanceof DownloadError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -193,71 +175,64 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(DownloadError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(DownloadError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case PATH: + public void serialize(DownloadError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PATH: { g.writeStartObject(); - g.writeStringField(".tag", "path"); - g.writeObjectField("path", value.pathValue); + writeTag("path", g); + g.writeFieldName("path"); + LookupError.Serializer.INSTANCE.serialize(value.pathValue, g); g.writeEndObject(); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(DownloadError.class, getTagMapping(), Tag.OTHER); - } @Override - public DownloadError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case PATH: { - LookupError value = null; - expectField(_p, "path"); - value = _p.readValueAs(LookupError.class); - _p.nextToken(); - return DownloadError.path(value); - } - case OTHER: { - return DownloadError.OTHER; - } + public DownloadError deserialize(JsonParser p) throws IOException, JsonParseException { + DownloadError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("path", DownloadError.Tag.PATH); - values.put("other", DownloadError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("path".equals(tag)) { + LookupError fieldValue = null; + expectField("path", p); + fieldValue = LookupError.Serializer.INSTANCE.deserialize(p); + value = DownloadError.path(fieldValue); + } + else { + value = DownloadError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/DownloadErrorException.java b/src/main/java/com/dropbox/core/v2/files/DownloadErrorException.java index 9150f02a3..0029e070f 100644 --- a/src/main/java/com/dropbox/core/v2/files/DownloadErrorException.java +++ b/src/main/java/com/dropbox/core/v2/files/DownloadErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; diff --git a/src/main/java/com/dropbox/core/v2/files/FileMetadata.java b/src/main/java/com/dropbox/core/v2/files/FileMetadata.java index 9d0d07054..46a559737 100644 --- a/src/main/java/com/dropbox/core/v2/files/FileMetadata.java +++ b/src/main/java/com/dropbox/core/v2/files/FileMetadata.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.dropbox.core.v2.properties.PropertyGroup; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.Date; import java.util.List; -@JsonSerialize(using=FileMetadata.Serializer.class) -@JsonDeserialize(using=FileMetadata.Deserializer.class) public class FileMetadata extends Metadata { // struct FileMetadata - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String id; protected final Date clientModified; protected final Date serverModified; @@ -519,7 +502,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -531,187 +514,166 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(FileMetadata.class); - } - - public Serializer(boolean unwrapping) { - super(FileMetadata.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(FileMetadata value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeStringField(".tag", "file"); - g.writeObjectField("name", value.name); - g.writeObjectField("path_lower", value.pathLower); - g.writeObjectField("path_display", value.pathDisplay); - g.writeObjectField("id", value.id); - g.writeObjectField("client_modified", value.clientModified); - g.writeObjectField("server_modified", value.serverModified); - g.writeObjectField("rev", value.rev); - g.writeObjectField("size", value.size); + public void serialize(FileMetadata value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + writeTag("file", g); + g.writeFieldName("name"); + StoneSerializers.string().serialize(value.name, g); + g.writeFieldName("path_lower"); + StoneSerializers.string().serialize(value.pathLower, g); + g.writeFieldName("path_display"); + StoneSerializers.string().serialize(value.pathDisplay, g); + g.writeFieldName("id"); + StoneSerializers.string().serialize(value.id, g); + g.writeFieldName("client_modified"); + StoneSerializers.timestamp().serialize(value.clientModified, g); + g.writeFieldName("server_modified"); + StoneSerializers.timestamp().serialize(value.serverModified, g); + g.writeFieldName("rev"); + StoneSerializers.string().serialize(value.rev, g); + g.writeFieldName("size"); + StoneSerializers.uInt64().serialize(value.size, g); if (value.parentSharedFolderId != null) { - g.writeObjectField("parent_shared_folder_id", value.parentSharedFolderId); + g.writeFieldName("parent_shared_folder_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.parentSharedFolderId, g); } if (value.mediaInfo != null) { - g.writeObjectField("media_info", value.mediaInfo); + g.writeFieldName("media_info"); + StoneSerializers.nullable(MediaInfo.Serializer.INSTANCE).serialize(value.mediaInfo, g); } if (value.sharingInfo != null) { - g.writeObjectField("sharing_info", value.sharingInfo); + g.writeFieldName("sharing_info"); + StoneSerializers.nullable(FileSharingInfo.Serializer.INSTANCE).serialize(value.sharingInfo, g); } if (value.propertyGroups != null) { - g.writeObjectField("property_groups", value.propertyGroups); + g.writeFieldName("property_groups"); + StoneSerializers.nullable(StoneSerializers.list(PropertyGroup.Serializer.INSTANCE)).serialize(value.propertyGroups, g); } if (value.hasExplicitSharedMembers != null) { - g.writeObjectField("has_explicit_shared_members", value.hasExplicitSharedMembers); + g.writeFieldName("has_explicit_shared_members"); + StoneSerializers.nullable(StoneSerializers.boolean_()).serialize(value.hasExplicitSharedMembers, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(FileMetadata.class); - } - - public Deserializer(boolean unwrapping) { - super(FileMetadata.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public FileMetadata deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - String _subtype_tag = readEnumeratedSubtypeTag(_p, "file"); - - String name = null; - String pathLower = null; - String pathDisplay = null; - String id = null; - Date clientModified = null; - Date serverModified = null; - String rev = null; - Long size = null; - String parentSharedFolderId = null; - MediaInfo mediaInfo = null; - FileSharingInfo sharingInfo = null; - List propertyGroups = null; - Boolean hasExplicitSharedMembers = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("name".equals(_field)) { - name = getStringValue(_p); - _p.nextToken(); + public FileMetadata deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + FileMetadata value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + if ("file".equals(tag)) { + tag = null; } - else if ("path_lower".equals(_field)) { - pathLower = getStringValue(_p); - _p.nextToken(); - } - else if ("path_display".equals(_field)) { - pathDisplay = getStringValue(_p); - _p.nextToken(); - } - else if ("id".equals(_field)) { - id = getStringValue(_p); - _p.nextToken(); - } - else if ("client_modified".equals(_field)) { - clientModified = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); - } - else if ("server_modified".equals(_field)) { - serverModified = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); + } + if (tag == null) { + String f_name = null; + String f_pathLower = null; + String f_pathDisplay = null; + String f_id = null; + Date f_clientModified = null; + Date f_serverModified = null; + String f_rev = null; + Long f_size = null; + String f_parentSharedFolderId = null; + MediaInfo f_mediaInfo = null; + FileSharingInfo f_sharingInfo = null; + List f_propertyGroups = null; + Boolean f_hasExplicitSharedMembers = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("name".equals(field)) { + f_name = StoneSerializers.string().deserialize(p); + } + else if ("path_lower".equals(field)) { + f_pathLower = StoneSerializers.string().deserialize(p); + } + else if ("path_display".equals(field)) { + f_pathDisplay = StoneSerializers.string().deserialize(p); + } + else if ("id".equals(field)) { + f_id = StoneSerializers.string().deserialize(p); + } + else if ("client_modified".equals(field)) { + f_clientModified = StoneSerializers.timestamp().deserialize(p); + } + else if ("server_modified".equals(field)) { + f_serverModified = StoneSerializers.timestamp().deserialize(p); + } + else if ("rev".equals(field)) { + f_rev = StoneSerializers.string().deserialize(p); + } + else if ("size".equals(field)) { + f_size = StoneSerializers.uInt64().deserialize(p); + } + else if ("parent_shared_folder_id".equals(field)) { + f_parentSharedFolderId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("media_info".equals(field)) { + f_mediaInfo = StoneSerializers.nullable(MediaInfo.Serializer.INSTANCE).deserialize(p); + } + else if ("sharing_info".equals(field)) { + f_sharingInfo = StoneSerializers.nullable(FileSharingInfo.Serializer.INSTANCE).deserialize(p); + } + else if ("property_groups".equals(field)) { + f_propertyGroups = StoneSerializers.nullable(StoneSerializers.list(PropertyGroup.Serializer.INSTANCE)).deserialize(p); + } + else if ("has_explicit_shared_members".equals(field)) { + f_hasExplicitSharedMembers = StoneSerializers.nullable(StoneSerializers.boolean_()).deserialize(p); + } + else { + skipValue(p); + } } - else if ("rev".equals(_field)) { - rev = getStringValue(_p); - _p.nextToken(); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } - else if ("size".equals(_field)) { - size = _p.getLongValue(); - assertUnsigned(_p, size); - _p.nextToken(); + if (f_pathLower == null) { + throw new JsonParseException(p, "Required field \"path_lower\" missing."); } - else if ("parent_shared_folder_id".equals(_field)) { - parentSharedFolderId = getStringValue(_p); - _p.nextToken(); + if (f_pathDisplay == null) { + throw new JsonParseException(p, "Required field \"path_display\" missing."); } - else if ("media_info".equals(_field)) { - mediaInfo = _p.readValueAs(MediaInfo.class); - _p.nextToken(); + if (f_id == null) { + throw new JsonParseException(p, "Required field \"id\" missing."); } - else if ("sharing_info".equals(_field)) { - sharingInfo = _p.readValueAs(FileSharingInfo.class); - _p.nextToken(); + if (f_clientModified == null) { + throw new JsonParseException(p, "Required field \"client_modified\" missing."); } - else if ("property_groups".equals(_field)) { - expectArrayStart(_p); - propertyGroups = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - PropertyGroup _x = null; - _x = _p.readValueAs(PropertyGroup.class); - _p.nextToken(); - propertyGroups.add(_x); - } - expectArrayEnd(_p); - _p.nextToken(); + if (f_serverModified == null) { + throw new JsonParseException(p, "Required field \"server_modified\" missing."); } - else if ("has_explicit_shared_members".equals(_field)) { - hasExplicitSharedMembers = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_rev == null) { + throw new JsonParseException(p, "Required field \"rev\" missing."); } - else { - skipValue(_p); + if (f_size == null) { + throw new JsonParseException(p, "Required field \"size\" missing."); } + value = new FileMetadata(f_name, f_pathLower, f_pathDisplay, f_id, f_clientModified, f_serverModified, f_rev, f_size, f_parentSharedFolderId, f_mediaInfo, f_sharingInfo, f_propertyGroups, f_hasExplicitSharedMembers); } - - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (pathLower == null) { - throw new JsonParseException(_p, "Required field \"path_lower\" is missing."); - } - if (pathDisplay == null) { - throw new JsonParseException(_p, "Required field \"path_display\" is missing."); - } - if (id == null) { - throw new JsonParseException(_p, "Required field \"id\" is missing."); - } - if (clientModified == null) { - throw new JsonParseException(_p, "Required field \"client_modified\" is missing."); + if (!collapsed) { + expectEndObject(p); } - if (serverModified == null) { - throw new JsonParseException(_p, "Required field \"server_modified\" is missing."); - } - if (rev == null) { - throw new JsonParseException(_p, "Required field \"rev\" is missing."); - } - if (size == null) { - throw new JsonParseException(_p, "Required field \"size\" is missing."); - } - - return new FileMetadata(name, pathLower, pathDisplay, id, clientModified, serverModified, rev, size, parentSharedFolderId, mediaInfo, sharingInfo, propertyGroups, hasExplicitSharedMembers); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/FileSharingInfo.java b/src/main/java/com/dropbox/core/v2/files/FileSharingInfo.java index eb54299fc..d0234f016 100644 --- a/src/main/java/com/dropbox/core/v2/files/FileSharingInfo.java +++ b/src/main/java/com/dropbox/core/v2/files/FileSharingInfo.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Sharing info for a file which is contained by a shared folder. */ -@JsonSerialize(using=FileSharingInfo.Serializer.class) -@JsonDeserialize(using=FileSharingInfo.Deserializer.class) public class FileSharingInfo extends SharingInfo { // struct FileSharingInfo - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String parentSharedFolderId; protected final String modifiedBy; @@ -140,7 +123,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -152,95 +135,76 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(FileSharingInfo.class); - } - - public Serializer(boolean unwrapping) { - super(FileSharingInfo.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(FileSharingInfo value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("read_only", value.readOnly); - g.writeObjectField("parent_shared_folder_id", value.parentSharedFolderId); + public void serialize(FileSharingInfo value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("read_only"); + StoneSerializers.boolean_().serialize(value.readOnly, g); + g.writeFieldName("parent_shared_folder_id"); + StoneSerializers.string().serialize(value.parentSharedFolderId, g); if (value.modifiedBy != null) { - g.writeObjectField("modified_by", value.modifiedBy); + g.writeFieldName("modified_by"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.modifiedBy, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(FileSharingInfo.class); - } - - public Deserializer(boolean unwrapping) { - super(FileSharingInfo.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public FileSharingInfo deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - Boolean readOnly = null; - String parentSharedFolderId = null; - String modifiedBy = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("read_only".equals(_field)) { - readOnly = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("parent_shared_folder_id".equals(_field)) { - parentSharedFolderId = getStringValue(_p); - _p.nextToken(); + public FileSharingInfo deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + FileSharingInfo value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Boolean f_readOnly = null; + String f_parentSharedFolderId = null; + String f_modifiedBy = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("read_only".equals(field)) { + f_readOnly = StoneSerializers.boolean_().deserialize(p); + } + else if ("parent_shared_folder_id".equals(field)) { + f_parentSharedFolderId = StoneSerializers.string().deserialize(p); + } + else if ("modified_by".equals(field)) { + f_modifiedBy = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } - else if ("modified_by".equals(_field)) { - modifiedBy = getStringValue(_p); - _p.nextToken(); + if (f_readOnly == null) { + throw new JsonParseException(p, "Required field \"read_only\" missing."); } - else { - skipValue(_p); + if (f_parentSharedFolderId == null) { + throw new JsonParseException(p, "Required field \"parent_shared_folder_id\" missing."); } + value = new FileSharingInfo(f_readOnly, f_parentSharedFolderId, f_modifiedBy); } - - if (readOnly == null) { - throw new JsonParseException(_p, "Required field \"read_only\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (parentSharedFolderId == null) { - throw new JsonParseException(_p, "Required field \"parent_shared_folder_id\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new FileSharingInfo(readOnly, parentSharedFolderId, modifiedBy); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/FolderMetadata.java b/src/main/java/com/dropbox/core/v2/files/FolderMetadata.java index cf321d2b9..9764cf83b 100644 --- a/src/main/java/com/dropbox/core/v2/files/FolderMetadata.java +++ b/src/main/java/com/dropbox/core/v2/files/FolderMetadata.java @@ -1,41 +1,24 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.dropbox.core.v2.properties.PropertyGroup; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=FolderMetadata.Serializer.class) -@JsonDeserialize(using=FolderMetadata.Deserializer.class) public class FolderMetadata extends Metadata { // struct FolderMetadata - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String id; protected final String sharedFolderId; protected final FolderSharingInfo sharingInfo; @@ -355,7 +338,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -367,142 +350,122 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(FolderMetadata.class); - } - - public Serializer(boolean unwrapping) { - super(FolderMetadata.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(FolderMetadata value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeStringField(".tag", "folder"); - g.writeObjectField("name", value.name); - g.writeObjectField("path_lower", value.pathLower); - g.writeObjectField("path_display", value.pathDisplay); - g.writeObjectField("id", value.id); + public void serialize(FolderMetadata value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + writeTag("folder", g); + g.writeFieldName("name"); + StoneSerializers.string().serialize(value.name, g); + g.writeFieldName("path_lower"); + StoneSerializers.string().serialize(value.pathLower, g); + g.writeFieldName("path_display"); + StoneSerializers.string().serialize(value.pathDisplay, g); + g.writeFieldName("id"); + StoneSerializers.string().serialize(value.id, g); if (value.parentSharedFolderId != null) { - g.writeObjectField("parent_shared_folder_id", value.parentSharedFolderId); + g.writeFieldName("parent_shared_folder_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.parentSharedFolderId, g); } if (value.sharedFolderId != null) { - g.writeObjectField("shared_folder_id", value.sharedFolderId); + g.writeFieldName("shared_folder_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.sharedFolderId, g); } if (value.sharingInfo != null) { - g.writeObjectField("sharing_info", value.sharingInfo); + g.writeFieldName("sharing_info"); + StoneSerializers.nullable(FolderSharingInfo.Serializer.INSTANCE).serialize(value.sharingInfo, g); } if (value.propertyGroups != null) { - g.writeObjectField("property_groups", value.propertyGroups); + g.writeFieldName("property_groups"); + StoneSerializers.nullable(StoneSerializers.list(PropertyGroup.Serializer.INSTANCE)).serialize(value.propertyGroups, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(FolderMetadata.class); - } - - public Deserializer(boolean unwrapping) { - super(FolderMetadata.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public FolderMetadata deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - String _subtype_tag = readEnumeratedSubtypeTag(_p, "folder"); - - String name = null; - String pathLower = null; - String pathDisplay = null; - String id = null; - String parentSharedFolderId = null; - String sharedFolderId = null; - FolderSharingInfo sharingInfo = null; - List propertyGroups = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("name".equals(_field)) { - name = getStringValue(_p); - _p.nextToken(); + public FolderMetadata deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + FolderMetadata value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + if ("folder".equals(tag)) { + tag = null; } - else if ("path_lower".equals(_field)) { - pathLower = getStringValue(_p); - _p.nextToken(); - } - else if ("path_display".equals(_field)) { - pathDisplay = getStringValue(_p); - _p.nextToken(); - } - else if ("id".equals(_field)) { - id = getStringValue(_p); - _p.nextToken(); - } - else if ("parent_shared_folder_id".equals(_field)) { - parentSharedFolderId = getStringValue(_p); - _p.nextToken(); + } + if (tag == null) { + String f_name = null; + String f_pathLower = null; + String f_pathDisplay = null; + String f_id = null; + String f_parentSharedFolderId = null; + String f_sharedFolderId = null; + FolderSharingInfo f_sharingInfo = null; + List f_propertyGroups = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("name".equals(field)) { + f_name = StoneSerializers.string().deserialize(p); + } + else if ("path_lower".equals(field)) { + f_pathLower = StoneSerializers.string().deserialize(p); + } + else if ("path_display".equals(field)) { + f_pathDisplay = StoneSerializers.string().deserialize(p); + } + else if ("id".equals(field)) { + f_id = StoneSerializers.string().deserialize(p); + } + else if ("parent_shared_folder_id".equals(field)) { + f_parentSharedFolderId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("shared_folder_id".equals(field)) { + f_sharedFolderId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("sharing_info".equals(field)) { + f_sharingInfo = StoneSerializers.nullable(FolderSharingInfo.Serializer.INSTANCE).deserialize(p); + } + else if ("property_groups".equals(field)) { + f_propertyGroups = StoneSerializers.nullable(StoneSerializers.list(PropertyGroup.Serializer.INSTANCE)).deserialize(p); + } + else { + skipValue(p); + } } - else if ("shared_folder_id".equals(_field)) { - sharedFolderId = getStringValue(_p); - _p.nextToken(); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } - else if ("sharing_info".equals(_field)) { - sharingInfo = _p.readValueAs(FolderSharingInfo.class); - _p.nextToken(); + if (f_pathLower == null) { + throw new JsonParseException(p, "Required field \"path_lower\" missing."); } - else if ("property_groups".equals(_field)) { - expectArrayStart(_p); - propertyGroups = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - PropertyGroup _x = null; - _x = _p.readValueAs(PropertyGroup.class); - _p.nextToken(); - propertyGroups.add(_x); - } - expectArrayEnd(_p); - _p.nextToken(); + if (f_pathDisplay == null) { + throw new JsonParseException(p, "Required field \"path_display\" missing."); } - else { - skipValue(_p); + if (f_id == null) { + throw new JsonParseException(p, "Required field \"id\" missing."); } + value = new FolderMetadata(f_name, f_pathLower, f_pathDisplay, f_id, f_parentSharedFolderId, f_sharedFolderId, f_sharingInfo, f_propertyGroups); } - - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (pathLower == null) { - throw new JsonParseException(_p, "Required field \"path_lower\" is missing."); + if (!collapsed) { + expectEndObject(p); } - if (pathDisplay == null) { - throw new JsonParseException(_p, "Required field \"path_display\" is missing."); - } - if (id == null) { - throw new JsonParseException(_p, "Required field \"id\" is missing."); - } - - return new FolderMetadata(name, pathLower, pathDisplay, id, parentSharedFolderId, sharedFolderId, sharingInfo, propertyGroups); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/FolderSharingInfo.java b/src/main/java/com/dropbox/core/v2/files/FolderSharingInfo.java index b1771da82..6b15c1a54 100644 --- a/src/main/java/com/dropbox/core/v2/files/FolderSharingInfo.java +++ b/src/main/java/com/dropbox/core/v2/files/FolderSharingInfo.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; @@ -29,15 +18,9 @@ * Sharing info for a folder which is contained in a shared folder or is a * shared folder mount point. */ -@JsonSerialize(using=FolderSharingInfo.Serializer.class) -@JsonDeserialize(using=FolderSharingInfo.Deserializer.class) public class FolderSharingInfo extends SharingInfo { // struct FolderSharingInfo - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String parentSharedFolderId; protected final String sharedFolderId; @@ -218,7 +201,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -230,94 +213,75 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(FolderSharingInfo.class); - } - - public Serializer(boolean unwrapping) { - super(FolderSharingInfo.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(FolderSharingInfo value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("read_only", value.readOnly); + public void serialize(FolderSharingInfo value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("read_only"); + StoneSerializers.boolean_().serialize(value.readOnly, g); if (value.parentSharedFolderId != null) { - g.writeObjectField("parent_shared_folder_id", value.parentSharedFolderId); + g.writeFieldName("parent_shared_folder_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.parentSharedFolderId, g); } if (value.sharedFolderId != null) { - g.writeObjectField("shared_folder_id", value.sharedFolderId); + g.writeFieldName("shared_folder_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.sharedFolderId, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(FolderSharingInfo.class); - } - - public Deserializer(boolean unwrapping) { - super(FolderSharingInfo.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public FolderSharingInfo deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - Boolean readOnly = null; - String parentSharedFolderId = null; - String sharedFolderId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("read_only".equals(_field)) { - readOnly = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("parent_shared_folder_id".equals(_field)) { - parentSharedFolderId = getStringValue(_p); - _p.nextToken(); - } - else if ("shared_folder_id".equals(_field)) { - sharedFolderId = getStringValue(_p); - _p.nextToken(); + public FolderSharingInfo deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + FolderSharingInfo value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Boolean f_readOnly = null; + String f_parentSharedFolderId = null; + String f_sharedFolderId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("read_only".equals(field)) { + f_readOnly = StoneSerializers.boolean_().deserialize(p); + } + else if ("parent_shared_folder_id".equals(field)) { + f_parentSharedFolderId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("shared_folder_id".equals(field)) { + f_sharedFolderId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_readOnly == null) { + throw new JsonParseException(p, "Required field \"read_only\" missing."); } + value = new FolderSharingInfo(f_readOnly, f_parentSharedFolderId, f_sharedFolderId); } - - if (readOnly == null) { - throw new JsonParseException(_p, "Required field \"read_only\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new FolderSharingInfo(readOnly, parentSharedFolderId, sharedFolderId); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/GetCopyReferenceArg.java b/src/main/java/com/dropbox/core/v2/files/GetCopyReferenceArg.java index 209ce6139..cd548d302 100644 --- a/src/main/java/com/dropbox/core/v2/files/GetCopyReferenceArg.java +++ b/src/main/java/com/dropbox/core/v2/files/GetCopyReferenceArg.java @@ -1,46 +1,29 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=GetCopyReferenceArg.Serializer.class) -@JsonDeserialize(using=GetCopyReferenceArg.Deserializer.class) class GetCopyReferenceArg { // struct GetCopyReferenceArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String path; /** * * @param path The path to the file or folder you want to get a copy * reference to. Must match pattern "{@code - * ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -49,7 +32,7 @@ public GetCopyReferenceArg(String path) { if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("((/|id:).*)|(rev:[0-9a-f]{9,})", path)) { + if (!java.util.regex.Pattern.matches("(/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -89,7 +72,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -101,78 +84,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetCopyReferenceArg.class); - } - - public Serializer(boolean unwrapping) { - super(GetCopyReferenceArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GetCopyReferenceArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("path", value.path); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetCopyReferenceArg.class); - } - - public Deserializer(boolean unwrapping) { - super(GetCopyReferenceArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GetCopyReferenceArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("path"); + StoneSerializers.string().serialize(value.path, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GetCopyReferenceArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String path = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); + public GetCopyReferenceArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GetCopyReferenceArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_path = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("path".equals(field)) { + f_path = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_path == null) { + throw new JsonParseException(p, "Required field \"path\" missing."); } + value = new GetCopyReferenceArg(f_path); } - - if (path == null) { - throw new JsonParseException(_p, "Required field \"path\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new GetCopyReferenceArg(path); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/GetCopyReferenceError.java b/src/main/java/com/dropbox/core/v2/files/GetCopyReferenceError.java index 3e5e4dc91..f8ec0e6ac 100644 --- a/src/main/java/com/dropbox/core/v2/files/GetCopyReferenceError.java +++ b/src/main/java/com/dropbox/core/v2/files/GetCopyReferenceError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=GetCopyReferenceError.Serializer.class) -@JsonDeserialize(using=GetCopyReferenceError.Deserializer.class) public final class GetCopyReferenceError { // union GetCopyReferenceError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link GetCopyReferenceError}. */ @@ -190,7 +172,7 @@ else if (obj instanceof GetCopyReferenceError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -202,71 +184,64 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetCopyReferenceError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GetCopyReferenceError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case PATH: + public void serialize(GetCopyReferenceError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PATH: { g.writeStartObject(); - g.writeStringField(".tag", "path"); - g.writeObjectField("path", value.pathValue); + writeTag("path", g); + g.writeFieldName("path"); + LookupError.Serializer.INSTANCE.serialize(value.pathValue, g); g.writeEndObject(); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetCopyReferenceError.class, getTagMapping(), Tag.OTHER); - } @Override - public GetCopyReferenceError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case PATH: { - LookupError value = null; - expectField(_p, "path"); - value = _p.readValueAs(LookupError.class); - _p.nextToken(); - return GetCopyReferenceError.path(value); - } - case OTHER: { - return GetCopyReferenceError.OTHER; - } + public GetCopyReferenceError deserialize(JsonParser p) throws IOException, JsonParseException { + GetCopyReferenceError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("path", GetCopyReferenceError.Tag.PATH); - values.put("other", GetCopyReferenceError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("path".equals(tag)) { + LookupError fieldValue = null; + expectField("path", p); + fieldValue = LookupError.Serializer.INSTANCE.deserialize(p); + value = GetCopyReferenceError.path(fieldValue); + } + else { + value = GetCopyReferenceError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/GetCopyReferenceErrorException.java b/src/main/java/com/dropbox/core/v2/files/GetCopyReferenceErrorException.java index eb3e74d21..61d8b99bf 100644 --- a/src/main/java/com/dropbox/core/v2/files/GetCopyReferenceErrorException.java +++ b/src/main/java/com/dropbox/core/v2/files/GetCopyReferenceErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; diff --git a/src/main/java/com/dropbox/core/v2/files/GetCopyReferenceResult.java b/src/main/java/com/dropbox/core/v2/files/GetCopyReferenceResult.java index 514bdb446..0c86a1309 100644 --- a/src/main/java/com/dropbox/core/v2/files/GetCopyReferenceResult.java +++ b/src/main/java/com/dropbox/core/v2/files/GetCopyReferenceResult.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.Date; -@JsonSerialize(using=GetCopyReferenceResult.Serializer.class) -@JsonDeserialize(using=GetCopyReferenceResult.Deserializer.class) public class GetCopyReferenceResult { // struct GetCopyReferenceResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final Metadata metadata; protected final String copyReference; protected final Date expires; @@ -126,7 +109,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -138,96 +121,77 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetCopyReferenceResult.class); - } - - public Serializer(boolean unwrapping) { - super(GetCopyReferenceResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GetCopyReferenceResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("metadata", value.metadata); - g.writeObjectField("copy_reference", value.copyReference); - g.writeObjectField("expires", value.expires); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetCopyReferenceResult.class); - } - - public Deserializer(boolean unwrapping) { - super(GetCopyReferenceResult.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GetCopyReferenceResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("metadata"); + Metadata.Serializer.INSTANCE.serialize(value.metadata, g); + g.writeFieldName("copy_reference"); + StoneSerializers.string().serialize(value.copyReference, g); + g.writeFieldName("expires"); + StoneSerializers.timestamp().serialize(value.expires, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GetCopyReferenceResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - Metadata metadata = null; - String copyReference = null; - Date expires = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("metadata".equals(_field)) { - metadata = _p.readValueAs(Metadata.class); - _p.nextToken(); + public GetCopyReferenceResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GetCopyReferenceResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Metadata f_metadata = null; + String f_copyReference = null; + Date f_expires = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("metadata".equals(field)) { + f_metadata = Metadata.Serializer.INSTANCE.deserialize(p); + } + else if ("copy_reference".equals(field)) { + f_copyReference = StoneSerializers.string().deserialize(p); + } + else if ("expires".equals(field)) { + f_expires = StoneSerializers.timestamp().deserialize(p); + } + else { + skipValue(p); + } } - else if ("copy_reference".equals(_field)) { - copyReference = getStringValue(_p); - _p.nextToken(); + if (f_metadata == null) { + throw new JsonParseException(p, "Required field \"metadata\" missing."); } - else if ("expires".equals(_field)) { - expires = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); + if (f_copyReference == null) { + throw new JsonParseException(p, "Required field \"copy_reference\" missing."); } - else { - skipValue(_p); + if (f_expires == null) { + throw new JsonParseException(p, "Required field \"expires\" missing."); } + value = new GetCopyReferenceResult(f_metadata, f_copyReference, f_expires); } - - if (metadata == null) { - throw new JsonParseException(_p, "Required field \"metadata\" is missing."); - } - if (copyReference == null) { - throw new JsonParseException(_p, "Required field \"copy_reference\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (expires == null) { - throw new JsonParseException(_p, "Required field \"expires\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new GetCopyReferenceResult(metadata, copyReference, expires); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/GetMetadataArg.java b/src/main/java/com/dropbox/core/v2/files/GetMetadataArg.java index 1e9ad616a..89195c05a 100644 --- a/src/main/java/com/dropbox/core/v2/files/GetMetadataArg.java +++ b/src/main/java/com/dropbox/core/v2/files/GetMetadataArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=GetMetadataArg.Serializer.class) -@JsonDeserialize(using=GetMetadataArg.Deserializer.class) class GetMetadataArg { // struct GetMetadataArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String path; protected final boolean includeMediaInfo; protected final boolean includeDeleted; @@ -44,7 +27,8 @@ class GetMetadataArg { * specifying values for all optional fields. * * @param path The path of a file or folder on Dropbox. Must match pattern - * "{@code ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * "{@code (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code + * null}. * @param includeMediaInfo If true, {@link FileMetadata#getMediaInfo} is * set for photo and video. * @param includeDeleted If true, {@link DeletedMetadata} will be returned @@ -61,7 +45,7 @@ public GetMetadataArg(String path, boolean includeMediaInfo, boolean includeDele if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("((/|id:).*)|(rev:[0-9a-f]{9,})", path)) { + if (!java.util.regex.Pattern.matches("(/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -74,7 +58,8 @@ public GetMetadataArg(String path, boolean includeMediaInfo, boolean includeDele * The default values for unset fields will be used. * * @param path The path of a file or folder on Dropbox. Must match pattern - * "{@code ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * "{@code (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code + * null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -128,7 +113,8 @@ public boolean getIncludeHasExplicitSharedMembers() { * Returns a new builder for creating an instance of this class. * * @param path The path of a file or folder on Dropbox. Must match pattern - * "{@code ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * "{@code (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code + * null}. * * @return builder for this class. * @@ -153,7 +139,7 @@ protected Builder(String path) { if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("((/|id:).*)|(rev:[0-9a-f]{9,})", path)) { + if (!java.util.regex.Pattern.matches("(/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -273,7 +259,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -285,96 +271,77 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetMetadataArg.class); - } - - public Serializer(boolean unwrapping) { - super(GetMetadataArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GetMetadataArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("path", value.path); - g.writeObjectField("include_media_info", value.includeMediaInfo); - g.writeObjectField("include_deleted", value.includeDeleted); - g.writeObjectField("include_has_explicit_shared_members", value.includeHasExplicitSharedMembers); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetMetadataArg.class); - } - - public Deserializer(boolean unwrapping) { - super(GetMetadataArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GetMetadataArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("path"); + StoneSerializers.string().serialize(value.path, g); + g.writeFieldName("include_media_info"); + StoneSerializers.boolean_().serialize(value.includeMediaInfo, g); + g.writeFieldName("include_deleted"); + StoneSerializers.boolean_().serialize(value.includeDeleted, g); + g.writeFieldName("include_has_explicit_shared_members"); + StoneSerializers.boolean_().serialize(value.includeHasExplicitSharedMembers, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GetMetadataArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String path = null; - boolean includeMediaInfo = false; - boolean includeDeleted = false; - boolean includeHasExplicitSharedMembers = false; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); - } - else if ("include_media_info".equals(_field)) { - includeMediaInfo = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("include_deleted".equals(_field)) { - includeDeleted = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("include_has_explicit_shared_members".equals(_field)) { - includeHasExplicitSharedMembers = _p.getValueAsBoolean(); - _p.nextToken(); + public GetMetadataArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GetMetadataArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_path = null; + Boolean f_includeMediaInfo = false; + Boolean f_includeDeleted = false; + Boolean f_includeHasExplicitSharedMembers = false; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("path".equals(field)) { + f_path = StoneSerializers.string().deserialize(p); + } + else if ("include_media_info".equals(field)) { + f_includeMediaInfo = StoneSerializers.boolean_().deserialize(p); + } + else if ("include_deleted".equals(field)) { + f_includeDeleted = StoneSerializers.boolean_().deserialize(p); + } + else if ("include_has_explicit_shared_members".equals(field)) { + f_includeHasExplicitSharedMembers = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_path == null) { + throw new JsonParseException(p, "Required field \"path\" missing."); } + value = new GetMetadataArg(f_path, f_includeMediaInfo, f_includeDeleted, f_includeHasExplicitSharedMembers); } - - if (path == null) { - throw new JsonParseException(_p, "Required field \"path\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new GetMetadataArg(path, includeMediaInfo, includeDeleted, includeHasExplicitSharedMembers); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/GetMetadataBuilder.java b/src/main/java/com/dropbox/core/v2/files/GetMetadataBuilder.java index 21933c9b1..5a8793270 100644 --- a/src/main/java/com/dropbox/core/v2/files/GetMetadataBuilder.java +++ b/src/main/java/com/dropbox/core/v2/files/GetMetadataBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; @@ -13,26 +13,26 @@ * request.

*/ public class GetMetadataBuilder { - private final DbxUserFilesRequests files; + private final DbxUserFilesRequests files_; private final GetMetadataArg.Builder getMetadataArgBuilder; /** * Creates a new instance of this builder. * - * @param files Dropbox namespace-specific client used to issue files + * @param files_ Dropbox namespace-specific client used to issue files * requests. * @param getMetadataArgBuilder Request argument builder. * * @return instsance of this builder */ - GetMetadataBuilder(DbxUserFilesRequests files, GetMetadataArg.Builder getMetadataArgBuilder) { - if (files == null) { - throw new NullPointerException("files"); + GetMetadataBuilder(DbxUserFilesRequests files_, GetMetadataArg.Builder getMetadataArgBuilder) { + if (files_ == null) { + throw new NullPointerException("files_"); } + this.files_ = files_; if (getMetadataArgBuilder == null) { throw new NullPointerException("getMetadataArgBuilder"); } - this.files = files; this.getMetadataArgBuilder = getMetadataArgBuilder; } @@ -88,7 +88,7 @@ public GetMetadataBuilder withIncludeHasExplicitSharedMembers(Boolean includeHas * Issues the request. */ public Metadata start() throws GetMetadataErrorException, DbxException { - GetMetadataArg arg = this.getMetadataArgBuilder.build(); - return files.getMetadata(arg); + GetMetadataArg arg_ = this.getMetadataArgBuilder.build(); + return files_.getMetadata(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/files/GetMetadataError.java b/src/main/java/com/dropbox/core/v2/files/GetMetadataError.java index 7ecbdf33a..fde97680d 100644 --- a/src/main/java/com/dropbox/core/v2/files/GetMetadataError.java +++ b/src/main/java/com/dropbox/core/v2/files/GetMetadataError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is a tagged union. Tagged unions instances are always associated @@ -32,15 +20,9 @@ * return {@code true}. You can use {@link #tag()} to determine the tag * associated with this instance. */ -@JsonSerialize(using=GetMetadataError.Serializer.class) -@JsonDeserialize(using=GetMetadataError.Deserializer.class) public final class GetMetadataError { // union GetMetadataError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link GetMetadataError}. */ @@ -152,7 +134,7 @@ else if (obj instanceof GetMetadataError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -164,64 +146,63 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); + return Serializer.INSTANCE.serialize(this, true); } - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetMetadataError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GetMetadataError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case PATH: + public void serialize(GetMetadataError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PATH: { g.writeStartObject(); - g.writeStringField(".tag", "path"); - g.writeObjectField("path", value.pathValue); + writeTag("path", g); + g.writeFieldName("path"); + LookupError.Serializer.INSTANCE.serialize(value.pathValue, g); g.writeEndObject(); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetMetadataError.class, getTagMapping(), null); - } @Override - public GetMetadataError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case PATH: { - LookupError value = null; - expectField(_p, "path"); - value = _p.readValueAs(LookupError.class); - _p.nextToken(); - return GetMetadataError.path(value); - } + public GetMetadataError deserialize(JsonParser p) throws IOException, JsonParseException { + GetMetadataError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("path", GetMetadataError.Tag.PATH); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("path".equals(tag)) { + LookupError fieldValue = null; + expectField("path", p); + fieldValue = LookupError.Serializer.INSTANCE.deserialize(p); + value = GetMetadataError.path(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/GetMetadataErrorException.java b/src/main/java/com/dropbox/core/v2/files/GetMetadataErrorException.java index 51966ec20..86c0467d9 100644 --- a/src/main/java/com/dropbox/core/v2/files/GetMetadataErrorException.java +++ b/src/main/java/com/dropbox/core/v2/files/GetMetadataErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; diff --git a/src/main/java/com/dropbox/core/v2/files/GetPreviewBuilder.java b/src/main/java/com/dropbox/core/v2/files/GetPreviewBuilder.java new file mode 100644 index 000000000..e7bd42cef --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/files/GetPreviewBuilder.java @@ -0,0 +1,74 @@ +/* DO NOT EDIT */ +/* This file was generated from files.stone */ + +package com.dropbox.core.v2.files; + +import com.dropbox.core.DbxDownloader; +import com.dropbox.core.DbxException; +import com.dropbox.core.v2.DbxDownloadStyleBuilder; + +/** + * The request builder returned by {@link + * DbxUserFilesRequests#getPreview(String)}. + * + *

Use this class to set optional request parameters and complete the + * request.

+ */ +public class GetPreviewBuilder extends DbxDownloadStyleBuilder { + private final DbxUserFilesRequests files_; + private final String path; + private String rev; + + /** + * Creates a new instance of this builder. + * + * @param path The path of the file to preview. Must match pattern "{@code + * (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * @param files_ Dropbox namespace-specific client used to issue files + * requests. + * + * @return instsance of this builder + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + GetPreviewBuilder(DbxUserFilesRequests files_, String path) { + if (files_ == null) { + throw new NullPointerException("files_"); + } + this.files_ = files_; + this.path = path; + this.rev = null; + } + + /** + * Set value for optional field. + * + * @param rev Deprecated. Please specify revision in the {@code path} + * argument to {@link DbxUserFilesRequests#getPreview(String)} instead. + * Must have length of at least 9 and match pattern "{@code [0-9a-f]+}". + * + * @return this builder + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public GetPreviewBuilder withRev(String rev) { + if (rev != null) { + if (rev.length() < 9) { + throw new IllegalArgumentException("String 'rev' is shorter than 9"); + } + if (!java.util.regex.Pattern.matches("[0-9a-f]+", rev)) { + throw new IllegalArgumentException("String 'rev' does not match pattern"); + } + } + this.rev = rev; + return this; + } + + @Override + public DbxDownloader start() throws PreviewErrorException, DbxException { + PreviewArg arg_ = new PreviewArg(path, rev); + return files_.getPreview(arg_, getHeaders()); + } +} diff --git a/src/main/java/com/dropbox/core/v2/files/GetTemporaryLinkArg.java b/src/main/java/com/dropbox/core/v2/files/GetTemporaryLinkArg.java index ad873349a..1f5b87b2b 100644 --- a/src/main/java/com/dropbox/core/v2/files/GetTemporaryLinkArg.java +++ b/src/main/java/com/dropbox/core/v2/files/GetTemporaryLinkArg.java @@ -1,46 +1,29 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=GetTemporaryLinkArg.Serializer.class) -@JsonDeserialize(using=GetTemporaryLinkArg.Deserializer.class) class GetTemporaryLinkArg { // struct GetTemporaryLinkArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String path; /** * * @param path The path to the file you want a temporary link to. Must - * match pattern "{@code ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be - * {@code null}. + * match pattern "{@code (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and + * not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -49,7 +32,7 @@ public GetTemporaryLinkArg(String path) { if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("((/|id:).*)|(rev:[0-9a-f]{9,})", path)) { + if (!java.util.regex.Pattern.matches("(/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -89,7 +72,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -101,78 +84,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetTemporaryLinkArg.class); - } - - public Serializer(boolean unwrapping) { - super(GetTemporaryLinkArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GetTemporaryLinkArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("path", value.path); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetTemporaryLinkArg.class); - } - - public Deserializer(boolean unwrapping) { - super(GetTemporaryLinkArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GetTemporaryLinkArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("path"); + StoneSerializers.string().serialize(value.path, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GetTemporaryLinkArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String path = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); + public GetTemporaryLinkArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GetTemporaryLinkArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_path = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("path".equals(field)) { + f_path = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_path == null) { + throw new JsonParseException(p, "Required field \"path\" missing."); } + value = new GetTemporaryLinkArg(f_path); } - - if (path == null) { - throw new JsonParseException(_p, "Required field \"path\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new GetTemporaryLinkArg(path); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/GetTemporaryLinkError.java b/src/main/java/com/dropbox/core/v2/files/GetTemporaryLinkError.java index 98ab0f39e..e98ec0c0b 100644 --- a/src/main/java/com/dropbox/core/v2/files/GetTemporaryLinkError.java +++ b/src/main/java/com/dropbox/core/v2/files/GetTemporaryLinkError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=GetTemporaryLinkError.Serializer.class) -@JsonDeserialize(using=GetTemporaryLinkError.Deserializer.class) public final class GetTemporaryLinkError { // union GetTemporaryLinkError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link GetTemporaryLinkError}. */ @@ -190,7 +172,7 @@ else if (obj instanceof GetTemporaryLinkError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -202,71 +184,64 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetTemporaryLinkError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GetTemporaryLinkError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case PATH: + public void serialize(GetTemporaryLinkError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PATH: { g.writeStartObject(); - g.writeStringField(".tag", "path"); - g.writeObjectField("path", value.pathValue); + writeTag("path", g); + g.writeFieldName("path"); + LookupError.Serializer.INSTANCE.serialize(value.pathValue, g); g.writeEndObject(); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetTemporaryLinkError.class, getTagMapping(), Tag.OTHER); - } @Override - public GetTemporaryLinkError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case PATH: { - LookupError value = null; - expectField(_p, "path"); - value = _p.readValueAs(LookupError.class); - _p.nextToken(); - return GetTemporaryLinkError.path(value); - } - case OTHER: { - return GetTemporaryLinkError.OTHER; - } + public GetTemporaryLinkError deserialize(JsonParser p) throws IOException, JsonParseException { + GetTemporaryLinkError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("path", GetTemporaryLinkError.Tag.PATH); - values.put("other", GetTemporaryLinkError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("path".equals(tag)) { + LookupError fieldValue = null; + expectField("path", p); + fieldValue = LookupError.Serializer.INSTANCE.deserialize(p); + value = GetTemporaryLinkError.path(fieldValue); + } + else { + value = GetTemporaryLinkError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/GetTemporaryLinkErrorException.java b/src/main/java/com/dropbox/core/v2/files/GetTemporaryLinkErrorException.java index e1543814c..0a802420c 100644 --- a/src/main/java/com/dropbox/core/v2/files/GetTemporaryLinkErrorException.java +++ b/src/main/java/com/dropbox/core/v2/files/GetTemporaryLinkErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; diff --git a/src/main/java/com/dropbox/core/v2/files/GetTemporaryLinkResult.java b/src/main/java/com/dropbox/core/v2/files/GetTemporaryLinkResult.java index 39fe9b1f8..7f10e1726 100644 --- a/src/main/java/com/dropbox/core/v2/files/GetTemporaryLinkResult.java +++ b/src/main/java/com/dropbox/core/v2/files/GetTemporaryLinkResult.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=GetTemporaryLinkResult.Serializer.class) -@JsonDeserialize(using=GetTemporaryLinkResult.Deserializer.class) public class GetTemporaryLinkResult { // struct GetTemporaryLinkResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final FileMetadata metadata; protected final String link; @@ -103,7 +86,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -115,87 +98,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetTemporaryLinkResult.class); - } - - public Serializer(boolean unwrapping) { - super(GetTemporaryLinkResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GetTemporaryLinkResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("metadata", value.metadata); - g.writeObjectField("link", value.link); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetTemporaryLinkResult.class); - } - - public Deserializer(boolean unwrapping) { - super(GetTemporaryLinkResult.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GetTemporaryLinkResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("metadata"); + FileMetadata.Serializer.INSTANCE.serialize(value.metadata, g); + g.writeFieldName("link"); + StoneSerializers.string().serialize(value.link, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GetTemporaryLinkResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - FileMetadata metadata = null; - String link = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("metadata".equals(_field)) { - metadata = _p.readValueAs(FileMetadata.class); - _p.nextToken(); + public GetTemporaryLinkResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GetTemporaryLinkResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + FileMetadata f_metadata = null; + String f_link = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("metadata".equals(field)) { + f_metadata = FileMetadata.Serializer.INSTANCE.deserialize(p); + } + else if ("link".equals(field)) { + f_link = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else if ("link".equals(_field)) { - link = getStringValue(_p); - _p.nextToken(); + if (f_metadata == null) { + throw new JsonParseException(p, "Required field \"metadata\" missing."); } - else { - skipValue(_p); + if (f_link == null) { + throw new JsonParseException(p, "Required field \"link\" missing."); } + value = new GetTemporaryLinkResult(f_metadata, f_link); } - - if (metadata == null) { - throw new JsonParseException(_p, "Required field \"metadata\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (link == null) { - throw new JsonParseException(_p, "Required field \"link\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new GetTemporaryLinkResult(metadata, link); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/GetThumbnailBuilder.java b/src/main/java/com/dropbox/core/v2/files/GetThumbnailBuilder.java index 404bf385c..a1b3fddc3 100644 --- a/src/main/java/com/dropbox/core/v2/files/GetThumbnailBuilder.java +++ b/src/main/java/com/dropbox/core/v2/files/GetThumbnailBuilder.java @@ -1,9 +1,11 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; +import com.dropbox.core.DbxDownloader; import com.dropbox.core.DbxException; +import com.dropbox.core.v2.DbxDownloadStyleBuilder; /** * The request builder returned by {@link @@ -12,27 +14,27 @@ *

Use this class to set optional request parameters and complete the * request.

*/ -public class GetThumbnailBuilder extends com.dropbox.core.v2.DbxDownloadStyleBuilder { - private final DbxUserFilesRequests files; +public class GetThumbnailBuilder extends DbxDownloadStyleBuilder { + private final DbxUserFilesRequests files_; private final ThumbnailArg.Builder thumbnailArgBuilder; /** * Creates a new instance of this builder. * - * @param files Dropbox namespace-specific client used to issue files + * @param files_ Dropbox namespace-specific client used to issue files * requests. * @param thumbnailArgBuilder Request argument builder. * * @return instsance of this builder */ - GetThumbnailBuilder(DbxUserFilesRequests files, ThumbnailArg.Builder thumbnailArgBuilder) { - if (files == null) { - throw new NullPointerException("files"); + GetThumbnailBuilder(DbxUserFilesRequests files_, ThumbnailArg.Builder thumbnailArgBuilder) { + if (files_ == null) { + throw new NullPointerException("files_"); } + this.files_ = files_; if (thumbnailArgBuilder == null) { throw new NullPointerException("thumbnailArgBuilder"); } - this.files = files; this.thumbnailArgBuilder = thumbnailArgBuilder; } @@ -71,8 +73,8 @@ public GetThumbnailBuilder withSize(ThumbnailSize size) { } @Override - public com.dropbox.core.DbxDownloader start() throws ThumbnailErrorException, DbxException { - ThumbnailArg arg = this.thumbnailArgBuilder.build(); - return files.getThumbnail(arg); + public DbxDownloader start() throws ThumbnailErrorException, DbxException { + ThumbnailArg arg_ = this.thumbnailArgBuilder.build(); + return files_.getThumbnail(arg_, getHeaders()); } } diff --git a/src/main/java/com/dropbox/core/v2/files/GpsCoordinates.java b/src/main/java/com/dropbox/core/v2/files/GpsCoordinates.java index 391c48e72..e03404a4c 100644 --- a/src/main/java/com/dropbox/core/v2/files/GpsCoordinates.java +++ b/src/main/java/com/dropbox/core/v2/files/GpsCoordinates.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * GPS coordinates for a photo or video. */ -@JsonSerialize(using=GpsCoordinates.Serializer.class) -@JsonDeserialize(using=GpsCoordinates.Deserializer.class) public class GpsCoordinates { // struct GpsCoordinates - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final double latitude; protected final double longitude; @@ -97,7 +80,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -109,87 +92,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GpsCoordinates.class); - } - - public Serializer(boolean unwrapping) { - super(GpsCoordinates.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GpsCoordinates value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("latitude", value.latitude); - g.writeObjectField("longitude", value.longitude); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GpsCoordinates.class); - } - - public Deserializer(boolean unwrapping) { - super(GpsCoordinates.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GpsCoordinates value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("latitude"); + StoneSerializers.float64().serialize(value.latitude, g); + g.writeFieldName("longitude"); + StoneSerializers.float64().serialize(value.longitude, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GpsCoordinates deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - Double latitude = null; - Double longitude = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("latitude".equals(_field)) { - latitude = _p.getDoubleValue(); - _p.nextToken(); + public GpsCoordinates deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GpsCoordinates value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Double f_latitude = null; + Double f_longitude = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("latitude".equals(field)) { + f_latitude = StoneSerializers.float64().deserialize(p); + } + else if ("longitude".equals(field)) { + f_longitude = StoneSerializers.float64().deserialize(p); + } + else { + skipValue(p); + } } - else if ("longitude".equals(_field)) { - longitude = _p.getDoubleValue(); - _p.nextToken(); + if (f_latitude == null) { + throw new JsonParseException(p, "Required field \"latitude\" missing."); } - else { - skipValue(_p); + if (f_longitude == null) { + throw new JsonParseException(p, "Required field \"longitude\" missing."); } + value = new GpsCoordinates(f_latitude, f_longitude); } - - if (latitude == null) { - throw new JsonParseException(_p, "Required field \"latitude\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (longitude == null) { - throw new JsonParseException(_p, "Required field \"longitude\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new GpsCoordinates(latitude, longitude); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/ListFolderArg.java b/src/main/java/com/dropbox/core/v2/files/ListFolderArg.java index 17b8f706e..b2bf6eb8b 100644 --- a/src/main/java/com/dropbox/core/v2/files/ListFolderArg.java +++ b/src/main/java/com/dropbox/core/v2/files/ListFolderArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=ListFolderArg.Serializer.class) -@JsonDeserialize(using=ListFolderArg.Deserializer.class) public class ListFolderArg { // struct ListFolderArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String path; protected final boolean recursive; protected final boolean includeMediaInfo; @@ -45,7 +28,7 @@ public class ListFolderArg { * specifying values for all optional fields. * * @param path The path to the folder you want to see the contents of. Must - * match pattern "{@code (/.*)?}" and not be {@code null}. + * match pattern "{@code (/(.|[\\r\\n])*)?}" and not be {@code null}. * @param recursive If true, the list folder operation will be applied * recursively to all subfolders and the response will contain contents * of all subfolders. @@ -64,7 +47,7 @@ public ListFolderArg(String path, boolean recursive, boolean includeMediaInfo, b if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("(/.*)?", path)) { + if (!java.util.regex.Pattern.matches("(/(.|[\\r\\n])*)?", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -78,7 +61,7 @@ public ListFolderArg(String path, boolean recursive, boolean includeMediaInfo, b * The default values for unset fields will be used. * * @param path The path to the folder you want to see the contents of. Must - * match pattern "{@code (/.*)?}" and not be {@code null}. + * match pattern "{@code (/(.|[\\r\\n])*)?}" and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -143,7 +126,7 @@ public boolean getIncludeHasExplicitSharedMembers() { * Returns a new builder for creating an instance of this class. * * @param path The path to the folder you want to see the contents of. Must - * match pattern "{@code (/.*)?}" and not be {@code null}. + * match pattern "{@code (/(.|[\\r\\n])*)?}" and not be {@code null}. * * @return builder for this class. * @@ -169,7 +152,7 @@ protected Builder(String path) { if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("(/.*)?", path)) { + if (!java.util.regex.Pattern.matches("(/(.|[\\r\\n])*)?", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -314,7 +297,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -326,102 +309,83 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListFolderArg.class); - } - - public Serializer(boolean unwrapping) { - super(ListFolderArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(ListFolderArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("path", value.path); - g.writeObjectField("recursive", value.recursive); - g.writeObjectField("include_media_info", value.includeMediaInfo); - g.writeObjectField("include_deleted", value.includeDeleted); - g.writeObjectField("include_has_explicit_shared_members", value.includeHasExplicitSharedMembers); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListFolderArg.class); - } - - public Deserializer(boolean unwrapping) { - super(ListFolderArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(ListFolderArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("path"); + StoneSerializers.string().serialize(value.path, g); + g.writeFieldName("recursive"); + StoneSerializers.boolean_().serialize(value.recursive, g); + g.writeFieldName("include_media_info"); + StoneSerializers.boolean_().serialize(value.includeMediaInfo, g); + g.writeFieldName("include_deleted"); + StoneSerializers.boolean_().serialize(value.includeDeleted, g); + g.writeFieldName("include_has_explicit_shared_members"); + StoneSerializers.boolean_().serialize(value.includeHasExplicitSharedMembers, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public ListFolderArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String path = null; - boolean recursive = false; - boolean includeMediaInfo = false; - boolean includeDeleted = false; - boolean includeHasExplicitSharedMembers = false; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); - } - else if ("recursive".equals(_field)) { - recursive = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("include_media_info".equals(_field)) { - includeMediaInfo = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("include_deleted".equals(_field)) { - includeDeleted = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("include_has_explicit_shared_members".equals(_field)) { - includeHasExplicitSharedMembers = _p.getValueAsBoolean(); - _p.nextToken(); + public ListFolderArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListFolderArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_path = null; + Boolean f_recursive = false; + Boolean f_includeMediaInfo = false; + Boolean f_includeDeleted = false; + Boolean f_includeHasExplicitSharedMembers = false; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("path".equals(field)) { + f_path = StoneSerializers.string().deserialize(p); + } + else if ("recursive".equals(field)) { + f_recursive = StoneSerializers.boolean_().deserialize(p); + } + else if ("include_media_info".equals(field)) { + f_includeMediaInfo = StoneSerializers.boolean_().deserialize(p); + } + else if ("include_deleted".equals(field)) { + f_includeDeleted = StoneSerializers.boolean_().deserialize(p); + } + else if ("include_has_explicit_shared_members".equals(field)) { + f_includeHasExplicitSharedMembers = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_path == null) { + throw new JsonParseException(p, "Required field \"path\" missing."); } + value = new ListFolderArg(f_path, f_recursive, f_includeMediaInfo, f_includeDeleted, f_includeHasExplicitSharedMembers); } - - if (path == null) { - throw new JsonParseException(_p, "Required field \"path\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new ListFolderArg(path, recursive, includeMediaInfo, includeDeleted, includeHasExplicitSharedMembers); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/ListFolderBuilder.java b/src/main/java/com/dropbox/core/v2/files/ListFolderBuilder.java index 5e98650cf..90ad670b8 100644 --- a/src/main/java/com/dropbox/core/v2/files/ListFolderBuilder.java +++ b/src/main/java/com/dropbox/core/v2/files/ListFolderBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; @@ -13,26 +13,26 @@ * request.

*/ public class ListFolderBuilder { - private final DbxUserFilesRequests files; + private final DbxUserFilesRequests files_; private final ListFolderArg.Builder listFolderArgBuilder; /** * Creates a new instance of this builder. * - * @param files Dropbox namespace-specific client used to issue files + * @param files_ Dropbox namespace-specific client used to issue files * requests. * @param listFolderArgBuilder Request argument builder. * * @return instsance of this builder */ - ListFolderBuilder(DbxUserFilesRequests files, ListFolderArg.Builder listFolderArgBuilder) { - if (files == null) { - throw new NullPointerException("files"); + ListFolderBuilder(DbxUserFilesRequests files_, ListFolderArg.Builder listFolderArgBuilder) { + if (files_ == null) { + throw new NullPointerException("files_"); } + this.files_ = files_; if (listFolderArgBuilder == null) { throw new NullPointerException("listFolderArgBuilder"); } - this.files = files; this.listFolderArgBuilder = listFolderArgBuilder; } @@ -105,7 +105,7 @@ public ListFolderBuilder withIncludeHasExplicitSharedMembers(Boolean includeHasE * Issues the request. */ public ListFolderResult start() throws ListFolderErrorException, DbxException { - ListFolderArg arg = this.listFolderArgBuilder.build(); - return files.listFolder(arg); + ListFolderArg arg_ = this.listFolderArgBuilder.build(); + return files_.listFolder(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/files/ListFolderContinueArg.java b/src/main/java/com/dropbox/core/v2/files/ListFolderContinueArg.java index 9e194e26b..22b7fe194 100644 --- a/src/main/java/com/dropbox/core/v2/files/ListFolderContinueArg.java +++ b/src/main/java/com/dropbox/core/v2/files/ListFolderContinueArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=ListFolderContinueArg.Serializer.class) -@JsonDeserialize(using=ListFolderContinueArg.Deserializer.class) class ListFolderContinueArg { // struct ListFolderContinueArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String cursor; /** @@ -92,7 +75,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -104,78 +87,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListFolderContinueArg.class); - } - - public Serializer(boolean unwrapping) { - super(ListFolderContinueArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(ListFolderContinueArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("cursor", value.cursor); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListFolderContinueArg.class); - } - - public Deserializer(boolean unwrapping) { - super(ListFolderContinueArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(ListFolderContinueArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("cursor"); + StoneSerializers.string().serialize(value.cursor, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public ListFolderContinueArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String cursor = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); + public ListFolderContinueArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListFolderContinueArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_cursor = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("cursor".equals(field)) { + f_cursor = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_cursor == null) { + throw new JsonParseException(p, "Required field \"cursor\" missing."); } + value = new ListFolderContinueArg(f_cursor); } - - if (cursor == null) { - throw new JsonParseException(_p, "Required field \"cursor\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new ListFolderContinueArg(cursor); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/ListFolderContinueError.java b/src/main/java/com/dropbox/core/v2/files/ListFolderContinueError.java index 10b6620c5..ab70646fe 100644 --- a/src/main/java/com/dropbox/core/v2/files/ListFolderContinueError.java +++ b/src/main/java/com/dropbox/core/v2/files/ListFolderContinueError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=ListFolderContinueError.Serializer.class) -@JsonDeserialize(using=ListFolderContinueError.Deserializer.class) public final class ListFolderContinueError { // union ListFolderContinueError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link ListFolderContinueError}. */ @@ -213,7 +195,7 @@ else if (obj instanceof ListFolderContinueError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -225,78 +207,71 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListFolderContinueError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ListFolderContinueError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case PATH: + public void serialize(ListFolderContinueError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PATH: { g.writeStartObject(); - g.writeStringField(".tag", "path"); - g.writeObjectField("path", value.pathValue); + writeTag("path", g); + g.writeFieldName("path"); + LookupError.Serializer.INSTANCE.serialize(value.pathValue, g); g.writeEndObject(); break; - case RESET: + } + case RESET: { g.writeString("reset"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListFolderContinueError.class, getTagMapping(), Tag.OTHER); - } @Override - public ListFolderContinueError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case PATH: { - LookupError value = null; - expectField(_p, "path"); - value = _p.readValueAs(LookupError.class); - _p.nextToken(); - return ListFolderContinueError.path(value); - } - case RESET: { - return ListFolderContinueError.RESET; - } - case OTHER: { - return ListFolderContinueError.OTHER; - } + public ListFolderContinueError deserialize(JsonParser p) throws IOException, JsonParseException { + ListFolderContinueError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("path", ListFolderContinueError.Tag.PATH); - values.put("reset", ListFolderContinueError.Tag.RESET); - values.put("other", ListFolderContinueError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("path".equals(tag)) { + LookupError fieldValue = null; + expectField("path", p); + fieldValue = LookupError.Serializer.INSTANCE.deserialize(p); + value = ListFolderContinueError.path(fieldValue); + } + else if ("reset".equals(tag)) { + value = ListFolderContinueError.RESET; + } + else { + value = ListFolderContinueError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/ListFolderContinueErrorException.java b/src/main/java/com/dropbox/core/v2/files/ListFolderContinueErrorException.java index 0874e6880..0fa9e5f3e 100644 --- a/src/main/java/com/dropbox/core/v2/files/ListFolderContinueErrorException.java +++ b/src/main/java/com/dropbox/core/v2/files/ListFolderContinueErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; diff --git a/src/main/java/com/dropbox/core/v2/files/ListFolderError.java b/src/main/java/com/dropbox/core/v2/files/ListFolderError.java index 5e172df7d..19d16c6cb 100644 --- a/src/main/java/com/dropbox/core/v2/files/ListFolderError.java +++ b/src/main/java/com/dropbox/core/v2/files/ListFolderError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=ListFolderError.Serializer.class) -@JsonDeserialize(using=ListFolderError.Deserializer.class) public final class ListFolderError { // union ListFolderError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link ListFolderError}. */ @@ -181,7 +163,7 @@ else if (obj instanceof ListFolderError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -193,71 +175,64 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListFolderError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ListFolderError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case PATH: + public void serialize(ListFolderError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PATH: { g.writeStartObject(); - g.writeStringField(".tag", "path"); - g.writeObjectField("path", value.pathValue); + writeTag("path", g); + g.writeFieldName("path"); + LookupError.Serializer.INSTANCE.serialize(value.pathValue, g); g.writeEndObject(); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListFolderError.class, getTagMapping(), Tag.OTHER); - } @Override - public ListFolderError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case PATH: { - LookupError value = null; - expectField(_p, "path"); - value = _p.readValueAs(LookupError.class); - _p.nextToken(); - return ListFolderError.path(value); - } - case OTHER: { - return ListFolderError.OTHER; - } + public ListFolderError deserialize(JsonParser p) throws IOException, JsonParseException { + ListFolderError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("path", ListFolderError.Tag.PATH); - values.put("other", ListFolderError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("path".equals(tag)) { + LookupError fieldValue = null; + expectField("path", p); + fieldValue = LookupError.Serializer.INSTANCE.deserialize(p); + value = ListFolderError.path(fieldValue); + } + else { + value = ListFolderError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/ListFolderErrorException.java b/src/main/java/com/dropbox/core/v2/files/ListFolderErrorException.java index 1cb01596a..e0f7e3273 100644 --- a/src/main/java/com/dropbox/core/v2/files/ListFolderErrorException.java +++ b/src/main/java/com/dropbox/core/v2/files/ListFolderErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; diff --git a/src/main/java/com/dropbox/core/v2/files/ListFolderGetLatestCursorBuilder.java b/src/main/java/com/dropbox/core/v2/files/ListFolderGetLatestCursorBuilder.java index 3d410c1ae..1a27bd8ad 100644 --- a/src/main/java/com/dropbox/core/v2/files/ListFolderGetLatestCursorBuilder.java +++ b/src/main/java/com/dropbox/core/v2/files/ListFolderGetLatestCursorBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; @@ -13,26 +13,26 @@ * request.

*/ public class ListFolderGetLatestCursorBuilder { - private final DbxUserFilesRequests files; + private final DbxUserFilesRequests files_; private final ListFolderArg.Builder listFolderArgBuilder; /** * Creates a new instance of this builder. * - * @param files Dropbox namespace-specific client used to issue files + * @param files_ Dropbox namespace-specific client used to issue files * requests. * @param listFolderArgBuilder Request argument builder. * * @return instsance of this builder */ - ListFolderGetLatestCursorBuilder(DbxUserFilesRequests files, ListFolderArg.Builder listFolderArgBuilder) { - if (files == null) { - throw new NullPointerException("files"); + ListFolderGetLatestCursorBuilder(DbxUserFilesRequests files_, ListFolderArg.Builder listFolderArgBuilder) { + if (files_ == null) { + throw new NullPointerException("files_"); } + this.files_ = files_; if (listFolderArgBuilder == null) { throw new NullPointerException("listFolderArgBuilder"); } - this.files = files; this.listFolderArgBuilder = listFolderArgBuilder; } @@ -105,7 +105,7 @@ public ListFolderGetLatestCursorBuilder withIncludeHasExplicitSharedMembers(Bool * Issues the request. */ public ListFolderGetLatestCursorResult start() throws ListFolderErrorException, DbxException { - ListFolderArg arg = this.listFolderArgBuilder.build(); - return files.listFolderGetLatestCursor(arg); + ListFolderArg arg_ = this.listFolderArgBuilder.build(); + return files_.listFolderGetLatestCursor(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/files/ListFolderGetLatestCursorResult.java b/src/main/java/com/dropbox/core/v2/files/ListFolderGetLatestCursorResult.java index 78dd675a0..dbb910d0d 100644 --- a/src/main/java/com/dropbox/core/v2/files/ListFolderGetLatestCursorResult.java +++ b/src/main/java/com/dropbox/core/v2/files/ListFolderGetLatestCursorResult.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=ListFolderGetLatestCursorResult.Serializer.class) -@JsonDeserialize(using=ListFolderGetLatestCursorResult.Deserializer.class) public class ListFolderGetLatestCursorResult { // struct ListFolderGetLatestCursorResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String cursor; /** @@ -92,7 +75,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -104,78 +87,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListFolderGetLatestCursorResult.class); - } - - public Serializer(boolean unwrapping) { - super(ListFolderGetLatestCursorResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(ListFolderGetLatestCursorResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("cursor", value.cursor); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListFolderGetLatestCursorResult.class); - } - - public Deserializer(boolean unwrapping) { - super(ListFolderGetLatestCursorResult.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(ListFolderGetLatestCursorResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("cursor"); + StoneSerializers.string().serialize(value.cursor, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public ListFolderGetLatestCursorResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String cursor = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); + public ListFolderGetLatestCursorResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListFolderGetLatestCursorResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_cursor = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("cursor".equals(field)) { + f_cursor = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_cursor == null) { + throw new JsonParseException(p, "Required field \"cursor\" missing."); } + value = new ListFolderGetLatestCursorResult(f_cursor); } - - if (cursor == null) { - throw new JsonParseException(_p, "Required field \"cursor\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new ListFolderGetLatestCursorResult(cursor); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/ListFolderLongpollArg.java b/src/main/java/com/dropbox/core/v2/files/ListFolderLongpollArg.java index de51e672e..29d09e66d 100644 --- a/src/main/java/com/dropbox/core/v2/files/ListFolderLongpollArg.java +++ b/src/main/java/com/dropbox/core/v2/files/ListFolderLongpollArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=ListFolderLongpollArg.Serializer.class) -@JsonDeserialize(using=ListFolderLongpollArg.Deserializer.class) class ListFolderLongpollArg { // struct ListFolderLongpollArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String cursor; protected final long timeout; @@ -142,7 +125,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -154,85 +137,65 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListFolderLongpollArg.class); - } - - public Serializer(boolean unwrapping) { - super(ListFolderLongpollArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(ListFolderLongpollArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("cursor", value.cursor); - g.writeObjectField("timeout", value.timeout); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListFolderLongpollArg.class); - } - - public Deserializer(boolean unwrapping) { - super(ListFolderLongpollArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(ListFolderLongpollArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("cursor"); + StoneSerializers.string().serialize(value.cursor, g); + g.writeFieldName("timeout"); + StoneSerializers.uInt64().serialize(value.timeout, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public ListFolderLongpollArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String cursor = null; - long timeout = 30L; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); - } - else if ("timeout".equals(_field)) { - timeout = _p.getLongValue(); - assertUnsigned(_p, timeout); - _p.nextToken(); + public ListFolderLongpollArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListFolderLongpollArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_cursor = null; + Long f_timeout = 30L; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("cursor".equals(field)) { + f_cursor = StoneSerializers.string().deserialize(p); + } + else if ("timeout".equals(field)) { + f_timeout = StoneSerializers.uInt64().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_cursor == null) { + throw new JsonParseException(p, "Required field \"cursor\" missing."); } + value = new ListFolderLongpollArg(f_cursor, f_timeout); } - - if (cursor == null) { - throw new JsonParseException(_p, "Required field \"cursor\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new ListFolderLongpollArg(cursor, timeout); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/ListFolderLongpollError.java b/src/main/java/com/dropbox/core/v2/files/ListFolderLongpollError.java index 71e53d452..f6903afe9 100644 --- a/src/main/java/com/dropbox/core/v2/files/ListFolderLongpollError.java +++ b/src/main/java/com/dropbox/core/v2/files/ListFolderLongpollError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=ListFolderLongpollError.Serializer.class) -@JsonDeserialize(using=ListFolderLongpollError.Deserializer.class) public enum ListFolderLongpollError { // union ListFolderLongpollError /** @@ -44,47 +30,54 @@ public enum ListFolderLongpollError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListFolderLongpollError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ListFolderLongpollError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(ListFolderLongpollError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case RESET: + case RESET: { g.writeString("reset"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListFolderLongpollError.class, getTagMapping(), ListFolderLongpollError.OTHER); - } @Override - public ListFolderLongpollError deserialize(ListFolderLongpollError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("reset", ListFolderLongpollError.RESET); - values.put("other", ListFolderLongpollError.OTHER); - return Collections.unmodifiableMap(values); + public ListFolderLongpollError deserialize(JsonParser p) throws IOException, JsonParseException { + ListFolderLongpollError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("reset".equals(tag)) { + value = ListFolderLongpollError.RESET; + } + else { + value = ListFolderLongpollError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/ListFolderLongpollErrorException.java b/src/main/java/com/dropbox/core/v2/files/ListFolderLongpollErrorException.java index 934a22d26..4e0bf00ca 100644 --- a/src/main/java/com/dropbox/core/v2/files/ListFolderLongpollErrorException.java +++ b/src/main/java/com/dropbox/core/v2/files/ListFolderLongpollErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; diff --git a/src/main/java/com/dropbox/core/v2/files/ListFolderLongpollResult.java b/src/main/java/com/dropbox/core/v2/files/ListFolderLongpollResult.java index 72b55ca2a..232588055 100644 --- a/src/main/java/com/dropbox/core/v2/files/ListFolderLongpollResult.java +++ b/src/main/java/com/dropbox/core/v2/files/ListFolderLongpollResult.java @@ -1,47 +1,30 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=ListFolderLongpollResult.Serializer.class) -@JsonDeserialize(using=ListFolderLongpollResult.Deserializer.class) public class ListFolderLongpollResult { // struct ListFolderLongpollResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final boolean changes; protected final Long backoff; /** * * @param changes Indicates whether new changes are available. If true, - * call {@link DbxUserFilesRequests#listFolder(String)} to retrieve the - * changes. + * call {@link DbxUserFilesRequests#listFolderContinue(String)} to + * retrieve the changes. * @param backoff If present, backoff for at least this many seconds before * calling {@link DbxUserFilesRequests#listFolderLongpoll(String)} * again. @@ -55,8 +38,8 @@ public ListFolderLongpollResult(boolean changes, Long backoff) { * The default values for unset fields will be used. * * @param changes Indicates whether new changes are available. If true, - * call {@link DbxUserFilesRequests#listFolder(String)} to retrieve the - * changes. + * call {@link DbxUserFilesRequests#listFolderContinue(String)} to + * retrieve the changes. */ public ListFolderLongpollResult(boolean changes) { this(changes, null); @@ -64,7 +47,7 @@ public ListFolderLongpollResult(boolean changes) { /** * Indicates whether new changes are available. If true, call {@link - * DbxUserFilesRequests#listFolder(String)} to retrieve the changes. + * DbxUserFilesRequests#listFolderContinue(String)} to retrieve the changes. * * @return value for this field. */ @@ -110,7 +93,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -122,87 +105,67 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListFolderLongpollResult.class); - } - - public Serializer(boolean unwrapping) { - super(ListFolderLongpollResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(ListFolderLongpollResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("changes", value.changes); + public void serialize(ListFolderLongpollResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("changes"); + StoneSerializers.boolean_().serialize(value.changes, g); if (value.backoff != null) { - g.writeObjectField("backoff", value.backoff); + g.writeFieldName("backoff"); + StoneSerializers.nullable(StoneSerializers.uInt64()).serialize(value.backoff, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListFolderLongpollResult.class); - } - - public Deserializer(boolean unwrapping) { - super(ListFolderLongpollResult.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public ListFolderLongpollResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - Boolean changes = null; - Long backoff = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("changes".equals(_field)) { - changes = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("backoff".equals(_field)) { - backoff = _p.getLongValue(); - assertUnsigned(_p, backoff); - _p.nextToken(); + public ListFolderLongpollResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListFolderLongpollResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Boolean f_changes = null; + Long f_backoff = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("changes".equals(field)) { + f_changes = StoneSerializers.boolean_().deserialize(p); + } + else if ("backoff".equals(field)) { + f_backoff = StoneSerializers.nullable(StoneSerializers.uInt64()).deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_changes == null) { + throw new JsonParseException(p, "Required field \"changes\" missing."); } + value = new ListFolderLongpollResult(f_changes, f_backoff); } - - if (changes == null) { - throw new JsonParseException(_p, "Required field \"changes\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new ListFolderLongpollResult(changes, backoff); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/ListFolderResult.java b/src/main/java/com/dropbox/core/v2/files/ListFolderResult.java index ca86a5dbf..bc4c3c706 100644 --- a/src/main/java/com/dropbox/core/v2/files/ListFolderResult.java +++ b/src/main/java/com/dropbox/core/v2/files/ListFolderResult.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=ListFolderResult.Serializer.class) -@JsonDeserialize(using=ListFolderResult.Deserializer.class) public class ListFolderResult { // struct ListFolderResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List entries; protected final String cursor; protected final boolean hasMore; @@ -134,7 +117,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -146,104 +129,77 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListFolderResult.class); - } - - public Serializer(boolean unwrapping) { - super(ListFolderResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(ListFolderResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("entries", value.entries); - g.writeObjectField("cursor", value.cursor); - g.writeObjectField("has_more", value.hasMore); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListFolderResult.class); - } - - public Deserializer(boolean unwrapping) { - super(ListFolderResult.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(ListFolderResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("entries"); + StoneSerializers.list(Metadata.Serializer.INSTANCE).serialize(value.entries, g); + g.writeFieldName("cursor"); + StoneSerializers.string().serialize(value.cursor, g); + g.writeFieldName("has_more"); + StoneSerializers.boolean_().serialize(value.hasMore, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public ListFolderResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List entries = null; - String cursor = null; - Boolean hasMore = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("entries".equals(_field)) { - expectArrayStart(_p); - entries = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Metadata _x = null; - _x = _p.readValueAs(Metadata.class); - _p.nextToken(); - entries.add(_x); + public ListFolderResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListFolderResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_entries = null; + String f_cursor = null; + Boolean f_hasMore = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("entries".equals(field)) { + f_entries = StoneSerializers.list(Metadata.Serializer.INSTANCE).deserialize(p); + } + else if ("cursor".equals(field)) { + f_cursor = StoneSerializers.string().deserialize(p); + } + else if ("has_more".equals(field)) { + f_hasMore = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); + if (f_entries == null) { + throw new JsonParseException(p, "Required field \"entries\" missing."); } - else if ("has_more".equals(_field)) { - hasMore = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_cursor == null) { + throw new JsonParseException(p, "Required field \"cursor\" missing."); } - else { - skipValue(_p); + if (f_hasMore == null) { + throw new JsonParseException(p, "Required field \"has_more\" missing."); } + value = new ListFolderResult(f_entries, f_cursor, f_hasMore); } - - if (entries == null) { - throw new JsonParseException(_p, "Required field \"entries\" is missing."); - } - if (cursor == null) { - throw new JsonParseException(_p, "Required field \"cursor\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (hasMore == null) { - throw new JsonParseException(_p, "Required field \"has_more\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new ListFolderResult(entries, cursor, hasMore); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/ListRevisionsArg.java b/src/main/java/com/dropbox/core/v2/files/ListRevisionsArg.java index ce324c737..50860685a 100644 --- a/src/main/java/com/dropbox/core/v2/files/ListRevisionsArg.java +++ b/src/main/java/com/dropbox/core/v2/files/ListRevisionsArg.java @@ -1,46 +1,29 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=ListRevisionsArg.Serializer.class) -@JsonDeserialize(using=ListRevisionsArg.Deserializer.class) class ListRevisionsArg { // struct ListRevisionsArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String path; protected final long limit; /** * * @param path The path to the file you want to see the revisions of. Must - * match pattern "{@code /.*}" and not be {@code null}. + * match pattern "{@code /(.|[\\r\\n])*}" and not be {@code null}. * @param limit The maximum number of revision entries returned. Must be * greater than or equal to 1 and be less than or equal to 100. * @@ -51,7 +34,7 @@ public ListRevisionsArg(String path, long limit) { if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("/.*", path)) { + if (!java.util.regex.Pattern.matches("/(.|[\\r\\n])*", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -68,7 +51,7 @@ public ListRevisionsArg(String path, long limit) { * The default values for unset fields will be used. * * @param path The path to the file you want to see the revisions of. Must - * match pattern "{@code /.*}" and not be {@code null}. + * match pattern "{@code /(.|[\\r\\n])*}" and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -124,7 +107,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -136,85 +119,65 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListRevisionsArg.class); - } - - public Serializer(boolean unwrapping) { - super(ListRevisionsArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(ListRevisionsArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("path", value.path); - g.writeObjectField("limit", value.limit); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListRevisionsArg.class); - } - - public Deserializer(boolean unwrapping) { - super(ListRevisionsArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(ListRevisionsArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("path"); + StoneSerializers.string().serialize(value.path, g); + g.writeFieldName("limit"); + StoneSerializers.uInt64().serialize(value.limit, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public ListRevisionsArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String path = null; - long limit = 10L; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); - } - else if ("limit".equals(_field)) { - limit = _p.getLongValue(); - assertUnsigned(_p, limit); - _p.nextToken(); + public ListRevisionsArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListRevisionsArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_path = null; + Long f_limit = 10L; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("path".equals(field)) { + f_path = StoneSerializers.string().deserialize(p); + } + else if ("limit".equals(field)) { + f_limit = StoneSerializers.uInt64().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_path == null) { + throw new JsonParseException(p, "Required field \"path\" missing."); } + value = new ListRevisionsArg(f_path, f_limit); } - - if (path == null) { - throw new JsonParseException(_p, "Required field \"path\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new ListRevisionsArg(path, limit); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/ListRevisionsError.java b/src/main/java/com/dropbox/core/v2/files/ListRevisionsError.java index 28cd93a91..28d0e08c3 100644 --- a/src/main/java/com/dropbox/core/v2/files/ListRevisionsError.java +++ b/src/main/java/com/dropbox/core/v2/files/ListRevisionsError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=ListRevisionsError.Serializer.class) -@JsonDeserialize(using=ListRevisionsError.Deserializer.class) public final class ListRevisionsError { // union ListRevisionsError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link ListRevisionsError}. */ @@ -190,7 +172,7 @@ else if (obj instanceof ListRevisionsError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -202,71 +184,64 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListRevisionsError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ListRevisionsError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case PATH: + public void serialize(ListRevisionsError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PATH: { g.writeStartObject(); - g.writeStringField(".tag", "path"); - g.writeObjectField("path", value.pathValue); + writeTag("path", g); + g.writeFieldName("path"); + LookupError.Serializer.INSTANCE.serialize(value.pathValue, g); g.writeEndObject(); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListRevisionsError.class, getTagMapping(), Tag.OTHER); - } @Override - public ListRevisionsError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case PATH: { - LookupError value = null; - expectField(_p, "path"); - value = _p.readValueAs(LookupError.class); - _p.nextToken(); - return ListRevisionsError.path(value); - } - case OTHER: { - return ListRevisionsError.OTHER; - } + public ListRevisionsError deserialize(JsonParser p) throws IOException, JsonParseException { + ListRevisionsError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("path", ListRevisionsError.Tag.PATH); - values.put("other", ListRevisionsError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("path".equals(tag)) { + LookupError fieldValue = null; + expectField("path", p); + fieldValue = LookupError.Serializer.INSTANCE.deserialize(p); + value = ListRevisionsError.path(fieldValue); + } + else { + value = ListRevisionsError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/ListRevisionsErrorException.java b/src/main/java/com/dropbox/core/v2/files/ListRevisionsErrorException.java index af9034a43..b5b706dac 100644 --- a/src/main/java/com/dropbox/core/v2/files/ListRevisionsErrorException.java +++ b/src/main/java/com/dropbox/core/v2/files/ListRevisionsErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; diff --git a/src/main/java/com/dropbox/core/v2/files/ListRevisionsResult.java b/src/main/java/com/dropbox/core/v2/files/ListRevisionsResult.java index 8703de113..085e348f4 100644 --- a/src/main/java/com/dropbox/core/v2/files/ListRevisionsResult.java +++ b/src/main/java/com/dropbox/core/v2/files/ListRevisionsResult.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=ListRevisionsResult.Serializer.class) -@JsonDeserialize(using=ListRevisionsResult.Deserializer.class) public class ListRevisionsResult { // struct ListRevisionsResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final boolean isDeleted; protected final List entries; @@ -107,7 +90,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -119,95 +102,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListRevisionsResult.class); - } - - public Serializer(boolean unwrapping) { - super(ListRevisionsResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(ListRevisionsResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("is_deleted", value.isDeleted); - g.writeObjectField("entries", value.entries); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListRevisionsResult.class); - } - - public Deserializer(boolean unwrapping) { - super(ListRevisionsResult.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(ListRevisionsResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("is_deleted"); + StoneSerializers.boolean_().serialize(value.isDeleted, g); + g.writeFieldName("entries"); + StoneSerializers.list(FileMetadata.Serializer.INSTANCE).serialize(value.entries, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public ListRevisionsResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - Boolean isDeleted = null; - List entries = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("is_deleted".equals(_field)) { - isDeleted = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("entries".equals(_field)) { - expectArrayStart(_p); - entries = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - FileMetadata _x = null; - _x = _p.readValueAs(FileMetadata.class); - _p.nextToken(); - entries.add(_x); + public ListRevisionsResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListRevisionsResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Boolean f_isDeleted = null; + List f_entries = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("is_deleted".equals(field)) { + f_isDeleted = StoneSerializers.boolean_().deserialize(p); + } + else if ("entries".equals(field)) { + f_entries = StoneSerializers.list(FileMetadata.Serializer.INSTANCE).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); + else { + skipValue(p); + } + } + if (f_isDeleted == null) { + throw new JsonParseException(p, "Required field \"is_deleted\" missing."); } - else { - skipValue(_p); + if (f_entries == null) { + throw new JsonParseException(p, "Required field \"entries\" missing."); } + value = new ListRevisionsResult(f_isDeleted, f_entries); } - - if (isDeleted == null) { - throw new JsonParseException(_p, "Required field \"is_deleted\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (entries == null) { - throw new JsonParseException(_p, "Required field \"entries\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new ListRevisionsResult(isDeleted, entries); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/LookupError.java b/src/main/java/com/dropbox/core/v2/files/LookupError.java index b093b1faa..cb6492534 100644 --- a/src/main/java/com/dropbox/core/v2/files/LookupError.java +++ b/src/main/java/com/dropbox/core/v2/files/LookupError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=LookupError.Serializer.class) -@JsonDeserialize(using=LookupError.Deserializer.class) public final class LookupError { // union LookupError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link LookupError}. */ @@ -288,7 +270,7 @@ else if (obj instanceof LookupError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -300,104 +282,99 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); + return Serializer.INSTANCE.serialize(this, true); } - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(LookupError.class); - } + /** + * For internal use only. + */ + public static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(LookupError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case MALFORMED_PATH: + public void serialize(LookupError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case MALFORMED_PATH: { g.writeStartObject(); - g.writeStringField(".tag", "malformed_path"); - if (value.malformedPathValue != null) { - g.writeObjectField("malformed_path", value.malformedPathValue); - } + writeTag("malformed_path", g); + g.writeFieldName("malformed_path"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.malformedPathValue, g); g.writeEndObject(); break; - case NOT_FOUND: + } + case NOT_FOUND: { g.writeString("not_found"); break; - case NOT_FILE: + } + case NOT_FILE: { g.writeString("not_file"); break; - case NOT_FOLDER: + } + case NOT_FOLDER: { g.writeString("not_folder"); break; - case RESTRICTED_CONTENT: + } + case RESTRICTED_CONTENT: { g.writeString("restricted_content"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(LookupError.class, getTagMapping(), Tag.OTHER); - } @Override - public LookupError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case MALFORMED_PATH: { - if (isObjectEnd(_p)) { - return LookupError.malformedPath(); - } - String value = null; - expectField(_p, "malformed_path"); - value = getStringValue(_p); - _p.nextToken(); - return LookupError.malformedPath(value); - } - case NOT_FOUND: { - return LookupError.NOT_FOUND; - } - case NOT_FILE: { - return LookupError.NOT_FILE; - } - case NOT_FOLDER: { - return LookupError.NOT_FOLDER; + public LookupError deserialize(JsonParser p) throws IOException, JsonParseException { + LookupError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("malformed_path".equals(tag)) { + String fieldValue = null; + if (p.getCurrentToken() != JsonToken.END_OBJECT) { + expectField("malformed_path", p); + fieldValue = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); } - case RESTRICTED_CONTENT: { - return LookupError.RESTRICTED_CONTENT; + if (fieldValue == null) { + value = LookupError.malformedPath(); } - case OTHER: { - return LookupError.OTHER; + else { + value = LookupError.malformedPath(fieldValue); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("malformed_path", LookupError.Tag.MALFORMED_PATH); - values.put("not_found", LookupError.Tag.NOT_FOUND); - values.put("not_file", LookupError.Tag.NOT_FILE); - values.put("not_folder", LookupError.Tag.NOT_FOLDER); - values.put("restricted_content", LookupError.Tag.RESTRICTED_CONTENT); - values.put("other", LookupError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else if ("not_found".equals(tag)) { + value = LookupError.NOT_FOUND; + } + else if ("not_file".equals(tag)) { + value = LookupError.NOT_FILE; + } + else if ("not_folder".equals(tag)) { + value = LookupError.NOT_FOLDER; + } + else if ("restricted_content".equals(tag)) { + value = LookupError.RESTRICTED_CONTENT; + } + else { + value = LookupError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/MediaInfo.java b/src/main/java/com/dropbox/core/v2/files/MediaInfo.java index 743432290..4089616ef 100644 --- a/src/main/java/com/dropbox/core/v2/files/MediaInfo.java +++ b/src/main/java/com/dropbox/core/v2/files/MediaInfo.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is a tagged union. Tagged unions instances are always associated @@ -32,15 +20,9 @@ * return {@code true}. You can use {@link #tag()} to determine the tag * associated with this instance. */ -@JsonSerialize(using=MediaInfo.Serializer.class) -@JsonDeserialize(using=MediaInfo.Deserializer.class) public final class MediaInfo { // union MediaInfo - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link MediaInfo}. */ @@ -183,7 +165,7 @@ else if (obj instanceof MediaInfo) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -195,71 +177,70 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MediaInfo.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MediaInfo value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case PENDING: + public void serialize(MediaInfo value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PENDING: { g.writeString("pending"); break; - case METADATA: + } + case METADATA: { g.writeStartObject(); - g.writeStringField(".tag", "metadata"); - g.writeObjectField("metadata", value.metadataValue); + writeTag("metadata", g); + g.writeFieldName("metadata"); + MediaMetadata.Serializer.INSTANCE.serialize(value.metadataValue, g); g.writeEndObject(); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MediaInfo.class, getTagMapping(), null); - } - - @Override - public MediaInfo deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case PENDING: { - return MediaInfo.PENDING; } - case METADATA: { - MediaMetadata value = null; - expectField(_p, "metadata"); - value = _p.readValueAs(MediaMetadata.class); - _p.nextToken(); - return MediaInfo.metadata(value); + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("pending", MediaInfo.Tag.PENDING); - values.put("metadata", MediaInfo.Tag.METADATA); - return Collections.unmodifiableMap(values); + @Override + public MediaInfo deserialize(JsonParser p) throws IOException, JsonParseException { + MediaInfo value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("pending".equals(tag)) { + value = MediaInfo.PENDING; + } + else if ("metadata".equals(tag)) { + MediaMetadata fieldValue = null; + expectField("metadata", p); + fieldValue = MediaMetadata.Serializer.INSTANCE.deserialize(p); + value = MediaInfo.metadata(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/MediaMetadata.java b/src/main/java/com/dropbox/core/v2/files/MediaMetadata.java index 5921bcf82..f446444a4 100644 --- a/src/main/java/com/dropbox/core/v2/files/MediaMetadata.java +++ b/src/main/java/com/dropbox/core/v2/files/MediaMetadata.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.Date; @@ -29,15 +18,9 @@ /** * Metadata for a photo or video. */ -@JsonSerialize(using=MediaMetadata.Serializer.class) -@JsonDeserialize(using=MediaMetadata.Deserializer.class) public class MediaMetadata { // struct MediaMetadata - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final Dimensions dimensions; protected final GpsCoordinates location; protected final Date timeTaken; @@ -195,7 +178,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -207,95 +190,94 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MediaMetadata.class); - } - - public Serializer(boolean unwrapping) { - super(MediaMetadata.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(MediaMetadata value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(MediaMetadata value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (value instanceof PhotoMetadata) { + PhotoMetadata.Serializer.INSTANCE.serialize((PhotoMetadata) value, g, collapse); + return; + } + if (value instanceof VideoMetadata) { + VideoMetadata.Serializer.INSTANCE.serialize((VideoMetadata) value, g, collapse); + return; + } + if (!collapse) { + g.writeStartObject(); + } if (value.dimensions != null) { - g.writeObjectField("dimensions", value.dimensions); + g.writeFieldName("dimensions"); + StoneSerializers.nullable(Dimensions.Serializer.INSTANCE).serialize(value.dimensions, g); } if (value.location != null) { - g.writeObjectField("location", value.location); + g.writeFieldName("location"); + StoneSerializers.nullable(GpsCoordinates.Serializer.INSTANCE).serialize(value.location, g); } if (value.timeTaken != null) { - g.writeObjectField("time_taken", value.timeTaken); + g.writeFieldName("time_taken"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.timeTaken, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MediaMetadata.class, PhotoMetadata.class, VideoMetadata.class); - } - - public Deserializer(boolean unwrapping) { - super(MediaMetadata.class, unwrapping, PhotoMetadata.class, VideoMetadata.class); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public MediaMetadata deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - String _subtype_tag = readEnumeratedSubtypeTag(_p); - if ("photo".equals(_subtype_tag)) { - return readCollapsedStructValue(PhotoMetadata.class, _p, _ctx); - } - if ("video".equals(_subtype_tag)) { - return readCollapsedStructValue(VideoMetadata.class, _p, _ctx); - } - - Dimensions dimensions = null; - GpsCoordinates location = null; - Date timeTaken = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("dimensions".equals(_field)) { - dimensions = _p.readValueAs(Dimensions.class); - _p.nextToken(); - } - else if ("location".equals(_field)) { - location = _p.readValueAs(GpsCoordinates.class); - _p.nextToken(); - } - else if ("time_taken".equals(_field)) { - timeTaken = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); + public MediaMetadata deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MediaMetadata value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + if ("".equals(tag)) { + tag = null; } - else { - skipValue(_p); + } + if (tag == null) { + Dimensions f_dimensions = null; + GpsCoordinates f_location = null; + Date f_timeTaken = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("dimensions".equals(field)) { + f_dimensions = StoneSerializers.nullable(Dimensions.Serializer.INSTANCE).deserialize(p); + } + else if ("location".equals(field)) { + f_location = StoneSerializers.nullable(GpsCoordinates.Serializer.INSTANCE).deserialize(p); + } + else if ("time_taken".equals(field)) { + f_timeTaken = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else { + skipValue(p); + } } + value = new MediaMetadata(f_dimensions, f_location, f_timeTaken); } - - - return new MediaMetadata(dimensions, location, timeTaken); + else if ("".equals(tag)) { + value = MediaMetadata.Serializer.INSTANCE.deserialize(p, true); + } + else if ("photo".equals(tag)) { + value = PhotoMetadata.Serializer.INSTANCE.deserialize(p, true); + } + else if ("video".equals(tag)) { + value = VideoMetadata.Serializer.INSTANCE.deserialize(p, true); + } + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/Metadata.java b/src/main/java/com/dropbox/core/v2/files/Metadata.java index a91e2956a..7baf7a2ef 100644 --- a/src/main/java/com/dropbox/core/v2/files/Metadata.java +++ b/src/main/java/com/dropbox/core/v2/files/Metadata.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Metadata for a file or folder. */ -@JsonSerialize(using=Metadata.Serializer.class) -@JsonDeserialize(using=Metadata.Deserializer.class) public class Metadata { // struct Metadata - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String name; protected final String pathLower; protected final String pathDisplay; @@ -182,7 +165,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -194,109 +177,112 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(Metadata.class); - } - - public Serializer(boolean unwrapping) { - super(Metadata.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(Metadata value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("name", value.name); - g.writeObjectField("path_lower", value.pathLower); - g.writeObjectField("path_display", value.pathDisplay); - if (value.parentSharedFolderId != null) { - g.writeObjectField("parent_shared_folder_id", value.parentSharedFolderId); + public void serialize(Metadata value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (value instanceof FileMetadata) { + FileMetadata.Serializer.INSTANCE.serialize((FileMetadata) value, g, collapse); + return; } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(Metadata.class, FileMetadata.class, FolderMetadata.class, DeletedMetadata.class); - } - - public Deserializer(boolean unwrapping) { - super(Metadata.class, unwrapping, FileMetadata.class, FolderMetadata.class, DeletedMetadata.class); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); - } - - @Override - public Metadata deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - String _subtype_tag = readEnumeratedSubtypeTag(_p); - if ("file".equals(_subtype_tag)) { - return readCollapsedStructValue(FileMetadata.class, _p, _ctx); + if (value instanceof FolderMetadata) { + FolderMetadata.Serializer.INSTANCE.serialize((FolderMetadata) value, g, collapse); + return; } - if ("folder".equals(_subtype_tag)) { - return readCollapsedStructValue(FolderMetadata.class, _p, _ctx); + if (value instanceof DeletedMetadata) { + DeletedMetadata.Serializer.INSTANCE.serialize((DeletedMetadata) value, g, collapse); + return; } - if ("deleted".equals(_subtype_tag)) { - return readCollapsedStructValue(DeletedMetadata.class, _p, _ctx); + if (!collapse) { + g.writeStartObject(); } + g.writeFieldName("name"); + StoneSerializers.string().serialize(value.name, g); + g.writeFieldName("path_lower"); + StoneSerializers.string().serialize(value.pathLower, g); + g.writeFieldName("path_display"); + StoneSerializers.string().serialize(value.pathDisplay, g); + if (value.parentSharedFolderId != null) { + g.writeFieldName("parent_shared_folder_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.parentSharedFolderId, g); + } + if (!collapse) { + g.writeEndObject(); + } + } - String name = null; - String pathLower = null; - String pathDisplay = null; - String parentSharedFolderId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("name".equals(_field)) { - name = getStringValue(_p); - _p.nextToken(); + @Override + public Metadata deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + Metadata value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + if ("".equals(tag)) { + tag = null; } - else if ("path_lower".equals(_field)) { - pathLower = getStringValue(_p); - _p.nextToken(); + } + if (tag == null) { + String f_name = null; + String f_pathLower = null; + String f_pathDisplay = null; + String f_parentSharedFolderId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("name".equals(field)) { + f_name = StoneSerializers.string().deserialize(p); + } + else if ("path_lower".equals(field)) { + f_pathLower = StoneSerializers.string().deserialize(p); + } + else if ("path_display".equals(field)) { + f_pathDisplay = StoneSerializers.string().deserialize(p); + } + else if ("parent_shared_folder_id".equals(field)) { + f_parentSharedFolderId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } - else if ("path_display".equals(_field)) { - pathDisplay = getStringValue(_p); - _p.nextToken(); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } - else if ("parent_shared_folder_id".equals(_field)) { - parentSharedFolderId = getStringValue(_p); - _p.nextToken(); + if (f_pathLower == null) { + throw new JsonParseException(p, "Required field \"path_lower\" missing."); } - else { - skipValue(_p); + if (f_pathDisplay == null) { + throw new JsonParseException(p, "Required field \"path_display\" missing."); } + value = new Metadata(f_name, f_pathLower, f_pathDisplay, f_parentSharedFolderId); } - - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); + else if ("".equals(tag)) { + value = Metadata.Serializer.INSTANCE.deserialize(p, true); } - if (pathLower == null) { - throw new JsonParseException(_p, "Required field \"path_lower\" is missing."); + else if ("file".equals(tag)) { + value = FileMetadata.Serializer.INSTANCE.deserialize(p, true); } - if (pathDisplay == null) { - throw new JsonParseException(_p, "Required field \"path_display\" is missing."); + else if ("folder".equals(tag)) { + value = FolderMetadata.Serializer.INSTANCE.deserialize(p, true); } - - return new Metadata(name, pathLower, pathDisplay, parentSharedFolderId); + else if ("deleted".equals(tag)) { + value = DeletedMetadata.Serializer.INSTANCE.deserialize(p, true); + } + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/PhotoMetadata.java b/src/main/java/com/dropbox/core/v2/files/PhotoMetadata.java index e9cf07aa5..a2715e193 100644 --- a/src/main/java/com/dropbox/core/v2/files/PhotoMetadata.java +++ b/src/main/java/com/dropbox/core/v2/files/PhotoMetadata.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.Date; @@ -29,15 +18,9 @@ /** * Metadata for a photo. */ -@JsonSerialize(using=PhotoMetadata.Serializer.class) -@JsonDeserialize(using=PhotoMetadata.Deserializer.class) public class PhotoMetadata extends MediaMetadata { // struct PhotoMetadata - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Metadata for a photo. @@ -116,7 +99,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -128,90 +111,78 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(PhotoMetadata.class); - } - - public Serializer(boolean unwrapping) { - super(PhotoMetadata.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(PhotoMetadata value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeStringField(".tag", "photo"); + public void serialize(PhotoMetadata value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + writeTag("photo", g); if (value.dimensions != null) { - g.writeObjectField("dimensions", value.dimensions); + g.writeFieldName("dimensions"); + StoneSerializers.nullable(Dimensions.Serializer.INSTANCE).serialize(value.dimensions, g); } if (value.location != null) { - g.writeObjectField("location", value.location); + g.writeFieldName("location"); + StoneSerializers.nullable(GpsCoordinates.Serializer.INSTANCE).serialize(value.location, g); } if (value.timeTaken != null) { - g.writeObjectField("time_taken", value.timeTaken); + g.writeFieldName("time_taken"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.timeTaken, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(PhotoMetadata.class); - } - - public Deserializer(boolean unwrapping) { - super(PhotoMetadata.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public PhotoMetadata deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - String _subtype_tag = readEnumeratedSubtypeTag(_p, "photo"); - - Dimensions dimensions = null; - GpsCoordinates location = null; - Date timeTaken = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("dimensions".equals(_field)) { - dimensions = _p.readValueAs(Dimensions.class); - _p.nextToken(); - } - else if ("location".equals(_field)) { - location = _p.readValueAs(GpsCoordinates.class); - _p.nextToken(); + public PhotoMetadata deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + PhotoMetadata value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + if ("photo".equals(tag)) { + tag = null; } - else if ("time_taken".equals(_field)) { - timeTaken = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); - } - else { - skipValue(_p); + } + if (tag == null) { + Dimensions f_dimensions = null; + GpsCoordinates f_location = null; + Date f_timeTaken = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("dimensions".equals(field)) { + f_dimensions = StoneSerializers.nullable(Dimensions.Serializer.INSTANCE).deserialize(p); + } + else if ("location".equals(field)) { + f_location = StoneSerializers.nullable(GpsCoordinates.Serializer.INSTANCE).deserialize(p); + } + else if ("time_taken".equals(field)) { + f_timeTaken = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else { + skipValue(p); + } } + value = new PhotoMetadata(f_dimensions, f_location, f_timeTaken); } - - - return new PhotoMetadata(dimensions, location, timeTaken); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/PreviewArg.java b/src/main/java/com/dropbox/core/v2/files/PreviewArg.java index ec8473305..2e367b748 100644 --- a/src/main/java/com/dropbox/core/v2/files/PreviewArg.java +++ b/src/main/java/com/dropbox/core/v2/files/PreviewArg.java @@ -1,46 +1,29 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=PreviewArg.Serializer.class) -@JsonDeserialize(using=PreviewArg.Deserializer.class) class PreviewArg { // struct PreviewArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String path; protected final String rev; /** * * @param path The path of the file to preview. Must match pattern "{@code - * ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. * @param rev Deprecated. Please specify revision in the {@code path} * argument to {@link DbxUserFilesRequests#getPreview(String)} instead. * Must have length of at least 9 and match pattern "{@code [0-9a-f]+}". @@ -52,7 +35,7 @@ public PreviewArg(String path, String rev) { if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("((/|id:).*)|(rev:[0-9a-f]{9,})", path)) { + if (!java.util.regex.Pattern.matches("(/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -71,7 +54,7 @@ public PreviewArg(String path, String rev) { * The default values for unset fields will be used. * * @param path The path of the file to preview. Must match pattern "{@code - * ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -127,7 +110,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -139,86 +122,67 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(PreviewArg.class); - } - - public Serializer(boolean unwrapping) { - super(PreviewArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(PreviewArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("path", value.path); + public void serialize(PreviewArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("path"); + StoneSerializers.string().serialize(value.path, g); if (value.rev != null) { - g.writeObjectField("rev", value.rev); + g.writeFieldName("rev"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.rev, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(PreviewArg.class); - } - - public Deserializer(boolean unwrapping) { - super(PreviewArg.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public PreviewArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String path = null; - String rev = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); - } - else if ("rev".equals(_field)) { - rev = getStringValue(_p); - _p.nextToken(); + public PreviewArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + PreviewArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_path = null; + String f_rev = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("path".equals(field)) { + f_path = StoneSerializers.string().deserialize(p); + } + else if ("rev".equals(field)) { + f_rev = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_path == null) { + throw new JsonParseException(p, "Required field \"path\" missing."); } + value = new PreviewArg(f_path, f_rev); } - - if (path == null) { - throw new JsonParseException(_p, "Required field \"path\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new PreviewArg(path, rev); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/PreviewError.java b/src/main/java/com/dropbox/core/v2/files/PreviewError.java index cb89c144d..99ab771e4 100644 --- a/src/main/java/com/dropbox/core/v2/files/PreviewError.java +++ b/src/main/java/com/dropbox/core/v2/files/PreviewError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is a tagged union. Tagged unions instances are always associated @@ -32,15 +20,9 @@ * return {@code true}. You can use {@link #tag()} to determine the tag * associated with this instance. */ -@JsonSerialize(using=PreviewError.Serializer.class) -@JsonDeserialize(using=PreviewError.Deserializer.class) public final class PreviewError { // union PreviewError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link PreviewError}. */ @@ -225,7 +207,7 @@ else if (obj instanceof PreviewError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -237,85 +219,84 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(PreviewError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(PreviewError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case PATH: + public void serialize(PreviewError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PATH: { g.writeStartObject(); - g.writeStringField(".tag", "path"); - g.writeObjectField("path", value.pathValue); + writeTag("path", g); + g.writeFieldName("path"); + LookupError.Serializer.INSTANCE.serialize(value.pathValue, g); g.writeEndObject(); break; - case IN_PROGRESS: + } + case IN_PROGRESS: { g.writeString("in_progress"); break; - case UNSUPPORTED_EXTENSION: + } + case UNSUPPORTED_EXTENSION: { g.writeString("unsupported_extension"); break; - case UNSUPPORTED_CONTENT: + } + case UNSUPPORTED_CONTENT: { g.writeString("unsupported_content"); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(PreviewError.class, getTagMapping(), null); - } - - @Override - public PreviewError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case PATH: { - LookupError value = null; - expectField(_p, "path"); - value = _p.readValueAs(LookupError.class); - _p.nextToken(); - return PreviewError.path(value); - } - case IN_PROGRESS: { - return PreviewError.IN_PROGRESS; - } - case UNSUPPORTED_EXTENSION: { - return PreviewError.UNSUPPORTED_EXTENSION; } - case UNSUPPORTED_CONTENT: { - return PreviewError.UNSUPPORTED_CONTENT; + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("path", PreviewError.Tag.PATH); - values.put("in_progress", PreviewError.Tag.IN_PROGRESS); - values.put("unsupported_extension", PreviewError.Tag.UNSUPPORTED_EXTENSION); - values.put("unsupported_content", PreviewError.Tag.UNSUPPORTED_CONTENT); - return Collections.unmodifiableMap(values); + @Override + public PreviewError deserialize(JsonParser p) throws IOException, JsonParseException { + PreviewError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("path".equals(tag)) { + LookupError fieldValue = null; + expectField("path", p); + fieldValue = LookupError.Serializer.INSTANCE.deserialize(p); + value = PreviewError.path(fieldValue); + } + else if ("in_progress".equals(tag)) { + value = PreviewError.IN_PROGRESS; + } + else if ("unsupported_extension".equals(tag)) { + value = PreviewError.UNSUPPORTED_EXTENSION; + } + else if ("unsupported_content".equals(tag)) { + value = PreviewError.UNSUPPORTED_CONTENT; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/PreviewErrorException.java b/src/main/java/com/dropbox/core/v2/files/PreviewErrorException.java index 4ca32fa97..18870ee54 100644 --- a/src/main/java/com/dropbox/core/v2/files/PreviewErrorException.java +++ b/src/main/java/com/dropbox/core/v2/files/PreviewErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; diff --git a/src/main/java/com/dropbox/core/v2/files/RelocationArg.java b/src/main/java/com/dropbox/core/v2/files/RelocationArg.java index 081b6524d..64d17ca26 100644 --- a/src/main/java/com/dropbox/core/v2/files/RelocationArg.java +++ b/src/main/java/com/dropbox/core/v2/files/RelocationArg.java @@ -1,48 +1,31 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=RelocationArg.Serializer.class) -@JsonDeserialize(using=RelocationArg.Deserializer.class) public class RelocationArg { // struct RelocationArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String fromPath; protected final String toPath; /** * * @param fromPath Path in the user's Dropbox to be copied or moved. Must - * match pattern "{@code /.*}" and not be {@code null}. + * match pattern "{@code /(.|[\\r\\n])*}" and not be {@code null}. * @param toPath Path in the user's Dropbox that is the destination. Must - * match pattern "{@code /.*}" and not be {@code null}. + * match pattern "{@code /(.|[\\r\\n])*}" and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -51,14 +34,14 @@ public RelocationArg(String fromPath, String toPath) { if (fromPath == null) { throw new IllegalArgumentException("Required value for 'fromPath' is null"); } - if (!java.util.regex.Pattern.matches("/.*", fromPath)) { + if (!java.util.regex.Pattern.matches("/(.|[\\r\\n])*", fromPath)) { throw new IllegalArgumentException("String 'fromPath' does not match pattern"); } this.fromPath = fromPath; if (toPath == null) { throw new IllegalArgumentException("Required value for 'toPath' is null"); } - if (!java.util.regex.Pattern.matches("/.*", toPath)) { + if (!java.util.regex.Pattern.matches("/(.|[\\r\\n])*", toPath)) { throw new IllegalArgumentException("String 'toPath' does not match pattern"); } this.toPath = toPath; @@ -110,7 +93,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -122,87 +105,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RelocationArg.class); - } - - public Serializer(boolean unwrapping) { - super(RelocationArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(RelocationArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("from_path", value.fromPath); - g.writeObjectField("to_path", value.toPath); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RelocationArg.class); - } - - public Deserializer(boolean unwrapping) { - super(RelocationArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(RelocationArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("from_path"); + StoneSerializers.string().serialize(value.fromPath, g); + g.writeFieldName("to_path"); + StoneSerializers.string().serialize(value.toPath, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public RelocationArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String fromPath = null; - String toPath = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("from_path".equals(_field)) { - fromPath = getStringValue(_p); - _p.nextToken(); + public RelocationArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + RelocationArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_fromPath = null; + String f_toPath = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("from_path".equals(field)) { + f_fromPath = StoneSerializers.string().deserialize(p); + } + else if ("to_path".equals(field)) { + f_toPath = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else if ("to_path".equals(_field)) { - toPath = getStringValue(_p); - _p.nextToken(); + if (f_fromPath == null) { + throw new JsonParseException(p, "Required field \"from_path\" missing."); } - else { - skipValue(_p); + if (f_toPath == null) { + throw new JsonParseException(p, "Required field \"to_path\" missing."); } + value = new RelocationArg(f_fromPath, f_toPath); } - - if (fromPath == null) { - throw new JsonParseException(_p, "Required field \"from_path\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (toPath == null) { - throw new JsonParseException(_p, "Required field \"to_path\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new RelocationArg(fromPath, toPath); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/RelocationError.java b/src/main/java/com/dropbox/core/v2/files/RelocationError.java index 991ff69dd..e76ae5042 100644 --- a/src/main/java/com/dropbox/core/v2/files/RelocationError.java +++ b/src/main/java/com/dropbox/core/v2/files/RelocationError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=RelocationError.Serializer.class) -@JsonDeserialize(using=RelocationError.Deserializer.class) public final class RelocationError { // union RelocationError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link RelocationError}. */ @@ -367,7 +349,7 @@ else if (obj instanceof RelocationError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -379,127 +361,120 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RelocationError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(RelocationError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case FROM_LOOKUP: + public void serialize(RelocationError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case FROM_LOOKUP: { g.writeStartObject(); - g.writeStringField(".tag", "from_lookup"); - g.writeObjectField("from_lookup", value.fromLookupValue); + writeTag("from_lookup", g); + g.writeFieldName("from_lookup"); + LookupError.Serializer.INSTANCE.serialize(value.fromLookupValue, g); g.writeEndObject(); break; - case FROM_WRITE: + } + case FROM_WRITE: { g.writeStartObject(); - g.writeStringField(".tag", "from_write"); - g.writeObjectField("from_write", value.fromWriteValue); + writeTag("from_write", g); + g.writeFieldName("from_write"); + WriteError.Serializer.INSTANCE.serialize(value.fromWriteValue, g); g.writeEndObject(); break; - case TO: + } + case TO: { g.writeStartObject(); - g.writeStringField(".tag", "to"); - g.writeObjectField("to", value.toValue); + writeTag("to", g); + g.writeFieldName("to"); + WriteError.Serializer.INSTANCE.serialize(value.toValue, g); g.writeEndObject(); break; - case CANT_COPY_SHARED_FOLDER: + } + case CANT_COPY_SHARED_FOLDER: { g.writeString("cant_copy_shared_folder"); break; - case CANT_NEST_SHARED_FOLDER: + } + case CANT_NEST_SHARED_FOLDER: { g.writeString("cant_nest_shared_folder"); break; - case CANT_MOVE_FOLDER_INTO_ITSELF: + } + case CANT_MOVE_FOLDER_INTO_ITSELF: { g.writeString("cant_move_folder_into_itself"); break; - case TOO_MANY_FILES: + } + case TOO_MANY_FILES: { g.writeString("too_many_files"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RelocationError.class, getTagMapping(), Tag.OTHER); - } @Override - public RelocationError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case FROM_LOOKUP: { - LookupError value = null; - expectField(_p, "from_lookup"); - value = _p.readValueAs(LookupError.class); - _p.nextToken(); - return RelocationError.fromLookup(value); - } - case FROM_WRITE: { - WriteError value = null; - expectField(_p, "from_write"); - value = _p.readValueAs(WriteError.class); - _p.nextToken(); - return RelocationError.fromWrite(value); - } - case TO: { - WriteError value = null; - expectField(_p, "to"); - value = _p.readValueAs(WriteError.class); - _p.nextToken(); - return RelocationError.to(value); - } - case CANT_COPY_SHARED_FOLDER: { - return RelocationError.CANT_COPY_SHARED_FOLDER; - } - case CANT_NEST_SHARED_FOLDER: { - return RelocationError.CANT_NEST_SHARED_FOLDER; - } - case CANT_MOVE_FOLDER_INTO_ITSELF: { - return RelocationError.CANT_MOVE_FOLDER_INTO_ITSELF; - } - case TOO_MANY_FILES: { - return RelocationError.TOO_MANY_FILES; - } - case OTHER: { - return RelocationError.OTHER; - } + public RelocationError deserialize(JsonParser p) throws IOException, JsonParseException { + RelocationError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("from_lookup", RelocationError.Tag.FROM_LOOKUP); - values.put("from_write", RelocationError.Tag.FROM_WRITE); - values.put("to", RelocationError.Tag.TO); - values.put("cant_copy_shared_folder", RelocationError.Tag.CANT_COPY_SHARED_FOLDER); - values.put("cant_nest_shared_folder", RelocationError.Tag.CANT_NEST_SHARED_FOLDER); - values.put("cant_move_folder_into_itself", RelocationError.Tag.CANT_MOVE_FOLDER_INTO_ITSELF); - values.put("too_many_files", RelocationError.Tag.TOO_MANY_FILES); - values.put("other", RelocationError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("from_lookup".equals(tag)) { + LookupError fieldValue = null; + expectField("from_lookup", p); + fieldValue = LookupError.Serializer.INSTANCE.deserialize(p); + value = RelocationError.fromLookup(fieldValue); + } + else if ("from_write".equals(tag)) { + WriteError fieldValue = null; + expectField("from_write", p); + fieldValue = WriteError.Serializer.INSTANCE.deserialize(p); + value = RelocationError.fromWrite(fieldValue); + } + else if ("to".equals(tag)) { + WriteError fieldValue = null; + expectField("to", p); + fieldValue = WriteError.Serializer.INSTANCE.deserialize(p); + value = RelocationError.to(fieldValue); + } + else if ("cant_copy_shared_folder".equals(tag)) { + value = RelocationError.CANT_COPY_SHARED_FOLDER; + } + else if ("cant_nest_shared_folder".equals(tag)) { + value = RelocationError.CANT_NEST_SHARED_FOLDER; + } + else if ("cant_move_folder_into_itself".equals(tag)) { + value = RelocationError.CANT_MOVE_FOLDER_INTO_ITSELF; + } + else if ("too_many_files".equals(tag)) { + value = RelocationError.TOO_MANY_FILES; + } + else { + value = RelocationError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/RelocationErrorException.java b/src/main/java/com/dropbox/core/v2/files/RelocationErrorException.java index 52333d8e3..06947d789 100644 --- a/src/main/java/com/dropbox/core/v2/files/RelocationErrorException.java +++ b/src/main/java/com/dropbox/core/v2/files/RelocationErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; diff --git a/src/main/java/com/dropbox/core/v2/files/RestoreArg.java b/src/main/java/com/dropbox/core/v2/files/RestoreArg.java index 620768b16..c194e0062 100644 --- a/src/main/java/com/dropbox/core/v2/files/RestoreArg.java +++ b/src/main/java/com/dropbox/core/v2/files/RestoreArg.java @@ -1,46 +1,29 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=RestoreArg.Serializer.class) -@JsonDeserialize(using=RestoreArg.Deserializer.class) class RestoreArg { // struct RestoreArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String path; protected final String rev; /** * * @param path The path to the file you want to restore. Must match pattern - * "{@code /.*}" and not be {@code null}. + * "{@code /(.|[\\r\\n])*}" and not be {@code null}. * @param rev The revision to restore for the file. Must have length of at * least 9, match pattern "{@code [0-9a-f]+}", and not be {@code null}. * @@ -51,7 +34,7 @@ public RestoreArg(String path, String rev) { if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("/.*", path)) { + if (!java.util.regex.Pattern.matches("/(.|[\\r\\n])*", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -113,7 +96,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -125,87 +108,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RestoreArg.class); - } - - public Serializer(boolean unwrapping) { - super(RestoreArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(RestoreArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("path", value.path); - g.writeObjectField("rev", value.rev); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RestoreArg.class); - } - - public Deserializer(boolean unwrapping) { - super(RestoreArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(RestoreArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("path"); + StoneSerializers.string().serialize(value.path, g); + g.writeFieldName("rev"); + StoneSerializers.string().serialize(value.rev, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public RestoreArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String path = null; - String rev = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); + public RestoreArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + RestoreArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_path = null; + String f_rev = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("path".equals(field)) { + f_path = StoneSerializers.string().deserialize(p); + } + else if ("rev".equals(field)) { + f_rev = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else if ("rev".equals(_field)) { - rev = getStringValue(_p); - _p.nextToken(); + if (f_path == null) { + throw new JsonParseException(p, "Required field \"path\" missing."); } - else { - skipValue(_p); + if (f_rev == null) { + throw new JsonParseException(p, "Required field \"rev\" missing."); } + value = new RestoreArg(f_path, f_rev); } - - if (path == null) { - throw new JsonParseException(_p, "Required field \"path\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (rev == null) { - throw new JsonParseException(_p, "Required field \"rev\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new RestoreArg(path, rev); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/RestoreError.java b/src/main/java/com/dropbox/core/v2/files/RestoreError.java index d61cb6a2b..0fc1f4146 100644 --- a/src/main/java/com/dropbox/core/v2/files/RestoreError.java +++ b/src/main/java/com/dropbox/core/v2/files/RestoreError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=RestoreError.Serializer.class) -@JsonDeserialize(using=RestoreError.Deserializer.class) public final class RestoreError { // union RestoreError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link RestoreError}. */ @@ -275,7 +257,7 @@ else if (obj instanceof RestoreError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -287,92 +269,85 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RestoreError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(RestoreError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case PATH_LOOKUP: + public void serialize(RestoreError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PATH_LOOKUP: { g.writeStartObject(); - g.writeStringField(".tag", "path_lookup"); - g.writeObjectField("path_lookup", value.pathLookupValue); + writeTag("path_lookup", g); + g.writeFieldName("path_lookup"); + LookupError.Serializer.INSTANCE.serialize(value.pathLookupValue, g); g.writeEndObject(); break; - case PATH_WRITE: + } + case PATH_WRITE: { g.writeStartObject(); - g.writeStringField(".tag", "path_write"); - g.writeObjectField("path_write", value.pathWriteValue); + writeTag("path_write", g); + g.writeFieldName("path_write"); + WriteError.Serializer.INSTANCE.serialize(value.pathWriteValue, g); g.writeEndObject(); break; - case INVALID_REVISION: + } + case INVALID_REVISION: { g.writeString("invalid_revision"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RestoreError.class, getTagMapping(), Tag.OTHER); - } @Override - public RestoreError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case PATH_LOOKUP: { - LookupError value = null; - expectField(_p, "path_lookup"); - value = _p.readValueAs(LookupError.class); - _p.nextToken(); - return RestoreError.pathLookup(value); - } - case PATH_WRITE: { - WriteError value = null; - expectField(_p, "path_write"); - value = _p.readValueAs(WriteError.class); - _p.nextToken(); - return RestoreError.pathWrite(value); - } - case INVALID_REVISION: { - return RestoreError.INVALID_REVISION; - } - case OTHER: { - return RestoreError.OTHER; - } + public RestoreError deserialize(JsonParser p) throws IOException, JsonParseException { + RestoreError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("path_lookup", RestoreError.Tag.PATH_LOOKUP); - values.put("path_write", RestoreError.Tag.PATH_WRITE); - values.put("invalid_revision", RestoreError.Tag.INVALID_REVISION); - values.put("other", RestoreError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("path_lookup".equals(tag)) { + LookupError fieldValue = null; + expectField("path_lookup", p); + fieldValue = LookupError.Serializer.INSTANCE.deserialize(p); + value = RestoreError.pathLookup(fieldValue); + } + else if ("path_write".equals(tag)) { + WriteError fieldValue = null; + expectField("path_write", p); + fieldValue = WriteError.Serializer.INSTANCE.deserialize(p); + value = RestoreError.pathWrite(fieldValue); + } + else if ("invalid_revision".equals(tag)) { + value = RestoreError.INVALID_REVISION; + } + else { + value = RestoreError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/RestoreErrorException.java b/src/main/java/com/dropbox/core/v2/files/RestoreErrorException.java index 8229470ee..0fc7fcc90 100644 --- a/src/main/java/com/dropbox/core/v2/files/RestoreErrorException.java +++ b/src/main/java/com/dropbox/core/v2/files/RestoreErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; diff --git a/src/main/java/com/dropbox/core/v2/files/SaveCopyReferenceArg.java b/src/main/java/com/dropbox/core/v2/files/SaveCopyReferenceArg.java index 921ff9b5c..3af81446c 100644 --- a/src/main/java/com/dropbox/core/v2/files/SaveCopyReferenceArg.java +++ b/src/main/java/com/dropbox/core/v2/files/SaveCopyReferenceArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=SaveCopyReferenceArg.Serializer.class) -@JsonDeserialize(using=SaveCopyReferenceArg.Deserializer.class) class SaveCopyReferenceArg { // struct SaveCopyReferenceArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String copyReference; protected final String path; @@ -43,7 +26,7 @@ class SaveCopyReferenceArg { * DbxUserFilesRequests#copyReferenceGet(String)}. Must not be {@code * null}. * @param path Path in the user's Dropbox that is the destination. Must - * match pattern "{@code /.*}" and not be {@code null}. + * match pattern "{@code /(.|[\\r\\n])*}" and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -56,7 +39,7 @@ public SaveCopyReferenceArg(String copyReference, String path) { if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("/.*", path)) { + if (!java.util.regex.Pattern.matches("/(.|[\\r\\n])*", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -109,7 +92,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -121,87 +104,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SaveCopyReferenceArg.class); - } - - public Serializer(boolean unwrapping) { - super(SaveCopyReferenceArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(SaveCopyReferenceArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("copy_reference", value.copyReference); - g.writeObjectField("path", value.path); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SaveCopyReferenceArg.class); - } - - public Deserializer(boolean unwrapping) { - super(SaveCopyReferenceArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(SaveCopyReferenceArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("copy_reference"); + StoneSerializers.string().serialize(value.copyReference, g); + g.writeFieldName("path"); + StoneSerializers.string().serialize(value.path, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public SaveCopyReferenceArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String copyReference = null; - String path = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("copy_reference".equals(_field)) { - copyReference = getStringValue(_p); - _p.nextToken(); + public SaveCopyReferenceArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + SaveCopyReferenceArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_copyReference = null; + String f_path = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("copy_reference".equals(field)) { + f_copyReference = StoneSerializers.string().deserialize(p); + } + else if ("path".equals(field)) { + f_path = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); + if (f_copyReference == null) { + throw new JsonParseException(p, "Required field \"copy_reference\" missing."); } - else { - skipValue(_p); + if (f_path == null) { + throw new JsonParseException(p, "Required field \"path\" missing."); } + value = new SaveCopyReferenceArg(f_copyReference, f_path); } - - if (copyReference == null) { - throw new JsonParseException(_p, "Required field \"copy_reference\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (path == null) { - throw new JsonParseException(_p, "Required field \"path\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new SaveCopyReferenceArg(copyReference, path); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/SaveCopyReferenceError.java b/src/main/java/com/dropbox/core/v2/files/SaveCopyReferenceError.java index 88c22dc1f..0f23f7e90 100644 --- a/src/main/java/com/dropbox/core/v2/files/SaveCopyReferenceError.java +++ b/src/main/java/com/dropbox/core/v2/files/SaveCopyReferenceError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=SaveCopyReferenceError.Serializer.class) -@JsonDeserialize(using=SaveCopyReferenceError.Deserializer.class) public final class SaveCopyReferenceError { // union SaveCopyReferenceError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link SaveCopyReferenceError}. */ @@ -274,7 +256,7 @@ else if (obj instanceof SaveCopyReferenceError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -286,99 +268,92 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); + return Serializer.INSTANCE.serialize(this, true); } - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SaveCopyReferenceError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(SaveCopyReferenceError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case PATH: + public void serialize(SaveCopyReferenceError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PATH: { g.writeStartObject(); - g.writeStringField(".tag", "path"); - g.writeObjectField("path", value.pathValue); + writeTag("path", g); + g.writeFieldName("path"); + WriteError.Serializer.INSTANCE.serialize(value.pathValue, g); g.writeEndObject(); break; - case INVALID_COPY_REFERENCE: + } + case INVALID_COPY_REFERENCE: { g.writeString("invalid_copy_reference"); break; - case NO_PERMISSION: + } + case NO_PERMISSION: { g.writeString("no_permission"); break; - case NOT_FOUND: + } + case NOT_FOUND: { g.writeString("not_found"); break; - case TOO_MANY_FILES: + } + case TOO_MANY_FILES: { g.writeString("too_many_files"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SaveCopyReferenceError.class, getTagMapping(), Tag.OTHER); - } @Override - public SaveCopyReferenceError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case PATH: { - WriteError value = null; - expectField(_p, "path"); - value = _p.readValueAs(WriteError.class); - _p.nextToken(); - return SaveCopyReferenceError.path(value); - } - case INVALID_COPY_REFERENCE: { - return SaveCopyReferenceError.INVALID_COPY_REFERENCE; - } - case NO_PERMISSION: { - return SaveCopyReferenceError.NO_PERMISSION; - } - case NOT_FOUND: { - return SaveCopyReferenceError.NOT_FOUND; - } - case TOO_MANY_FILES: { - return SaveCopyReferenceError.TOO_MANY_FILES; - } - case OTHER: { - return SaveCopyReferenceError.OTHER; - } + public SaveCopyReferenceError deserialize(JsonParser p) throws IOException, JsonParseException { + SaveCopyReferenceError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("path", SaveCopyReferenceError.Tag.PATH); - values.put("invalid_copy_reference", SaveCopyReferenceError.Tag.INVALID_COPY_REFERENCE); - values.put("no_permission", SaveCopyReferenceError.Tag.NO_PERMISSION); - values.put("not_found", SaveCopyReferenceError.Tag.NOT_FOUND); - values.put("too_many_files", SaveCopyReferenceError.Tag.TOO_MANY_FILES); - values.put("other", SaveCopyReferenceError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("path".equals(tag)) { + WriteError fieldValue = null; + expectField("path", p); + fieldValue = WriteError.Serializer.INSTANCE.deserialize(p); + value = SaveCopyReferenceError.path(fieldValue); + } + else if ("invalid_copy_reference".equals(tag)) { + value = SaveCopyReferenceError.INVALID_COPY_REFERENCE; + } + else if ("no_permission".equals(tag)) { + value = SaveCopyReferenceError.NO_PERMISSION; + } + else if ("not_found".equals(tag)) { + value = SaveCopyReferenceError.NOT_FOUND; + } + else if ("too_many_files".equals(tag)) { + value = SaveCopyReferenceError.TOO_MANY_FILES; + } + else { + value = SaveCopyReferenceError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/SaveCopyReferenceErrorException.java b/src/main/java/com/dropbox/core/v2/files/SaveCopyReferenceErrorException.java index 05c06c76e..4a77bfeba 100644 --- a/src/main/java/com/dropbox/core/v2/files/SaveCopyReferenceErrorException.java +++ b/src/main/java/com/dropbox/core/v2/files/SaveCopyReferenceErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; diff --git a/src/main/java/com/dropbox/core/v2/files/SaveCopyReferenceResult.java b/src/main/java/com/dropbox/core/v2/files/SaveCopyReferenceResult.java index cd9967a81..787cebefb 100644 --- a/src/main/java/com/dropbox/core/v2/files/SaveCopyReferenceResult.java +++ b/src/main/java/com/dropbox/core/v2/files/SaveCopyReferenceResult.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=SaveCopyReferenceResult.Serializer.class) -@JsonDeserialize(using=SaveCopyReferenceResult.Deserializer.class) public class SaveCopyReferenceResult { // struct SaveCopyReferenceResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final Metadata metadata; /** @@ -85,7 +68,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -97,78 +80,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SaveCopyReferenceResult.class); - } - - public Serializer(boolean unwrapping) { - super(SaveCopyReferenceResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(SaveCopyReferenceResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("metadata", value.metadata); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SaveCopyReferenceResult.class); - } - - public Deserializer(boolean unwrapping) { - super(SaveCopyReferenceResult.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(SaveCopyReferenceResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("metadata"); + Metadata.Serializer.INSTANCE.serialize(value.metadata, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public SaveCopyReferenceResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - Metadata metadata = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("metadata".equals(_field)) { - metadata = _p.readValueAs(Metadata.class); - _p.nextToken(); + public SaveCopyReferenceResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + SaveCopyReferenceResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Metadata f_metadata = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("metadata".equals(field)) { + f_metadata = Metadata.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_metadata == null) { + throw new JsonParseException(p, "Required field \"metadata\" missing."); } + value = new SaveCopyReferenceResult(f_metadata); } - - if (metadata == null) { - throw new JsonParseException(_p, "Required field \"metadata\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new SaveCopyReferenceResult(metadata); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/SaveUrlArg.java b/src/main/java/com/dropbox/core/v2/files/SaveUrlArg.java new file mode 100644 index 000000000..51f43411e --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/files/SaveUrlArg.java @@ -0,0 +1,168 @@ +/* DO NOT EDIT */ +/* This file was generated from files.stone */ + +package com.dropbox.core.v2.files; + +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + +import java.io.IOException; + +class SaveUrlArg { + // struct SaveUrlArg + + protected final String path; + protected final String url; + + /** + * + * @param path The path in Dropbox where the URL will be saved to. Must + * match pattern "{@code /(.|[\\r\\n])*}" and not be {@code null}. + * @param url The URL to be saved. Must not be {@code null}. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public SaveUrlArg(String path, String url) { + if (path == null) { + throw new IllegalArgumentException("Required value for 'path' is null"); + } + if (!java.util.regex.Pattern.matches("/(.|[\\r\\n])*", path)) { + throw new IllegalArgumentException("String 'path' does not match pattern"); + } + this.path = path; + if (url == null) { + throw new IllegalArgumentException("Required value for 'url' is null"); + } + this.url = url; + } + + /** + * The path in Dropbox where the URL will be saved to. + * + * @return value for this field, never {@code null}. + */ + public String getPath() { + return path; + } + + /** + * The URL to be saved. + * + * @return value for this field, never {@code null}. + */ + public String getUrl() { + return url; + } + + @Override + public int hashCode() { + int hash = java.util.Arrays.hashCode(new Object [] { + path, + url + }); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + // be careful with inheritance + else if (obj.getClass().equals(this.getClass())) { + SaveUrlArg other = (SaveUrlArg) obj; + return ((this.path == other.path) || (this.path.equals(other.path))) + && ((this.url == other.url) || (this.url.equals(other.url))) + ; + } + else { + return false; + } + } + + @Override + public String toString() { + return Serializer.INSTANCE.serialize(this, false); + } + + /** + * Returns a String representation of this object formatted for easier + * readability. + * + *

The returned String may contain newlines.

+ * + * @return Formatted, multiline String representation of this object + */ + public String toStringMultiline() { + return Serializer.INSTANCE.serialize(this, true); + } + + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); + + @Override + public void serialize(SaveUrlArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("path"); + StoneSerializers.string().serialize(value.path, g); + g.writeFieldName("url"); + StoneSerializers.string().serialize(value.url, g); + if (!collapse) { + g.writeEndObject(); + } + } + + @Override + public SaveUrlArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + SaveUrlArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_path = null; + String f_url = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("path".equals(field)) { + f_path = StoneSerializers.string().deserialize(p); + } + else if ("url".equals(field)) { + f_url = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } + } + if (f_path == null) { + throw new JsonParseException(p, "Required field \"path\" missing."); + } + if (f_url == null) { + throw new JsonParseException(p, "Required field \"url\" missing."); + } + value = new SaveUrlArg(f_path, f_url); + } + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; + } + } +} diff --git a/src/main/java/com/dropbox/core/v2/files/SaveUrlError.java b/src/main/java/com/dropbox/core/v2/files/SaveUrlError.java new file mode 100644 index 000000000..117b256a3 --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/files/SaveUrlError.java @@ -0,0 +1,331 @@ +/* DO NOT EDIT */ +/* This file was generated from files.stone */ + +package com.dropbox.core.v2.files; + +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + +import java.io.IOException; + +/** + * This class is an open tagged union. Tagged unions instances are always + * associated to a specific tag. This means only one of the {@code isAbc()} + * methods will return {@code true}. You can use {@link #tag()} to determine the + * tag associated with this instance. + * + *

Open unions may be extended in the future with additional tags. If a new + * tag is introduced that this SDK does not recognized, the {@link #OTHER} value + * will be used.

+ */ +public final class SaveUrlError { + // union SaveUrlError + + /** + * Discriminating tag type for {@link SaveUrlError}. + */ + public enum Tag { + PATH, // WriteError + /** + * Failed downloading the given URL. + */ + DOWNLOAD_FAILED, + /** + * The given URL is invalid. + */ + INVALID_URL, + /** + * The file where the URL is saved to no longer exists. + */ + NOT_FOUND, + /** + * Catch-all used for unknown tag values returned by the Dropbox + * servers. + * + *

Receiving a catch-all value typically indicates this SDK version + * is not up to date. Consider updating your SDK version to handle the + * new tags.

+ */ + OTHER; // *catch_all + } + + /** + * Failed downloading the given URL. + */ + public static final SaveUrlError DOWNLOAD_FAILED = new SaveUrlError(Tag.DOWNLOAD_FAILED, null); + /** + * The given URL is invalid. + */ + public static final SaveUrlError INVALID_URL = new SaveUrlError(Tag.INVALID_URL, null); + /** + * The file where the URL is saved to no longer exists. + */ + public static final SaveUrlError NOT_FOUND = new SaveUrlError(Tag.NOT_FOUND, null); + /** + * Catch-all used for unknown tag values returned by the Dropbox servers. + * + *

Receiving a catch-all value typically indicates this SDK version is + * not up to date. Consider updating your SDK version to handle the new + * tags.

+ */ + public static final SaveUrlError OTHER = new SaveUrlError(Tag.OTHER, null); + + private final Tag tag; + private final WriteError pathValue; + + /** + * + * @param tag Discriminating tag for this instance. + */ + private SaveUrlError(Tag tag, WriteError pathValue) { + this.tag = tag; + this.pathValue = pathValue; + } + + /** + * Returns the tag for this instance. + * + *

This class is a tagged union. Tagged unions instances are always + * associated to a specific tag. This means only one of the {@code isXyz()} + * methods will return {@code true}. Callers are recommended to use the tag + * value in a {@code switch} statement to properly handle the different + * values for this {@code SaveUrlError}.

+ * + *

If a tag returned by the server is unrecognized by this SDK, the + * {@link Tag#OTHER} value will be used.

+ * + * @return the tag for this instance. + */ + public Tag tag() { + return tag; + } + + /** + * Returns {@code true} if this instance has the tag {@link Tag#PATH}, + * {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link Tag#PATH}, + * {@code false} otherwise. + */ + public boolean isPath() { + return this.tag == Tag.PATH; + } + + /** + * Returns an instance of {@code SaveUrlError} that has its tag set to + * {@link Tag#PATH}. + * + * @param value value to assign to this instance. + * + * @return Instance of {@code SaveUrlError} with its tag set to {@link + * Tag#PATH}. + * + * @throws IllegalArgumentException if {@code value} is {@code null}. + */ + public static SaveUrlError path(WriteError value) { + if (value == null) { + throw new IllegalArgumentException("Value is null"); + } + return new SaveUrlError(Tag.PATH, value); + } + + /** + * This instance must be tagged as {@link Tag#PATH}. + * + * @return The {@link SaveUrlError#path} value associated with this instance + * if {@link #isPath} is {@code true}. + * + * @throws IllegalStateException If {@link #isPath} is {@code false}. + */ + public WriteError getPathValue() { + if (this.tag != Tag.PATH) { + throw new IllegalStateException("Invalid tag: required Tag.PATH, but was Tag." + tag.name()); + } + return pathValue; + } + + /** + * Returns {@code true} if this instance has the tag {@link + * Tag#DOWNLOAD_FAILED}, {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link + * Tag#DOWNLOAD_FAILED}, {@code false} otherwise. + */ + public boolean isDownloadFailed() { + return this.tag == Tag.DOWNLOAD_FAILED; + } + + /** + * Returns {@code true} if this instance has the tag {@link + * Tag#INVALID_URL}, {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link + * Tag#INVALID_URL}, {@code false} otherwise. + */ + public boolean isInvalidUrl() { + return this.tag == Tag.INVALID_URL; + } + + /** + * Returns {@code true} if this instance has the tag {@link Tag#NOT_FOUND}, + * {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link Tag#NOT_FOUND}, + * {@code false} otherwise. + */ + public boolean isNotFound() { + return this.tag == Tag.NOT_FOUND; + } + + /** + * Returns {@code true} if this instance has the tag {@link Tag#OTHER}, + * {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link Tag#OTHER}, + * {@code false} otherwise. + */ + public boolean isOther() { + return this.tag == Tag.OTHER; + } + + @Override + public int hashCode() { + int hash = java.util.Arrays.hashCode(new Object [] { + tag, + pathValue + }); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + else if (obj instanceof SaveUrlError) { + SaveUrlError other = (SaveUrlError) obj; + if (this.tag != other.tag) { + return false; + } + switch (tag) { + case PATH: + return (this.pathValue == other.pathValue) || (this.pathValue.equals(other.pathValue)); + case DOWNLOAD_FAILED: + return true; + case INVALID_URL: + return true; + case NOT_FOUND: + return true; + case OTHER: + return true; + default: + return false; + } + } + else { + return false; + } + } + + @Override + public String toString() { + return Serializer.INSTANCE.serialize(this, false); + } + + /** + * Returns a String representation of this object formatted for easier + * readability. + * + *

The returned String may contain newlines.

+ * + * @return Formatted, multiline String representation of this object + */ + public String toStringMultiline() { + return Serializer.INSTANCE.serialize(this, true); + } + + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); + + @Override + public void serialize(SaveUrlError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PATH: { + g.writeStartObject(); + writeTag("path", g); + g.writeFieldName("path"); + WriteError.Serializer.INSTANCE.serialize(value.pathValue, g); + g.writeEndObject(); + break; + } + case DOWNLOAD_FAILED: { + g.writeString("download_failed"); + break; + } + case INVALID_URL: { + g.writeString("invalid_url"); + break; + } + case NOT_FOUND: { + g.writeString("not_found"); + break; + } + default: { + g.writeString("other"); + } + } + } + + @Override + public SaveUrlError deserialize(JsonParser p) throws IOException, JsonParseException { + SaveUrlError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("path".equals(tag)) { + WriteError fieldValue = null; + expectField("path", p); + fieldValue = WriteError.Serializer.INSTANCE.deserialize(p); + value = SaveUrlError.path(fieldValue); + } + else if ("download_failed".equals(tag)) { + value = SaveUrlError.DOWNLOAD_FAILED; + } + else if ("invalid_url".equals(tag)) { + value = SaveUrlError.INVALID_URL; + } + else if ("not_found".equals(tag)) { + value = SaveUrlError.NOT_FOUND; + } + else { + value = SaveUrlError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; + } + } +} diff --git a/src/main/java/com/dropbox/core/v2/files/SaveUrlErrorException.java b/src/main/java/com/dropbox/core/v2/files/SaveUrlErrorException.java new file mode 100644 index 000000000..e10c549eb --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/files/SaveUrlErrorException.java @@ -0,0 +1,28 @@ +/* DO NOT EDIT */ +/* This file was generated from files.stone */ + +package com.dropbox.core.v2.files; + +import com.dropbox.core.DbxApiException; +import com.dropbox.core.LocalizedText; + +/** + * Exception thrown when the server responds with a {@link SaveUrlError} error. + */ +public class SaveUrlErrorException extends DbxApiException { + private static final long serialVersionUID = 0L; + + /** + * The error reported by {@link + * DbxUserFilesRequests#saveUrl(String,String)}. + */ + public final SaveUrlError errorValue; + + public SaveUrlErrorException(String requestId, LocalizedText userMessage, SaveUrlError errorValue) { + super(requestId, userMessage, buildMessage("save_url", userMessage, errorValue)); + if (errorValue == null) { + throw new NullPointerException("errorValue"); + } + this.errorValue = errorValue; + } +} diff --git a/src/main/java/com/dropbox/core/v2/files/SaveUrlJobStatus.java b/src/main/java/com/dropbox/core/v2/files/SaveUrlJobStatus.java new file mode 100644 index 000000000..a89454604 --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/files/SaveUrlJobStatus.java @@ -0,0 +1,309 @@ +/* DO NOT EDIT */ +/* This file was generated from files.stone */ + +package com.dropbox.core.v2.files; + +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + +import java.io.IOException; + +/** + * This class is a tagged union. Tagged unions instances are always associated + * to a specific tag. This means only one of the {@code isAbc()} methods will + * return {@code true}. You can use {@link #tag()} to determine the tag + * associated with this instance. + */ +public final class SaveUrlJobStatus { + // union SaveUrlJobStatus + + /** + * Discriminating tag type for {@link SaveUrlJobStatus}. + */ + public enum Tag { + /** + * The asynchronous job is still in progress. + */ + IN_PROGRESS, + /** + * Metadata of the file where the URL is saved to. + */ + COMPLETE, // FileMetadata + FAILED; // SaveUrlError + } + + /** + * The asynchronous job is still in progress. + */ + public static final SaveUrlJobStatus IN_PROGRESS = new SaveUrlJobStatus(Tag.IN_PROGRESS, null, null); + + private final Tag tag; + private final FileMetadata completeValue; + private final SaveUrlError failedValue; + + /** + * + * @param tag Discriminating tag for this instance. + */ + private SaveUrlJobStatus(Tag tag, FileMetadata completeValue, SaveUrlError failedValue) { + this.tag = tag; + this.completeValue = completeValue; + this.failedValue = failedValue; + } + + /** + * Returns the tag for this instance. + * + *

This class is a tagged union. Tagged unions instances are always + * associated to a specific tag. This means only one of the {@code isXyz()} + * methods will return {@code true}. Callers are recommended to use the tag + * value in a {@code switch} statement to properly handle the different + * values for this {@code SaveUrlJobStatus}.

+ * + * @return the tag for this instance. + */ + public Tag tag() { + return tag; + } + + /** + * Returns {@code true} if this instance has the tag {@link + * Tag#IN_PROGRESS}, {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link + * Tag#IN_PROGRESS}, {@code false} otherwise. + */ + public boolean isInProgress() { + return this.tag == Tag.IN_PROGRESS; + } + + /** + * Returns {@code true} if this instance has the tag {@link Tag#COMPLETE}, + * {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link Tag#COMPLETE}, + * {@code false} otherwise. + */ + public boolean isComplete() { + return this.tag == Tag.COMPLETE; + } + + /** + * Returns an instance of {@code SaveUrlJobStatus} that has its tag set to + * {@link Tag#COMPLETE}. + * + *

Metadata of the file where the URL is saved to.

+ * + * @param value value to assign to this instance. + * + * @return Instance of {@code SaveUrlJobStatus} with its tag set to {@link + * Tag#COMPLETE}. + * + * @throws IllegalArgumentException if {@code value} is {@code null}. + */ + public static SaveUrlJobStatus complete(FileMetadata value) { + if (value == null) { + throw new IllegalArgumentException("Value is null"); + } + return new SaveUrlJobStatus(Tag.COMPLETE, value, null); + } + + /** + * Metadata of the file where the URL is saved to. + * + *

This instance must be tagged as {@link Tag#COMPLETE}.

+ * + * @return The {@link SaveUrlJobStatus#complete} value associated with this + * instance if {@link #isComplete} is {@code true}. + * + * @throws IllegalStateException If {@link #isComplete} is {@code false}. + */ + public FileMetadata getCompleteValue() { + if (this.tag != Tag.COMPLETE) { + throw new IllegalStateException("Invalid tag: required Tag.COMPLETE, but was Tag." + tag.name()); + } + return completeValue; + } + + /** + * Returns {@code true} if this instance has the tag {@link Tag#FAILED}, + * {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link Tag#FAILED}, + * {@code false} otherwise. + */ + public boolean isFailed() { + return this.tag == Tag.FAILED; + } + + /** + * Returns an instance of {@code SaveUrlJobStatus} that has its tag set to + * {@link Tag#FAILED}. + * + * @param value value to assign to this instance. + * + * @return Instance of {@code SaveUrlJobStatus} with its tag set to {@link + * Tag#FAILED}. + * + * @throws IllegalArgumentException if {@code value} is {@code null}. + */ + public static SaveUrlJobStatus failed(SaveUrlError value) { + if (value == null) { + throw new IllegalArgumentException("Value is null"); + } + return new SaveUrlJobStatus(Tag.FAILED, null, value); + } + + /** + * This instance must be tagged as {@link Tag#FAILED}. + * + * @return The {@link SaveUrlJobStatus#failed} value associated with this + * instance if {@link #isFailed} is {@code true}. + * + * @throws IllegalStateException If {@link #isFailed} is {@code false}. + */ + public SaveUrlError getFailedValue() { + if (this.tag != Tag.FAILED) { + throw new IllegalStateException("Invalid tag: required Tag.FAILED, but was Tag." + tag.name()); + } + return failedValue; + } + + @Override + public int hashCode() { + int hash = java.util.Arrays.hashCode(new Object [] { + tag, + completeValue, + failedValue + }); + hash = (31 * super.hashCode()) + hash; + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + else if (obj instanceof SaveUrlJobStatus) { + SaveUrlJobStatus other = (SaveUrlJobStatus) obj; + if (this.tag != other.tag) { + return false; + } + switch (tag) { + case IN_PROGRESS: + return true; + case COMPLETE: + return (this.completeValue == other.completeValue) || (this.completeValue.equals(other.completeValue)); + case FAILED: + return (this.failedValue == other.failedValue) || (this.failedValue.equals(other.failedValue)); + default: + return false; + } + } + else { + return false; + } + } + + @Override + public String toString() { + return Serializer.INSTANCE.serialize(this, false); + } + + /** + * Returns a String representation of this object formatted for easier + * readability. + * + *

The returned String may contain newlines.

+ * + * @return Formatted, multiline String representation of this object + */ + public String toStringMultiline() { + return Serializer.INSTANCE.serialize(this, true); + } + + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); + + @Override + public void serialize(SaveUrlJobStatus value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case IN_PROGRESS: { + g.writeString("in_progress"); + break; + } + case COMPLETE: { + g.writeStartObject(); + writeTag("complete", g); + g.writeFieldName("complete"); + FileMetadata.Serializer.INSTANCE.serialize(value.completeValue, g); + g.writeEndObject(); + break; + } + case FAILED: { + g.writeStartObject(); + writeTag("failed", g); + g.writeFieldName("failed"); + SaveUrlError.Serializer.INSTANCE.serialize(value.failedValue, g); + g.writeEndObject(); + break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); + } + } + } + + @Override + public SaveUrlJobStatus deserialize(JsonParser p) throws IOException, JsonParseException { + SaveUrlJobStatus value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("in_progress".equals(tag)) { + value = SaveUrlJobStatus.IN_PROGRESS; + } + else if ("complete".equals(tag)) { + FileMetadata fieldValue = null; + expectField("complete", p); + fieldValue = FileMetadata.Serializer.INSTANCE.deserialize(p); + value = SaveUrlJobStatus.complete(fieldValue); + } + else if ("failed".equals(tag)) { + SaveUrlError fieldValue = null; + expectField("failed", p); + fieldValue = SaveUrlError.Serializer.INSTANCE.deserialize(p); + value = SaveUrlJobStatus.failed(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; + } + } +} diff --git a/src/main/java/com/dropbox/core/v2/files/SaveUrlResult.java b/src/main/java/com/dropbox/core/v2/files/SaveUrlResult.java new file mode 100644 index 000000000..1b8e58415 --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/files/SaveUrlResult.java @@ -0,0 +1,296 @@ +/* DO NOT EDIT */ +/* This file was generated from files.stone */ + +package com.dropbox.core.v2.files; + +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + +import java.io.IOException; + +/** + * This class is a tagged union. Tagged unions instances are always associated + * to a specific tag. This means only one of the {@code isAbc()} methods will + * return {@code true}. You can use {@link #tag()} to determine the tag + * associated with this instance. + */ +public final class SaveUrlResult { + // union SaveUrlResult + + /** + * Discriminating tag type for {@link SaveUrlResult}. + */ + public enum Tag { + /** + * This response indicates that the processing is asynchronous. The + * string is an id that can be used to obtain the status of the + * asynchronous job. + */ + ASYNC_JOB_ID, // String + /** + * Metadata of the file where the URL is saved to. + */ + COMPLETE; // FileMetadata + } + + private final Tag tag; + private final String asyncJobIdValue; + private final FileMetadata completeValue; + + /** + * + * @param tag Discriminating tag for this instance. + */ + private SaveUrlResult(Tag tag, String asyncJobIdValue, FileMetadata completeValue) { + this.tag = tag; + this.asyncJobIdValue = asyncJobIdValue; + this.completeValue = completeValue; + } + + /** + * Returns the tag for this instance. + * + *

This class is a tagged union. Tagged unions instances are always + * associated to a specific tag. This means only one of the {@code isXyz()} + * methods will return {@code true}. Callers are recommended to use the tag + * value in a {@code switch} statement to properly handle the different + * values for this {@code SaveUrlResult}.

+ * + * @return the tag for this instance. + */ + public Tag tag() { + return tag; + } + + /** + * Returns {@code true} if this instance has the tag {@link + * Tag#ASYNC_JOB_ID}, {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link + * Tag#ASYNC_JOB_ID}, {@code false} otherwise. + */ + public boolean isAsyncJobId() { + return this.tag == Tag.ASYNC_JOB_ID; + } + + /** + * Returns an instance of {@code SaveUrlResult} that has its tag set to + * {@link Tag#ASYNC_JOB_ID}. + * + *

This response indicates that the processing is asynchronous. The + * string is an id that can be used to obtain the status of the asynchronous + * job.

+ * + * @param value value to assign to this instance. + * + * @return Instance of {@code SaveUrlResult} with its tag set to {@link + * Tag#ASYNC_JOB_ID}. + * + * @throws IllegalArgumentException if {@code value} is shorter than 1 or + * is {@code null}. + */ + public static SaveUrlResult asyncJobId(String value) { + if (value == null) { + throw new IllegalArgumentException("Value is null"); + } + if (value.length() < 1) { + throw new IllegalArgumentException("String is shorter than 1"); + } + return new SaveUrlResult(Tag.ASYNC_JOB_ID, value, null); + } + + /** + * This response indicates that the processing is asynchronous. The string + * is an id that can be used to obtain the status of the asynchronous job. + * + *

This instance must be tagged as {@link Tag#ASYNC_JOB_ID}.

+ * + * @return The {@link SaveUrlResult#asyncJobId} value associated with this + * instance if {@link #isAsyncJobId} is {@code true}. + * + * @throws IllegalStateException If {@link #isAsyncJobId} is {@code false}. + */ + public String getAsyncJobIdValue() { + if (this.tag != Tag.ASYNC_JOB_ID) { + throw new IllegalStateException("Invalid tag: required Tag.ASYNC_JOB_ID, but was Tag." + tag.name()); + } + return asyncJobIdValue; + } + + /** + * Returns {@code true} if this instance has the tag {@link Tag#COMPLETE}, + * {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link Tag#COMPLETE}, + * {@code false} otherwise. + */ + public boolean isComplete() { + return this.tag == Tag.COMPLETE; + } + + /** + * Returns an instance of {@code SaveUrlResult} that has its tag set to + * {@link Tag#COMPLETE}. + * + *

Metadata of the file where the URL is saved to.

+ * + * @param value value to assign to this instance. + * + * @return Instance of {@code SaveUrlResult} with its tag set to {@link + * Tag#COMPLETE}. + * + * @throws IllegalArgumentException if {@code value} is {@code null}. + */ + public static SaveUrlResult complete(FileMetadata value) { + if (value == null) { + throw new IllegalArgumentException("Value is null"); + } + return new SaveUrlResult(Tag.COMPLETE, null, value); + } + + /** + * Metadata of the file where the URL is saved to. + * + *

This instance must be tagged as {@link Tag#COMPLETE}.

+ * + * @return The {@link SaveUrlResult#complete} value associated with this + * instance if {@link #isComplete} is {@code true}. + * + * @throws IllegalStateException If {@link #isComplete} is {@code false}. + */ + public FileMetadata getCompleteValue() { + if (this.tag != Tag.COMPLETE) { + throw new IllegalStateException("Invalid tag: required Tag.COMPLETE, but was Tag." + tag.name()); + } + return completeValue; + } + + @Override + public int hashCode() { + int hash = java.util.Arrays.hashCode(new Object [] { + tag, + asyncJobIdValue, + completeValue + }); + hash = (31 * super.hashCode()) + hash; + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + else if (obj instanceof SaveUrlResult) { + SaveUrlResult other = (SaveUrlResult) obj; + if (this.tag != other.tag) { + return false; + } + switch (tag) { + case ASYNC_JOB_ID: + return (this.asyncJobIdValue == other.asyncJobIdValue) || (this.asyncJobIdValue.equals(other.asyncJobIdValue)); + case COMPLETE: + return (this.completeValue == other.completeValue) || (this.completeValue.equals(other.completeValue)); + default: + return false; + } + } + else { + return false; + } + } + + @Override + public String toString() { + return Serializer.INSTANCE.serialize(this, false); + } + + /** + * Returns a String representation of this object formatted for easier + * readability. + * + *

The returned String may contain newlines.

+ * + * @return Formatted, multiline String representation of this object + */ + public String toStringMultiline() { + return Serializer.INSTANCE.serialize(this, true); + } + + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); + + @Override + public void serialize(SaveUrlResult value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case ASYNC_JOB_ID: { + g.writeStartObject(); + writeTag("async_job_id", g); + g.writeFieldName("async_job_id"); + StoneSerializers.string().serialize(value.asyncJobIdValue, g); + g.writeEndObject(); + break; + } + case COMPLETE: { + g.writeStartObject(); + writeTag("complete", g); + g.writeFieldName("complete"); + FileMetadata.Serializer.INSTANCE.serialize(value.completeValue, g); + g.writeEndObject(); + break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); + } + } + } + + @Override + public SaveUrlResult deserialize(JsonParser p) throws IOException, JsonParseException { + SaveUrlResult value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("async_job_id".equals(tag)) { + String fieldValue = null; + expectField("async_job_id", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = SaveUrlResult.asyncJobId(fieldValue); + } + else if ("complete".equals(tag)) { + FileMetadata fieldValue = null; + expectField("complete", p); + fieldValue = FileMetadata.Serializer.INSTANCE.deserialize(p); + value = SaveUrlResult.complete(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; + } + } +} diff --git a/src/main/java/com/dropbox/core/v2/files/SearchArg.java b/src/main/java/com/dropbox/core/v2/files/SearchArg.java index e93db7606..1a4048f4d 100644 --- a/src/main/java/com/dropbox/core/v2/files/SearchArg.java +++ b/src/main/java/com/dropbox/core/v2/files/SearchArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=SearchArg.Serializer.class) -@JsonDeserialize(using=SearchArg.Deserializer.class) class SearchArg { // struct SearchArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String path; protected final String query; protected final long start; @@ -45,8 +28,8 @@ class SearchArg { * specifying values for all optional fields. * * @param path The path in the user's Dropbox to search. Should probably be - * a folder. Must match pattern "{@code (/.*)?}" and not be {@code - * null}. + * a folder. Must match pattern "{@code (/(.|[\\r\\n])*)?}" and not be + * {@code null}. * @param query The string to search for. The search string is split on * spaces into multiple tokens. For file name searching, the last token * is used for prefix matching (i.e. "bat c" matches "bat cave" but not @@ -66,7 +49,7 @@ public SearchArg(String path, String query, long start, long maxResults, SearchM if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("(/.*)?", path)) { + if (!java.util.regex.Pattern.matches("(/(.|[\\r\\n])*)?", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -92,8 +75,8 @@ public SearchArg(String path, String query, long start, long maxResults, SearchM * The default values for unset fields will be used. * * @param path The path in the user's Dropbox to search. Should probably be - * a folder. Must match pattern "{@code (/.*)?}" and not be {@code - * null}. + * a folder. Must match pattern "{@code (/(.|[\\r\\n])*)?}" and not be + * {@code null}. * @param query The string to search for. The search string is split on * spaces into multiple tokens. For file name searching, the last token * is used for prefix matching (i.e. "bat c" matches "bat cave" but not @@ -162,8 +145,8 @@ public SearchMode getMode() { * Returns a new builder for creating an instance of this class. * * @param path The path in the user's Dropbox to search. Should probably be - * a folder. Must match pattern "{@code (/.*)?}" and not be {@code - * null}. + * a folder. Must match pattern "{@code (/(.|[\\r\\n])*)?}" and not be + * {@code null}. * @param query The string to search for. The search string is split on * spaces into multiple tokens. For file name searching, the last token * is used for prefix matching (i.e. "bat c" matches "bat cave" but not @@ -193,7 +176,7 @@ protected Builder(String path, String query) { if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("(/.*)?", path)) { + if (!java.util.regex.Pattern.matches("(/(.|[\\r\\n])*)?", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -326,7 +309,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -338,107 +321,86 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SearchArg.class); - } - - public Serializer(boolean unwrapping) { - super(SearchArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(SearchArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("path", value.path); - g.writeObjectField("query", value.query); - g.writeObjectField("start", value.start); - g.writeObjectField("max_results", value.maxResults); - g.writeObjectField("mode", value.mode); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SearchArg.class); - } - - public Deserializer(boolean unwrapping) { - super(SearchArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(SearchArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("path"); + StoneSerializers.string().serialize(value.path, g); + g.writeFieldName("query"); + StoneSerializers.string().serialize(value.query, g); + g.writeFieldName("start"); + StoneSerializers.uInt64().serialize(value.start, g); + g.writeFieldName("max_results"); + StoneSerializers.uInt64().serialize(value.maxResults, g); + g.writeFieldName("mode"); + SearchMode.Serializer.INSTANCE.serialize(value.mode, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public SearchArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String path = null; - String query = null; - long start = 0L; - long maxResults = 100L; - SearchMode mode = SearchMode.FILENAME; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); - } - else if ("query".equals(_field)) { - query = getStringValue(_p); - _p.nextToken(); - } - else if ("start".equals(_field)) { - start = _p.getLongValue(); - assertUnsigned(_p, start); - _p.nextToken(); - } - else if ("max_results".equals(_field)) { - maxResults = _p.getLongValue(); - assertUnsigned(_p, maxResults); - _p.nextToken(); + public SearchArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + SearchArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_path = null; + String f_query = null; + Long f_start = 0L; + Long f_maxResults = 100L; + SearchMode f_mode = SearchMode.FILENAME; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("path".equals(field)) { + f_path = StoneSerializers.string().deserialize(p); + } + else if ("query".equals(field)) { + f_query = StoneSerializers.string().deserialize(p); + } + else if ("start".equals(field)) { + f_start = StoneSerializers.uInt64().deserialize(p); + } + else if ("max_results".equals(field)) { + f_maxResults = StoneSerializers.uInt64().deserialize(p); + } + else if ("mode".equals(field)) { + f_mode = SearchMode.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else if ("mode".equals(_field)) { - mode = _p.readValueAs(SearchMode.class); - _p.nextToken(); + if (f_path == null) { + throw new JsonParseException(p, "Required field \"path\" missing."); } - else { - skipValue(_p); + if (f_query == null) { + throw new JsonParseException(p, "Required field \"query\" missing."); } + value = new SearchArg(f_path, f_query, f_start, f_maxResults, f_mode); } - - if (path == null) { - throw new JsonParseException(_p, "Required field \"path\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (query == null) { - throw new JsonParseException(_p, "Required field \"query\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new SearchArg(path, query, start, maxResults, mode); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/SearchBuilder.java b/src/main/java/com/dropbox/core/v2/files/SearchBuilder.java index c4efa945b..bc0ecf5c9 100644 --- a/src/main/java/com/dropbox/core/v2/files/SearchBuilder.java +++ b/src/main/java/com/dropbox/core/v2/files/SearchBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; @@ -13,26 +13,26 @@ * request.

*/ public class SearchBuilder { - private final DbxUserFilesRequests files; + private final DbxUserFilesRequests files_; private final SearchArg.Builder searchArgBuilder; /** * Creates a new instance of this builder. * - * @param files Dropbox namespace-specific client used to issue files + * @param files_ Dropbox namespace-specific client used to issue files * requests. * @param searchArgBuilder Request argument builder. * * @return instsance of this builder */ - SearchBuilder(DbxUserFilesRequests files, SearchArg.Builder searchArgBuilder) { - if (files == null) { - throw new NullPointerException("files"); + SearchBuilder(DbxUserFilesRequests files_, SearchArg.Builder searchArgBuilder) { + if (files_ == null) { + throw new NullPointerException("files_"); } + this.files_ = files_; if (searchArgBuilder == null) { throw new NullPointerException("searchArgBuilder"); } - this.files = files; this.searchArgBuilder = searchArgBuilder; } @@ -92,7 +92,7 @@ public SearchBuilder withMode(SearchMode mode) { * Issues the request. */ public SearchResult start() throws SearchErrorException, DbxException { - SearchArg arg = this.searchArgBuilder.build(); - return files.search(arg); + SearchArg arg_ = this.searchArgBuilder.build(); + return files_.search(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/files/SearchError.java b/src/main/java/com/dropbox/core/v2/files/SearchError.java index 408687114..8e0b0f314 100644 --- a/src/main/java/com/dropbox/core/v2/files/SearchError.java +++ b/src/main/java/com/dropbox/core/v2/files/SearchError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=SearchError.Serializer.class) -@JsonDeserialize(using=SearchError.Deserializer.class) public final class SearchError { // union SearchError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link SearchError}. */ @@ -181,7 +163,7 @@ else if (obj instanceof SearchError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -193,71 +175,64 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SearchError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(SearchError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case PATH: + public void serialize(SearchError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PATH: { g.writeStartObject(); - g.writeStringField(".tag", "path"); - g.writeObjectField("path", value.pathValue); + writeTag("path", g); + g.writeFieldName("path"); + LookupError.Serializer.INSTANCE.serialize(value.pathValue, g); g.writeEndObject(); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SearchError.class, getTagMapping(), Tag.OTHER); - } @Override - public SearchError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case PATH: { - LookupError value = null; - expectField(_p, "path"); - value = _p.readValueAs(LookupError.class); - _p.nextToken(); - return SearchError.path(value); - } - case OTHER: { - return SearchError.OTHER; - } + public SearchError deserialize(JsonParser p) throws IOException, JsonParseException { + SearchError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("path", SearchError.Tag.PATH); - values.put("other", SearchError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("path".equals(tag)) { + LookupError fieldValue = null; + expectField("path", p); + fieldValue = LookupError.Serializer.INSTANCE.deserialize(p); + value = SearchError.path(fieldValue); + } + else { + value = SearchError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/SearchErrorException.java b/src/main/java/com/dropbox/core/v2/files/SearchErrorException.java index c38440d98..df3003c06 100644 --- a/src/main/java/com/dropbox/core/v2/files/SearchErrorException.java +++ b/src/main/java/com/dropbox/core/v2/files/SearchErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; diff --git a/src/main/java/com/dropbox/core/v2/files/SearchMatch.java b/src/main/java/com/dropbox/core/v2/files/SearchMatch.java index 07484f9c2..08ca02932 100644 --- a/src/main/java/com/dropbox/core/v2/files/SearchMatch.java +++ b/src/main/java/com/dropbox/core/v2/files/SearchMatch.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=SearchMatch.Serializer.class) -@JsonDeserialize(using=SearchMatch.Deserializer.class) public class SearchMatch { // struct SearchMatch - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final SearchMatchType matchType; protected final Metadata metadata; @@ -103,7 +86,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -115,87 +98,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SearchMatch.class); - } - - public Serializer(boolean unwrapping) { - super(SearchMatch.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(SearchMatch value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("match_type", value.matchType); - g.writeObjectField("metadata", value.metadata); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SearchMatch.class); - } - - public Deserializer(boolean unwrapping) { - super(SearchMatch.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(SearchMatch value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("match_type"); + SearchMatchType.Serializer.INSTANCE.serialize(value.matchType, g); + g.writeFieldName("metadata"); + Metadata.Serializer.INSTANCE.serialize(value.metadata, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public SearchMatch deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - SearchMatchType matchType = null; - Metadata metadata = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("match_type".equals(_field)) { - matchType = _p.readValueAs(SearchMatchType.class); - _p.nextToken(); + public SearchMatch deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + SearchMatch value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + SearchMatchType f_matchType = null; + Metadata f_metadata = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("match_type".equals(field)) { + f_matchType = SearchMatchType.Serializer.INSTANCE.deserialize(p); + } + else if ("metadata".equals(field)) { + f_metadata = Metadata.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else if ("metadata".equals(_field)) { - metadata = _p.readValueAs(Metadata.class); - _p.nextToken(); + if (f_matchType == null) { + throw new JsonParseException(p, "Required field \"match_type\" missing."); } - else { - skipValue(_p); + if (f_metadata == null) { + throw new JsonParseException(p, "Required field \"metadata\" missing."); } + value = new SearchMatch(f_matchType, f_metadata); } - - if (matchType == null) { - throw new JsonParseException(_p, "Required field \"match_type\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (metadata == null) { - throw new JsonParseException(_p, "Required field \"metadata\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new SearchMatch(matchType, metadata); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/SearchMatchType.java b/src/main/java/com/dropbox/core/v2/files/SearchMatchType.java index 767694c7f..0f6451516 100644 --- a/src/main/java/com/dropbox/core/v2/files/SearchMatchType.java +++ b/src/main/java/com/dropbox/core/v2/files/SearchMatchType.java @@ -1,36 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Indicates what type of match was found for a given item. */ -@JsonSerialize(using=SearchMatchType.Serializer.class) -@JsonDeserialize(using=SearchMatchType.Deserializer.class) public enum SearchMatchType { // union SearchMatchType /** @@ -46,51 +32,67 @@ public enum SearchMatchType { */ BOTH; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SearchMatchType.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(SearchMatchType value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(SearchMatchType value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case FILENAME: + case FILENAME: { g.writeString("filename"); break; - case CONTENT: + } + case CONTENT: { g.writeString("content"); break; - case BOTH: + } + case BOTH: { g.writeString("both"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SearchMatchType.class, getTagMapping(), null); - } @Override - public SearchMatchType deserialize(SearchMatchType _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("filename", SearchMatchType.FILENAME); - values.put("content", SearchMatchType.CONTENT); - values.put("both", SearchMatchType.BOTH); - return Collections.unmodifiableMap(values); + public SearchMatchType deserialize(JsonParser p) throws IOException, JsonParseException { + SearchMatchType value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("filename".equals(tag)) { + value = SearchMatchType.FILENAME; + } + else if ("content".equals(tag)) { + value = SearchMatchType.CONTENT; + } + else if ("both".equals(tag)) { + value = SearchMatchType.BOTH; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/SearchMode.java b/src/main/java/com/dropbox/core/v2/files/SearchMode.java index 25882df4b..ec3358dd0 100644 --- a/src/main/java/com/dropbox/core/v2/files/SearchMode.java +++ b/src/main/java/com/dropbox/core/v2/files/SearchMode.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=SearchMode.Serializer.class) -@JsonDeserialize(using=SearchMode.Deserializer.class) public enum SearchMode { // union SearchMode /** @@ -43,51 +29,67 @@ public enum SearchMode { */ DELETED_FILENAME; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SearchMode.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(SearchMode value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(SearchMode value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case FILENAME: + case FILENAME: { g.writeString("filename"); break; - case FILENAME_AND_CONTENT: + } + case FILENAME_AND_CONTENT: { g.writeString("filename_and_content"); break; - case DELETED_FILENAME: + } + case DELETED_FILENAME: { g.writeString("deleted_filename"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SearchMode.class, getTagMapping(), null); - } @Override - public SearchMode deserialize(SearchMode _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("filename", SearchMode.FILENAME); - values.put("filename_and_content", SearchMode.FILENAME_AND_CONTENT); - values.put("deleted_filename", SearchMode.DELETED_FILENAME); - return Collections.unmodifiableMap(values); + public SearchMode deserialize(JsonParser p) throws IOException, JsonParseException { + SearchMode value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("filename".equals(tag)) { + value = SearchMode.FILENAME; + } + else if ("filename_and_content".equals(tag)) { + value = SearchMode.FILENAME_AND_CONTENT; + } + else if ("deleted_filename".equals(tag)) { + value = SearchMode.DELETED_FILENAME; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/SearchResult.java b/src/main/java/com/dropbox/core/v2/files/SearchResult.java index 14293b48c..58cb92c37 100644 --- a/src/main/java/com/dropbox/core/v2/files/SearchResult.java +++ b/src/main/java/com/dropbox/core/v2/files/SearchResult.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=SearchResult.Serializer.class) -@JsonDeserialize(using=SearchResult.Deserializer.class) public class SearchResult { // struct SearchResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List matches; protected final boolean more; protected final long start; @@ -128,7 +111,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -140,105 +123,77 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SearchResult.class); - } - - public Serializer(boolean unwrapping) { - super(SearchResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(SearchResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("matches", value.matches); - g.writeObjectField("more", value.more); - g.writeObjectField("start", value.start); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SearchResult.class); - } - - public Deserializer(boolean unwrapping) { - super(SearchResult.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(SearchResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("matches"); + StoneSerializers.list(SearchMatch.Serializer.INSTANCE).serialize(value.matches, g); + g.writeFieldName("more"); + StoneSerializers.boolean_().serialize(value.more, g); + g.writeFieldName("start"); + StoneSerializers.uInt64().serialize(value.start, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public SearchResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List matches = null; - Boolean more = null; - Long start = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("matches".equals(_field)) { - expectArrayStart(_p); - matches = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - SearchMatch _x = null; - _x = _p.readValueAs(SearchMatch.class); - _p.nextToken(); - matches.add(_x); + public SearchResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + SearchResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_matches = null; + Boolean f_more = null; + Long f_start = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("matches".equals(field)) { + f_matches = StoneSerializers.list(SearchMatch.Serializer.INSTANCE).deserialize(p); + } + else if ("more".equals(field)) { + f_more = StoneSerializers.boolean_().deserialize(p); + } + else if ("start".equals(field)) { + f_start = StoneSerializers.uInt64().deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else if ("more".equals(_field)) { - more = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_matches == null) { + throw new JsonParseException(p, "Required field \"matches\" missing."); } - else if ("start".equals(_field)) { - start = _p.getLongValue(); - assertUnsigned(_p, start); - _p.nextToken(); + if (f_more == null) { + throw new JsonParseException(p, "Required field \"more\" missing."); } - else { - skipValue(_p); + if (f_start == null) { + throw new JsonParseException(p, "Required field \"start\" missing."); } + value = new SearchResult(f_matches, f_more, f_start); } - - if (matches == null) { - throw new JsonParseException(_p, "Required field \"matches\" is missing."); - } - if (more == null) { - throw new JsonParseException(_p, "Required field \"more\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (start == null) { - throw new JsonParseException(_p, "Required field \"start\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new SearchResult(matches, more, start); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/SharingInfo.java b/src/main/java/com/dropbox/core/v2/files/SharingInfo.java index b08a41f80..657108b1f 100644 --- a/src/main/java/com/dropbox/core/v2/files/SharingInfo.java +++ b/src/main/java/com/dropbox/core/v2/files/SharingInfo.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Sharing info for a file or folder. */ -@JsonSerialize(using=SharingInfo.Serializer.class) -@JsonDeserialize(using=SharingInfo.Deserializer.class) public class SharingInfo { // struct SharingInfo - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final boolean readOnly; /** @@ -83,7 +66,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -95,78 +78,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SharingInfo.class); - } - - public Serializer(boolean unwrapping) { - super(SharingInfo.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(SharingInfo value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("read_only", value.readOnly); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SharingInfo.class); - } - - public Deserializer(boolean unwrapping) { - super(SharingInfo.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(SharingInfo value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("read_only"); + StoneSerializers.boolean_().serialize(value.readOnly, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public SharingInfo deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - Boolean readOnly = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("read_only".equals(_field)) { - readOnly = _p.getValueAsBoolean(); - _p.nextToken(); + public SharingInfo deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + SharingInfo value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Boolean f_readOnly = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("read_only".equals(field)) { + f_readOnly = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_readOnly == null) { + throw new JsonParseException(p, "Required field \"read_only\" missing."); } + value = new SharingInfo(f_readOnly); } - - if (readOnly == null) { - throw new JsonParseException(_p, "Required field \"read_only\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new SharingInfo(readOnly); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/ThumbnailArg.java b/src/main/java/com/dropbox/core/v2/files/ThumbnailArg.java index a270e6031..3e19d7472 100644 --- a/src/main/java/com/dropbox/core/v2/files/ThumbnailArg.java +++ b/src/main/java/com/dropbox/core/v2/files/ThumbnailArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=ThumbnailArg.Serializer.class) -@JsonDeserialize(using=ThumbnailArg.Deserializer.class) class ThumbnailArg { // struct ThumbnailArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String path; protected final ThumbnailFormat format; protected final ThumbnailSize size; @@ -43,8 +26,8 @@ class ThumbnailArg { * specifying values for all optional fields. * * @param path The path to the image file you want to thumbnail. Must match - * pattern "{@code ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code - * null}. + * pattern "{@code (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not + * be {@code null}. * @param format The format for the thumbnail image, jpeg (default) or png. * For images that are photos, jpeg should be preferred, while png is * better for screenshots and digital arts. @@ -57,7 +40,7 @@ public ThumbnailArg(String path, ThumbnailFormat format, ThumbnailSize size) { if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("((/|id:).*)|(rev:[0-9a-f]{9,})", path)) { + if (!java.util.regex.Pattern.matches("(/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -75,8 +58,8 @@ public ThumbnailArg(String path, ThumbnailFormat format, ThumbnailSize size) { * The default values for unset fields will be used. * * @param path The path to the image file you want to thumbnail. Must match - * pattern "{@code ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code - * null}. + * pattern "{@code (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not + * be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -120,8 +103,8 @@ public ThumbnailSize getSize() { * Returns a new builder for creating an instance of this class. * * @param path The path to the image file you want to thumbnail. Must match - * pattern "{@code ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code - * null}. + * pattern "{@code (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not + * be {@code null}. * * @return builder for this class. * @@ -145,7 +128,7 @@ protected Builder(String path) { if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("((/|id:).*)|(rev:[0-9a-f]{9,})", path)) { + if (!java.util.regex.Pattern.matches("(/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -238,7 +221,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -250,90 +233,71 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ThumbnailArg.class); - } - - public Serializer(boolean unwrapping) { - super(ThumbnailArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(ThumbnailArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("path", value.path); - g.writeObjectField("format", value.format); - g.writeObjectField("size", value.size); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ThumbnailArg.class); - } - - public Deserializer(boolean unwrapping) { - super(ThumbnailArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(ThumbnailArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("path"); + StoneSerializers.string().serialize(value.path, g); + g.writeFieldName("format"); + ThumbnailFormat.Serializer.INSTANCE.serialize(value.format, g); + g.writeFieldName("size"); + ThumbnailSize.Serializer.INSTANCE.serialize(value.size, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public ThumbnailArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String path = null; - ThumbnailFormat format = ThumbnailFormat.JPEG; - ThumbnailSize size = ThumbnailSize.W64H64; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); - } - else if ("format".equals(_field)) { - format = _p.readValueAs(ThumbnailFormat.class); - _p.nextToken(); - } - else if ("size".equals(_field)) { - size = _p.readValueAs(ThumbnailSize.class); - _p.nextToken(); + public ThumbnailArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ThumbnailArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_path = null; + ThumbnailFormat f_format = ThumbnailFormat.JPEG; + ThumbnailSize f_size = ThumbnailSize.W64H64; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("path".equals(field)) { + f_path = StoneSerializers.string().deserialize(p); + } + else if ("format".equals(field)) { + f_format = ThumbnailFormat.Serializer.INSTANCE.deserialize(p); + } + else if ("size".equals(field)) { + f_size = ThumbnailSize.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_path == null) { + throw new JsonParseException(p, "Required field \"path\" missing."); } + value = new ThumbnailArg(f_path, f_format, f_size); } - - if (path == null) { - throw new JsonParseException(_p, "Required field \"path\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new ThumbnailArg(path, format, size); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/ThumbnailError.java b/src/main/java/com/dropbox/core/v2/files/ThumbnailError.java index e4270a223..7b414163a 100644 --- a/src/main/java/com/dropbox/core/v2/files/ThumbnailError.java +++ b/src/main/java/com/dropbox/core/v2/files/ThumbnailError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is a tagged union. Tagged unions instances are always associated @@ -32,15 +20,9 @@ * return {@code true}. You can use {@link #tag()} to determine the tag * associated with this instance. */ -@JsonSerialize(using=ThumbnailError.Serializer.class) -@JsonDeserialize(using=ThumbnailError.Deserializer.class) public final class ThumbnailError { // union ThumbnailError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link ThumbnailError}. */ @@ -223,7 +205,7 @@ else if (obj instanceof ThumbnailError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -235,85 +217,84 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ThumbnailError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ThumbnailError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case PATH: + public void serialize(ThumbnailError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PATH: { g.writeStartObject(); - g.writeStringField(".tag", "path"); - g.writeObjectField("path", value.pathValue); + writeTag("path", g); + g.writeFieldName("path"); + LookupError.Serializer.INSTANCE.serialize(value.pathValue, g); g.writeEndObject(); break; - case UNSUPPORTED_EXTENSION: + } + case UNSUPPORTED_EXTENSION: { g.writeString("unsupported_extension"); break; - case UNSUPPORTED_IMAGE: + } + case UNSUPPORTED_IMAGE: { g.writeString("unsupported_image"); break; - case CONVERSION_ERROR: + } + case CONVERSION_ERROR: { g.writeString("conversion_error"); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ThumbnailError.class, getTagMapping(), null); - } - - @Override - public ThumbnailError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case PATH: { - LookupError value = null; - expectField(_p, "path"); - value = _p.readValueAs(LookupError.class); - _p.nextToken(); - return ThumbnailError.path(value); - } - case UNSUPPORTED_EXTENSION: { - return ThumbnailError.UNSUPPORTED_EXTENSION; - } - case UNSUPPORTED_IMAGE: { - return ThumbnailError.UNSUPPORTED_IMAGE; } - case CONVERSION_ERROR: { - return ThumbnailError.CONVERSION_ERROR; + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("path", ThumbnailError.Tag.PATH); - values.put("unsupported_extension", ThumbnailError.Tag.UNSUPPORTED_EXTENSION); - values.put("unsupported_image", ThumbnailError.Tag.UNSUPPORTED_IMAGE); - values.put("conversion_error", ThumbnailError.Tag.CONVERSION_ERROR); - return Collections.unmodifiableMap(values); + @Override + public ThumbnailError deserialize(JsonParser p) throws IOException, JsonParseException { + ThumbnailError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("path".equals(tag)) { + LookupError fieldValue = null; + expectField("path", p); + fieldValue = LookupError.Serializer.INSTANCE.deserialize(p); + value = ThumbnailError.path(fieldValue); + } + else if ("unsupported_extension".equals(tag)) { + value = ThumbnailError.UNSUPPORTED_EXTENSION; + } + else if ("unsupported_image".equals(tag)) { + value = ThumbnailError.UNSUPPORTED_IMAGE; + } + else if ("conversion_error".equals(tag)) { + value = ThumbnailError.CONVERSION_ERROR; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/ThumbnailErrorException.java b/src/main/java/com/dropbox/core/v2/files/ThumbnailErrorException.java index a79cb7fef..2a837c678 100644 --- a/src/main/java/com/dropbox/core/v2/files/ThumbnailErrorException.java +++ b/src/main/java/com/dropbox/core/v2/files/ThumbnailErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; diff --git a/src/main/java/com/dropbox/core/v2/files/ThumbnailFormat.java b/src/main/java/com/dropbox/core/v2/files/ThumbnailFormat.java index 34e512e33..f66efeae3 100644 --- a/src/main/java/com/dropbox/core/v2/files/ThumbnailFormat.java +++ b/src/main/java/com/dropbox/core/v2/files/ThumbnailFormat.java @@ -1,79 +1,78 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=ThumbnailFormat.Serializer.class) -@JsonDeserialize(using=ThumbnailFormat.Deserializer.class) public enum ThumbnailFormat { // union ThumbnailFormat JPEG, PNG; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ThumbnailFormat.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ThumbnailFormat value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(ThumbnailFormat value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case JPEG: + case JPEG: { g.writeString("jpeg"); break; - case PNG: + } + case PNG: { g.writeString("png"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ThumbnailFormat.class, getTagMapping(), null); - } @Override - public ThumbnailFormat deserialize(ThumbnailFormat _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("jpeg", ThumbnailFormat.JPEG); - values.put("png", ThumbnailFormat.PNG); - return Collections.unmodifiableMap(values); + public ThumbnailFormat deserialize(JsonParser p) throws IOException, JsonParseException { + ThumbnailFormat value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("jpeg".equals(tag)) { + value = ThumbnailFormat.JPEG; + } + else if ("png".equals(tag)) { + value = ThumbnailFormat.PNG; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/ThumbnailSize.java b/src/main/java/com/dropbox/core/v2/files/ThumbnailSize.java index dd96cbd28..43bf52239 100644 --- a/src/main/java/com/dropbox/core/v2/files/ThumbnailSize.java +++ b/src/main/java/com/dropbox/core/v2/files/ThumbnailSize.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=ThumbnailSize.Serializer.class) -@JsonDeserialize(using=ThumbnailSize.Deserializer.class) public enum ThumbnailSize { // union ThumbnailSize /** @@ -51,59 +37,81 @@ public enum ThumbnailSize { */ W1024H768; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ThumbnailSize.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ThumbnailSize value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(ThumbnailSize value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case W32H32: + case W32H32: { g.writeString("w32h32"); break; - case W64H64: + } + case W64H64: { g.writeString("w64h64"); break; - case W128H128: + } + case W128H128: { g.writeString("w128h128"); break; - case W640H480: + } + case W640H480: { g.writeString("w640h480"); break; - case W1024H768: + } + case W1024H768: { g.writeString("w1024h768"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ThumbnailSize.class, getTagMapping(), null); - } @Override - public ThumbnailSize deserialize(ThumbnailSize _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("w32h32", ThumbnailSize.W32H32); - values.put("w64h64", ThumbnailSize.W64H64); - values.put("w128h128", ThumbnailSize.W128H128); - values.put("w640h480", ThumbnailSize.W640H480); - values.put("w1024h768", ThumbnailSize.W1024H768); - return Collections.unmodifiableMap(values); + public ThumbnailSize deserialize(JsonParser p) throws IOException, JsonParseException { + ThumbnailSize value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("w32h32".equals(tag)) { + value = ThumbnailSize.W32H32; + } + else if ("w64h64".equals(tag)) { + value = ThumbnailSize.W64H64; + } + else if ("w128h128".equals(tag)) { + value = ThumbnailSize.W128H128; + } + else if ("w640h480".equals(tag)) { + value = ThumbnailSize.W640H480; + } + else if ("w1024h768".equals(tag)) { + value = ThumbnailSize.W1024H768; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/UploadBuilder.java b/src/main/java/com/dropbox/core/v2/files/UploadBuilder.java index 56630ded3..35cb5f35d 100644 --- a/src/main/java/com/dropbox/core/v2/files/UploadBuilder.java +++ b/src/main/java/com/dropbox/core/v2/files/UploadBuilder.java @@ -1,9 +1,10 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; import com.dropbox.core.DbxException; +import com.dropbox.core.DbxUploader; import java.util.Date; @@ -15,26 +16,26 @@ * request.

*/ public class UploadBuilder extends com.dropbox.core.v2.DbxUploadStyleBuilder { - private final DbxUserFilesRequests files; + private final DbxUserFilesRequests files_; private final CommitInfo.Builder commitInfoBuilder; /** * Creates a new instance of this builder. * - * @param files Dropbox namespace-specific client used to issue files + * @param files_ Dropbox namespace-specific client used to issue files * requests. * @param commitInfoBuilder Request argument builder. * * @return instsance of this builder */ - UploadBuilder(DbxUserFilesRequests files, CommitInfo.Builder commitInfoBuilder) { - if (files == null) { - throw new NullPointerException("files"); + UploadBuilder(DbxUserFilesRequests files_, CommitInfo.Builder commitInfoBuilder) { + if (files_ == null) { + throw new NullPointerException("files_"); } + this.files_ = files_; if (commitInfoBuilder == null) { throw new NullPointerException("commitInfoBuilder"); } - this.files = files; this.commitInfoBuilder = commitInfoBuilder; } @@ -109,7 +110,7 @@ public UploadBuilder withMute(Boolean mute) { @Override public UploadUploader start() throws UploadErrorException, DbxException { - CommitInfo arg = this.commitInfoBuilder.build(); - return files.upload(arg); + CommitInfo arg_ = this.commitInfoBuilder.build(); + return files_.upload(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/files/UploadError.java b/src/main/java/com/dropbox/core/v2/files/UploadError.java index 3af88794b..d9896a186 100644 --- a/src/main/java/com/dropbox/core/v2/files/UploadError.java +++ b/src/main/java/com/dropbox/core/v2/files/UploadError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=UploadError.Serializer.class) -@JsonDeserialize(using=UploadError.Deserializer.class) public final class UploadError { // union UploadError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link UploadError}. */ @@ -188,7 +170,7 @@ else if (obj instanceof UploadError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -200,69 +182,62 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UploadError.class, UploadWriteFailed.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(UploadError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case PATH: + public void serialize(UploadError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PATH: { g.writeStartObject(); - g.writeStringField(".tag", "path"); - getUnwrappingSerializer(UploadWriteFailed.class).serialize(value.pathValue, g, provider); + writeTag("path", g); + UploadWriteFailed.Serializer.INSTANCE.serialize(value.pathValue, g, true); g.writeEndObject(); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UploadError.class, getTagMapping(), Tag.OTHER, UploadWriteFailed.class); - } @Override - public UploadError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case PATH: { - UploadWriteFailed value = null; - value = readCollapsedStructValue(UploadWriteFailed.class, _p, _ctx); - return UploadError.path(value); - } - case OTHER: { - return UploadError.OTHER; - } + public UploadError deserialize(JsonParser p) throws IOException, JsonParseException { + UploadError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("path", UploadError.Tag.PATH); - values.put("other", UploadError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("path".equals(tag)) { + UploadWriteFailed fieldValue = null; + fieldValue = UploadWriteFailed.Serializer.INSTANCE.deserialize(p, true); + value = UploadError.path(fieldValue); + } + else { + value = UploadError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/UploadErrorException.java b/src/main/java/com/dropbox/core/v2/files/UploadErrorException.java index da9104b54..ca95c553d 100644 --- a/src/main/java/com/dropbox/core/v2/files/UploadErrorException.java +++ b/src/main/java/com/dropbox/core/v2/files/UploadErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; diff --git a/src/main/java/com/dropbox/core/v2/files/UploadSessionAppendArg.java b/src/main/java/com/dropbox/core/v2/files/UploadSessionAppendArg.java index 5704fb1c7..ac88dbf63 100644 --- a/src/main/java/com/dropbox/core/v2/files/UploadSessionAppendArg.java +++ b/src/main/java/com/dropbox/core/v2/files/UploadSessionAppendArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=UploadSessionAppendArg.Serializer.class) -@JsonDeserialize(using=UploadSessionAppendArg.Deserializer.class) class UploadSessionAppendArg { // struct UploadSessionAppendArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final UploadSessionCursor cursor; protected final boolean close; @@ -118,7 +101,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -130,84 +113,65 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UploadSessionAppendArg.class); - } - - public Serializer(boolean unwrapping) { - super(UploadSessionAppendArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(UploadSessionAppendArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("cursor", value.cursor); - g.writeObjectField("close", value.close); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UploadSessionAppendArg.class); - } - - public Deserializer(boolean unwrapping) { - super(UploadSessionAppendArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(UploadSessionAppendArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("cursor"); + UploadSessionCursor.Serializer.INSTANCE.serialize(value.cursor, g); + g.writeFieldName("close"); + StoneSerializers.boolean_().serialize(value.close, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public UploadSessionAppendArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - UploadSessionCursor cursor = null; - boolean close = false; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("cursor".equals(_field)) { - cursor = _p.readValueAs(UploadSessionCursor.class); - _p.nextToken(); - } - else if ("close".equals(_field)) { - close = _p.getValueAsBoolean(); - _p.nextToken(); + public UploadSessionAppendArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + UploadSessionAppendArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + UploadSessionCursor f_cursor = null; + Boolean f_close = false; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("cursor".equals(field)) { + f_cursor = UploadSessionCursor.Serializer.INSTANCE.deserialize(p); + } + else if ("close".equals(field)) { + f_close = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_cursor == null) { + throw new JsonParseException(p, "Required field \"cursor\" missing."); } + value = new UploadSessionAppendArg(f_cursor, f_close); } - - if (cursor == null) { - throw new JsonParseException(_p, "Required field \"cursor\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new UploadSessionAppendArg(cursor, close); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/UploadSessionAppendUploader.java b/src/main/java/com/dropbox/core/v2/files/UploadSessionAppendUploader.java index 5dadfedb1..d36fb9494 100644 --- a/src/main/java/com/dropbox/core/v2/files/UploadSessionAppendUploader.java +++ b/src/main/java/com/dropbox/core/v2/files/UploadSessionAppendUploader.java @@ -1,15 +1,11 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.DbxRequestUtil; import com.dropbox.core.DbxUploader; +import com.dropbox.core.DbxWrappedException; import com.dropbox.core.http.HttpRequestor; -import com.dropbox.core.json.JsonUtil; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JavaType; import java.io.IOException; @@ -25,8 +21,6 @@ * (see {@link DbxUploader} for examples).

*/ public class UploadSessionAppendUploader extends DbxUploader { - private static final JavaType _RESULT_TYPE = JsonUtil.createType(new TypeReference() {}); - private static final JavaType _ERROR_TYPE = JsonUtil.createType(new TypeReference() {}); /** * Creates a new instance of this uploader. @@ -36,9 +30,10 @@ public class UploadSessionAppendUploader extends DbxUploader */ public class UploadSessionAppendV2Uploader extends DbxUploader { - private static final JavaType _RESULT_TYPE = JsonUtil.createType(new TypeReference() {}); - private static final JavaType _ERROR_TYPE = JsonUtil.createType(new TypeReference() {}); /** * Creates a new instance of this uploader. @@ -36,9 +30,10 @@ public class UploadSessionAppendV2Uploader extends DbxUploader { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UploadSessionCursor.class); - } - - public Serializer(boolean unwrapping) { - super(UploadSessionCursor.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(UploadSessionCursor value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("session_id", value.sessionId); - g.writeObjectField("offset", value.offset); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UploadSessionCursor.class); - } - - public Deserializer(boolean unwrapping) { - super(UploadSessionCursor.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(UploadSessionCursor value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("session_id"); + StoneSerializers.string().serialize(value.sessionId, g); + g.writeFieldName("offset"); + StoneSerializers.uInt64().serialize(value.offset, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public UploadSessionCursor deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String sessionId = null; - Long offset = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("session_id".equals(_field)) { - sessionId = getStringValue(_p); - _p.nextToken(); + public UploadSessionCursor deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + UploadSessionCursor value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_sessionId = null; + Long f_offset = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("session_id".equals(field)) { + f_sessionId = StoneSerializers.string().deserialize(p); + } + else if ("offset".equals(field)) { + f_offset = StoneSerializers.uInt64().deserialize(p); + } + else { + skipValue(p); + } } - else if ("offset".equals(_field)) { - offset = _p.getLongValue(); - assertUnsigned(_p, offset); - _p.nextToken(); + if (f_sessionId == null) { + throw new JsonParseException(p, "Required field \"session_id\" missing."); } - else { - skipValue(_p); + if (f_offset == null) { + throw new JsonParseException(p, "Required field \"offset\" missing."); } + value = new UploadSessionCursor(f_sessionId, f_offset); } - - if (sessionId == null) { - throw new JsonParseException(_p, "Required field \"session_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (offset == null) { - throw new JsonParseException(_p, "Required field \"offset\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new UploadSessionCursor(sessionId, offset); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/UploadSessionFinishArg.java b/src/main/java/com/dropbox/core/v2/files/UploadSessionFinishArg.java index 63e831fdb..7bc8db050 100644 --- a/src/main/java/com/dropbox/core/v2/files/UploadSessionFinishArg.java +++ b/src/main/java/com/dropbox/core/v2/files/UploadSessionFinishArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=UploadSessionFinishArg.Serializer.class) -@JsonDeserialize(using=UploadSessionFinishArg.Deserializer.class) class UploadSessionFinishArg { // struct UploadSessionFinishArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final UploadSessionCursor cursor; protected final CommitInfo commit; @@ -104,7 +87,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -116,87 +99,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UploadSessionFinishArg.class); - } - - public Serializer(boolean unwrapping) { - super(UploadSessionFinishArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(UploadSessionFinishArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("cursor", value.cursor); - g.writeObjectField("commit", value.commit); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UploadSessionFinishArg.class); - } - - public Deserializer(boolean unwrapping) { - super(UploadSessionFinishArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(UploadSessionFinishArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("cursor"); + UploadSessionCursor.Serializer.INSTANCE.serialize(value.cursor, g); + g.writeFieldName("commit"); + CommitInfo.Serializer.INSTANCE.serialize(value.commit, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public UploadSessionFinishArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - UploadSessionCursor cursor = null; - CommitInfo commit = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("cursor".equals(_field)) { - cursor = _p.readValueAs(UploadSessionCursor.class); - _p.nextToken(); + public UploadSessionFinishArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + UploadSessionFinishArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + UploadSessionCursor f_cursor = null; + CommitInfo f_commit = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("cursor".equals(field)) { + f_cursor = UploadSessionCursor.Serializer.INSTANCE.deserialize(p); + } + else if ("commit".equals(field)) { + f_commit = CommitInfo.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else if ("commit".equals(_field)) { - commit = _p.readValueAs(CommitInfo.class); - _p.nextToken(); + if (f_cursor == null) { + throw new JsonParseException(p, "Required field \"cursor\" missing."); } - else { - skipValue(_p); + if (f_commit == null) { + throw new JsonParseException(p, "Required field \"commit\" missing."); } + value = new UploadSessionFinishArg(f_cursor, f_commit); } - - if (cursor == null) { - throw new JsonParseException(_p, "Required field \"cursor\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (commit == null) { - throw new JsonParseException(_p, "Required field \"commit\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new UploadSessionFinishArg(cursor, commit); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/UploadSessionFinishError.java b/src/main/java/com/dropbox/core/v2/files/UploadSessionFinishError.java index ce2b1126e..5c62fb9b6 100644 --- a/src/main/java/com/dropbox/core/v2/files/UploadSessionFinishError.java +++ b/src/main/java/com/dropbox/core/v2/files/UploadSessionFinishError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=UploadSessionFinishError.Serializer.class) -@JsonDeserialize(using=UploadSessionFinishError.Deserializer.class) public final class UploadSessionFinishError { // union UploadSessionFinishError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link UploadSessionFinishError}. */ @@ -273,7 +255,7 @@ else if (obj instanceof UploadSessionFinishError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -285,92 +267,85 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UploadSessionFinishError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(UploadSessionFinishError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case LOOKUP_FAILED: + public void serialize(UploadSessionFinishError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case LOOKUP_FAILED: { g.writeStartObject(); - g.writeStringField(".tag", "lookup_failed"); - g.writeObjectField("lookup_failed", value.lookupFailedValue); + writeTag("lookup_failed", g); + g.writeFieldName("lookup_failed"); + UploadSessionLookupError.Serializer.INSTANCE.serialize(value.lookupFailedValue, g); g.writeEndObject(); break; - case PATH: + } + case PATH: { g.writeStartObject(); - g.writeStringField(".tag", "path"); - g.writeObjectField("path", value.pathValue); + writeTag("path", g); + g.writeFieldName("path"); + WriteError.Serializer.INSTANCE.serialize(value.pathValue, g); g.writeEndObject(); break; - case TOO_MANY_SHARED_FOLDER_TARGETS: + } + case TOO_MANY_SHARED_FOLDER_TARGETS: { g.writeString("too_many_shared_folder_targets"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UploadSessionFinishError.class, getTagMapping(), Tag.OTHER); - } @Override - public UploadSessionFinishError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case LOOKUP_FAILED: { - UploadSessionLookupError value = null; - expectField(_p, "lookup_failed"); - value = _p.readValueAs(UploadSessionLookupError.class); - _p.nextToken(); - return UploadSessionFinishError.lookupFailed(value); - } - case PATH: { - WriteError value = null; - expectField(_p, "path"); - value = _p.readValueAs(WriteError.class); - _p.nextToken(); - return UploadSessionFinishError.path(value); - } - case TOO_MANY_SHARED_FOLDER_TARGETS: { - return UploadSessionFinishError.TOO_MANY_SHARED_FOLDER_TARGETS; - } - case OTHER: { - return UploadSessionFinishError.OTHER; - } + public UploadSessionFinishError deserialize(JsonParser p) throws IOException, JsonParseException { + UploadSessionFinishError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("lookup_failed", UploadSessionFinishError.Tag.LOOKUP_FAILED); - values.put("path", UploadSessionFinishError.Tag.PATH); - values.put("too_many_shared_folder_targets", UploadSessionFinishError.Tag.TOO_MANY_SHARED_FOLDER_TARGETS); - values.put("other", UploadSessionFinishError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("lookup_failed".equals(tag)) { + UploadSessionLookupError fieldValue = null; + expectField("lookup_failed", p); + fieldValue = UploadSessionLookupError.Serializer.INSTANCE.deserialize(p); + value = UploadSessionFinishError.lookupFailed(fieldValue); + } + else if ("path".equals(tag)) { + WriteError fieldValue = null; + expectField("path", p); + fieldValue = WriteError.Serializer.INSTANCE.deserialize(p); + value = UploadSessionFinishError.path(fieldValue); + } + else if ("too_many_shared_folder_targets".equals(tag)) { + value = UploadSessionFinishError.TOO_MANY_SHARED_FOLDER_TARGETS; + } + else { + value = UploadSessionFinishError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/UploadSessionFinishErrorException.java b/src/main/java/com/dropbox/core/v2/files/UploadSessionFinishErrorException.java index 7e2b19d2b..8a987f043 100644 --- a/src/main/java/com/dropbox/core/v2/files/UploadSessionFinishErrorException.java +++ b/src/main/java/com/dropbox/core/v2/files/UploadSessionFinishErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; diff --git a/src/main/java/com/dropbox/core/v2/files/UploadSessionFinishUploader.java b/src/main/java/com/dropbox/core/v2/files/UploadSessionFinishUploader.java index 86938938f..2a8badc85 100644 --- a/src/main/java/com/dropbox/core/v2/files/UploadSessionFinishUploader.java +++ b/src/main/java/com/dropbox/core/v2/files/UploadSessionFinishUploader.java @@ -1,15 +1,11 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.DbxRequestUtil; import com.dropbox.core.DbxUploader; +import com.dropbox.core.DbxWrappedException; import com.dropbox.core.http.HttpRequestor; -import com.dropbox.core.json.JsonUtil; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JavaType; import java.io.IOException; @@ -25,8 +21,6 @@ * (see {@link DbxUploader} for examples).

*/ public class UploadSessionFinishUploader extends DbxUploader { - private static final JavaType _RESULT_TYPE = JsonUtil.createType(new TypeReference() {}); - private static final JavaType _ERROR_TYPE = JsonUtil.createType(new TypeReference() {}); /** * Creates a new instance of this uploader. @@ -36,9 +30,10 @@ public class UploadSessionFinishUploader extends DbxUploader */ -@JsonSerialize(using=UploadSessionLookupError.Serializer.class) -@JsonDeserialize(using=UploadSessionLookupError.Deserializer.class) public final class UploadSessionLookupError { // union UploadSessionLookupError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link UploadSessionLookupError}. */ @@ -265,7 +247,7 @@ else if (obj instanceof UploadSessionLookupError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -277,90 +259,83 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UploadSessionLookupError.class, UploadSessionOffsetError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(UploadSessionLookupError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case NOT_FOUND: + public void serialize(UploadSessionLookupError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case NOT_FOUND: { g.writeString("not_found"); break; - case INCORRECT_OFFSET: + } + case INCORRECT_OFFSET: { g.writeStartObject(); - g.writeStringField(".tag", "incorrect_offset"); - getUnwrappingSerializer(UploadSessionOffsetError.class).serialize(value.incorrectOffsetValue, g, provider); + writeTag("incorrect_offset", g); + UploadSessionOffsetError.Serializer.INSTANCE.serialize(value.incorrectOffsetValue, g, true); g.writeEndObject(); break; - case CLOSED: + } + case CLOSED: { g.writeString("closed"); break; - case NOT_CLOSED: + } + case NOT_CLOSED: { g.writeString("not_closed"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UploadSessionLookupError.class, getTagMapping(), Tag.OTHER, UploadSessionOffsetError.class); - } @Override - public UploadSessionLookupError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case NOT_FOUND: { - return UploadSessionLookupError.NOT_FOUND; - } - case INCORRECT_OFFSET: { - UploadSessionOffsetError value = null; - value = readCollapsedStructValue(UploadSessionOffsetError.class, _p, _ctx); - return UploadSessionLookupError.incorrectOffset(value); - } - case CLOSED: { - return UploadSessionLookupError.CLOSED; - } - case NOT_CLOSED: { - return UploadSessionLookupError.NOT_CLOSED; - } - case OTHER: { - return UploadSessionLookupError.OTHER; - } + public UploadSessionLookupError deserialize(JsonParser p) throws IOException, JsonParseException { + UploadSessionLookupError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("not_found", UploadSessionLookupError.Tag.NOT_FOUND); - values.put("incorrect_offset", UploadSessionLookupError.Tag.INCORRECT_OFFSET); - values.put("closed", UploadSessionLookupError.Tag.CLOSED); - values.put("not_closed", UploadSessionLookupError.Tag.NOT_CLOSED); - values.put("other", UploadSessionLookupError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("not_found".equals(tag)) { + value = UploadSessionLookupError.NOT_FOUND; + } + else if ("incorrect_offset".equals(tag)) { + UploadSessionOffsetError fieldValue = null; + fieldValue = UploadSessionOffsetError.Serializer.INSTANCE.deserialize(p, true); + value = UploadSessionLookupError.incorrectOffset(fieldValue); + } + else if ("closed".equals(tag)) { + value = UploadSessionLookupError.CLOSED; + } + else if ("not_closed".equals(tag)) { + value = UploadSessionLookupError.NOT_CLOSED; + } + else { + value = UploadSessionLookupError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/UploadSessionLookupErrorException.java b/src/main/java/com/dropbox/core/v2/files/UploadSessionLookupErrorException.java index 5f77a02cc..ea82d923b 100644 --- a/src/main/java/com/dropbox/core/v2/files/UploadSessionLookupErrorException.java +++ b/src/main/java/com/dropbox/core/v2/files/UploadSessionLookupErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; diff --git a/src/main/java/com/dropbox/core/v2/files/UploadSessionOffsetError.java b/src/main/java/com/dropbox/core/v2/files/UploadSessionOffsetError.java index e393d9fb9..12f81d07b 100644 --- a/src/main/java/com/dropbox/core/v2/files/UploadSessionOffsetError.java +++ b/src/main/java/com/dropbox/core/v2/files/UploadSessionOffsetError.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=UploadSessionOffsetError.Serializer.class) -@JsonDeserialize(using=UploadSessionOffsetError.Deserializer.class) public class UploadSessionOffsetError { // struct UploadSessionOffsetError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final long correctOffset; /** @@ -78,7 +61,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -90,79 +73,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UploadSessionOffsetError.class); - } - - public Serializer(boolean unwrapping) { - super(UploadSessionOffsetError.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(UploadSessionOffsetError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("correct_offset", value.correctOffset); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UploadSessionOffsetError.class); - } - - public Deserializer(boolean unwrapping) { - super(UploadSessionOffsetError.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(UploadSessionOffsetError value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("correct_offset"); + StoneSerializers.uInt64().serialize(value.correctOffset, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public UploadSessionOffsetError deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - Long correctOffset = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("correct_offset".equals(_field)) { - correctOffset = _p.getLongValue(); - assertUnsigned(_p, correctOffset); - _p.nextToken(); + public UploadSessionOffsetError deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + UploadSessionOffsetError value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Long f_correctOffset = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("correct_offset".equals(field)) { + f_correctOffset = StoneSerializers.uInt64().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_correctOffset == null) { + throw new JsonParseException(p, "Required field \"correct_offset\" missing."); } + value = new UploadSessionOffsetError(f_correctOffset); } - - if (correctOffset == null) { - throw new JsonParseException(_p, "Required field \"correct_offset\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new UploadSessionOffsetError(correctOffset); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/UploadSessionStartArg.java b/src/main/java/com/dropbox/core/v2/files/UploadSessionStartArg.java index 55639d5ac..c906deb98 100644 --- a/src/main/java/com/dropbox/core/v2/files/UploadSessionStartArg.java +++ b/src/main/java/com/dropbox/core/v2/files/UploadSessionStartArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=UploadSessionStartArg.Serializer.class) -@JsonDeserialize(using=UploadSessionStartArg.Deserializer.class) class UploadSessionStartArg { // struct UploadSessionStartArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final boolean close; /** @@ -90,7 +73,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -102,75 +85,56 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UploadSessionStartArg.class); - } - - public Serializer(boolean unwrapping) { - super(UploadSessionStartArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(UploadSessionStartArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("close", value.close); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UploadSessionStartArg.class); - } - - public Deserializer(boolean unwrapping) { - super(UploadSessionStartArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(UploadSessionStartArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("close"); + StoneSerializers.boolean_().serialize(value.close, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public UploadSessionStartArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - boolean close = false; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("close".equals(_field)) { - close = _p.getValueAsBoolean(); - _p.nextToken(); - } - else { - skipValue(_p); + public UploadSessionStartArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + UploadSessionStartArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Boolean f_close = false; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("close".equals(field)) { + f_close = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } } + value = new UploadSessionStartArg(f_close); } - - - return new UploadSessionStartArg(close); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/UploadSessionStartResult.java b/src/main/java/com/dropbox/core/v2/files/UploadSessionStartResult.java index 4d203e4c6..b2e0e0cab 100644 --- a/src/main/java/com/dropbox/core/v2/files/UploadSessionStartResult.java +++ b/src/main/java/com/dropbox/core/v2/files/UploadSessionStartResult.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=UploadSessionStartResult.Serializer.class) -@JsonDeserialize(using=UploadSessionStartResult.Deserializer.class) public class UploadSessionStartResult { // struct UploadSessionStartResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String sessionId; /** @@ -90,7 +73,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -102,78 +85,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UploadSessionStartResult.class); - } - - public Serializer(boolean unwrapping) { - super(UploadSessionStartResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(UploadSessionStartResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("session_id", value.sessionId); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UploadSessionStartResult.class); - } - - public Deserializer(boolean unwrapping) { - super(UploadSessionStartResult.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(UploadSessionStartResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("session_id"); + StoneSerializers.string().serialize(value.sessionId, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public UploadSessionStartResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String sessionId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("session_id".equals(_field)) { - sessionId = getStringValue(_p); - _p.nextToken(); + public UploadSessionStartResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + UploadSessionStartResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_sessionId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("session_id".equals(field)) { + f_sessionId = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_sessionId == null) { + throw new JsonParseException(p, "Required field \"session_id\" missing."); } + value = new UploadSessionStartResult(f_sessionId); } - - if (sessionId == null) { - throw new JsonParseException(_p, "Required field \"session_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new UploadSessionStartResult(sessionId); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/UploadSessionStartUploader.java b/src/main/java/com/dropbox/core/v2/files/UploadSessionStartUploader.java index a44f33054..e46fe41c6 100644 --- a/src/main/java/com/dropbox/core/v2/files/UploadSessionStartUploader.java +++ b/src/main/java/com/dropbox/core/v2/files/UploadSessionStartUploader.java @@ -1,16 +1,12 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; import com.dropbox.core.DbxApiException; -import com.dropbox.core.DbxRequestUtil; import com.dropbox.core.DbxUploader; +import com.dropbox.core.DbxWrappedException; import com.dropbox.core.http.HttpRequestor; -import com.dropbox.core.json.JsonUtil; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JavaType; import java.io.IOException; @@ -26,8 +22,6 @@ * (see {@link DbxUploader} for examples).

*/ public class UploadSessionStartUploader extends DbxUploader { - private static final JavaType _RESULT_TYPE = JsonUtil.createType(new TypeReference() {}); - private static final JavaType _ERROR_TYPE = JsonUtil.createType(new TypeReference() {}); /** * Creates a new instance of this uploader. @@ -37,9 +31,10 @@ public class UploadSessionStartUploader extends DbxUploader */ public class UploadUploader extends DbxUploader { - private static final JavaType _RESULT_TYPE = JsonUtil.createType(new TypeReference() {}); - private static final JavaType _ERROR_TYPE = JsonUtil.createType(new TypeReference() {}); /** * Creates a new instance of this uploader. @@ -36,9 +30,10 @@ public class UploadUploader extends DbxUploader { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UploadWriteFailed.class); - } - - public Serializer(boolean unwrapping) { - super(UploadWriteFailed.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(UploadWriteFailed value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("reason", value.reason); - g.writeObjectField("upload_session_id", value.uploadSessionId); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UploadWriteFailed.class); - } - - public Deserializer(boolean unwrapping) { - super(UploadWriteFailed.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(UploadWriteFailed value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("reason"); + WriteError.Serializer.INSTANCE.serialize(value.reason, g); + g.writeFieldName("upload_session_id"); + StoneSerializers.string().serialize(value.uploadSessionId, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public UploadWriteFailed deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - WriteError reason = null; - String uploadSessionId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("reason".equals(_field)) { - reason = _p.readValueAs(WriteError.class); - _p.nextToken(); + public UploadWriteFailed deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + UploadWriteFailed value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + WriteError f_reason = null; + String f_uploadSessionId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("reason".equals(field)) { + f_reason = WriteError.Serializer.INSTANCE.deserialize(p); + } + else if ("upload_session_id".equals(field)) { + f_uploadSessionId = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else if ("upload_session_id".equals(_field)) { - uploadSessionId = getStringValue(_p); - _p.nextToken(); + if (f_reason == null) { + throw new JsonParseException(p, "Required field \"reason\" missing."); } - else { - skipValue(_p); + if (f_uploadSessionId == null) { + throw new JsonParseException(p, "Required field \"upload_session_id\" missing."); } + value = new UploadWriteFailed(f_reason, f_uploadSessionId); } - - if (reason == null) { - throw new JsonParseException(_p, "Required field \"reason\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (uploadSessionId == null) { - throw new JsonParseException(_p, "Required field \"upload_session_id\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new UploadWriteFailed(reason, uploadSessionId); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/VideoMetadata.java b/src/main/java/com/dropbox/core/v2/files/VideoMetadata.java index 3a4c6d80e..d682ce584 100644 --- a/src/main/java/com/dropbox/core/v2/files/VideoMetadata.java +++ b/src/main/java/com/dropbox/core/v2/files/VideoMetadata.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.Date; @@ -29,15 +18,9 @@ /** * Metadata for a video. */ -@JsonSerialize(using=VideoMetadata.Serializer.class) -@JsonDeserialize(using=VideoMetadata.Deserializer.class) public class VideoMetadata extends MediaMetadata { // struct VideoMetadata - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final Long duration; /** @@ -147,7 +130,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -159,99 +142,86 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(VideoMetadata.class); - } - - public Serializer(boolean unwrapping) { - super(VideoMetadata.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(VideoMetadata value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeStringField(".tag", "video"); + public void serialize(VideoMetadata value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + writeTag("video", g); if (value.dimensions != null) { - g.writeObjectField("dimensions", value.dimensions); + g.writeFieldName("dimensions"); + StoneSerializers.nullable(Dimensions.Serializer.INSTANCE).serialize(value.dimensions, g); } if (value.location != null) { - g.writeObjectField("location", value.location); + g.writeFieldName("location"); + StoneSerializers.nullable(GpsCoordinates.Serializer.INSTANCE).serialize(value.location, g); } if (value.timeTaken != null) { - g.writeObjectField("time_taken", value.timeTaken); + g.writeFieldName("time_taken"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.timeTaken, g); } if (value.duration != null) { - g.writeObjectField("duration", value.duration); + g.writeFieldName("duration"); + StoneSerializers.nullable(StoneSerializers.uInt64()).serialize(value.duration, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(VideoMetadata.class); - } - - public Deserializer(boolean unwrapping) { - super(VideoMetadata.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public VideoMetadata deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - String _subtype_tag = readEnumeratedSubtypeTag(_p, "video"); - - Dimensions dimensions = null; - GpsCoordinates location = null; - Date timeTaken = null; - Long duration = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("dimensions".equals(_field)) { - dimensions = _p.readValueAs(Dimensions.class); - _p.nextToken(); - } - else if ("location".equals(_field)) { - location = _p.readValueAs(GpsCoordinates.class); - _p.nextToken(); + public VideoMetadata deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + VideoMetadata value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + if ("video".equals(tag)) { + tag = null; } - else if ("time_taken".equals(_field)) { - timeTaken = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); - } - else if ("duration".equals(_field)) { - duration = _p.getLongValue(); - assertUnsigned(_p, duration); - _p.nextToken(); - } - else { - skipValue(_p); + } + if (tag == null) { + Dimensions f_dimensions = null; + GpsCoordinates f_location = null; + Date f_timeTaken = null; + Long f_duration = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("dimensions".equals(field)) { + f_dimensions = StoneSerializers.nullable(Dimensions.Serializer.INSTANCE).deserialize(p); + } + else if ("location".equals(field)) { + f_location = StoneSerializers.nullable(GpsCoordinates.Serializer.INSTANCE).deserialize(p); + } + else if ("time_taken".equals(field)) { + f_timeTaken = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else if ("duration".equals(field)) { + f_duration = StoneSerializers.nullable(StoneSerializers.uInt64()).deserialize(p); + } + else { + skipValue(p); + } } + value = new VideoMetadata(f_dimensions, f_location, f_timeTaken, f_duration); } - - - return new VideoMetadata(dimensions, location, timeTaken, duration); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/WriteConflictError.java b/src/main/java/com/dropbox/core/v2/files/WriteConflictError.java index 2afb43026..9db74729b 100644 --- a/src/main/java/com/dropbox/core/v2/files/WriteConflictError.java +++ b/src/main/java/com/dropbox/core/v2/files/WriteConflictError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=WriteConflictError.Serializer.class) -@JsonDeserialize(using=WriteConflictError.Deserializer.class) public enum WriteConflictError { // union WriteConflictError /** @@ -52,55 +38,68 @@ public enum WriteConflictError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(WriteConflictError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(WriteConflictError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(WriteConflictError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case FILE: + case FILE: { g.writeString("file"); break; - case FOLDER: + } + case FOLDER: { g.writeString("folder"); break; - case FILE_ANCESTOR: + } + case FILE_ANCESTOR: { g.writeString("file_ancestor"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(WriteConflictError.class, getTagMapping(), WriteConflictError.OTHER); - } @Override - public WriteConflictError deserialize(WriteConflictError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("file", WriteConflictError.FILE); - values.put("folder", WriteConflictError.FOLDER); - values.put("file_ancestor", WriteConflictError.FILE_ANCESTOR); - values.put("other", WriteConflictError.OTHER); - return Collections.unmodifiableMap(values); + public WriteConflictError deserialize(JsonParser p) throws IOException, JsonParseException { + WriteConflictError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("file".equals(tag)) { + value = WriteConflictError.FILE; + } + else if ("folder".equals(tag)) { + value = WriteConflictError.FOLDER; + } + else if ("file_ancestor".equals(tag)) { + value = WriteConflictError.FILE_ANCESTOR; + } + else { + value = WriteConflictError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/WriteError.java b/src/main/java/com/dropbox/core/v2/files/WriteError.java index ab261fdf9..516b20b16 100644 --- a/src/main/java/com/dropbox/core/v2/files/WriteError.java +++ b/src/main/java/com/dropbox/core/v2/files/WriteError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=WriteError.Serializer.class) -@JsonDeserialize(using=WriteError.Deserializer.class) public final class WriteError { // union WriteError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link WriteError}. */ @@ -320,7 +302,7 @@ else if (obj instanceof WriteError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -332,111 +314,106 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); + return Serializer.INSTANCE.serialize(this, true); } - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(WriteError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(WriteError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case MALFORMED_PATH: + public void serialize(WriteError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case MALFORMED_PATH: { g.writeStartObject(); - g.writeStringField(".tag", "malformed_path"); - if (value.malformedPathValue != null) { - g.writeObjectField("malformed_path", value.malformedPathValue); - } + writeTag("malformed_path", g); + g.writeFieldName("malformed_path"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.malformedPathValue, g); g.writeEndObject(); break; - case CONFLICT: + } + case CONFLICT: { g.writeStartObject(); - g.writeStringField(".tag", "conflict"); - g.writeObjectField("conflict", value.conflictValue); + writeTag("conflict", g); + g.writeFieldName("conflict"); + WriteConflictError.Serializer.INSTANCE.serialize(value.conflictValue, g); g.writeEndObject(); break; - case NO_WRITE_PERMISSION: + } + case NO_WRITE_PERMISSION: { g.writeString("no_write_permission"); break; - case INSUFFICIENT_SPACE: + } + case INSUFFICIENT_SPACE: { g.writeString("insufficient_space"); break; - case DISALLOWED_NAME: + } + case DISALLOWED_NAME: { g.writeString("disallowed_name"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(WriteError.class, getTagMapping(), Tag.OTHER); - } @Override - public WriteError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case MALFORMED_PATH: { - if (isObjectEnd(_p)) { - return WriteError.malformedPath(); - } - String value = null; - expectField(_p, "malformed_path"); - value = getStringValue(_p); - _p.nextToken(); - return WriteError.malformedPath(value); - } - case CONFLICT: { - WriteConflictError value = null; - expectField(_p, "conflict"); - value = _p.readValueAs(WriteConflictError.class); - _p.nextToken(); - return WriteError.conflict(value); - } - case NO_WRITE_PERMISSION: { - return WriteError.NO_WRITE_PERMISSION; - } - case INSUFFICIENT_SPACE: { - return WriteError.INSUFFICIENT_SPACE; + public WriteError deserialize(JsonParser p) throws IOException, JsonParseException { + WriteError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("malformed_path".equals(tag)) { + String fieldValue = null; + if (p.getCurrentToken() != JsonToken.END_OBJECT) { + expectField("malformed_path", p); + fieldValue = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); } - case DISALLOWED_NAME: { - return WriteError.DISALLOWED_NAME; + if (fieldValue == null) { + value = WriteError.malformedPath(); } - case OTHER: { - return WriteError.OTHER; + else { + value = WriteError.malformedPath(fieldValue); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("malformed_path", WriteError.Tag.MALFORMED_PATH); - values.put("conflict", WriteError.Tag.CONFLICT); - values.put("no_write_permission", WriteError.Tag.NO_WRITE_PERMISSION); - values.put("insufficient_space", WriteError.Tag.INSUFFICIENT_SPACE); - values.put("disallowed_name", WriteError.Tag.DISALLOWED_NAME); - values.put("other", WriteError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else if ("conflict".equals(tag)) { + WriteConflictError fieldValue = null; + expectField("conflict", p); + fieldValue = WriteConflictError.Serializer.INSTANCE.deserialize(p); + value = WriteError.conflict(fieldValue); + } + else if ("no_write_permission".equals(tag)) { + value = WriteError.NO_WRITE_PERMISSION; + } + else if ("insufficient_space".equals(tag)) { + value = WriteError.INSUFFICIENT_SPACE; + } + else if ("disallowed_name".equals(tag)) { + value = WriteError.DISALLOWED_NAME; + } + else { + value = WriteError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/WriteMode.java b/src/main/java/com/dropbox/core/v2/files/WriteMode.java index d8de81ce9..74c05d0a8 100644 --- a/src/main/java/com/dropbox/core/v2/files/WriteMode.java +++ b/src/main/java/com/dropbox/core/v2/files/WriteMode.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ package com.dropbox.core.v2.files; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Your intent when writing a file to some path. This is used to determine what @@ -41,15 +29,9 @@ * methods will return {@code true}. You can use {@link #tag()} to determine the * tag associated with this instance.

*/ -@JsonSerialize(using=WriteMode.Serializer.class) -@JsonDeserialize(using=WriteMode.Deserializer.class) public final class WriteMode { // union WriteMode - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link WriteMode}. */ @@ -242,7 +224,7 @@ else if (obj instanceof WriteMode) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -254,78 +236,77 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(WriteMode.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(WriteMode value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case ADD: + public void serialize(WriteMode value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case ADD: { g.writeString("add"); break; - case OVERWRITE: + } + case OVERWRITE: { g.writeString("overwrite"); break; - case UPDATE: + } + case UPDATE: { g.writeStartObject(); - g.writeStringField(".tag", "update"); - g.writeObjectField("update", value.updateValue); + writeTag("update", g); + g.writeFieldName("update"); + StoneSerializers.string().serialize(value.updateValue, g); g.writeEndObject(); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(WriteMode.class, getTagMapping(), null); - } - - @Override - public WriteMode deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case ADD: { - return WriteMode.ADD; } - case OVERWRITE: { - return WriteMode.OVERWRITE; - } - case UPDATE: { - String value = null; - expectField(_p, "update"); - value = getStringValue(_p); - _p.nextToken(); - return WriteMode.update(value); + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("add", WriteMode.Tag.ADD); - values.put("overwrite", WriteMode.Tag.OVERWRITE); - values.put("update", WriteMode.Tag.UPDATE); - return Collections.unmodifiableMap(values); + @Override + public WriteMode deserialize(JsonParser p) throws IOException, JsonParseException { + WriteMode value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("add".equals(tag)) { + value = WriteMode.ADD; + } + else if ("overwrite".equals(tag)) { + value = WriteMode.OVERWRITE; + } + else if ("update".equals(tag)) { + String fieldValue = null; + expectField("update", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = WriteMode.update(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/files/package-info.java b/src/main/java/com/dropbox/core/v2/files/package-info.java index 667a81099..b4b2f8819 100644 --- a/src/main/java/com/dropbox/core/v2/files/package-info.java +++ b/src/main/java/com/dropbox/core/v2/files/package-info.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from files.babel */ +/* This file was generated from files.stone */ /** * This namespace contains endpoints and data types for basic file operations. diff --git a/src/main/java/com/dropbox/core/v2/properties/GetPropertyTemplateArg.java b/src/main/java/com/dropbox/core/v2/properties/GetPropertyTemplateArg.java index 56eef73d6..d57dd4f1f 100644 --- a/src/main/java/com/dropbox/core/v2/properties/GetPropertyTemplateArg.java +++ b/src/main/java/com/dropbox/core/v2/properties/GetPropertyTemplateArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from properties.babel */ +/* This file was generated from properties.stone */ package com.dropbox.core.v2.properties; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=GetPropertyTemplateArg.Serializer.class) -@JsonDeserialize(using=GetPropertyTemplateArg.Deserializer.class) public class GetPropertyTemplateArg { // struct GetPropertyTemplateArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String templateId; /** @@ -93,7 +76,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -105,78 +88,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetPropertyTemplateArg.class); - } - - public Serializer(boolean unwrapping) { - super(GetPropertyTemplateArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GetPropertyTemplateArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("template_id", value.templateId); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetPropertyTemplateArg.class); - } - - public Deserializer(boolean unwrapping) { - super(GetPropertyTemplateArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GetPropertyTemplateArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("template_id"); + StoneSerializers.string().serialize(value.templateId, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GetPropertyTemplateArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String templateId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("template_id".equals(_field)) { - templateId = getStringValue(_p); - _p.nextToken(); + public GetPropertyTemplateArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GetPropertyTemplateArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_templateId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("template_id".equals(field)) { + f_templateId = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_templateId == null) { + throw new JsonParseException(p, "Required field \"template_id\" missing."); } + value = new GetPropertyTemplateArg(f_templateId); } - - if (templateId == null) { - throw new JsonParseException(_p, "Required field \"template_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new GetPropertyTemplateArg(templateId); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/properties/GetPropertyTemplateResult.java b/src/main/java/com/dropbox/core/v2/properties/GetPropertyTemplateResult.java index 7e636c279..950a45be1 100644 --- a/src/main/java/com/dropbox/core/v2/properties/GetPropertyTemplateResult.java +++ b/src/main/java/com/dropbox/core/v2/properties/GetPropertyTemplateResult.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from properties.babel */ +/* This file was generated from properties.stone */ package com.dropbox.core.v2.properties; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; @@ -29,15 +18,9 @@ /** * The Property template for the specified template. */ -@JsonSerialize(using=GetPropertyTemplateResult.Serializer.class) -@JsonDeserialize(using=GetPropertyTemplateResult.Deserializer.class) public class GetPropertyTemplateResult extends PropertyGroupTemplate { // struct GetPropertyTemplateResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * The Property template for the specified template. @@ -85,7 +68,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -97,104 +80,77 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetPropertyTemplateResult.class); - } - - public Serializer(boolean unwrapping) { - super(GetPropertyTemplateResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GetPropertyTemplateResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("name", value.name); - g.writeObjectField("description", value.description); - g.writeObjectField("fields", value.fields); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetPropertyTemplateResult.class); - } - - public Deserializer(boolean unwrapping) { - super(GetPropertyTemplateResult.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GetPropertyTemplateResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("name"); + StoneSerializers.string().serialize(value.name, g); + g.writeFieldName("description"); + StoneSerializers.string().serialize(value.description, g); + g.writeFieldName("fields"); + StoneSerializers.list(PropertyFieldTemplate.Serializer.INSTANCE).serialize(value.fields, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GetPropertyTemplateResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String name = null; - String description = null; - List fields = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("name".equals(_field)) { - name = getStringValue(_p); - _p.nextToken(); + public GetPropertyTemplateResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GetPropertyTemplateResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_name = null; + String f_description = null; + List f_fields = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("name".equals(field)) { + f_name = StoneSerializers.string().deserialize(p); + } + else if ("description".equals(field)) { + f_description = StoneSerializers.string().deserialize(p); + } + else if ("fields".equals(field)) { + f_fields = StoneSerializers.list(PropertyFieldTemplate.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); + } } - else if ("description".equals(_field)) { - description = getStringValue(_p); - _p.nextToken(); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } - else if ("fields".equals(_field)) { - expectArrayStart(_p); - fields = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - PropertyFieldTemplate _x = null; - _x = _p.readValueAs(PropertyFieldTemplate.class); - _p.nextToken(); - fields.add(_x); - } - expectArrayEnd(_p); - _p.nextToken(); + if (f_description == null) { + throw new JsonParseException(p, "Required field \"description\" missing."); } - else { - skipValue(_p); + if (f_fields == null) { + throw new JsonParseException(p, "Required field \"fields\" missing."); } + value = new GetPropertyTemplateResult(f_name, f_description, f_fields); } - - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); - } - if (description == null) { - throw new JsonParseException(_p, "Required field \"description\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (fields == null) { - throw new JsonParseException(_p, "Required field \"fields\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new GetPropertyTemplateResult(name, description, fields); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/properties/ListPropertyTemplateIds.java b/src/main/java/com/dropbox/core/v2/properties/ListPropertyTemplateIds.java index b552d7c4e..34f6ebdd1 100644 --- a/src/main/java/com/dropbox/core/v2/properties/ListPropertyTemplateIds.java +++ b/src/main/java/com/dropbox/core/v2/properties/ListPropertyTemplateIds.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from properties.babel */ +/* This file was generated from properties.stone */ package com.dropbox.core.v2.properties; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=ListPropertyTemplateIds.Serializer.class) -@JsonDeserialize(using=ListPropertyTemplateIds.Deserializer.class) public class ListPropertyTemplateIds { // struct ListPropertyTemplateIds - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List templateIds; /** @@ -98,7 +81,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -110,86 +93,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListPropertyTemplateIds.class); - } - - public Serializer(boolean unwrapping) { - super(ListPropertyTemplateIds.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(ListPropertyTemplateIds value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("template_ids", value.templateIds); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListPropertyTemplateIds.class); - } - - public Deserializer(boolean unwrapping) { - super(ListPropertyTemplateIds.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(ListPropertyTemplateIds value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("template_ids"); + StoneSerializers.list(StoneSerializers.string()).serialize(value.templateIds, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public ListPropertyTemplateIds deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List templateIds = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("template_ids".equals(_field)) { - expectArrayStart(_p); - templateIds = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - String _x = null; - _x = getStringValue(_p); - _p.nextToken(); - templateIds.add(_x); + public ListPropertyTemplateIds deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListPropertyTemplateIds value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_templateIds = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("template_ids".equals(field)) { + f_templateIds = StoneSerializers.list(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else { - skipValue(_p); + if (f_templateIds == null) { + throw new JsonParseException(p, "Required field \"template_ids\" missing."); } + value = new ListPropertyTemplateIds(f_templateIds); } - - if (templateIds == null) { - throw new JsonParseException(_p, "Required field \"template_ids\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new ListPropertyTemplateIds(templateIds); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/properties/ModifyPropertyTemplateError.java b/src/main/java/com/dropbox/core/v2/properties/ModifyPropertyTemplateError.java index 7ef47dd42..5d0a87565 100644 --- a/src/main/java/com/dropbox/core/v2/properties/ModifyPropertyTemplateError.java +++ b/src/main/java/com/dropbox/core/v2/properties/ModifyPropertyTemplateError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from properties.babel */ +/* This file was generated from properties.stone */ package com.dropbox.core.v2.properties; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is a tagged union. Tagged unions instances are always associated @@ -32,15 +20,9 @@ * return {@code true}. You can use {@link #tag()} to determine the tag * associated with this instance. */ -@JsonSerialize(using=ModifyPropertyTemplateError.Serializer.class) -@JsonDeserialize(using=ModifyPropertyTemplateError.Deserializer.class) public final class ModifyPropertyTemplateError { // union ModifyPropertyTemplateError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link ModifyPropertyTemplateError}. */ @@ -298,7 +280,7 @@ else if (obj instanceof ModifyPropertyTemplateError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -310,103 +292,105 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ModifyPropertyTemplateError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ModifyPropertyTemplateError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case TEMPLATE_NOT_FOUND: + public void serialize(ModifyPropertyTemplateError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case TEMPLATE_NOT_FOUND: { g.writeStartObject(); - g.writeStringField(".tag", "template_not_found"); - g.writeObjectField("template_not_found", value.templateNotFoundValue); + writeTag("template_not_found", g); + g.writeFieldName("template_not_found"); + StoneSerializers.string().serialize(value.templateNotFoundValue, g); g.writeEndObject(); break; - case RESTRICTED_CONTENT: + } + case RESTRICTED_CONTENT: { g.writeString("restricted_content"); break; - case OTHER: + } + case OTHER: { g.writeString("other"); break; - case CONFLICTING_PROPERTY_NAMES: + } + case CONFLICTING_PROPERTY_NAMES: { g.writeString("conflicting_property_names"); break; - case TOO_MANY_PROPERTIES: + } + case TOO_MANY_PROPERTIES: { g.writeString("too_many_properties"); break; - case TOO_MANY_TEMPLATES: + } + case TOO_MANY_TEMPLATES: { g.writeString("too_many_templates"); break; - case TEMPLATE_ATTRIBUTE_TOO_LARGE: + } + case TEMPLATE_ATTRIBUTE_TOO_LARGE: { g.writeString("template_attribute_too_large"); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ModifyPropertyTemplateError.class, getTagMapping(), null); - } - - @Override - public ModifyPropertyTemplateError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case TEMPLATE_NOT_FOUND: { - String value = null; - expectField(_p, "template_not_found"); - value = getStringValue(_p); - _p.nextToken(); - return ModifyPropertyTemplateError.templateNotFound(value); - } - case RESTRICTED_CONTENT: { - return ModifyPropertyTemplateError.RESTRICTED_CONTENT; - } - case OTHER: { - return ModifyPropertyTemplateError.OTHER; - } - case CONFLICTING_PROPERTY_NAMES: { - return ModifyPropertyTemplateError.CONFLICTING_PROPERTY_NAMES; - } - case TOO_MANY_PROPERTIES: { - return ModifyPropertyTemplateError.TOO_MANY_PROPERTIES; } - case TOO_MANY_TEMPLATES: { - return ModifyPropertyTemplateError.TOO_MANY_TEMPLATES; - } - case TEMPLATE_ATTRIBUTE_TOO_LARGE: { - return ModifyPropertyTemplateError.TEMPLATE_ATTRIBUTE_TOO_LARGE; + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("conflicting_property_names", ModifyPropertyTemplateError.Tag.CONFLICTING_PROPERTY_NAMES); - values.put("too_many_properties", ModifyPropertyTemplateError.Tag.TOO_MANY_PROPERTIES); - values.put("too_many_templates", ModifyPropertyTemplateError.Tag.TOO_MANY_TEMPLATES); - values.put("template_attribute_too_large", ModifyPropertyTemplateError.Tag.TEMPLATE_ATTRIBUTE_TOO_LARGE); - return Collections.unmodifiableMap(values); + @Override + public ModifyPropertyTemplateError deserialize(JsonParser p) throws IOException, JsonParseException { + ModifyPropertyTemplateError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("template_not_found".equals(tag)) { + String fieldValue = null; + expectField("template_not_found", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = ModifyPropertyTemplateError.templateNotFound(fieldValue); + } + else if ("restricted_content".equals(tag)) { + value = ModifyPropertyTemplateError.RESTRICTED_CONTENT; + } + else if ("other".equals(tag)) { + value = ModifyPropertyTemplateError.OTHER; + } + else if ("conflicting_property_names".equals(tag)) { + value = ModifyPropertyTemplateError.CONFLICTING_PROPERTY_NAMES; + } + else if ("too_many_properties".equals(tag)) { + value = ModifyPropertyTemplateError.TOO_MANY_PROPERTIES; + } + else if ("too_many_templates".equals(tag)) { + value = ModifyPropertyTemplateError.TOO_MANY_TEMPLATES; + } + else if ("template_attribute_too_large".equals(tag)) { + value = ModifyPropertyTemplateError.TEMPLATE_ATTRIBUTE_TOO_LARGE; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/properties/ModifyPropertyTemplateErrorException.java b/src/main/java/com/dropbox/core/v2/properties/ModifyPropertyTemplateErrorException.java deleted file mode 100644 index 5f59072cc..000000000 --- a/src/main/java/com/dropbox/core/v2/properties/ModifyPropertyTemplateErrorException.java +++ /dev/null @@ -1,29 +0,0 @@ -/* DO NOT EDIT */ -/* This file was generated from properties.babel */ - -package com.dropbox.core.v2.properties; - -import com.dropbox.core.DbxApiException; -import com.dropbox.core.LocalizedText; - -/** - * Exception thrown when the server responds with a {@link - * ModifyPropertyTemplateError} error. - */ -public class ModifyPropertyTemplateErrorException extends DbxApiException { - private static final long serialVersionUID = 0L; - - /** - * The error reported by {@link - * com.dropbox.core.v2.team.DbxTeamTeamRequests#propertiesTemplateUpdate(String)}. - */ - public final ModifyPropertyTemplateError errorValue; - - public ModifyPropertyTemplateErrorException(String requestId, LocalizedText userMessage, ModifyPropertyTemplateError errorValue) { - super(requestId, userMessage, buildMessage("properties/template/update", userMessage, errorValue)); - if (errorValue == null) { - throw new NullPointerException("errorValue"); - } - this.errorValue = errorValue; - } -} diff --git a/src/main/java/com/dropbox/core/v2/properties/PropertyField.java b/src/main/java/com/dropbox/core/v2/properties/PropertyField.java index efe3abd23..d74857e5c 100644 --- a/src/main/java/com/dropbox/core/v2/properties/PropertyField.java +++ b/src/main/java/com/dropbox/core/v2/properties/PropertyField.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from properties.babel */ +/* This file was generated from properties.stone */ package com.dropbox.core.v2.properties; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=PropertyField.Serializer.class) -@JsonDeserialize(using=PropertyField.Deserializer.class) public class PropertyField { // struct PropertyField - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String name; protected final String value; @@ -107,7 +90,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -119,87 +102,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(PropertyField.class); - } - - public Serializer(boolean unwrapping) { - super(PropertyField.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(PropertyField value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("name", value.name); - g.writeObjectField("value", value.value); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(PropertyField.class); - } - - public Deserializer(boolean unwrapping) { - super(PropertyField.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(PropertyField value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("name"); + StoneSerializers.string().serialize(value.name, g); + g.writeFieldName("value"); + StoneSerializers.string().serialize(value.value, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public PropertyField deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String name = null; - String value = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("name".equals(_field)) { - name = getStringValue(_p); - _p.nextToken(); + public PropertyField deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + PropertyField value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_name = null; + String f_value = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("name".equals(field)) { + f_name = StoneSerializers.string().deserialize(p); + } + else if ("value".equals(field)) { + f_value = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else if ("value".equals(_field)) { - value = getStringValue(_p); - _p.nextToken(); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } - else { - skipValue(_p); + if (f_value == null) { + throw new JsonParseException(p, "Required field \"value\" missing."); } + value = new PropertyField(f_name, f_value); } - - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (value == null) { - throw new JsonParseException(_p, "Required field \"value\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new PropertyField(name, value); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/properties/PropertyFieldTemplate.java b/src/main/java/com/dropbox/core/v2/properties/PropertyFieldTemplate.java index 41361bbb7..0139aa08c 100644 --- a/src/main/java/com/dropbox/core/v2/properties/PropertyFieldTemplate.java +++ b/src/main/java/com/dropbox/core/v2/properties/PropertyFieldTemplate.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from properties.babel */ +/* This file was generated from properties.stone */ package com.dropbox.core.v2.properties; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; @@ -29,15 +18,9 @@ * Describe a single property field type which that can be part of a property * template. */ -@JsonSerialize(using=PropertyFieldTemplate.Serializer.class) -@JsonDeserialize(using=PropertyFieldTemplate.Deserializer.class) public class PropertyFieldTemplate { // struct PropertyFieldTemplate - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String name; protected final String description; protected final PropertyType type; @@ -134,7 +117,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -146,96 +129,77 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(PropertyFieldTemplate.class); - } - - public Serializer(boolean unwrapping) { - super(PropertyFieldTemplate.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(PropertyFieldTemplate value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("name", value.name); - g.writeObjectField("description", value.description); - g.writeObjectField("type", value.type); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(PropertyFieldTemplate.class); - } - - public Deserializer(boolean unwrapping) { - super(PropertyFieldTemplate.class, unwrapping); - } + /** + * For internal use only. + */ + public static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(PropertyFieldTemplate value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("name"); + StoneSerializers.string().serialize(value.name, g); + g.writeFieldName("description"); + StoneSerializers.string().serialize(value.description, g); + g.writeFieldName("type"); + PropertyType.Serializer.INSTANCE.serialize(value.type, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public PropertyFieldTemplate deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String name = null; - String description = null; - PropertyType type = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("name".equals(_field)) { - name = getStringValue(_p); - _p.nextToken(); + public PropertyFieldTemplate deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + PropertyFieldTemplate value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_name = null; + String f_description = null; + PropertyType f_type = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("name".equals(field)) { + f_name = StoneSerializers.string().deserialize(p); + } + else if ("description".equals(field)) { + f_description = StoneSerializers.string().deserialize(p); + } + else if ("type".equals(field)) { + f_type = PropertyType.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else if ("description".equals(_field)) { - description = getStringValue(_p); - _p.nextToken(); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } - else if ("type".equals(_field)) { - type = _p.readValueAs(PropertyType.class); - _p.nextToken(); + if (f_description == null) { + throw new JsonParseException(p, "Required field \"description\" missing."); } - else { - skipValue(_p); + if (f_type == null) { + throw new JsonParseException(p, "Required field \"type\" missing."); } + value = new PropertyFieldTemplate(f_name, f_description, f_type); } - - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); - } - if (description == null) { - throw new JsonParseException(_p, "Required field \"description\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (type == null) { - throw new JsonParseException(_p, "Required field \"type\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new PropertyFieldTemplate(name, description, type); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/properties/PropertyGroup.java b/src/main/java/com/dropbox/core/v2/properties/PropertyGroup.java index 605c3ae0d..73940555b 100644 --- a/src/main/java/com/dropbox/core/v2/properties/PropertyGroup.java +++ b/src/main/java/com/dropbox/core/v2/properties/PropertyGroup.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from properties.babel */ +/* This file was generated from properties.stone */ package com.dropbox.core.v2.properties; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; @@ -29,15 +18,9 @@ /** * Collection of custom properties in filled property templates. */ -@JsonSerialize(using=PropertyGroup.Serializer.class) -@JsonDeserialize(using=PropertyGroup.Deserializer.class) public class PropertyGroup { // struct PropertyGroup - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String templateId; protected final List fields; @@ -123,7 +106,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -135,95 +118,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(PropertyGroup.class); - } - - public Serializer(boolean unwrapping) { - super(PropertyGroup.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(PropertyGroup value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("template_id", value.templateId); - g.writeObjectField("fields", value.fields); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(PropertyGroup.class); - } - - public Deserializer(boolean unwrapping) { - super(PropertyGroup.class, unwrapping); - } + /** + * For internal use only. + */ + public static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(PropertyGroup value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("template_id"); + StoneSerializers.string().serialize(value.templateId, g); + g.writeFieldName("fields"); + StoneSerializers.list(PropertyField.Serializer.INSTANCE).serialize(value.fields, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public PropertyGroup deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String templateId = null; - List fields = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("template_id".equals(_field)) { - templateId = getStringValue(_p); - _p.nextToken(); - } - else if ("fields".equals(_field)) { - expectArrayStart(_p); - fields = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - PropertyField _x = null; - _x = _p.readValueAs(PropertyField.class); - _p.nextToken(); - fields.add(_x); + public PropertyGroup deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + PropertyGroup value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_templateId = null; + List f_fields = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("template_id".equals(field)) { + f_templateId = StoneSerializers.string().deserialize(p); + } + else if ("fields".equals(field)) { + f_fields = StoneSerializers.list(PropertyField.Serializer.INSTANCE).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); + else { + skipValue(p); + } + } + if (f_templateId == null) { + throw new JsonParseException(p, "Required field \"template_id\" missing."); } - else { - skipValue(_p); + if (f_fields == null) { + throw new JsonParseException(p, "Required field \"fields\" missing."); } + value = new PropertyGroup(f_templateId, f_fields); } - - if (templateId == null) { - throw new JsonParseException(_p, "Required field \"template_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (fields == null) { - throw new JsonParseException(_p, "Required field \"fields\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new PropertyGroup(templateId, fields); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/properties/PropertyGroupTemplate.java b/src/main/java/com/dropbox/core/v2/properties/PropertyGroupTemplate.java index 371c9b42f..08083267c 100644 --- a/src/main/java/com/dropbox/core/v2/properties/PropertyGroupTemplate.java +++ b/src/main/java/com/dropbox/core/v2/properties/PropertyGroupTemplate.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from properties.babel */ +/* This file was generated from properties.stone */ package com.dropbox.core.v2.properties; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; @@ -29,15 +18,9 @@ /** * Describes property templates that can be filled and associated with a file. */ -@JsonSerialize(using=PropertyGroupTemplate.Serializer.class) -@JsonDeserialize(using=PropertyGroupTemplate.Deserializer.class) public class PropertyGroupTemplate { // struct PropertyGroupTemplate - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String name; protected final String description; protected final List fields; @@ -139,7 +122,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -151,104 +134,77 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(PropertyGroupTemplate.class); - } - - public Serializer(boolean unwrapping) { - super(PropertyGroupTemplate.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(PropertyGroupTemplate value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("name", value.name); - g.writeObjectField("description", value.description); - g.writeObjectField("fields", value.fields); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(PropertyGroupTemplate.class); - } - - public Deserializer(boolean unwrapping) { - super(PropertyGroupTemplate.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(PropertyGroupTemplate value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("name"); + StoneSerializers.string().serialize(value.name, g); + g.writeFieldName("description"); + StoneSerializers.string().serialize(value.description, g); + g.writeFieldName("fields"); + StoneSerializers.list(PropertyFieldTemplate.Serializer.INSTANCE).serialize(value.fields, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public PropertyGroupTemplate deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String name = null; - String description = null; - List fields = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("name".equals(_field)) { - name = getStringValue(_p); - _p.nextToken(); + public PropertyGroupTemplate deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + PropertyGroupTemplate value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_name = null; + String f_description = null; + List f_fields = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("name".equals(field)) { + f_name = StoneSerializers.string().deserialize(p); + } + else if ("description".equals(field)) { + f_description = StoneSerializers.string().deserialize(p); + } + else if ("fields".equals(field)) { + f_fields = StoneSerializers.list(PropertyFieldTemplate.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); + } } - else if ("description".equals(_field)) { - description = getStringValue(_p); - _p.nextToken(); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } - else if ("fields".equals(_field)) { - expectArrayStart(_p); - fields = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - PropertyFieldTemplate _x = null; - _x = _p.readValueAs(PropertyFieldTemplate.class); - _p.nextToken(); - fields.add(_x); - } - expectArrayEnd(_p); - _p.nextToken(); + if (f_description == null) { + throw new JsonParseException(p, "Required field \"description\" missing."); } - else { - skipValue(_p); + if (f_fields == null) { + throw new JsonParseException(p, "Required field \"fields\" missing."); } + value = new PropertyGroupTemplate(f_name, f_description, f_fields); } - - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); - } - if (description == null) { - throw new JsonParseException(_p, "Required field \"description\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (fields == null) { - throw new JsonParseException(_p, "Required field \"fields\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new PropertyGroupTemplate(name, description, fields); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/properties/PropertyTemplateError.java b/src/main/java/com/dropbox/core/v2/properties/PropertyTemplateError.java index c332e3939..570ddf238 100644 --- a/src/main/java/com/dropbox/core/v2/properties/PropertyTemplateError.java +++ b/src/main/java/com/dropbox/core/v2/properties/PropertyTemplateError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from properties.babel */ +/* This file was generated from properties.stone */ package com.dropbox.core.v2.properties; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=PropertyTemplateError.Serializer.class) -@JsonDeserialize(using=PropertyTemplateError.Deserializer.class) public final class PropertyTemplateError { // union PropertyTemplateError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link PropertyTemplateError}. */ @@ -218,7 +200,7 @@ else if (obj instanceof PropertyTemplateError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -230,78 +212,71 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(PropertyTemplateError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(PropertyTemplateError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case TEMPLATE_NOT_FOUND: + public void serialize(PropertyTemplateError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case TEMPLATE_NOT_FOUND: { g.writeStartObject(); - g.writeStringField(".tag", "template_not_found"); - g.writeObjectField("template_not_found", value.templateNotFoundValue); + writeTag("template_not_found", g); + g.writeFieldName("template_not_found"); + StoneSerializers.string().serialize(value.templateNotFoundValue, g); g.writeEndObject(); break; - case RESTRICTED_CONTENT: + } + case RESTRICTED_CONTENT: { g.writeString("restricted_content"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(PropertyTemplateError.class, getTagMapping(), Tag.OTHER); - } @Override - public PropertyTemplateError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case TEMPLATE_NOT_FOUND: { - String value = null; - expectField(_p, "template_not_found"); - value = getStringValue(_p); - _p.nextToken(); - return PropertyTemplateError.templateNotFound(value); - } - case RESTRICTED_CONTENT: { - return PropertyTemplateError.RESTRICTED_CONTENT; - } - case OTHER: { - return PropertyTemplateError.OTHER; - } + public PropertyTemplateError deserialize(JsonParser p) throws IOException, JsonParseException { + PropertyTemplateError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("template_not_found", PropertyTemplateError.Tag.TEMPLATE_NOT_FOUND); - values.put("restricted_content", PropertyTemplateError.Tag.RESTRICTED_CONTENT); - values.put("other", PropertyTemplateError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("template_not_found".equals(tag)) { + String fieldValue = null; + expectField("template_not_found", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = PropertyTemplateError.templateNotFound(fieldValue); + } + else if ("restricted_content".equals(tag)) { + value = PropertyTemplateError.RESTRICTED_CONTENT; + } + else { + value = PropertyTemplateError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/properties/PropertyTemplateErrorException.java b/src/main/java/com/dropbox/core/v2/properties/PropertyTemplateErrorException.java deleted file mode 100644 index e8e7f97d5..000000000 --- a/src/main/java/com/dropbox/core/v2/properties/PropertyTemplateErrorException.java +++ /dev/null @@ -1,29 +0,0 @@ -/* DO NOT EDIT */ -/* This file was generated from properties.babel */ - -package com.dropbox.core.v2.properties; - -import com.dropbox.core.DbxApiException; -import com.dropbox.core.LocalizedText; - -/** - * Exception thrown when the server responds with a {@link - * PropertyTemplateError} error. - */ -public class PropertyTemplateErrorException extends DbxApiException { - private static final long serialVersionUID = 0L; - - /** - * The error reported by {@link - * com.dropbox.core.v2.team.DbxTeamTeamRequests#propertiesTemplateList()}. - */ - public final PropertyTemplateError errorValue; - - public PropertyTemplateErrorException(String requestId, LocalizedText userMessage, PropertyTemplateError errorValue) { - super(requestId, userMessage, buildMessage("properties/template/list", userMessage, errorValue)); - if (errorValue == null) { - throw new NullPointerException("errorValue"); - } - this.errorValue = errorValue; - } -} diff --git a/src/main/java/com/dropbox/core/v2/properties/PropertyType.java b/src/main/java/com/dropbox/core/v2/properties/PropertyType.java index c49449fc9..08c31ca1a 100644 --- a/src/main/java/com/dropbox/core/v2/properties/PropertyType.java +++ b/src/main/java/com/dropbox/core/v2/properties/PropertyType.java @@ -1,37 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from properties.babel */ +/* This file was generated from properties.stone */ package com.dropbox.core.v2.properties; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Data type of the given property added. This endpoint is in beta and only * properties of type strings is supported. */ -@JsonSerialize(using=PropertyType.Serializer.class) -@JsonDeserialize(using=PropertyType.Deserializer.class) public enum PropertyType { // union PropertyType /** @@ -47,47 +33,54 @@ public enum PropertyType { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(PropertyType.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(PropertyType value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(PropertyType value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case STRING: + case STRING: { g.writeString("string"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(PropertyType.class, getTagMapping(), PropertyType.OTHER); - } @Override - public PropertyType deserialize(PropertyType _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("string", PropertyType.STRING); - values.put("other", PropertyType.OTHER); - return Collections.unmodifiableMap(values); + public PropertyType deserialize(JsonParser p) throws IOException, JsonParseException { + PropertyType value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("string".equals(tag)) { + value = PropertyType.STRING; + } + else { + value = PropertyType.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/properties/package-info.java b/src/main/java/com/dropbox/core/v2/properties/package-info.java index 32b466bfe..19feb143f 100644 --- a/src/main/java/com/dropbox/core/v2/properties/package-info.java +++ b/src/main/java/com/dropbox/core/v2/properties/package-info.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from properties.babel */ +/* This file was generated from properties.stone */ /** * This namespace contains helper entities for property and property/template diff --git a/src/main/java/com/dropbox/core/v2/sharing/AccessLevel.java b/src/main/java/com/dropbox/core/v2/sharing/AccessLevel.java index 82c3fbd49..d1c5ae1d6 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/AccessLevel.java +++ b/src/main/java/com/dropbox/core/v2/sharing/AccessLevel.java @@ -1,36 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Defines the access levels for collaborators. */ -@JsonSerialize(using=AccessLevel.Serializer.class) -@JsonDeserialize(using=AccessLevel.Deserializer.class) public enum AccessLevel { // union AccessLevel /** @@ -47,6 +33,11 @@ public enum AccessLevel { * The collaborator can only view the shared folder. */ VIEWER, + /** + * The collaborator can only view the shared folder and does not have any + * access to comments. + */ + VIEWER_NO_COMMENT, /** * Catch-all used for unknown tag values returned by the Dropbox servers. * @@ -56,55 +47,75 @@ public enum AccessLevel { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(AccessLevel.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(AccessLevel value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(AccessLevel value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case OWNER: + case OWNER: { g.writeString("owner"); break; - case EDITOR: + } + case EDITOR: { g.writeString("editor"); break; - case VIEWER: + } + case VIEWER: { g.writeString("viewer"); break; - case OTHER: - g.writeString("other"); + } + case VIEWER_NO_COMMENT: { + g.writeString("viewer_no_comment"); break; + } + default: { + g.writeString("other"); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(AccessLevel.class, getTagMapping(), AccessLevel.OTHER); - } @Override - public AccessLevel deserialize(AccessLevel _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("owner", AccessLevel.OWNER); - values.put("editor", AccessLevel.EDITOR); - values.put("viewer", AccessLevel.VIEWER); - values.put("other", AccessLevel.OTHER); - return Collections.unmodifiableMap(values); + public AccessLevel deserialize(JsonParser p) throws IOException, JsonParseException { + AccessLevel value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("owner".equals(tag)) { + value = AccessLevel.OWNER; + } + else if ("editor".equals(tag)) { + value = AccessLevel.EDITOR; + } + else if ("viewer".equals(tag)) { + value = AccessLevel.VIEWER; + } + else if ("viewer_no_comment".equals(tag)) { + value = AccessLevel.VIEWER_NO_COMMENT; + } + else { + value = AccessLevel.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/AclUpdatePolicy.java b/src/main/java/com/dropbox/core/v2/sharing/AclUpdatePolicy.java index 63e05c16b..33f80872b 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/AclUpdatePolicy.java +++ b/src/main/java/com/dropbox/core/v2/sharing/AclUpdatePolicy.java @@ -1,37 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Policy governing who can change a shared folder's access control list (ACL). * In other words, who can add, remove, or change the privileges of members. */ -@JsonSerialize(using=AclUpdatePolicy.Serializer.class) -@JsonDeserialize(using=AclUpdatePolicy.Deserializer.class) public enum AclUpdatePolicy { // union AclUpdatePolicy /** @@ -52,51 +38,61 @@ public enum AclUpdatePolicy { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(AclUpdatePolicy.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(AclUpdatePolicy value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(AclUpdatePolicy value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case OWNER: + case OWNER: { g.writeString("owner"); break; - case EDITORS: + } + case EDITORS: { g.writeString("editors"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(AclUpdatePolicy.class, getTagMapping(), AclUpdatePolicy.OTHER); - } @Override - public AclUpdatePolicy deserialize(AclUpdatePolicy _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("owner", AclUpdatePolicy.OWNER); - values.put("editors", AclUpdatePolicy.EDITORS); - values.put("other", AclUpdatePolicy.OTHER); - return Collections.unmodifiableMap(values); + public AclUpdatePolicy deserialize(JsonParser p) throws IOException, JsonParseException { + AclUpdatePolicy value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("owner".equals(tag)) { + value = AclUpdatePolicy.OWNER; + } + else if ("editors".equals(tag)) { + value = AclUpdatePolicy.EDITORS; + } + else { + value = AclUpdatePolicy.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/AddFolderMemberArg.java b/src/main/java/com/dropbox/core/v2/sharing/AddFolderMemberArg.java index 553e607ca..d450b406f 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/AddFolderMemberArg.java +++ b/src/main/java/com/dropbox/core/v2/sharing/AddFolderMemberArg.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=AddFolderMemberArg.Serializer.class) -@JsonDeserialize(using=AddFolderMemberArg.Deserializer.class) class AddFolderMemberArg { // struct AddFolderMemberArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String sharedFolderId; protected final List members; protected final boolean quiet; @@ -273,7 +256,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -285,109 +268,82 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(AddFolderMemberArg.class); - } - - public Serializer(boolean unwrapping) { - super(AddFolderMemberArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(AddFolderMemberArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("shared_folder_id", value.sharedFolderId); - g.writeObjectField("members", value.members); - g.writeObjectField("quiet", value.quiet); + public void serialize(AddFolderMemberArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("shared_folder_id"); + StoneSerializers.string().serialize(value.sharedFolderId, g); + g.writeFieldName("members"); + StoneSerializers.list(AddMember.Serializer.INSTANCE).serialize(value.members, g); + g.writeFieldName("quiet"); + StoneSerializers.boolean_().serialize(value.quiet, g); if (value.customMessage != null) { - g.writeObjectField("custom_message", value.customMessage); + g.writeFieldName("custom_message"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.customMessage, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(AddFolderMemberArg.class); - } - - public Deserializer(boolean unwrapping) { - super(AddFolderMemberArg.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public AddFolderMemberArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String sharedFolderId = null; - List members = null; - boolean quiet = false; - String customMessage = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("shared_folder_id".equals(_field)) { - sharedFolderId = getStringValue(_p); - _p.nextToken(); - } - else if ("members".equals(_field)) { - expectArrayStart(_p); - members = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - AddMember _x = null; - _x = _p.readValueAs(AddMember.class); - _p.nextToken(); - members.add(_x); + public AddFolderMemberArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + AddFolderMemberArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_sharedFolderId = null; + List f_members = null; + Boolean f_quiet = false; + String f_customMessage = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("shared_folder_id".equals(field)) { + f_sharedFolderId = StoneSerializers.string().deserialize(p); + } + else if ("members".equals(field)) { + f_members = StoneSerializers.list(AddMember.Serializer.INSTANCE).deserialize(p); + } + else if ("quiet".equals(field)) { + f_quiet = StoneSerializers.boolean_().deserialize(p); + } + else if ("custom_message".equals(field)) { + f_customMessage = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("quiet".equals(_field)) { - quiet = _p.getValueAsBoolean(); - _p.nextToken(); } - else if ("custom_message".equals(_field)) { - customMessage = getStringValue(_p); - _p.nextToken(); + if (f_sharedFolderId == null) { + throw new JsonParseException(p, "Required field \"shared_folder_id\" missing."); } - else { - skipValue(_p); + if (f_members == null) { + throw new JsonParseException(p, "Required field \"members\" missing."); } + value = new AddFolderMemberArg(f_sharedFolderId, f_members, f_quiet, f_customMessage); } - - if (sharedFolderId == null) { - throw new JsonParseException(_p, "Required field \"shared_folder_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (members == null) { - throw new JsonParseException(_p, "Required field \"members\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new AddFolderMemberArg(sharedFolderId, members, quiet, customMessage); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/AddFolderMemberBuilder.java b/src/main/java/com/dropbox/core/v2/sharing/AddFolderMemberBuilder.java index 738f10cbb..7b1e6f818 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/AddFolderMemberBuilder.java +++ b/src/main/java/com/dropbox/core/v2/sharing/AddFolderMemberBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; @@ -13,26 +13,26 @@ * request.

*/ public class AddFolderMemberBuilder { - private final DbxUserSharingRequests sharing; + private final DbxUserSharingRequests sharing_; private final AddFolderMemberArg.Builder addFolderMemberArgBuilder; /** * Creates a new instance of this builder. * - * @param sharing Dropbox namespace-specific client used to issue sharing + * @param sharing_ Dropbox namespace-specific client used to issue sharing * requests. * @param addFolderMemberArgBuilder Request argument builder. * * @return instsance of this builder */ - AddFolderMemberBuilder(DbxUserSharingRequests sharing, AddFolderMemberArg.Builder addFolderMemberArgBuilder) { - if (sharing == null) { - throw new NullPointerException("sharing"); + AddFolderMemberBuilder(DbxUserSharingRequests sharing_, AddFolderMemberArg.Builder addFolderMemberArgBuilder) { + if (sharing_ == null) { + throw new NullPointerException("sharing_"); } + this.sharing_ = sharing_; if (addFolderMemberArgBuilder == null) { throw new NullPointerException("addFolderMemberArgBuilder"); } - this.sharing = sharing; this.addFolderMemberArgBuilder = addFolderMemberArgBuilder; } @@ -72,7 +72,7 @@ public AddFolderMemberBuilder withCustomMessage(String customMessage) { * Issues the request. */ public void start() throws AddFolderMemberErrorException, DbxException { - AddFolderMemberArg arg = this.addFolderMemberArgBuilder.build(); - sharing.addFolderMember(arg); + AddFolderMemberArg arg_ = this.addFolderMemberArgBuilder.build(); + sharing_.addFolderMember(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/AddFolderMemberError.java b/src/main/java/com/dropbox/core/v2/sharing/AddFolderMemberError.java index 4804d9a3b..41103f873 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/AddFolderMemberError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/AddFolderMemberError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=AddFolderMemberError.Serializer.class) -@JsonDeserialize(using=AddFolderMemberError.Deserializer.class) public final class AddFolderMemberError { // union AddFolderMemberError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link AddFolderMemberError}. */ @@ -499,7 +481,7 @@ else if (obj instanceof AddFolderMemberError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -511,157 +493,148 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(AddFolderMemberError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(AddFolderMemberError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case ACCESS_ERROR: + public void serialize(AddFolderMemberError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case ACCESS_ERROR: { g.writeStartObject(); - g.writeStringField(".tag", "access_error"); - g.writeObjectField("access_error", value.accessErrorValue); + writeTag("access_error", g); + g.writeFieldName("access_error"); + SharedFolderAccessError.Serializer.INSTANCE.serialize(value.accessErrorValue, g); g.writeEndObject(); break; - case EMAIL_UNVERIFIED: + } + case EMAIL_UNVERIFIED: { g.writeString("email_unverified"); break; - case BAD_MEMBER: + } + case BAD_MEMBER: { g.writeStartObject(); - g.writeStringField(".tag", "bad_member"); - g.writeObjectField("bad_member", value.badMemberValue); + writeTag("bad_member", g); + g.writeFieldName("bad_member"); + AddMemberSelectorError.Serializer.INSTANCE.serialize(value.badMemberValue, g); g.writeEndObject(); break; - case CANT_SHARE_OUTSIDE_TEAM: + } + case CANT_SHARE_OUTSIDE_TEAM: { g.writeString("cant_share_outside_team"); break; - case TOO_MANY_MEMBERS: + } + case TOO_MANY_MEMBERS: { g.writeStartObject(); - g.writeStringField(".tag", "too_many_members"); - g.writeObjectField("too_many_members", value.tooManyMembersValue); + writeTag("too_many_members", g); + g.writeFieldName("too_many_members"); + StoneSerializers.uInt64().serialize(value.tooManyMembersValue, g); g.writeEndObject(); break; - case TOO_MANY_PENDING_INVITES: + } + case TOO_MANY_PENDING_INVITES: { g.writeStartObject(); - g.writeStringField(".tag", "too_many_pending_invites"); - g.writeObjectField("too_many_pending_invites", value.tooManyPendingInvitesValue); + writeTag("too_many_pending_invites", g); + g.writeFieldName("too_many_pending_invites"); + StoneSerializers.uInt64().serialize(value.tooManyPendingInvitesValue, g); g.writeEndObject(); break; - case RATE_LIMIT: + } + case RATE_LIMIT: { g.writeString("rate_limit"); break; - case INSUFFICIENT_PLAN: + } + case INSUFFICIENT_PLAN: { g.writeString("insufficient_plan"); break; - case TEAM_FOLDER: + } + case TEAM_FOLDER: { g.writeString("team_folder"); break; - case NO_PERMISSION: + } + case NO_PERMISSION: { g.writeString("no_permission"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(AddFolderMemberError.class, getTagMapping(), Tag.OTHER); - } @Override - public AddFolderMemberError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case ACCESS_ERROR: { - SharedFolderAccessError value = null; - expectField(_p, "access_error"); - value = _p.readValueAs(SharedFolderAccessError.class); - _p.nextToken(); - return AddFolderMemberError.accessError(value); - } - case EMAIL_UNVERIFIED: { - return AddFolderMemberError.EMAIL_UNVERIFIED; - } - case BAD_MEMBER: { - AddMemberSelectorError value = null; - expectField(_p, "bad_member"); - value = _p.readValueAs(AddMemberSelectorError.class); - _p.nextToken(); - return AddFolderMemberError.badMember(value); - } - case CANT_SHARE_OUTSIDE_TEAM: { - return AddFolderMemberError.CANT_SHARE_OUTSIDE_TEAM; - } - case TOO_MANY_MEMBERS: { - Long value = null; - expectField(_p, "too_many_members"); - value = _p.getLongValue(); - assertUnsigned(_p, value); - _p.nextToken(); - return AddFolderMemberError.tooManyMembers(value); - } - case TOO_MANY_PENDING_INVITES: { - Long value = null; - expectField(_p, "too_many_pending_invites"); - value = _p.getLongValue(); - assertUnsigned(_p, value); - _p.nextToken(); - return AddFolderMemberError.tooManyPendingInvites(value); - } - case RATE_LIMIT: { - return AddFolderMemberError.RATE_LIMIT; - } - case INSUFFICIENT_PLAN: { - return AddFolderMemberError.INSUFFICIENT_PLAN; - } - case TEAM_FOLDER: { - return AddFolderMemberError.TEAM_FOLDER; - } - case NO_PERMISSION: { - return AddFolderMemberError.NO_PERMISSION; - } - case OTHER: { - return AddFolderMemberError.OTHER; - } + public AddFolderMemberError deserialize(JsonParser p) throws IOException, JsonParseException { + AddFolderMemberError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("access_error", AddFolderMemberError.Tag.ACCESS_ERROR); - values.put("email_unverified", AddFolderMemberError.Tag.EMAIL_UNVERIFIED); - values.put("bad_member", AddFolderMemberError.Tag.BAD_MEMBER); - values.put("cant_share_outside_team", AddFolderMemberError.Tag.CANT_SHARE_OUTSIDE_TEAM); - values.put("too_many_members", AddFolderMemberError.Tag.TOO_MANY_MEMBERS); - values.put("too_many_pending_invites", AddFolderMemberError.Tag.TOO_MANY_PENDING_INVITES); - values.put("rate_limit", AddFolderMemberError.Tag.RATE_LIMIT); - values.put("insufficient_plan", AddFolderMemberError.Tag.INSUFFICIENT_PLAN); - values.put("team_folder", AddFolderMemberError.Tag.TEAM_FOLDER); - values.put("no_permission", AddFolderMemberError.Tag.NO_PERMISSION); - values.put("other", AddFolderMemberError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("access_error".equals(tag)) { + SharedFolderAccessError fieldValue = null; + expectField("access_error", p); + fieldValue = SharedFolderAccessError.Serializer.INSTANCE.deserialize(p); + value = AddFolderMemberError.accessError(fieldValue); + } + else if ("email_unverified".equals(tag)) { + value = AddFolderMemberError.EMAIL_UNVERIFIED; + } + else if ("bad_member".equals(tag)) { + AddMemberSelectorError fieldValue = null; + expectField("bad_member", p); + fieldValue = AddMemberSelectorError.Serializer.INSTANCE.deserialize(p); + value = AddFolderMemberError.badMember(fieldValue); + } + else if ("cant_share_outside_team".equals(tag)) { + value = AddFolderMemberError.CANT_SHARE_OUTSIDE_TEAM; + } + else if ("too_many_members".equals(tag)) { + Long fieldValue = null; + expectField("too_many_members", p); + fieldValue = StoneSerializers.uInt64().deserialize(p); + value = AddFolderMemberError.tooManyMembers(fieldValue); + } + else if ("too_many_pending_invites".equals(tag)) { + Long fieldValue = null; + expectField("too_many_pending_invites", p); + fieldValue = StoneSerializers.uInt64().deserialize(p); + value = AddFolderMemberError.tooManyPendingInvites(fieldValue); + } + else if ("rate_limit".equals(tag)) { + value = AddFolderMemberError.RATE_LIMIT; + } + else if ("insufficient_plan".equals(tag)) { + value = AddFolderMemberError.INSUFFICIENT_PLAN; + } + else if ("team_folder".equals(tag)) { + value = AddFolderMemberError.TEAM_FOLDER; + } + else if ("no_permission".equals(tag)) { + value = AddFolderMemberError.NO_PERMISSION; + } + else { + value = AddFolderMemberError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/AddFolderMemberErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/AddFolderMemberErrorException.java index 8b9d509c7..5d0bca7f9 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/AddFolderMemberErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/AddFolderMemberErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/AddMember.java b/src/main/java/com/dropbox/core/v2/sharing/AddMember.java index 6a4c18b54..f901b2007 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/AddMember.java +++ b/src/main/java/com/dropbox/core/v2/sharing/AddMember.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; @@ -29,15 +18,9 @@ * The member and type of access the member should have when added to a shared * folder. */ -@JsonSerialize(using=AddMember.Serializer.class) -@JsonDeserialize(using=AddMember.Deserializer.class) public class AddMember { // struct AddMember - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final MemberSelector member; protected final AccessLevel accessLevel; @@ -128,7 +111,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -140,84 +123,65 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(AddMember.class); - } - - public Serializer(boolean unwrapping) { - super(AddMember.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(AddMember value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("member", value.member); - g.writeObjectField("access_level", value.accessLevel); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(AddMember.class); - } - - public Deserializer(boolean unwrapping) { - super(AddMember.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(AddMember value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("member"); + MemberSelector.Serializer.INSTANCE.serialize(value.member, g); + g.writeFieldName("access_level"); + AccessLevel.Serializer.INSTANCE.serialize(value.accessLevel, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public AddMember deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - MemberSelector member = null; - AccessLevel accessLevel = AccessLevel.VIEWER; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("member".equals(_field)) { - member = _p.readValueAs(MemberSelector.class); - _p.nextToken(); - } - else if ("access_level".equals(_field)) { - accessLevel = _p.readValueAs(AccessLevel.class); - _p.nextToken(); + public AddMember deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + AddMember value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + MemberSelector f_member = null; + AccessLevel f_accessLevel = AccessLevel.VIEWER; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("member".equals(field)) { + f_member = MemberSelector.Serializer.INSTANCE.deserialize(p); + } + else if ("access_level".equals(field)) { + f_accessLevel = AccessLevel.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_member == null) { + throw new JsonParseException(p, "Required field \"member\" missing."); } + value = new AddMember(f_member, f_accessLevel); } - - if (member == null) { - throw new JsonParseException(_p, "Required field \"member\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new AddMember(member, accessLevel); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/AddMemberSelectorError.java b/src/main/java/com/dropbox/core/v2/sharing/AddMemberSelectorError.java index eedc62b44..6f0b342c0 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/AddMemberSelectorError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/AddMemberSelectorError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=AddMemberSelectorError.Serializer.class) -@JsonDeserialize(using=AddMemberSelectorError.Deserializer.class) public final class AddMemberSelectorError { // union AddMemberSelectorError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link AddMemberSelectorError}. */ @@ -387,7 +369,7 @@ else if (obj instanceof AddMemberSelectorError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -399,113 +381,106 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); + return Serializer.INSTANCE.serialize(this, true); } - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(AddMemberSelectorError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(AddMemberSelectorError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case INVALID_DROPBOX_ID: + public void serialize(AddMemberSelectorError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case INVALID_DROPBOX_ID: { g.writeStartObject(); - g.writeStringField(".tag", "invalid_dropbox_id"); - g.writeObjectField("invalid_dropbox_id", value.invalidDropboxIdValue); + writeTag("invalid_dropbox_id", g); + g.writeFieldName("invalid_dropbox_id"); + StoneSerializers.string().serialize(value.invalidDropboxIdValue, g); g.writeEndObject(); break; - case INVALID_EMAIL: + } + case INVALID_EMAIL: { g.writeStartObject(); - g.writeStringField(".tag", "invalid_email"); - g.writeObjectField("invalid_email", value.invalidEmailValue); + writeTag("invalid_email", g); + g.writeFieldName("invalid_email"); + StoneSerializers.string().serialize(value.invalidEmailValue, g); g.writeEndObject(); break; - case UNVERIFIED_DROPBOX_ID: + } + case UNVERIFIED_DROPBOX_ID: { g.writeStartObject(); - g.writeStringField(".tag", "unverified_dropbox_id"); - g.writeObjectField("unverified_dropbox_id", value.unverifiedDropboxIdValue); + writeTag("unverified_dropbox_id", g); + g.writeFieldName("unverified_dropbox_id"); + StoneSerializers.string().serialize(value.unverifiedDropboxIdValue, g); g.writeEndObject(); break; - case GROUP_DELETED: + } + case GROUP_DELETED: { g.writeString("group_deleted"); break; - case GROUP_NOT_ON_TEAM: + } + case GROUP_NOT_ON_TEAM: { g.writeString("group_not_on_team"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(AddMemberSelectorError.class, getTagMapping(), Tag.OTHER); - } @Override - public AddMemberSelectorError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case INVALID_DROPBOX_ID: { - String value = null; - expectField(_p, "invalid_dropbox_id"); - value = getStringValue(_p); - _p.nextToken(); - return AddMemberSelectorError.invalidDropboxId(value); - } - case INVALID_EMAIL: { - String value = null; - expectField(_p, "invalid_email"); - value = getStringValue(_p); - _p.nextToken(); - return AddMemberSelectorError.invalidEmail(value); - } - case UNVERIFIED_DROPBOX_ID: { - String value = null; - expectField(_p, "unverified_dropbox_id"); - value = getStringValue(_p); - _p.nextToken(); - return AddMemberSelectorError.unverifiedDropboxId(value); - } - case GROUP_DELETED: { - return AddMemberSelectorError.GROUP_DELETED; - } - case GROUP_NOT_ON_TEAM: { - return AddMemberSelectorError.GROUP_NOT_ON_TEAM; - } - case OTHER: { - return AddMemberSelectorError.OTHER; - } + public AddMemberSelectorError deserialize(JsonParser p) throws IOException, JsonParseException { + AddMemberSelectorError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("invalid_dropbox_id", AddMemberSelectorError.Tag.INVALID_DROPBOX_ID); - values.put("invalid_email", AddMemberSelectorError.Tag.INVALID_EMAIL); - values.put("unverified_dropbox_id", AddMemberSelectorError.Tag.UNVERIFIED_DROPBOX_ID); - values.put("group_deleted", AddMemberSelectorError.Tag.GROUP_DELETED); - values.put("group_not_on_team", AddMemberSelectorError.Tag.GROUP_NOT_ON_TEAM); - values.put("other", AddMemberSelectorError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("invalid_dropbox_id".equals(tag)) { + String fieldValue = null; + expectField("invalid_dropbox_id", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = AddMemberSelectorError.invalidDropboxId(fieldValue); + } + else if ("invalid_email".equals(tag)) { + String fieldValue = null; + expectField("invalid_email", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = AddMemberSelectorError.invalidEmail(fieldValue); + } + else if ("unverified_dropbox_id".equals(tag)) { + String fieldValue = null; + expectField("unverified_dropbox_id", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = AddMemberSelectorError.unverifiedDropboxId(fieldValue); + } + else if ("group_deleted".equals(tag)) { + value = AddMemberSelectorError.GROUP_DELETED; + } + else if ("group_not_on_team".equals(tag)) { + value = AddMemberSelectorError.GROUP_NOT_ON_TEAM; + } + else { + value = AddMemberSelectorError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/CollectionLinkMetadata.java b/src/main/java/com/dropbox/core/v2/sharing/CollectionLinkMetadata.java index a01e3b324..619cb58a2 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/CollectionLinkMetadata.java +++ b/src/main/java/com/dropbox/core/v2/sharing/CollectionLinkMetadata.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.Date; @@ -29,15 +18,9 @@ /** * Metadata for a collection-based shared link. */ -@JsonSerialize(using=CollectionLinkMetadata.Serializer.class) -@JsonDeserialize(using=CollectionLinkMetadata.Deserializer.class) public class CollectionLinkMetadata extends LinkMetadata { // struct CollectionLinkMetadata - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Metadata for a collection-based shared link. @@ -95,7 +78,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -107,92 +90,80 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); + return Serializer.INSTANCE.serialize(this, true); } - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(CollectionLinkMetadata.class); - } - - public Serializer(boolean unwrapping) { - super(CollectionLinkMetadata.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(CollectionLinkMetadata value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeStringField(".tag", "collection"); - g.writeObjectField("url", value.url); - g.writeObjectField("visibility", value.visibility); + public void serialize(CollectionLinkMetadata value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + writeTag("collection", g); + g.writeFieldName("url"); + StoneSerializers.string().serialize(value.url, g); + g.writeFieldName("visibility"); + Visibility.Serializer.INSTANCE.serialize(value.visibility, g); if (value.expires != null) { - g.writeObjectField("expires", value.expires); + g.writeFieldName("expires"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.expires, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(CollectionLinkMetadata.class); - } - - public Deserializer(boolean unwrapping) { - super(CollectionLinkMetadata.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public CollectionLinkMetadata deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - String _subtype_tag = readEnumeratedSubtypeTag(_p, "collection"); - - String url = null; - Visibility visibility = null; - Date expires = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("url".equals(_field)) { - url = getStringValue(_p); - _p.nextToken(); + public CollectionLinkMetadata deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + CollectionLinkMetadata value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + if ("collection".equals(tag)) { + tag = null; } - else if ("visibility".equals(_field)) { - visibility = _p.readValueAs(Visibility.class); - _p.nextToken(); + } + if (tag == null) { + String f_url = null; + Visibility f_visibility = null; + Date f_expires = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("url".equals(field)) { + f_url = StoneSerializers.string().deserialize(p); + } + else if ("visibility".equals(field)) { + f_visibility = Visibility.Serializer.INSTANCE.deserialize(p); + } + else if ("expires".equals(field)) { + f_expires = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else { + skipValue(p); + } } - else if ("expires".equals(_field)) { - expires = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); + if (f_url == null) { + throw new JsonParseException(p, "Required field \"url\" missing."); } - else { - skipValue(_p); + if (f_visibility == null) { + throw new JsonParseException(p, "Required field \"visibility\" missing."); } + value = new CollectionLinkMetadata(f_url, f_visibility, f_expires); } - - if (url == null) { - throw new JsonParseException(_p, "Required field \"url\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (visibility == null) { - throw new JsonParseException(_p, "Required field \"visibility\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new CollectionLinkMetadata(url, visibility, expires); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkArg.java b/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkArg.java index c3e080802..e62927728 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkArg.java +++ b/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=CreateSharedLinkArg.Serializer.class) -@JsonDeserialize(using=CreateSharedLinkArg.Deserializer.class) class CreateSharedLinkArg { // struct CreateSharedLinkArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String path; protected final boolean shortUrl; protected final PendingUploadMode pendingUpload; @@ -212,7 +195,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -224,92 +207,73 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(CreateSharedLinkArg.class); - } - - public Serializer(boolean unwrapping) { - super(CreateSharedLinkArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(CreateSharedLinkArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("path", value.path); - g.writeObjectField("short_url", value.shortUrl); + public void serialize(CreateSharedLinkArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("path"); + StoneSerializers.string().serialize(value.path, g); + g.writeFieldName("short_url"); + StoneSerializers.boolean_().serialize(value.shortUrl, g); if (value.pendingUpload != null) { - g.writeObjectField("pending_upload", value.pendingUpload); + g.writeFieldName("pending_upload"); + StoneSerializers.nullable(PendingUploadMode.Serializer.INSTANCE).serialize(value.pendingUpload, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(CreateSharedLinkArg.class); - } - - public Deserializer(boolean unwrapping) { - super(CreateSharedLinkArg.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public CreateSharedLinkArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String path = null; - boolean shortUrl = false; - PendingUploadMode pendingUpload = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); - } - else if ("short_url".equals(_field)) { - shortUrl = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("pending_upload".equals(_field)) { - pendingUpload = _p.readValueAs(PendingUploadMode.class); - _p.nextToken(); + public CreateSharedLinkArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + CreateSharedLinkArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_path = null; + Boolean f_shortUrl = false; + PendingUploadMode f_pendingUpload = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("path".equals(field)) { + f_path = StoneSerializers.string().deserialize(p); + } + else if ("short_url".equals(field)) { + f_shortUrl = StoneSerializers.boolean_().deserialize(p); + } + else if ("pending_upload".equals(field)) { + f_pendingUpload = StoneSerializers.nullable(PendingUploadMode.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_path == null) { + throw new JsonParseException(p, "Required field \"path\" missing."); } + value = new CreateSharedLinkArg(f_path, f_shortUrl, f_pendingUpload); } - - if (path == null) { - throw new JsonParseException(_p, "Required field \"path\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new CreateSharedLinkArg(path, shortUrl, pendingUpload); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkBuilder.java b/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkBuilder.java index 28711fb92..c3475a05f 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkBuilder.java +++ b/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; @@ -13,26 +13,26 @@ * request.

*/ public class CreateSharedLinkBuilder { - private final DbxUserSharingRequests sharing; + private final DbxUserSharingRequests sharing_; private final CreateSharedLinkArg.Builder createSharedLinkArgBuilder; /** * Creates a new instance of this builder. * - * @param sharing Dropbox namespace-specific client used to issue sharing + * @param sharing_ Dropbox namespace-specific client used to issue sharing * requests. * @param createSharedLinkArgBuilder Request argument builder. * * @return instsance of this builder */ - CreateSharedLinkBuilder(DbxUserSharingRequests sharing, CreateSharedLinkArg.Builder createSharedLinkArgBuilder) { - if (sharing == null) { - throw new NullPointerException("sharing"); + CreateSharedLinkBuilder(DbxUserSharingRequests sharing_, CreateSharedLinkArg.Builder createSharedLinkArgBuilder) { + if (sharing_ == null) { + throw new NullPointerException("sharing_"); } + this.sharing_ = sharing_; if (createSharedLinkArgBuilder == null) { throw new NullPointerException("createSharedLinkArgBuilder"); } - this.sharing = sharing; this.createSharedLinkArgBuilder = createSharedLinkArgBuilder; } @@ -69,8 +69,9 @@ public CreateSharedLinkBuilder withPendingUpload(PendingUploadMode pendingUpload /** * Issues the request. */ + @SuppressWarnings("deprecation") public PathLinkMetadata start() throws CreateSharedLinkErrorException, DbxException { - CreateSharedLinkArg arg = this.createSharedLinkArgBuilder.build(); - return sharing.createSharedLink(arg); + CreateSharedLinkArg arg_ = this.createSharedLinkArgBuilder.build(); + return sharing_.createSharedLink(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkError.java b/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkError.java index 13bd0e09e..a4cf9374f 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkError.java @@ -1,31 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.dropbox.core.v2.files.LookupError; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -37,15 +25,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=CreateSharedLinkError.Serializer.class) -@JsonDeserialize(using=CreateSharedLinkError.Deserializer.class) public final class CreateSharedLinkError { // union CreateSharedLinkError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link CreateSharedLinkError}. */ @@ -191,7 +173,7 @@ else if (obj instanceof CreateSharedLinkError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -203,71 +185,64 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(CreateSharedLinkError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(CreateSharedLinkError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case PATH: + public void serialize(CreateSharedLinkError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PATH: { g.writeStartObject(); - g.writeStringField(".tag", "path"); - g.writeObjectField("path", value.pathValue); + writeTag("path", g); + g.writeFieldName("path"); + LookupError.Serializer.INSTANCE.serialize(value.pathValue, g); g.writeEndObject(); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(CreateSharedLinkError.class, getTagMapping(), Tag.OTHER); - } @Override - public CreateSharedLinkError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case PATH: { - LookupError value = null; - expectField(_p, "path"); - value = _p.readValueAs(LookupError.class); - _p.nextToken(); - return CreateSharedLinkError.path(value); - } - case OTHER: { - return CreateSharedLinkError.OTHER; - } + public CreateSharedLinkError deserialize(JsonParser p) throws IOException, JsonParseException { + CreateSharedLinkError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("path", CreateSharedLinkError.Tag.PATH); - values.put("other", CreateSharedLinkError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("path".equals(tag)) { + LookupError fieldValue = null; + expectField("path", p); + fieldValue = LookupError.Serializer.INSTANCE.deserialize(p); + value = CreateSharedLinkError.path(fieldValue); + } + else { + value = CreateSharedLinkError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkErrorException.java index 0f94ab0cf..a79cf1960 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkWithSettingsArg.java b/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkWithSettingsArg.java index f530b7c16..0fe3c6db2 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkWithSettingsArg.java +++ b/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkWithSettingsArg.java @@ -1,46 +1,30 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=CreateSharedLinkWithSettingsArg.Serializer.class) -@JsonDeserialize(using=CreateSharedLinkWithSettingsArg.Deserializer.class) class CreateSharedLinkWithSettingsArg { // struct CreateSharedLinkWithSettingsArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String path; protected final SharedLinkSettings settings; /** * * @param path The path to be shared by the shared link. Must match pattern - * "{@code ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * "{@code (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code + * null}. * @param settings The requested settings for the newly created shared * link. * @@ -51,7 +35,7 @@ public CreateSharedLinkWithSettingsArg(String path, SharedLinkSettings settings) if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("((/|id:).*)|(rev:[0-9a-f]{9,})", path)) { + if (!java.util.regex.Pattern.matches("(/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -62,7 +46,8 @@ public CreateSharedLinkWithSettingsArg(String path, SharedLinkSettings settings) * The default values for unset fields will be used. * * @param path The path to be shared by the shared link. Must match pattern - * "{@code ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * "{@code (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code + * null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -117,7 +102,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -129,86 +114,67 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(CreateSharedLinkWithSettingsArg.class); - } - - public Serializer(boolean unwrapping) { - super(CreateSharedLinkWithSettingsArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(CreateSharedLinkWithSettingsArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("path", value.path); + public void serialize(CreateSharedLinkWithSettingsArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("path"); + StoneSerializers.string().serialize(value.path, g); if (value.settings != null) { - g.writeObjectField("settings", value.settings); + g.writeFieldName("settings"); + StoneSerializers.nullable(SharedLinkSettings.Serializer.INSTANCE).serialize(value.settings, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(CreateSharedLinkWithSettingsArg.class); - } - - public Deserializer(boolean unwrapping) { - super(CreateSharedLinkWithSettingsArg.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public CreateSharedLinkWithSettingsArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String path = null; - SharedLinkSettings settings = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); - } - else if ("settings".equals(_field)) { - settings = _p.readValueAs(SharedLinkSettings.class); - _p.nextToken(); + public CreateSharedLinkWithSettingsArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + CreateSharedLinkWithSettingsArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_path = null; + SharedLinkSettings f_settings = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("path".equals(field)) { + f_path = StoneSerializers.string().deserialize(p); + } + else if ("settings".equals(field)) { + f_settings = StoneSerializers.nullable(SharedLinkSettings.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_path == null) { + throw new JsonParseException(p, "Required field \"path\" missing."); } + value = new CreateSharedLinkWithSettingsArg(f_path, f_settings); } - - if (path == null) { - throw new JsonParseException(_p, "Required field \"path\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new CreateSharedLinkWithSettingsArg(path, settings); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkWithSettingsError.java b/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkWithSettingsError.java index 0a5772cee..06f755dd6 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkWithSettingsError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkWithSettingsError.java @@ -1,31 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.dropbox.core.v2.files.LookupError; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is a tagged union. Tagged unions instances are always associated @@ -33,15 +21,9 @@ * return {@code true}. You can use {@link #tag()} to determine the tag * associated with this instance. */ -@JsonSerialize(using=CreateSharedLinkWithSettingsError.Serializer.class) -@JsonDeserialize(using=CreateSharedLinkWithSettingsError.Deserializer.class) public final class CreateSharedLinkWithSettingsError { // union CreateSharedLinkWithSettingsError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link CreateSharedLinkWithSettingsError}. */ @@ -276,7 +258,7 @@ else if (obj instanceof CreateSharedLinkWithSettingsError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -288,99 +270,98 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); + return Serializer.INSTANCE.serialize(this, true); } - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(CreateSharedLinkWithSettingsError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(CreateSharedLinkWithSettingsError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case PATH: + public void serialize(CreateSharedLinkWithSettingsError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PATH: { g.writeStartObject(); - g.writeStringField(".tag", "path"); - g.writeObjectField("path", value.pathValue); + writeTag("path", g); + g.writeFieldName("path"); + LookupError.Serializer.INSTANCE.serialize(value.pathValue, g); g.writeEndObject(); break; - case EMAIL_NOT_VERIFIED: + } + case EMAIL_NOT_VERIFIED: { g.writeString("email_not_verified"); break; - case SHARED_LINK_ALREADY_EXISTS: + } + case SHARED_LINK_ALREADY_EXISTS: { g.writeString("shared_link_already_exists"); break; - case SETTINGS_ERROR: + } + case SETTINGS_ERROR: { g.writeStartObject(); - g.writeStringField(".tag", "settings_error"); - g.writeObjectField("settings_error", value.settingsErrorValue); + writeTag("settings_error", g); + g.writeFieldName("settings_error"); + SharedLinkSettingsError.Serializer.INSTANCE.serialize(value.settingsErrorValue, g); g.writeEndObject(); break; - case ACCESS_DENIED: + } + case ACCESS_DENIED: { g.writeString("access_denied"); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(CreateSharedLinkWithSettingsError.class, getTagMapping(), null); - } - - @Override - public CreateSharedLinkWithSettingsError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case PATH: { - LookupError value = null; - expectField(_p, "path"); - value = _p.readValueAs(LookupError.class); - _p.nextToken(); - return CreateSharedLinkWithSettingsError.path(value); } - case EMAIL_NOT_VERIFIED: { - return CreateSharedLinkWithSettingsError.EMAIL_NOT_VERIFIED; - } - case SHARED_LINK_ALREADY_EXISTS: { - return CreateSharedLinkWithSettingsError.SHARED_LINK_ALREADY_EXISTS; - } - case SETTINGS_ERROR: { - SharedLinkSettingsError value = null; - expectField(_p, "settings_error"); - value = _p.readValueAs(SharedLinkSettingsError.class); - _p.nextToken(); - return CreateSharedLinkWithSettingsError.settingsError(value); - } - case ACCESS_DENIED: { - return CreateSharedLinkWithSettingsError.ACCESS_DENIED; + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("path", CreateSharedLinkWithSettingsError.Tag.PATH); - values.put("email_not_verified", CreateSharedLinkWithSettingsError.Tag.EMAIL_NOT_VERIFIED); - values.put("shared_link_already_exists", CreateSharedLinkWithSettingsError.Tag.SHARED_LINK_ALREADY_EXISTS); - values.put("settings_error", CreateSharedLinkWithSettingsError.Tag.SETTINGS_ERROR); - values.put("access_denied", CreateSharedLinkWithSettingsError.Tag.ACCESS_DENIED); - return Collections.unmodifiableMap(values); + @Override + public CreateSharedLinkWithSettingsError deserialize(JsonParser p) throws IOException, JsonParseException { + CreateSharedLinkWithSettingsError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("path".equals(tag)) { + LookupError fieldValue = null; + expectField("path", p); + fieldValue = LookupError.Serializer.INSTANCE.deserialize(p); + value = CreateSharedLinkWithSettingsError.path(fieldValue); + } + else if ("email_not_verified".equals(tag)) { + value = CreateSharedLinkWithSettingsError.EMAIL_NOT_VERIFIED; + } + else if ("shared_link_already_exists".equals(tag)) { + value = CreateSharedLinkWithSettingsError.SHARED_LINK_ALREADY_EXISTS; + } + else if ("settings_error".equals(tag)) { + SharedLinkSettingsError fieldValue = null; + expectField("settings_error", p); + fieldValue = SharedLinkSettingsError.Serializer.INSTANCE.deserialize(p); + value = CreateSharedLinkWithSettingsError.settingsError(fieldValue); + } + else if ("access_denied".equals(tag)) { + value = CreateSharedLinkWithSettingsError.ACCESS_DENIED; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkWithSettingsErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkWithSettingsErrorException.java index 4c1c24878..2feb51bee 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkWithSettingsErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/CreateSharedLinkWithSettingsErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/DbxUserSharingRequests.java b/src/main/java/com/dropbox/core/v2/sharing/DbxUserSharingRequests.java index 6c58163bf..a1a49a935 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/DbxUserSharingRequests.java +++ b/src/main/java/com/dropbox/core/v2/sharing/DbxUserSharingRequests.java @@ -1,24 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel, shared_links.babel */ +/* This file was generated from sharing_folders.stone, shared_links.stone */ package com.dropbox.core.v2.sharing; import com.dropbox.core.DbxApiException; import com.dropbox.core.DbxDownloader; import com.dropbox.core.DbxException; -import com.dropbox.core.DbxRequestUtil; +import com.dropbox.core.DbxWrappedException; import com.dropbox.core.http.HttpRequestor; -import com.dropbox.core.json.JsonUtil; import com.dropbox.core.v2.DbxDownloadStyleBuilder; import com.dropbox.core.v2.DbxRawClientV2; import com.dropbox.core.v2.async.LaunchEmptyResult; import com.dropbox.core.v2.async.PollArg; import com.dropbox.core.v2.async.PollErrorException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JavaType; - +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -51,11 +49,12 @@ void addFolderMember(AddFolderMemberArg addFolderMemberArg) throws AddFolderMemb "2/sharing/add_folder_member", addFolderMemberArg, false, - JsonUtil.createType(Void.class), - JsonUtil.createType(AddFolderMemberError.class)); + AddFolderMemberArg.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.void_(), + AddFolderMemberError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new AddFolderMemberErrorException(ew.getRequestId(), ew.getUserMessage(), (AddFolderMemberError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new AddFolderMemberErrorException(ex.getRequestId(), ex.getUserMessage(), (AddFolderMemberError) ex.getErrorValue()); } } @@ -78,7 +77,7 @@ void addFolderMember(AddFolderMemberArg addFolderMemberArg) throws AddFolderMemb * @throws IllegalArgumentException If any argument does not meet its * preconditions. */ - public void addFolderMember(String sharedFolderId, java.util.List members) throws AddFolderMemberErrorException, DbxException { + public void addFolderMember(String sharedFolderId, List members) throws AddFolderMemberErrorException, DbxException { AddFolderMemberArg arg = new AddFolderMemberArg(sharedFolderId, members); addFolderMember(arg); } @@ -102,9 +101,9 @@ public void addFolderMember(String sharedFolderId, java.util.List mem * @throws IllegalArgumentException If any argument does not meet its * preconditions. */ - public AddFolderMemberBuilder addFolderMemberBuilder(String sharedFolderId, java.util.List members) { - AddFolderMemberArg.Builder argBuilder = AddFolderMemberArg.newBuilder(sharedFolderId, members); - return new AddFolderMemberBuilder(this, argBuilder); + public AddFolderMemberBuilder addFolderMemberBuilder(String sharedFolderId, List members) { + AddFolderMemberArg.Builder argBuilder_ = AddFolderMemberArg.newBuilder(sharedFolderId, members); + return new AddFolderMemberBuilder(this, argBuilder_); } // @@ -124,11 +123,12 @@ JobStatus checkJobStatus(PollArg pollArg) throws PollErrorException, DbxExceptio "2/sharing/check_job_status", pollArg, false, - JsonUtil.createType(JobStatus.class), - JsonUtil.createType(com.dropbox.core.v2.async.PollError.class)); + PollArg.Serializer.INSTANCE, + JobStatus.Serializer.INSTANCE, + com.dropbox.core.v2.async.PollError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new PollErrorException(ew.getRequestId(), ew.getUserMessage(), (com.dropbox.core.v2.async.PollError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new PollErrorException(ex.getRequestId(), ex.getUserMessage(), (com.dropbox.core.v2.async.PollError) ex.getErrorValue()); } } @@ -165,11 +165,12 @@ ShareFolderJobStatus checkShareJobStatus(PollArg pollArg) throws PollErrorExcept "2/sharing/check_share_job_status", pollArg, false, - JsonUtil.createType(ShareFolderJobStatus.class), - JsonUtil.createType(com.dropbox.core.v2.async.PollError.class)); + PollArg.Serializer.INSTANCE, + ShareFolderJobStatus.Serializer.INSTANCE, + com.dropbox.core.v2.async.PollError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new PollErrorException(ew.getRequestId(), ew.getUserMessage(), (com.dropbox.core.v2.async.PollError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new PollErrorException(ex.getRequestId(), ex.getUserMessage(), (com.dropbox.core.v2.async.PollError) ex.getErrorValue()); } } @@ -218,11 +219,12 @@ PathLinkMetadata createSharedLink(CreateSharedLinkArg createSharedLinkArg) throw "2/sharing/create_shared_link", createSharedLinkArg, false, - JsonUtil.createType(PathLinkMetadata.class), - JsonUtil.createType(CreateSharedLinkError.class)); + CreateSharedLinkArg.Serializer.INSTANCE, + PathLinkMetadata.Serializer.INSTANCE, + CreateSharedLinkError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new CreateSharedLinkErrorException(ew.getRequestId(), ew.getUserMessage(), (CreateSharedLinkError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new CreateSharedLinkErrorException(ex.getRequestId(), ex.getUserMessage(), (CreateSharedLinkError) ex.getErrorValue()); } } @@ -282,8 +284,8 @@ public PathLinkMetadata createSharedLink(String path) throws CreateSharedLinkErr */ @Deprecated public CreateSharedLinkBuilder createSharedLinkBuilder(String path) { - CreateSharedLinkArg.Builder argBuilder = CreateSharedLinkArg.newBuilder(path); - return new CreateSharedLinkBuilder(this, argBuilder); + CreateSharedLinkArg.Builder argBuilder_ = CreateSharedLinkArg.newBuilder(path); + return new CreateSharedLinkBuilder(this, argBuilder_); } // @@ -305,11 +307,12 @@ SharedLinkMetadata createSharedLinkWithSettings(CreateSharedLinkWithSettingsArg "2/sharing/create_shared_link_with_settings", createSharedLinkWithSettingsArg, false, - JsonUtil.createType(SharedLinkMetadata.class), - JsonUtil.createType(CreateSharedLinkWithSettingsError.class)); + CreateSharedLinkWithSettingsArg.Serializer.INSTANCE, + SharedLinkMetadata.Serializer.INSTANCE, + CreateSharedLinkWithSettingsError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new CreateSharedLinkWithSettingsErrorException(ew.getRequestId(), ew.getUserMessage(), (CreateSharedLinkWithSettingsError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new CreateSharedLinkWithSettingsErrorException(ex.getRequestId(), ex.getUserMessage(), (CreateSharedLinkWithSettingsError) ex.getErrorValue()); } } @@ -320,7 +323,8 @@ SharedLinkMetadata createSharedLinkWithSettings(CreateSharedLinkWithSettingsArg * shared folder settings). * * @param path The path to be shared by the shared link. Must match pattern - * "{@code ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * "{@code (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code + * null}. * * @return The metadata of a shared link * @@ -339,7 +343,8 @@ public SharedLinkMetadata createSharedLinkWithSettings(String path) throws Creat * shared folder settings). * * @param path The path to be shared by the shared link. Must match pattern - * "{@code ((/|id:).*)|(rev:[0-9a-f]{9,})}" and not be {@code null}. + * "{@code (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}" and not be {@code + * null}. * @param settings The requested settings for the newly created shared * link. * @@ -371,11 +376,12 @@ SharedFolderMetadata getFolderMetadata(GetMetadataArgs getMetadataArgs) throws S "2/sharing/get_folder_metadata", getMetadataArgs, false, - JsonUtil.createType(SharedFolderMetadata.class), - JsonUtil.createType(SharedFolderAccessError.class)); + GetMetadataArgs.Serializer.INSTANCE, + SharedFolderMetadata.Serializer.INSTANCE, + SharedFolderAccessError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new SharedFolderAccessErrorException(ew.getRequestId(), ew.getUserMessage(), (SharedFolderAccessError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new SharedFolderAccessErrorException(ex.getRequestId(), ex.getUserMessage(), (SharedFolderAccessError) ex.getErrorValue()); } } @@ -412,7 +418,7 @@ public SharedFolderMetadata getFolderMetadata(String sharedFolderId) throws Shar * @throws IllegalArgumentException If any argument does not meet its * preconditions. */ - public SharedFolderMetadata getFolderMetadata(String sharedFolderId, java.util.List actions) throws SharedFolderAccessErrorException, DbxException { + public SharedFolderMetadata getFolderMetadata(String sharedFolderId, List actions) throws SharedFolderAccessErrorException, DbxException { if (actions != null) { for (FolderAction x : actions) { if (x == null) { @@ -435,17 +441,19 @@ public SharedFolderMetadata getFolderMetadata(String sharedFolderId, java.util.L * @return Downloader used to download the response body and view the server * response. */ - DbxDownloader getSharedLinkFile(GetSharedLinkMetadataArg getSharedLinkMetadataArg) throws GetSharedLinkFileErrorException, DbxException { + DbxDownloader getSharedLinkFile(GetSharedLinkMetadataArg getSharedLinkMetadataArg, List headers_) throws GetSharedLinkFileErrorException, DbxException { try { return client.downloadStyle(client.getHost().getContent(), "2/sharing/get_shared_link_file", getSharedLinkMetadataArg, false, - JsonUtil.createType(SharedLinkMetadata.class), - JsonUtil.createType(GetSharedLinkFileError.class)); + headers_, + GetSharedLinkMetadataArg.Serializer.INSTANCE, + SharedLinkMetadata.Serializer.INSTANCE, + GetSharedLinkFileError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new GetSharedLinkFileErrorException(ew.getRequestId(), ew.getUserMessage(), (GetSharedLinkFileError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new GetSharedLinkFileErrorException(ex.getRequestId(), ex.getUserMessage(), (GetSharedLinkFileError) ex.getErrorValue()); } } @@ -462,7 +470,7 @@ DbxDownloader getSharedLinkFile(GetSharedLinkMetadataArg get */ public DbxDownloader getSharedLinkFile(String url) throws GetSharedLinkFileErrorException, DbxException { GetSharedLinkMetadataArg arg = new GetSharedLinkMetadataArg(url); - return getSharedLinkFile(arg); + return getSharedLinkFile(arg, Collections.emptyList()); } /** @@ -477,8 +485,8 @@ public DbxDownloader getSharedLinkFile(String url) throws Ge * preconditions. */ public GetSharedLinkFileBuilder getSharedLinkFileBuilder(String url) { - GetSharedLinkMetadataArg.Builder argBuilder = GetSharedLinkMetadataArg.newBuilder(url); - return new GetSharedLinkFileBuilder(this, argBuilder); + GetSharedLinkMetadataArg.Builder argBuilder_ = GetSharedLinkMetadataArg.newBuilder(url); + return new GetSharedLinkFileBuilder(this, argBuilder_); } // @@ -497,11 +505,12 @@ SharedLinkMetadata getSharedLinkMetadata(GetSharedLinkMetadataArg getSharedLinkM "2/sharing/get_shared_link_metadata", getSharedLinkMetadataArg, false, - JsonUtil.createType(SharedLinkMetadata.class), - JsonUtil.createType(SharedLinkError.class)); + GetSharedLinkMetadataArg.Serializer.INSTANCE, + SharedLinkMetadata.Serializer.INSTANCE, + SharedLinkError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new SharedLinkErrorException(ew.getRequestId(), ew.getUserMessage(), (SharedLinkError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new SharedLinkErrorException(ex.getRequestId(), ex.getUserMessage(), (SharedLinkError) ex.getErrorValue()); } } @@ -532,8 +541,8 @@ public SharedLinkMetadata getSharedLinkMetadata(String url) throws SharedLinkErr * preconditions. */ public GetSharedLinkMetadataBuilder getSharedLinkMetadataBuilder(String url) { - GetSharedLinkMetadataArg.Builder argBuilder = GetSharedLinkMetadataArg.newBuilder(url); - return new GetSharedLinkMetadataBuilder(this, argBuilder); + GetSharedLinkMetadataArg.Builder argBuilder_ = GetSharedLinkMetadataArg.newBuilder(url); + return new GetSharedLinkMetadataBuilder(this, argBuilder_); } // @@ -559,11 +568,12 @@ GetSharedLinksResult getSharedLinks(GetSharedLinksArg getSharedLinksArg) throws "2/sharing/get_shared_links", getSharedLinksArg, false, - JsonUtil.createType(GetSharedLinksResult.class), - JsonUtil.createType(GetSharedLinksError.class)); + GetSharedLinksArg.Serializer.INSTANCE, + GetSharedLinksResult.Serializer.INSTANCE, + GetSharedLinksError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new GetSharedLinksErrorException(ew.getRequestId(), ew.getUserMessage(), (GetSharedLinksError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new GetSharedLinksErrorException(ex.getRequestId(), ex.getUserMessage(), (GetSharedLinksError) ex.getErrorValue()); } } @@ -621,11 +631,12 @@ SharedFolderMembers listFolderMembers(ListFolderMembersArgs listFolderMembersArg "2/sharing/list_folder_members", listFolderMembersArgs, false, - JsonUtil.createType(SharedFolderMembers.class), - JsonUtil.createType(SharedFolderAccessError.class)); + ListFolderMembersArgs.Serializer.INSTANCE, + SharedFolderMembers.Serializer.INSTANCE, + SharedFolderAccessError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new SharedFolderAccessErrorException(ew.getRequestId(), ew.getUserMessage(), (SharedFolderAccessError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new SharedFolderAccessErrorException(ex.getRequestId(), ex.getUserMessage(), (SharedFolderAccessError) ex.getErrorValue()); } } @@ -663,8 +674,8 @@ public SharedFolderMembers listFolderMembers(String sharedFolderId) throws Share * preconditions. */ public ListFolderMembersBuilder listFolderMembersBuilder(String sharedFolderId) { - ListFolderMembersArgs.Builder argBuilder = ListFolderMembersArgs.newBuilder(sharedFolderId); - return new ListFolderMembersBuilder(this, argBuilder); + ListFolderMembersArgs.Builder argBuilder_ = ListFolderMembersArgs.newBuilder(sharedFolderId); + return new ListFolderMembersBuilder(this, argBuilder_); } // @@ -686,11 +697,12 @@ SharedFolderMembers listFolderMembersContinue(ListFolderMembersContinueArg listF "2/sharing/list_folder_members/continue", listFolderMembersContinueArg, false, - JsonUtil.createType(SharedFolderMembers.class), - JsonUtil.createType(ListFolderMembersContinueError.class)); + ListFolderMembersContinueArg.Serializer.INSTANCE, + SharedFolderMembers.Serializer.INSTANCE, + ListFolderMembersContinueError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new ListFolderMembersContinueErrorException(ew.getRequestId(), ew.getUserMessage(), (ListFolderMembersContinueError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new ListFolderMembersContinueErrorException(ex.getRequestId(), ex.getUserMessage(), (ListFolderMembersContinueError) ex.getErrorValue()); } } @@ -735,11 +747,12 @@ ListFoldersResult listFolders(ListFoldersArgs listFoldersArgs) throws DbxExcepti "2/sharing/list_folders", listFoldersArgs, false, - JsonUtil.createType(ListFoldersResult.class), - JsonUtil.createType(Void.class)); + ListFoldersArgs.Serializer.INSTANCE, + ListFoldersResult.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.void_()); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new DbxApiException(ew.getRequestId(), ew.getUserMessage(), "Unexpected error response for \"list_folders\": ew.errValue"); + catch (DbxWrappedException ex) { + throw new DbxApiException(ex.getRequestId(), ex.getUserMessage(), "Unexpected error response for \"list_folders\":" + ex.getErrorValue()); } } @@ -768,8 +781,8 @@ public ListFoldersResult listFolders() throws DbxException { * the request. */ public ListFoldersBuilder listFoldersBuilder() { - ListFoldersArgs.Builder argBuilder = ListFoldersArgs.newBuilder(); - return new ListFoldersBuilder(this, argBuilder); + ListFoldersArgs.Builder argBuilder_ = ListFoldersArgs.newBuilder(); + return new ListFoldersBuilder(this, argBuilder_); } // @@ -796,11 +809,12 @@ ListFoldersResult listFoldersContinue(ListFoldersContinueArg listFoldersContinue "2/sharing/list_folders/continue", listFoldersContinueArg, false, - JsonUtil.createType(ListFoldersResult.class), - JsonUtil.createType(ListFoldersContinueError.class)); + ListFoldersContinueArg.Serializer.INSTANCE, + ListFoldersResult.Serializer.INSTANCE, + ListFoldersContinueError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new ListFoldersContinueErrorException(ew.getRequestId(), ew.getUserMessage(), (ListFoldersContinueError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new ListFoldersContinueErrorException(ex.getRequestId(), ex.getUserMessage(), (ListFoldersContinueError) ex.getErrorValue()); } } @@ -848,11 +862,12 @@ ListFoldersResult listMountableFolders(ListFoldersArgs listFoldersArgs) throws D "2/sharing/list_mountable_folders", listFoldersArgs, false, - JsonUtil.createType(ListFoldersResult.class), - JsonUtil.createType(Void.class)); + ListFoldersArgs.Serializer.INSTANCE, + ListFoldersResult.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.void_()); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new DbxApiException(ew.getRequestId(), ew.getUserMessage(), "Unexpected error response for \"list_mountable_folders\": ew.errValue"); + catch (DbxWrappedException ex) { + throw new DbxApiException(ex.getRequestId(), ex.getUserMessage(), "Unexpected error response for \"list_mountable_folders\":" + ex.getErrorValue()); } } @@ -881,8 +896,8 @@ public ListFoldersResult listMountableFolders() throws DbxException { * the request. */ public ListMountableFoldersBuilder listMountableFoldersBuilder() { - ListFoldersArgs.Builder argBuilder = ListFoldersArgs.newBuilder(); - return new ListMountableFoldersBuilder(this, argBuilder); + ListFoldersArgs.Builder argBuilder_ = ListFoldersArgs.newBuilder(); + return new ListMountableFoldersBuilder(this, argBuilder_); } // @@ -909,11 +924,12 @@ ListFoldersResult listMountableFoldersContinue(ListFoldersContinueArg listFolder "2/sharing/list_mountable_folders/continue", listFoldersContinueArg, false, - JsonUtil.createType(ListFoldersResult.class), - JsonUtil.createType(ListFoldersContinueError.class)); + ListFoldersContinueArg.Serializer.INSTANCE, + ListFoldersResult.Serializer.INSTANCE, + ListFoldersContinueError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new ListFoldersContinueErrorException(ew.getRequestId(), ew.getUserMessage(), (ListFoldersContinueError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new ListFoldersContinueErrorException(ex.getRequestId(), ex.getUserMessage(), (ListFoldersContinueError) ex.getErrorValue()); } } @@ -960,11 +976,12 @@ ListSharedLinksResult listSharedLinks(ListSharedLinksArg listSharedLinksArg) thr "2/sharing/list_shared_links", listSharedLinksArg, false, - JsonUtil.createType(ListSharedLinksResult.class), - JsonUtil.createType(ListSharedLinksError.class)); + ListSharedLinksArg.Serializer.INSTANCE, + ListSharedLinksResult.Serializer.INSTANCE, + ListSharedLinksError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new ListSharedLinksErrorException(ew.getRequestId(), ew.getUserMessage(), (ListSharedLinksError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new ListSharedLinksErrorException(ex.getRequestId(), ex.getUserMessage(), (ListSharedLinksError) ex.getErrorValue()); } } @@ -993,8 +1010,8 @@ public ListSharedLinksResult listSharedLinks() throws ListSharedLinksErrorExcept * the request. */ public ListSharedLinksBuilder listSharedLinksBuilder() { - ListSharedLinksArg.Builder argBuilder = ListSharedLinksArg.newBuilder(); - return new ListSharedLinksBuilder(this, argBuilder); + ListSharedLinksArg.Builder argBuilder_ = ListSharedLinksArg.newBuilder(); + return new ListSharedLinksBuilder(this, argBuilder_); } // @@ -1019,11 +1036,12 @@ SharedLinkMetadata modifySharedLinkSettings(ModifySharedLinkSettingsArgs modifyS "2/sharing/modify_shared_link_settings", modifySharedLinkSettingsArgs, false, - JsonUtil.createType(SharedLinkMetadata.class), - JsonUtil.createType(ModifySharedLinkSettingsError.class)); + ModifySharedLinkSettingsArgs.Serializer.INSTANCE, + SharedLinkMetadata.Serializer.INSTANCE, + ModifySharedLinkSettingsError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new ModifySharedLinkSettingsErrorException(ew.getRequestId(), ew.getUserMessage(), (ModifySharedLinkSettingsError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new ModifySharedLinkSettingsErrorException(ex.getRequestId(), ex.getUserMessage(), (ModifySharedLinkSettingsError) ex.getErrorValue()); } } @@ -1101,11 +1119,12 @@ SharedFolderMetadata mountFolder(MountFolderArg mountFolderArg) throws MountFold "2/sharing/mount_folder", mountFolderArg, false, - JsonUtil.createType(SharedFolderMetadata.class), - JsonUtil.createType(MountFolderError.class)); + MountFolderArg.Serializer.INSTANCE, + SharedFolderMetadata.Serializer.INSTANCE, + MountFolderError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new MountFolderErrorException(ew.getRequestId(), ew.getUserMessage(), (MountFolderError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new MountFolderErrorException(ex.getRequestId(), ex.getUserMessage(), (MountFolderError) ex.getErrorValue()); } } @@ -1136,39 +1155,80 @@ public SharedFolderMetadata mountFolder(String sharedFolderId) throws MountFolde /** * The current user relinquishes their membership in the designated shared * folder and will no longer have access to the folder. A folder owner - * cannot relinquish membership in their own folder. Apps must have full - * Dropbox access to use this endpoint. + * cannot relinquish membership in their own folder. This will run + * synchronously if leave_a_copy is false, and asynchronously if + * leave_a_copy is true. Apps must have full Dropbox access to use this + * endpoint. * + * + * @return Result returned by methods that may either launch an asynchronous + * job or complete synchronously. Upon synchronous completion of the + * job, no additional information is returned. */ - void relinquishFolderMembership(RelinquishFolderMembershipArg relinquishFolderMembershipArg) throws RelinquishFolderMembershipErrorException, DbxException { + LaunchEmptyResult relinquishFolderMembership(RelinquishFolderMembershipArg relinquishFolderMembershipArg) throws RelinquishFolderMembershipErrorException, DbxException { try { - client.rpcStyle(client.getHost().getApi(), - "2/sharing/relinquish_folder_membership", - relinquishFolderMembershipArg, - false, - JsonUtil.createType(Void.class), - JsonUtil.createType(RelinquishFolderMembershipError.class)); + return client.rpcStyle(client.getHost().getApi(), + "2/sharing/relinquish_folder_membership", + relinquishFolderMembershipArg, + false, + RelinquishFolderMembershipArg.Serializer.INSTANCE, + LaunchEmptyResult.Serializer.INSTANCE, + RelinquishFolderMembershipError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new RelinquishFolderMembershipErrorException(ew.getRequestId(), ew.getUserMessage(), (RelinquishFolderMembershipError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new RelinquishFolderMembershipErrorException(ex.getRequestId(), ex.getUserMessage(), (RelinquishFolderMembershipError) ex.getErrorValue()); } } /** * The current user relinquishes their membership in the designated shared * folder and will no longer have access to the folder. A folder owner - * cannot relinquish membership in their own folder. Apps must have full - * Dropbox access to use this endpoint. + * cannot relinquish membership in their own folder. This will run + * synchronously if leave_a_copy is false, and asynchronously if + * leave_a_copy is true. Apps must have full Dropbox access to use this + * endpoint. + * + *

The {@code leaveACopy} request parameter will default to {@code + * false} (see {@link #relinquishFolderMembership(String,boolean)}).

* * @param sharedFolderId The ID for the shared folder. Must match pattern * "{@code [-_0-9a-zA-Z:]+}" and not be {@code null}. * + * @return Result returned by methods that may either launch an asynchronous + * job or complete synchronously. Upon synchronous completion of the + * job, no additional information is returned. + * * @throws IllegalArgumentException If any argument does not meet its * preconditions. */ - public void relinquishFolderMembership(String sharedFolderId) throws RelinquishFolderMembershipErrorException, DbxException { + public LaunchEmptyResult relinquishFolderMembership(String sharedFolderId) throws RelinquishFolderMembershipErrorException, DbxException { RelinquishFolderMembershipArg arg = new RelinquishFolderMembershipArg(sharedFolderId); - relinquishFolderMembership(arg); + return relinquishFolderMembership(arg); + } + + /** + * The current user relinquishes their membership in the designated shared + * folder and will no longer have access to the folder. A folder owner + * cannot relinquish membership in their own folder. This will run + * synchronously if leave_a_copy is false, and asynchronously if + * leave_a_copy is true. Apps must have full Dropbox access to use this + * endpoint. + * + * @param sharedFolderId The ID for the shared folder. Must match pattern + * "{@code [-_0-9a-zA-Z:]+}" and not be {@code null}. + * @param leaveACopy Keep a copy of the folder's contents upon + * relinquishing membership. + * + * @return Result returned by methods that may either launch an asynchronous + * job or complete synchronously. Upon synchronous completion of the + * job, no additional information is returned. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public LaunchEmptyResult relinquishFolderMembership(String sharedFolderId, boolean leaveACopy) throws RelinquishFolderMembershipErrorException, DbxException { + RelinquishFolderMembershipArg arg = new RelinquishFolderMembershipArg(sharedFolderId, leaveACopy); + return relinquishFolderMembership(arg); } // @@ -1191,11 +1251,12 @@ LaunchEmptyResult removeFolderMember(RemoveFolderMemberArg removeFolderMemberArg "2/sharing/remove_folder_member", removeFolderMemberArg, false, - JsonUtil.createType(LaunchEmptyResult.class), - JsonUtil.createType(RemoveFolderMemberError.class)); + RemoveFolderMemberArg.Serializer.INSTANCE, + LaunchEmptyResult.Serializer.INSTANCE, + RemoveFolderMemberError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new RemoveFolderMemberErrorException(ew.getRequestId(), ew.getUserMessage(), (RemoveFolderMemberError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new RemoveFolderMemberErrorException(ex.getRequestId(), ex.getUserMessage(), (RemoveFolderMemberError) ex.getErrorValue()); } } @@ -1245,11 +1306,12 @@ void revokeSharedLink(RevokeSharedLinkArg revokeSharedLinkArg) throws RevokeShar "2/sharing/revoke_shared_link", revokeSharedLinkArg, false, - JsonUtil.createType(Void.class), - JsonUtil.createType(RevokeSharedLinkError.class)); + RevokeSharedLinkArg.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.void_(), + RevokeSharedLinkError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new RevokeSharedLinkErrorException(ew.getRequestId(), ew.getUserMessage(), (RevokeSharedLinkError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new RevokeSharedLinkErrorException(ex.getRequestId(), ex.getUserMessage(), (RevokeSharedLinkError) ex.getErrorValue()); } } @@ -1292,11 +1354,12 @@ ShareFolderLaunch shareFolder(ShareFolderArg shareFolderArg) throws ShareFolderE "2/sharing/share_folder", shareFolderArg, false, - JsonUtil.createType(ShareFolderLaunch.class), - JsonUtil.createType(ShareFolderError.class)); + ShareFolderArg.Serializer.INSTANCE, + ShareFolderLaunch.Serializer.INSTANCE, + ShareFolderError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new ShareFolderErrorException(ew.getRequestId(), ew.getUserMessage(), (ShareFolderError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new ShareFolderErrorException(ex.getRequestId(), ex.getUserMessage(), (ShareFolderError) ex.getErrorValue()); } } @@ -1313,8 +1376,8 @@ ShareFolderLaunch shareFolder(ShareFolderArg shareFolderArg) throws ShareFolderE * See {@link ShareFolderBuilder} for more details.

* * @param path The path to the folder to share. If it does not exist, then - * a new one is created. Must match pattern "{@code /.*}" and not be - * {@code null}. + * a new one is created. Must match pattern "{@code /(.|[\\r\\n])*}" and + * not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -1334,8 +1397,8 @@ public ShareFolderLaunch shareFolder(String path) throws ShareFolderErrorExcepti * Dropbox access to use this endpoint. * * @param path The path to the folder to share. If it does not exist, then - * a new one is created. Must match pattern "{@code /.*}" and not be - * {@code null}. + * a new one is created. Must match pattern "{@code /(.|[\\r\\n])*}" and + * not be {@code null}. * * @return Request builder for configuring request parameters and completing * the request. @@ -1344,8 +1407,8 @@ public ShareFolderLaunch shareFolder(String path) throws ShareFolderErrorExcepti * preconditions. */ public ShareFolderBuilder shareFolderBuilder(String path) { - ShareFolderArg.Builder argBuilder = ShareFolderArg.newBuilder(path); - return new ShareFolderBuilder(this, argBuilder); + ShareFolderArg.Builder argBuilder_ = ShareFolderArg.newBuilder(path); + return new ShareFolderBuilder(this, argBuilder_); } // @@ -1365,11 +1428,12 @@ void transferFolder(TransferFolderArg transferFolderArg) throws TransferFolderEr "2/sharing/transfer_folder", transferFolderArg, false, - JsonUtil.createType(Void.class), - JsonUtil.createType(TransferFolderError.class)); + TransferFolderArg.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.void_(), + TransferFolderError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new TransferFolderErrorException(ew.getRequestId(), ew.getUserMessage(), (TransferFolderError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new TransferFolderErrorException(ex.getRequestId(), ex.getUserMessage(), (TransferFolderError) ex.getErrorValue()); } } @@ -1409,11 +1473,12 @@ void unmountFolder(UnmountFolderArg unmountFolderArg) throws UnmountFolderErrorE "2/sharing/unmount_folder", unmountFolderArg, false, - JsonUtil.createType(Void.class), - JsonUtil.createType(UnmountFolderError.class)); + UnmountFolderArg.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.void_(), + UnmountFolderError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new UnmountFolderErrorException(ew.getRequestId(), ew.getUserMessage(), (UnmountFolderError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new UnmountFolderErrorException(ex.getRequestId(), ex.getUserMessage(), (UnmountFolderError) ex.getErrorValue()); } } @@ -1455,11 +1520,12 @@ LaunchEmptyResult unshareFolder(UnshareFolderArg unshareFolderArg) throws Unshar "2/sharing/unshare_folder", unshareFolderArg, false, - JsonUtil.createType(LaunchEmptyResult.class), - JsonUtil.createType(UnshareFolderError.class)); + UnshareFolderArg.Serializer.INSTANCE, + LaunchEmptyResult.Serializer.INSTANCE, + UnshareFolderError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new UnshareFolderErrorException(ew.getRequestId(), ew.getUserMessage(), (UnshareFolderError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new UnshareFolderErrorException(ex.getRequestId(), ex.getUserMessage(), (UnshareFolderError) ex.getErrorValue()); } } @@ -1527,11 +1593,12 @@ void updateFolderMember(UpdateFolderMemberArg updateFolderMemberArg) throws Upda "2/sharing/update_folder_member", updateFolderMemberArg, false, - JsonUtil.createType(Void.class), - JsonUtil.createType(UpdateFolderMemberError.class)); + UpdateFolderMemberArg.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.void_(), + UpdateFolderMemberError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new UpdateFolderMemberErrorException(ew.getRequestId(), ew.getUserMessage(), (UpdateFolderMemberError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new UpdateFolderMemberErrorException(ex.getRequestId(), ex.getUserMessage(), (UpdateFolderMemberError) ex.getErrorValue()); } } @@ -1578,11 +1645,12 @@ SharedFolderMetadata updateFolderPolicy(UpdateFolderPolicyArg updateFolderPolicy "2/sharing/update_folder_policy", updateFolderPolicyArg, false, - JsonUtil.createType(SharedFolderMetadata.class), - JsonUtil.createType(UpdateFolderPolicyError.class)); + UpdateFolderPolicyArg.Serializer.INSTANCE, + SharedFolderMetadata.Serializer.INSTANCE, + UpdateFolderPolicyError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new UpdateFolderPolicyErrorException(ew.getRequestId(), ew.getUserMessage(), (UpdateFolderPolicyError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new UpdateFolderPolicyErrorException(ex.getRequestId(), ex.getUserMessage(), (UpdateFolderPolicyError) ex.getErrorValue()); } } @@ -1620,7 +1688,7 @@ public SharedFolderMetadata updateFolderPolicy(String sharedFolderId) throws Upd * preconditions. */ public UpdateFolderPolicyBuilder updateFolderPolicyBuilder(String sharedFolderId) { - UpdateFolderPolicyArg.Builder argBuilder = UpdateFolderPolicyArg.newBuilder(sharedFolderId); - return new UpdateFolderPolicyBuilder(this, argBuilder); + UpdateFolderPolicyArg.Builder argBuilder_ = UpdateFolderPolicyArg.newBuilder(sharedFolderId); + return new UpdateFolderPolicyBuilder(this, argBuilder_); } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/FileLinkMetadata.java b/src/main/java/com/dropbox/core/v2/sharing/FileLinkMetadata.java index 402465e6a..d8343504e 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/FileLinkMetadata.java +++ b/src/main/java/com/dropbox/core/v2/sharing/FileLinkMetadata.java @@ -1,28 +1,17 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.dropbox.core.v2.users.Team; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.Date; @@ -30,15 +19,9 @@ /** * The metadata of a file shared link */ -@JsonSerialize(using=FileLinkMetadata.Serializer.class) -@JsonDeserialize(using=FileLinkMetadata.Deserializer.class) public class FileLinkMetadata extends SharedLinkMetadata { // struct FileLinkMetadata - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final Date clientModified; protected final Date serverModified; protected final String rev; @@ -297,7 +280,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -309,170 +292,157 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(FileLinkMetadata.class); - } - - public Serializer(boolean unwrapping) { - super(FileLinkMetadata.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(FileLinkMetadata value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeStringField(".tag", "file"); - g.writeObjectField("url", value.url); - g.writeObjectField("name", value.name); - g.writeObjectField("link_permissions", value.linkPermissions); - g.writeObjectField("client_modified", value.clientModified); - g.writeObjectField("server_modified", value.serverModified); - g.writeObjectField("rev", value.rev); - g.writeObjectField("size", value.size); + public void serialize(FileLinkMetadata value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + writeTag("file", g); + g.writeFieldName("url"); + StoneSerializers.string().serialize(value.url, g); + g.writeFieldName("name"); + StoneSerializers.string().serialize(value.name, g); + g.writeFieldName("link_permissions"); + LinkPermissions.Serializer.INSTANCE.serialize(value.linkPermissions, g); + g.writeFieldName("client_modified"); + StoneSerializers.timestamp().serialize(value.clientModified, g); + g.writeFieldName("server_modified"); + StoneSerializers.timestamp().serialize(value.serverModified, g); + g.writeFieldName("rev"); + StoneSerializers.string().serialize(value.rev, g); + g.writeFieldName("size"); + StoneSerializers.uInt64().serialize(value.size, g); if (value.id != null) { - g.writeObjectField("id", value.id); + g.writeFieldName("id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.id, g); } if (value.expires != null) { - g.writeObjectField("expires", value.expires); + g.writeFieldName("expires"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.expires, g); } if (value.pathLower != null) { - g.writeObjectField("path_lower", value.pathLower); + g.writeFieldName("path_lower"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.pathLower, g); } if (value.teamMemberInfo != null) { - g.writeObjectField("team_member_info", value.teamMemberInfo); + g.writeFieldName("team_member_info"); + StoneSerializers.nullable(TeamMemberInfo.Serializer.INSTANCE).serialize(value.teamMemberInfo, g); } if (value.contentOwnerTeamInfo != null) { - g.writeObjectField("content_owner_team_info", value.contentOwnerTeamInfo); + g.writeFieldName("content_owner_team_info"); + StoneSerializers.nullable(Team.Serializer.INSTANCE).serialize(value.contentOwnerTeamInfo, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(FileLinkMetadata.class); - } - - public Deserializer(boolean unwrapping) { - super(FileLinkMetadata.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public FileLinkMetadata deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - String _subtype_tag = readEnumeratedSubtypeTag(_p, "file"); - - String url = null; - String name = null; - LinkPermissions linkPermissions = null; - Date clientModified = null; - Date serverModified = null; - String rev = null; - Long size = null; - String id = null; - Date expires = null; - String pathLower = null; - TeamMemberInfo teamMemberInfo = null; - Team contentOwnerTeamInfo = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("url".equals(_field)) { - url = getStringValue(_p); - _p.nextToken(); - } - else if ("name".equals(_field)) { - name = getStringValue(_p); - _p.nextToken(); + public FileLinkMetadata deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + FileLinkMetadata value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + if ("file".equals(tag)) { + tag = null; } - else if ("link_permissions".equals(_field)) { - linkPermissions = _p.readValueAs(LinkPermissions.class); - _p.nextToken(); - } - else if ("client_modified".equals(_field)) { - clientModified = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); - } - else if ("server_modified".equals(_field)) { - serverModified = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); - } - else if ("rev".equals(_field)) { - rev = getStringValue(_p); - _p.nextToken(); + } + if (tag == null) { + String f_url = null; + String f_name = null; + LinkPermissions f_linkPermissions = null; + Date f_clientModified = null; + Date f_serverModified = null; + String f_rev = null; + Long f_size = null; + String f_id = null; + Date f_expires = null; + String f_pathLower = null; + TeamMemberInfo f_teamMemberInfo = null; + Team f_contentOwnerTeamInfo = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("url".equals(field)) { + f_url = StoneSerializers.string().deserialize(p); + } + else if ("name".equals(field)) { + f_name = StoneSerializers.string().deserialize(p); + } + else if ("link_permissions".equals(field)) { + f_linkPermissions = LinkPermissions.Serializer.INSTANCE.deserialize(p); + } + else if ("client_modified".equals(field)) { + f_clientModified = StoneSerializers.timestamp().deserialize(p); + } + else if ("server_modified".equals(field)) { + f_serverModified = StoneSerializers.timestamp().deserialize(p); + } + else if ("rev".equals(field)) { + f_rev = StoneSerializers.string().deserialize(p); + } + else if ("size".equals(field)) { + f_size = StoneSerializers.uInt64().deserialize(p); + } + else if ("id".equals(field)) { + f_id = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("expires".equals(field)) { + f_expires = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else if ("path_lower".equals(field)) { + f_pathLower = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("team_member_info".equals(field)) { + f_teamMemberInfo = StoneSerializers.nullable(TeamMemberInfo.Serializer.INSTANCE).deserialize(p); + } + else if ("content_owner_team_info".equals(field)) { + f_contentOwnerTeamInfo = StoneSerializers.nullable(Team.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); + } } - else if ("size".equals(_field)) { - size = _p.getLongValue(); - assertUnsigned(_p, size); - _p.nextToken(); + if (f_url == null) { + throw new JsonParseException(p, "Required field \"url\" missing."); } - else if ("id".equals(_field)) { - id = getStringValue(_p); - _p.nextToken(); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } - else if ("expires".equals(_field)) { - expires = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); + if (f_linkPermissions == null) { + throw new JsonParseException(p, "Required field \"link_permissions\" missing."); } - else if ("path_lower".equals(_field)) { - pathLower = getStringValue(_p); - _p.nextToken(); + if (f_clientModified == null) { + throw new JsonParseException(p, "Required field \"client_modified\" missing."); } - else if ("team_member_info".equals(_field)) { - teamMemberInfo = _p.readValueAs(TeamMemberInfo.class); - _p.nextToken(); + if (f_serverModified == null) { + throw new JsonParseException(p, "Required field \"server_modified\" missing."); } - else if ("content_owner_team_info".equals(_field)) { - contentOwnerTeamInfo = _p.readValueAs(Team.class); - _p.nextToken(); + if (f_rev == null) { + throw new JsonParseException(p, "Required field \"rev\" missing."); } - else { - skipValue(_p); + if (f_size == null) { + throw new JsonParseException(p, "Required field \"size\" missing."); } + value = new FileLinkMetadata(f_url, f_name, f_linkPermissions, f_clientModified, f_serverModified, f_rev, f_size, f_id, f_expires, f_pathLower, f_teamMemberInfo, f_contentOwnerTeamInfo); } - - if (url == null) { - throw new JsonParseException(_p, "Required field \"url\" is missing."); - } - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); - } - if (linkPermissions == null) { - throw new JsonParseException(_p, "Required field \"link_permissions\" is missing."); - } - if (clientModified == null) { - throw new JsonParseException(_p, "Required field \"client_modified\" is missing."); - } - if (serverModified == null) { - throw new JsonParseException(_p, "Required field \"server_modified\" is missing."); - } - if (rev == null) { - throw new JsonParseException(_p, "Required field \"rev\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (size == null) { - throw new JsonParseException(_p, "Required field \"size\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new FileLinkMetadata(url, name, linkPermissions, clientModified, serverModified, rev, size, id, expires, pathLower, teamMemberInfo, contentOwnerTeamInfo); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/FolderAction.java b/src/main/java/com/dropbox/core/v2/sharing/FolderAction.java index ec81d85c7..439654464 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/FolderAction.java +++ b/src/main/java/com/dropbox/core/v2/sharing/FolderAction.java @@ -1,36 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Actions that may be taken on shared folders. */ -@JsonSerialize(using=FolderAction.Serializer.class) -@JsonDeserialize(using=FolderAction.Deserializer.class) public enum FolderAction { // union FolderAction /** @@ -74,75 +60,103 @@ public enum FolderAction { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(FolderAction.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(FolderAction value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(FolderAction value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case CHANGE_OPTIONS: + case CHANGE_OPTIONS: { g.writeString("change_options"); break; - case EDIT_CONTENTS: + } + case EDIT_CONTENTS: { g.writeString("edit_contents"); break; - case INVITE_EDITOR: + } + case INVITE_EDITOR: { g.writeString("invite_editor"); break; - case INVITE_VIEWER: + } + case INVITE_VIEWER: { g.writeString("invite_viewer"); break; - case RELINQUISH_MEMBERSHIP: + } + case RELINQUISH_MEMBERSHIP: { g.writeString("relinquish_membership"); break; - case UNMOUNT: + } + case UNMOUNT: { g.writeString("unmount"); break; - case UNSHARE: + } + case UNSHARE: { g.writeString("unshare"); break; - case LEAVE_A_COPY: + } + case LEAVE_A_COPY: { g.writeString("leave_a_copy"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(FolderAction.class, getTagMapping(), FolderAction.OTHER); - } @Override - public FolderAction deserialize(FolderAction _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("change_options", FolderAction.CHANGE_OPTIONS); - values.put("edit_contents", FolderAction.EDIT_CONTENTS); - values.put("invite_editor", FolderAction.INVITE_EDITOR); - values.put("invite_viewer", FolderAction.INVITE_VIEWER); - values.put("relinquish_membership", FolderAction.RELINQUISH_MEMBERSHIP); - values.put("unmount", FolderAction.UNMOUNT); - values.put("unshare", FolderAction.UNSHARE); - values.put("leave_a_copy", FolderAction.LEAVE_A_COPY); - values.put("other", FolderAction.OTHER); - return Collections.unmodifiableMap(values); + public FolderAction deserialize(JsonParser p) throws IOException, JsonParseException { + FolderAction value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("change_options".equals(tag)) { + value = FolderAction.CHANGE_OPTIONS; + } + else if ("edit_contents".equals(tag)) { + value = FolderAction.EDIT_CONTENTS; + } + else if ("invite_editor".equals(tag)) { + value = FolderAction.INVITE_EDITOR; + } + else if ("invite_viewer".equals(tag)) { + value = FolderAction.INVITE_VIEWER; + } + else if ("relinquish_membership".equals(tag)) { + value = FolderAction.RELINQUISH_MEMBERSHIP; + } + else if ("unmount".equals(tag)) { + value = FolderAction.UNMOUNT; + } + else if ("unshare".equals(tag)) { + value = FolderAction.UNSHARE; + } + else if ("leave_a_copy".equals(tag)) { + value = FolderAction.LEAVE_A_COPY; + } + else { + value = FolderAction.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/FolderLinkMetadata.java b/src/main/java/com/dropbox/core/v2/sharing/FolderLinkMetadata.java index 16d91cd7d..e7f5edb96 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/FolderLinkMetadata.java +++ b/src/main/java/com/dropbox/core/v2/sharing/FolderLinkMetadata.java @@ -1,28 +1,17 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.dropbox.core.v2.users.Team; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.Date; @@ -30,15 +19,9 @@ /** * The metadata of a folder shared link */ -@JsonSerialize(using=FolderLinkMetadata.Serializer.class) -@JsonDeserialize(using=FolderLinkMetadata.Deserializer.class) public class FolderLinkMetadata extends SharedLinkMetadata { // struct FolderLinkMetadata - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * The metadata of a folder shared link @@ -160,7 +143,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -172,133 +155,121 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(FolderLinkMetadata.class); - } - - public Serializer(boolean unwrapping) { - super(FolderLinkMetadata.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(FolderLinkMetadata value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeStringField(".tag", "folder"); - g.writeObjectField("url", value.url); - g.writeObjectField("name", value.name); - g.writeObjectField("link_permissions", value.linkPermissions); + public void serialize(FolderLinkMetadata value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + writeTag("folder", g); + g.writeFieldName("url"); + StoneSerializers.string().serialize(value.url, g); + g.writeFieldName("name"); + StoneSerializers.string().serialize(value.name, g); + g.writeFieldName("link_permissions"); + LinkPermissions.Serializer.INSTANCE.serialize(value.linkPermissions, g); if (value.id != null) { - g.writeObjectField("id", value.id); + g.writeFieldName("id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.id, g); } if (value.expires != null) { - g.writeObjectField("expires", value.expires); + g.writeFieldName("expires"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.expires, g); } if (value.pathLower != null) { - g.writeObjectField("path_lower", value.pathLower); + g.writeFieldName("path_lower"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.pathLower, g); } if (value.teamMemberInfo != null) { - g.writeObjectField("team_member_info", value.teamMemberInfo); + g.writeFieldName("team_member_info"); + StoneSerializers.nullable(TeamMemberInfo.Serializer.INSTANCE).serialize(value.teamMemberInfo, g); } if (value.contentOwnerTeamInfo != null) { - g.writeObjectField("content_owner_team_info", value.contentOwnerTeamInfo); + g.writeFieldName("content_owner_team_info"); + StoneSerializers.nullable(Team.Serializer.INSTANCE).serialize(value.contentOwnerTeamInfo, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(FolderLinkMetadata.class); - } - - public Deserializer(boolean unwrapping) { - super(FolderLinkMetadata.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public FolderLinkMetadata deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - String _subtype_tag = readEnumeratedSubtypeTag(_p, "folder"); - - String url = null; - String name = null; - LinkPermissions linkPermissions = null; - String id = null; - Date expires = null; - String pathLower = null; - TeamMemberInfo teamMemberInfo = null; - Team contentOwnerTeamInfo = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("url".equals(_field)) { - url = getStringValue(_p); - _p.nextToken(); - } - else if ("name".equals(_field)) { - name = getStringValue(_p); - _p.nextToken(); + public FolderLinkMetadata deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + FolderLinkMetadata value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + if ("folder".equals(tag)) { + tag = null; } - else if ("link_permissions".equals(_field)) { - linkPermissions = _p.readValueAs(LinkPermissions.class); - _p.nextToken(); - } - else if ("id".equals(_field)) { - id = getStringValue(_p); - _p.nextToken(); - } - else if ("expires".equals(_field)) { - expires = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); - } - else if ("path_lower".equals(_field)) { - pathLower = getStringValue(_p); - _p.nextToken(); + } + if (tag == null) { + String f_url = null; + String f_name = null; + LinkPermissions f_linkPermissions = null; + String f_id = null; + Date f_expires = null; + String f_pathLower = null; + TeamMemberInfo f_teamMemberInfo = null; + Team f_contentOwnerTeamInfo = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("url".equals(field)) { + f_url = StoneSerializers.string().deserialize(p); + } + else if ("name".equals(field)) { + f_name = StoneSerializers.string().deserialize(p); + } + else if ("link_permissions".equals(field)) { + f_linkPermissions = LinkPermissions.Serializer.INSTANCE.deserialize(p); + } + else if ("id".equals(field)) { + f_id = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("expires".equals(field)) { + f_expires = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else if ("path_lower".equals(field)) { + f_pathLower = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("team_member_info".equals(field)) { + f_teamMemberInfo = StoneSerializers.nullable(TeamMemberInfo.Serializer.INSTANCE).deserialize(p); + } + else if ("content_owner_team_info".equals(field)) { + f_contentOwnerTeamInfo = StoneSerializers.nullable(Team.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); + } } - else if ("team_member_info".equals(_field)) { - teamMemberInfo = _p.readValueAs(TeamMemberInfo.class); - _p.nextToken(); + if (f_url == null) { + throw new JsonParseException(p, "Required field \"url\" missing."); } - else if ("content_owner_team_info".equals(_field)) { - contentOwnerTeamInfo = _p.readValueAs(Team.class); - _p.nextToken(); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } - else { - skipValue(_p); + if (f_linkPermissions == null) { + throw new JsonParseException(p, "Required field \"link_permissions\" missing."); } + value = new FolderLinkMetadata(f_url, f_name, f_linkPermissions, f_id, f_expires, f_pathLower, f_teamMemberInfo, f_contentOwnerTeamInfo); } - - if (url == null) { - throw new JsonParseException(_p, "Required field \"url\" is missing."); - } - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (linkPermissions == null) { - throw new JsonParseException(_p, "Required field \"link_permissions\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new FolderLinkMetadata(url, name, linkPermissions, id, expires, pathLower, teamMemberInfo, contentOwnerTeamInfo); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/FolderPermission.java b/src/main/java/com/dropbox/core/v2/sharing/FolderPermission.java index 0df84c69d..76a525e33 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/FolderPermission.java +++ b/src/main/java/com/dropbox/core/v2/sharing/FolderPermission.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Whether the user is allowed to take the action on the shared folder. */ -@JsonSerialize(using=FolderPermission.Serializer.class) -@JsonDeserialize(using=FolderPermission.Deserializer.class) public class FolderPermission { // struct FolderPermission - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final FolderAction action; protected final boolean allow; protected final PermissionDeniedReason reason; @@ -136,7 +119,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -148,95 +131,76 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(FolderPermission.class); - } - - public Serializer(boolean unwrapping) { - super(FolderPermission.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(FolderPermission value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("action", value.action); - g.writeObjectField("allow", value.allow); + public void serialize(FolderPermission value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("action"); + FolderAction.Serializer.INSTANCE.serialize(value.action, g); + g.writeFieldName("allow"); + StoneSerializers.boolean_().serialize(value.allow, g); if (value.reason != null) { - g.writeObjectField("reason", value.reason); + g.writeFieldName("reason"); + StoneSerializers.nullable(PermissionDeniedReason.Serializer.INSTANCE).serialize(value.reason, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(FolderPermission.class); - } - - public Deserializer(boolean unwrapping) { - super(FolderPermission.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public FolderPermission deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - FolderAction action = null; - Boolean allow = null; - PermissionDeniedReason reason = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("action".equals(_field)) { - action = _p.readValueAs(FolderAction.class); - _p.nextToken(); - } - else if ("allow".equals(_field)) { - allow = _p.getValueAsBoolean(); - _p.nextToken(); + public FolderPermission deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + FolderPermission value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + FolderAction f_action = null; + Boolean f_allow = null; + PermissionDeniedReason f_reason = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("action".equals(field)) { + f_action = FolderAction.Serializer.INSTANCE.deserialize(p); + } + else if ("allow".equals(field)) { + f_allow = StoneSerializers.boolean_().deserialize(p); + } + else if ("reason".equals(field)) { + f_reason = StoneSerializers.nullable(PermissionDeniedReason.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); + } } - else if ("reason".equals(_field)) { - reason = _p.readValueAs(PermissionDeniedReason.class); - _p.nextToken(); + if (f_action == null) { + throw new JsonParseException(p, "Required field \"action\" missing."); } - else { - skipValue(_p); + if (f_allow == null) { + throw new JsonParseException(p, "Required field \"allow\" missing."); } + value = new FolderPermission(f_action, f_allow, f_reason); } - - if (action == null) { - throw new JsonParseException(_p, "Required field \"action\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (allow == null) { - throw new JsonParseException(_p, "Required field \"allow\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new FolderPermission(action, allow, reason); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/FolderPolicy.java b/src/main/java/com/dropbox/core/v2/sharing/FolderPolicy.java index d38eb8789..61d25bb8a 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/FolderPolicy.java +++ b/src/main/java/com/dropbox/core/v2/sharing/FolderPolicy.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * A set of policies governing membership and privileges for a shared folder. */ -@JsonSerialize(using=FolderPolicy.Serializer.class) -@JsonDeserialize(using=FolderPolicy.Deserializer.class) public class FolderPolicy { // struct FolderPolicy - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final MemberPolicy memberPolicy; protected final MemberPolicy resolvedMemberPolicy; protected final AclUpdatePolicy aclUpdatePolicy; @@ -252,7 +235,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -264,103 +247,84 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(FolderPolicy.class); - } - - public Serializer(boolean unwrapping) { - super(FolderPolicy.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(FolderPolicy value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("acl_update_policy", value.aclUpdatePolicy); - g.writeObjectField("shared_link_policy", value.sharedLinkPolicy); + public void serialize(FolderPolicy value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("acl_update_policy"); + AclUpdatePolicy.Serializer.INSTANCE.serialize(value.aclUpdatePolicy, g); + g.writeFieldName("shared_link_policy"); + SharedLinkPolicy.Serializer.INSTANCE.serialize(value.sharedLinkPolicy, g); if (value.memberPolicy != null) { - g.writeObjectField("member_policy", value.memberPolicy); + g.writeFieldName("member_policy"); + StoneSerializers.nullable(MemberPolicy.Serializer.INSTANCE).serialize(value.memberPolicy, g); } if (value.resolvedMemberPolicy != null) { - g.writeObjectField("resolved_member_policy", value.resolvedMemberPolicy); + g.writeFieldName("resolved_member_policy"); + StoneSerializers.nullable(MemberPolicy.Serializer.INSTANCE).serialize(value.resolvedMemberPolicy, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(FolderPolicy.class); - } - - public Deserializer(boolean unwrapping) { - super(FolderPolicy.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public FolderPolicy deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - AclUpdatePolicy aclUpdatePolicy = null; - SharedLinkPolicy sharedLinkPolicy = null; - MemberPolicy memberPolicy = null; - MemberPolicy resolvedMemberPolicy = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("acl_update_policy".equals(_field)) { - aclUpdatePolicy = _p.readValueAs(AclUpdatePolicy.class); - _p.nextToken(); - } - else if ("shared_link_policy".equals(_field)) { - sharedLinkPolicy = _p.readValueAs(SharedLinkPolicy.class); - _p.nextToken(); - } - else if ("member_policy".equals(_field)) { - memberPolicy = _p.readValueAs(MemberPolicy.class); - _p.nextToken(); + public FolderPolicy deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + FolderPolicy value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + AclUpdatePolicy f_aclUpdatePolicy = null; + SharedLinkPolicy f_sharedLinkPolicy = null; + MemberPolicy f_memberPolicy = null; + MemberPolicy f_resolvedMemberPolicy = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("acl_update_policy".equals(field)) { + f_aclUpdatePolicy = AclUpdatePolicy.Serializer.INSTANCE.deserialize(p); + } + else if ("shared_link_policy".equals(field)) { + f_sharedLinkPolicy = SharedLinkPolicy.Serializer.INSTANCE.deserialize(p); + } + else if ("member_policy".equals(field)) { + f_memberPolicy = StoneSerializers.nullable(MemberPolicy.Serializer.INSTANCE).deserialize(p); + } + else if ("resolved_member_policy".equals(field)) { + f_resolvedMemberPolicy = StoneSerializers.nullable(MemberPolicy.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); + } } - else if ("resolved_member_policy".equals(_field)) { - resolvedMemberPolicy = _p.readValueAs(MemberPolicy.class); - _p.nextToken(); + if (f_aclUpdatePolicy == null) { + throw new JsonParseException(p, "Required field \"acl_update_policy\" missing."); } - else { - skipValue(_p); + if (f_sharedLinkPolicy == null) { + throw new JsonParseException(p, "Required field \"shared_link_policy\" missing."); } + value = new FolderPolicy(f_aclUpdatePolicy, f_sharedLinkPolicy, f_memberPolicy, f_resolvedMemberPolicy); } - - if (aclUpdatePolicy == null) { - throw new JsonParseException(_p, "Required field \"acl_update_policy\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (sharedLinkPolicy == null) { - throw new JsonParseException(_p, "Required field \"shared_link_policy\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new FolderPolicy(aclUpdatePolicy, sharedLinkPolicy, memberPolicy, resolvedMemberPolicy); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/GetMetadataArgs.java b/src/main/java/com/dropbox/core/v2/sharing/GetMetadataArgs.java index 744e60f86..f0b72e052 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/GetMetadataArgs.java +++ b/src/main/java/com/dropbox/core/v2/sharing/GetMetadataArgs.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=GetMetadataArgs.Serializer.class) -@JsonDeserialize(using=GetMetadataArgs.Deserializer.class) class GetMetadataArgs { // struct GetMetadataArgs - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String sharedFolderId; protected final List actions; @@ -125,7 +108,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -137,94 +120,67 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetMetadataArgs.class); - } - - public Serializer(boolean unwrapping) { - super(GetMetadataArgs.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(GetMetadataArgs value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("shared_folder_id", value.sharedFolderId); + public void serialize(GetMetadataArgs value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("shared_folder_id"); + StoneSerializers.string().serialize(value.sharedFolderId, g); if (value.actions != null) { - g.writeObjectField("actions", value.actions); + g.writeFieldName("actions"); + StoneSerializers.nullable(StoneSerializers.list(FolderAction.Serializer.INSTANCE)).serialize(value.actions, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetMetadataArgs.class); - } - - public Deserializer(boolean unwrapping) { - super(GetMetadataArgs.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public GetMetadataArgs deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String sharedFolderId = null; - List actions = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("shared_folder_id".equals(_field)) { - sharedFolderId = getStringValue(_p); - _p.nextToken(); - } - else if ("actions".equals(_field)) { - expectArrayStart(_p); - actions = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - FolderAction _x = null; - _x = _p.readValueAs(FolderAction.class); - _p.nextToken(); - actions.add(_x); + public GetMetadataArgs deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GetMetadataArgs value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_sharedFolderId = null; + List f_actions = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("shared_folder_id".equals(field)) { + f_sharedFolderId = StoneSerializers.string().deserialize(p); + } + else if ("actions".equals(field)) { + f_actions = StoneSerializers.nullable(StoneSerializers.list(FolderAction.Serializer.INSTANCE)).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else { - skipValue(_p); + if (f_sharedFolderId == null) { + throw new JsonParseException(p, "Required field \"shared_folder_id\" missing."); } + value = new GetMetadataArgs(f_sharedFolderId, f_actions); } - - if (sharedFolderId == null) { - throw new JsonParseException(_p, "Required field \"shared_folder_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new GetMetadataArgs(sharedFolderId, actions); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinkFileBuilder.java b/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinkFileBuilder.java index 42e71879e..4e92160ef 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinkFileBuilder.java +++ b/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinkFileBuilder.java @@ -1,9 +1,11 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; +import com.dropbox.core.DbxDownloader; import com.dropbox.core.DbxException; +import com.dropbox.core.v2.DbxDownloadStyleBuilder; /** * The request builder returned by {@link @@ -12,27 +14,27 @@ *

Use this class to set optional request parameters and complete the * request.

*/ -public class GetSharedLinkFileBuilder extends com.dropbox.core.v2.DbxDownloadStyleBuilder { - private final DbxUserSharingRequests sharing; +public class GetSharedLinkFileBuilder extends DbxDownloadStyleBuilder { + private final DbxUserSharingRequests sharing_; private final GetSharedLinkMetadataArg.Builder getSharedLinkMetadataArgBuilder; /** * Creates a new instance of this builder. * - * @param sharing Dropbox namespace-specific client used to issue sharing + * @param sharing_ Dropbox namespace-specific client used to issue sharing * requests. * @param getSharedLinkMetadataArgBuilder Request argument builder. * * @return instsance of this builder */ - GetSharedLinkFileBuilder(DbxUserSharingRequests sharing, GetSharedLinkMetadataArg.Builder getSharedLinkMetadataArgBuilder) { - if (sharing == null) { - throw new NullPointerException("sharing"); + GetSharedLinkFileBuilder(DbxUserSharingRequests sharing_, GetSharedLinkMetadataArg.Builder getSharedLinkMetadataArgBuilder) { + if (sharing_ == null) { + throw new NullPointerException("sharing_"); } + this.sharing_ = sharing_; if (getSharedLinkMetadataArgBuilder == null) { throw new NullPointerException("getSharedLinkMetadataArgBuilder"); } - this.sharing = sharing; this.getSharedLinkMetadataArgBuilder = getSharedLinkMetadataArgBuilder; } @@ -42,7 +44,7 @@ public class GetSharedLinkFileBuilder extends com.dropbox.core.v2.DbxDownloadSty * @param path If the shared link is to a folder, this parameter can be * used to retrieve the metadata for a specific file or sub-folder in * this folder. A relative path should be used. Must match pattern - * "{@code /.*}". + * "{@code /(.|[\\r\\n])*}". * * @return this builder * @@ -68,8 +70,8 @@ public GetSharedLinkFileBuilder withLinkPassword(String linkPassword) { } @Override - public com.dropbox.core.DbxDownloader start() throws GetSharedLinkFileErrorException, DbxException { - GetSharedLinkMetadataArg arg = this.getSharedLinkMetadataArgBuilder.build(); - return sharing.getSharedLinkFile(arg); + public DbxDownloader start() throws GetSharedLinkFileErrorException, DbxException { + GetSharedLinkMetadataArg arg_ = this.getSharedLinkMetadataArgBuilder.build(); + return sharing_.getSharedLinkFile(arg_, getHeaders()); } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinkFileError.java b/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinkFileError.java index fcf9707b9..df05a4529 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinkFileError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinkFileError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=GetSharedLinkFileError.Serializer.class) -@JsonDeserialize(using=GetSharedLinkFileError.Deserializer.class) public enum GetSharedLinkFileError { // union GetSharedLinkFileError /** @@ -47,52 +33,74 @@ public enum GetSharedLinkFileError { */ SHARED_LINK_IS_DIRECTORY; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetSharedLinkFileError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GetSharedLinkFileError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(GetSharedLinkFileError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case SHARED_LINK_NOT_FOUND: + case SHARED_LINK_NOT_FOUND: { g.writeString("shared_link_not_found"); break; - case SHARED_LINK_ACCESS_DENIED: + } + case SHARED_LINK_ACCESS_DENIED: { g.writeString("shared_link_access_denied"); break; - case OTHER: + } + case OTHER: { g.writeString("other"); break; - case SHARED_LINK_IS_DIRECTORY: + } + case SHARED_LINK_IS_DIRECTORY: { g.writeString("shared_link_is_directory"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetSharedLinkFileError.class, getTagMapping(), null); - } @Override - public GetSharedLinkFileError deserialize(GetSharedLinkFileError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("shared_link_is_directory", GetSharedLinkFileError.SHARED_LINK_IS_DIRECTORY); - return Collections.unmodifiableMap(values); + public GetSharedLinkFileError deserialize(JsonParser p) throws IOException, JsonParseException { + GetSharedLinkFileError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("shared_link_not_found".equals(tag)) { + value = GetSharedLinkFileError.SHARED_LINK_NOT_FOUND; + } + else if ("shared_link_access_denied".equals(tag)) { + value = GetSharedLinkFileError.SHARED_LINK_ACCESS_DENIED; + } + else if ("other".equals(tag)) { + value = GetSharedLinkFileError.OTHER; + } + else if ("shared_link_is_directory".equals(tag)) { + value = GetSharedLinkFileError.SHARED_LINK_IS_DIRECTORY; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinkFileErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinkFileErrorException.java index e83efddc5..8f4dbd770 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinkFileErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinkFileErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinkMetadataArg.java b/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinkMetadataArg.java index aff5aaafc..5062fdc0f 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinkMetadataArg.java +++ b/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinkMetadataArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=GetSharedLinkMetadataArg.Serializer.class) -@JsonDeserialize(using=GetSharedLinkMetadataArg.Deserializer.class) public class GetSharedLinkMetadataArg { // struct GetSharedLinkMetadataArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String url; protected final String path; protected final String linkPassword; @@ -46,7 +29,7 @@ public class GetSharedLinkMetadataArg { * @param path If the shared link is to a folder, this parameter can be * used to retrieve the metadata for a specific file or sub-folder in * this folder. A relative path should be used. Must match pattern - * "{@code /.*}". + * "{@code /(.|[\\r\\n])*}". * @param linkPassword If the shared link has a password, this parameter * can be used. * @@ -59,7 +42,7 @@ public GetSharedLinkMetadataArg(String url, String path, String linkPassword) { } this.url = url; if (path != null) { - if (!java.util.regex.Pattern.matches("/.*", path)) { + if (!java.util.regex.Pattern.matches("/(.|[\\r\\n])*", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } } @@ -146,7 +129,7 @@ protected Builder(String url) { * @param path If the shared link is to a folder, this parameter can be * used to retrieve the metadata for a specific file or sub-folder * in this folder. A relative path should be used. Must match - * pattern "{@code /.*}". + * pattern "{@code /(.|[\\r\\n])*}". * * @return this builder * @@ -155,7 +138,7 @@ protected Builder(String url) { */ public Builder withPath(String path) { if (path != null) { - if (!java.util.regex.Pattern.matches("/.*", path)) { + if (!java.util.regex.Pattern.matches("/(.|[\\r\\n])*", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } } @@ -217,7 +200,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -229,94 +212,75 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetSharedLinkMetadataArg.class); - } - - public Serializer(boolean unwrapping) { - super(GetSharedLinkMetadataArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(GetSharedLinkMetadataArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("url", value.url); + public void serialize(GetSharedLinkMetadataArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("url"); + StoneSerializers.string().serialize(value.url, g); if (value.path != null) { - g.writeObjectField("path", value.path); + g.writeFieldName("path"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.path, g); } if (value.linkPassword != null) { - g.writeObjectField("link_password", value.linkPassword); + g.writeFieldName("link_password"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.linkPassword, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetSharedLinkMetadataArg.class); - } - - public Deserializer(boolean unwrapping) { - super(GetSharedLinkMetadataArg.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public GetSharedLinkMetadataArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String url = null; - String path = null; - String linkPassword = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("url".equals(_field)) { - url = getStringValue(_p); - _p.nextToken(); - } - else if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); - } - else if ("link_password".equals(_field)) { - linkPassword = getStringValue(_p); - _p.nextToken(); + public GetSharedLinkMetadataArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GetSharedLinkMetadataArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_url = null; + String f_path = null; + String f_linkPassword = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("url".equals(field)) { + f_url = StoneSerializers.string().deserialize(p); + } + else if ("path".equals(field)) { + f_path = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("link_password".equals(field)) { + f_linkPassword = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_url == null) { + throw new JsonParseException(p, "Required field \"url\" missing."); } + value = new GetSharedLinkMetadataArg(f_url, f_path, f_linkPassword); } - - if (url == null) { - throw new JsonParseException(_p, "Required field \"url\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new GetSharedLinkMetadataArg(url, path, linkPassword); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinkMetadataBuilder.java b/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinkMetadataBuilder.java index f924de87b..7cd3b21ca 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinkMetadataBuilder.java +++ b/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinkMetadataBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; @@ -13,26 +13,26 @@ * request.

*/ public class GetSharedLinkMetadataBuilder { - private final DbxUserSharingRequests sharing; + private final DbxUserSharingRequests sharing_; private final GetSharedLinkMetadataArg.Builder getSharedLinkMetadataArgBuilder; /** * Creates a new instance of this builder. * - * @param sharing Dropbox namespace-specific client used to issue sharing + * @param sharing_ Dropbox namespace-specific client used to issue sharing * requests. * @param getSharedLinkMetadataArgBuilder Request argument builder. * * @return instsance of this builder */ - GetSharedLinkMetadataBuilder(DbxUserSharingRequests sharing, GetSharedLinkMetadataArg.Builder getSharedLinkMetadataArgBuilder) { - if (sharing == null) { - throw new NullPointerException("sharing"); + GetSharedLinkMetadataBuilder(DbxUserSharingRequests sharing_, GetSharedLinkMetadataArg.Builder getSharedLinkMetadataArgBuilder) { + if (sharing_ == null) { + throw new NullPointerException("sharing_"); } + this.sharing_ = sharing_; if (getSharedLinkMetadataArgBuilder == null) { throw new NullPointerException("getSharedLinkMetadataArgBuilder"); } - this.sharing = sharing; this.getSharedLinkMetadataArgBuilder = getSharedLinkMetadataArgBuilder; } @@ -42,7 +42,7 @@ public class GetSharedLinkMetadataBuilder { * @param path If the shared link is to a folder, this parameter can be * used to retrieve the metadata for a specific file or sub-folder in * this folder. A relative path should be used. Must match pattern - * "{@code /.*}". + * "{@code /(.|[\\r\\n])*}". * * @return this builder * @@ -71,7 +71,7 @@ public GetSharedLinkMetadataBuilder withLinkPassword(String linkPassword) { * Issues the request. */ public SharedLinkMetadata start() throws SharedLinkErrorException, DbxException { - GetSharedLinkMetadataArg arg = this.getSharedLinkMetadataArgBuilder.build(); - return sharing.getSharedLinkMetadata(arg); + GetSharedLinkMetadataArg arg_ = this.getSharedLinkMetadataArgBuilder.build(); + return sharing_.getSharedLinkMetadata(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinksArg.java b/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinksArg.java index d54f1281b..51b0ee86a 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinksArg.java +++ b/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinksArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=GetSharedLinksArg.Serializer.class) -@JsonDeserialize(using=GetSharedLinksArg.Deserializer.class) class GetSharedLinksArg { // struct GetSharedLinksArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String path; /** @@ -86,7 +69,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -98,77 +81,58 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetSharedLinksArg.class); - } - - public Serializer(boolean unwrapping) { - super(GetSharedLinksArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(GetSharedLinksArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(GetSharedLinksArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } if (value.path != null) { - g.writeObjectField("path", value.path); + g.writeFieldName("path"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.path, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetSharedLinksArg.class); - } - - public Deserializer(boolean unwrapping) { - super(GetSharedLinksArg.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public GetSharedLinksArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String path = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); - } - else { - skipValue(_p); + public GetSharedLinksArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GetSharedLinksArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_path = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("path".equals(field)) { + f_path = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } + value = new GetSharedLinksArg(f_path); } - - - return new GetSharedLinksArg(path); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinksError.java b/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinksError.java index 1a4c3acc0..3ed840278 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinksError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinksError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=GetSharedLinksError.Serializer.class) -@JsonDeserialize(using=GetSharedLinksError.Deserializer.class) public final class GetSharedLinksError { // union GetSharedLinksError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link GetSharedLinksError}. */ @@ -196,7 +178,7 @@ else if (obj instanceof GetSharedLinksError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -208,76 +190,71 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); + return Serializer.INSTANCE.serialize(this, true); } - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetSharedLinksError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GetSharedLinksError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case PATH: + public void serialize(GetSharedLinksError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PATH: { g.writeStartObject(); - g.writeStringField(".tag", "path"); - if (value.pathValue != null) { - g.writeObjectField("path", value.pathValue); - } + writeTag("path", g); + g.writeFieldName("path"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.pathValue, g); g.writeEndObject(); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetSharedLinksError.class, getTagMapping(), Tag.OTHER); - } @Override - public GetSharedLinksError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case PATH: { - if (isObjectEnd(_p)) { - return GetSharedLinksError.path(); - } - String value = null; - expectField(_p, "path"); - value = getStringValue(_p); - _p.nextToken(); - return GetSharedLinksError.path(value); + public GetSharedLinksError deserialize(JsonParser p) throws IOException, JsonParseException { + GetSharedLinksError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("path".equals(tag)) { + String fieldValue = null; + if (p.getCurrentToken() != JsonToken.END_OBJECT) { + expectField("path", p); + fieldValue = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); } - case OTHER: { - return GetSharedLinksError.OTHER; + if (fieldValue == null) { + value = GetSharedLinksError.path(); + } + else { + value = GetSharedLinksError.path(fieldValue); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("path", GetSharedLinksError.Tag.PATH); - values.put("other", GetSharedLinksError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + value = GetSharedLinksError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinksErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinksErrorException.java index 287f278a0..28a43f25d 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinksErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinksErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinksResult.java b/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinksResult.java index 146cc4a93..d24eeeabc 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinksResult.java +++ b/src/main/java/com/dropbox/core/v2/sharing/GetSharedLinksResult.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=GetSharedLinksResult.Serializer.class) -@JsonDeserialize(using=GetSharedLinksResult.Deserializer.class) public class GetSharedLinksResult { // struct GetSharedLinksResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List links; /** @@ -91,7 +74,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -103,86 +86,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetSharedLinksResult.class); - } - - public Serializer(boolean unwrapping) { - super(GetSharedLinksResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GetSharedLinksResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("links", value.links); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetSharedLinksResult.class); - } - - public Deserializer(boolean unwrapping) { - super(GetSharedLinksResult.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GetSharedLinksResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("links"); + StoneSerializers.list(LinkMetadata.Serializer.INSTANCE).serialize(value.links, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GetSharedLinksResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List links = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("links".equals(_field)) { - expectArrayStart(_p); - links = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - LinkMetadata _x = null; - _x = _p.readValueAs(LinkMetadata.class); - _p.nextToken(); - links.add(_x); + public GetSharedLinksResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GetSharedLinksResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_links = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("links".equals(field)) { + f_links = StoneSerializers.list(LinkMetadata.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else { - skipValue(_p); + if (f_links == null) { + throw new JsonParseException(p, "Required field \"links\" missing."); } + value = new GetSharedLinksResult(f_links); } - - if (links == null) { - throw new JsonParseException(_p, "Required field \"links\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new GetSharedLinksResult(links); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/GroupInfo.java b/src/main/java/com/dropbox/core/v2/sharing/GroupInfo.java index 2d3c5a769..034739766 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/GroupInfo.java +++ b/src/main/java/com/dropbox/core/v2/sharing/GroupInfo.java @@ -1,29 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; -import com.dropbox.core.v2.team.GroupSummary; -import com.dropbox.core.v2.team.GroupType; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; +import com.dropbox.core.v2.teamcommon.GroupSummary; +import com.dropbox.core.v2.teamcommon.GroupType; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; @@ -31,16 +20,11 @@ * The information about a group. Groups is a way to manage a list of users who * need same access permission to the shared folder. */ -@JsonSerialize(using=GroupInfo.Serializer.class) -@JsonDeserialize(using=GroupInfo.Deserializer.class) public class GroupInfo extends GroupSummary { // struct GroupInfo - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final GroupType groupType; + protected final boolean isOwner; protected final boolean sameTeam; /** @@ -53,6 +37,7 @@ public class GroupInfo extends GroupSummary { * @param groupName Must not be {@code null}. * @param groupId Must not be {@code null}. * @param groupType The type of group. Must not be {@code null}. + * @param isOwner If the current user is an owner of the group. * @param sameTeam If the group is owned by the current user's team. * @param groupExternalId External ID of group. This is an arbitrary ID * that an admin can attach to a group. @@ -61,12 +46,13 @@ public class GroupInfo extends GroupSummary { * @throws IllegalArgumentException If any argument does not meet its * preconditions. */ - public GroupInfo(String groupName, String groupId, GroupType groupType, boolean sameTeam, String groupExternalId, Long memberCount) { + public GroupInfo(String groupName, String groupId, GroupType groupType, boolean isOwner, boolean sameTeam, String groupExternalId, Long memberCount) { super(groupName, groupId, groupExternalId, memberCount); if (groupType == null) { throw new IllegalArgumentException("Required value for 'groupType' is null"); } this.groupType = groupType; + this.isOwner = isOwner; this.sameTeam = sameTeam; } @@ -79,13 +65,14 @@ public GroupInfo(String groupName, String groupId, GroupType groupType, boolean * @param groupName Must not be {@code null}. * @param groupId Must not be {@code null}. * @param groupType The type of group. Must not be {@code null}. + * @param isOwner If the current user is an owner of the group. * @param sameTeam If the group is owned by the current user's team. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. */ - public GroupInfo(String groupName, String groupId, GroupType groupType, boolean sameTeam) { - this(groupName, groupId, groupType, sameTeam, null, null); + public GroupInfo(String groupName, String groupId, GroupType groupType, boolean isOwner, boolean sameTeam) { + this(groupName, groupId, groupType, isOwner, sameTeam, null, null); } /** @@ -97,6 +84,15 @@ public GroupType getGroupType() { return groupType; } + /** + * If the current user is an owner of the group. + * + * @return value for this field. + */ + public boolean getIsOwner() { + return isOwner; + } + /** * If the group is owned by the current user's team. * @@ -112,6 +108,7 @@ public boolean getSameTeam() { * @param groupName Must not be {@code null}. * @param groupId Must not be {@code null}. * @param groupType The type of group. Must not be {@code null}. + * @param isOwner If the current user is an owner of the group. * @param sameTeam If the group is owned by the current user's team. * * @return builder for this class. @@ -119,8 +116,8 @@ public boolean getSameTeam() { * @throws IllegalArgumentException If any argument does not meet its * preconditions. */ - public static Builder newBuilder(String groupName, String groupId, GroupType groupType, boolean sameTeam) { - return new Builder(groupName, groupId, groupType, sameTeam); + public static Builder newBuilder(String groupName, String groupId, GroupType groupType, boolean isOwner, boolean sameTeam) { + return new Builder(groupName, groupId, groupType, isOwner, sameTeam); } /** @@ -128,14 +125,16 @@ public static Builder newBuilder(String groupName, String groupId, GroupType gro */ public static class Builder extends GroupSummary.Builder { protected final GroupType groupType; + protected final boolean isOwner; protected final boolean sameTeam; - protected Builder(String groupName, String groupId, GroupType groupType, boolean sameTeam) { + protected Builder(String groupName, String groupId, GroupType groupType, boolean isOwner, boolean sameTeam) { super(groupName, groupId); if (groupType == null) { throw new IllegalArgumentException("Required value for 'groupType' is null"); } this.groupType = groupType; + this.isOwner = isOwner; this.sameTeam = sameTeam; } @@ -146,7 +145,7 @@ protected Builder(String groupName, String groupId, GroupType groupType, boolean * @return new instance of {@link GroupInfo} */ public GroupInfo build() { - return new GroupInfo(groupName, groupId, groupType, sameTeam, groupExternalId, memberCount); + return new GroupInfo(groupName, groupId, groupType, isOwner, sameTeam, groupExternalId, memberCount); } } @@ -154,6 +153,7 @@ public GroupInfo build() { public int hashCode() { int hash = java.util.Arrays.hashCode(new Object [] { groupType, + isOwner, sameTeam }); hash = (31 * super.hashCode()) + hash; @@ -171,6 +171,7 @@ else if (obj.getClass().equals(this.getClass())) { return ((this.groupName == other.groupName) || (this.groupName.equals(other.groupName))) && ((this.groupId == other.groupId) || (this.groupId.equals(other.groupId))) && ((this.groupType == other.groupType) || (this.groupType.equals(other.groupType))) + && (this.isOwner == other.isOwner) && (this.sameTeam == other.sameTeam) && ((this.groupExternalId == other.groupExternalId) || (this.groupExternalId != null && this.groupExternalId.equals(other.groupExternalId))) && ((this.memberCount == other.memberCount) || (this.memberCount != null && this.memberCount.equals(other.memberCount))) @@ -183,7 +184,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -195,125 +196,111 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); + return Serializer.INSTANCE.serialize(this, true); } - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupInfo.class); - } - - public Serializer(boolean unwrapping) { - super(GroupInfo.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(GroupInfo value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("group_name", value.groupName); - g.writeObjectField("group_id", value.groupId); - g.writeObjectField("group_type", value.groupType); - g.writeObjectField("same_team", value.sameTeam); + public void serialize(GroupInfo value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("group_name"); + StoneSerializers.string().serialize(value.groupName, g); + g.writeFieldName("group_id"); + StoneSerializers.string().serialize(value.groupId, g); + g.writeFieldName("group_type"); + GroupType.Serializer.INSTANCE.serialize(value.groupType, g); + g.writeFieldName("is_owner"); + StoneSerializers.boolean_().serialize(value.isOwner, g); + g.writeFieldName("same_team"); + StoneSerializers.boolean_().serialize(value.sameTeam, g); if (value.groupExternalId != null) { - g.writeObjectField("group_external_id", value.groupExternalId); + g.writeFieldName("group_external_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.groupExternalId, g); } if (value.memberCount != null) { - g.writeObjectField("member_count", value.memberCount); + g.writeFieldName("member_count"); + StoneSerializers.nullable(StoneSerializers.uInt32()).serialize(value.memberCount, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupInfo.class); - } - - public Deserializer(boolean unwrapping) { - super(GroupInfo.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public GroupInfo deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String groupName = null; - String groupId = null; - GroupType groupType = null; - Boolean sameTeam = null; - String groupExternalId = null; - Long memberCount = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("group_name".equals(_field)) { - groupName = getStringValue(_p); - _p.nextToken(); - } - else if ("group_id".equals(_field)) { - groupId = getStringValue(_p); - _p.nextToken(); + public GroupInfo deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GroupInfo value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_groupName = null; + String f_groupId = null; + GroupType f_groupType = null; + Boolean f_isOwner = null; + Boolean f_sameTeam = null; + String f_groupExternalId = null; + Long f_memberCount = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("group_name".equals(field)) { + f_groupName = StoneSerializers.string().deserialize(p); + } + else if ("group_id".equals(field)) { + f_groupId = StoneSerializers.string().deserialize(p); + } + else if ("group_type".equals(field)) { + f_groupType = GroupType.Serializer.INSTANCE.deserialize(p); + } + else if ("is_owner".equals(field)) { + f_isOwner = StoneSerializers.boolean_().deserialize(p); + } + else if ("same_team".equals(field)) { + f_sameTeam = StoneSerializers.boolean_().deserialize(p); + } + else if ("group_external_id".equals(field)) { + f_groupExternalId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("member_count".equals(field)) { + f_memberCount = StoneSerializers.nullable(StoneSerializers.uInt32()).deserialize(p); + } + else { + skipValue(p); + } } - else if ("group_type".equals(_field)) { - groupType = _p.readValueAs(GroupType.class); - _p.nextToken(); + if (f_groupName == null) { + throw new JsonParseException(p, "Required field \"group_name\" missing."); } - else if ("same_team".equals(_field)) { - sameTeam = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_groupId == null) { + throw new JsonParseException(p, "Required field \"group_id\" missing."); } - else if ("group_external_id".equals(_field)) { - groupExternalId = getStringValue(_p); - _p.nextToken(); + if (f_groupType == null) { + throw new JsonParseException(p, "Required field \"group_type\" missing."); } - else if ("member_count".equals(_field)) { - memberCount = _p.getLongValue(); - assertUnsigned(_p, memberCount); - if (memberCount > Integer.MAX_VALUE) { - throw new JsonParseException(_p, "expecting a 32-bit unsigned integer, got: " + memberCount); - } - _p.nextToken(); + if (f_isOwner == null) { + throw new JsonParseException(p, "Required field \"is_owner\" missing."); } - else { - skipValue(_p); + if (f_sameTeam == null) { + throw new JsonParseException(p, "Required field \"same_team\" missing."); } + value = new GroupInfo(f_groupName, f_groupId, f_groupType, f_isOwner, f_sameTeam, f_groupExternalId, f_memberCount); } - - if (groupName == null) { - throw new JsonParseException(_p, "Required field \"group_name\" is missing."); - } - if (groupId == null) { - throw new JsonParseException(_p, "Required field \"group_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (groupType == null) { - throw new JsonParseException(_p, "Required field \"group_type\" is missing."); - } - if (sameTeam == null) { - throw new JsonParseException(_p, "Required field \"same_team\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new GroupInfo(groupName, groupId, groupType, sameTeam, groupExternalId, memberCount); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/GroupMembershipInfo.java b/src/main/java/com/dropbox/core/v2/sharing/GroupMembershipInfo.java index 08759b439..e78ff7f10 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/GroupMembershipInfo.java +++ b/src/main/java/com/dropbox/core/v2/sharing/GroupMembershipInfo.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; @@ -29,15 +18,9 @@ /** * The information about a group member of the shared folder. */ -@JsonSerialize(using=GroupMembershipInfo.Serializer.class) -@JsonDeserialize(using=GroupMembershipInfo.Deserializer.class) public class GroupMembershipInfo extends MembershipInfo { // struct GroupMembershipInfo - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final GroupInfo group; /** @@ -167,7 +150,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -179,117 +162,90 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupMembershipInfo.class); - } - - public Serializer(boolean unwrapping) { - super(GroupMembershipInfo.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(GroupMembershipInfo value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("access_type", value.accessType); - g.writeObjectField("group", value.group); + public void serialize(GroupMembershipInfo value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("access_type"); + AccessLevel.Serializer.INSTANCE.serialize(value.accessType, g); + g.writeFieldName("group"); + GroupInfo.Serializer.INSTANCE.serialize(value.group, g); if (value.permissions != null) { - g.writeObjectField("permissions", value.permissions); + g.writeFieldName("permissions"); + StoneSerializers.nullable(StoneSerializers.list(MemberPermission.Serializer.INSTANCE)).serialize(value.permissions, g); } if (value.initials != null) { - g.writeObjectField("initials", value.initials); + g.writeFieldName("initials"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.initials, g); + } + g.writeFieldName("is_inherited"); + StoneSerializers.boolean_().serialize(value.isInherited, g); + if (!collapse) { + g.writeEndObject(); } - g.writeObjectField("is_inherited", value.isInherited); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupMembershipInfo.class); - } - - public Deserializer(boolean unwrapping) { - super(GroupMembershipInfo.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public GroupMembershipInfo deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - AccessLevel accessType = null; - GroupInfo group = null; - List permissions = null; - String initials = null; - boolean isInherited = false; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("access_type".equals(_field)) { - accessType = _p.readValueAs(AccessLevel.class); - _p.nextToken(); - } - else if ("group".equals(_field)) { - group = _p.readValueAs(GroupInfo.class); - _p.nextToken(); - } - else if ("permissions".equals(_field)) { - expectArrayStart(_p); - permissions = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - MemberPermission _x = null; - _x = _p.readValueAs(MemberPermission.class); - _p.nextToken(); - permissions.add(_x); + public GroupMembershipInfo deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GroupMembershipInfo value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + AccessLevel f_accessType = null; + GroupInfo f_group = null; + List f_permissions = null; + String f_initials = null; + Boolean f_isInherited = false; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("access_type".equals(field)) { + f_accessType = AccessLevel.Serializer.INSTANCE.deserialize(p); + } + else if ("group".equals(field)) { + f_group = GroupInfo.Serializer.INSTANCE.deserialize(p); + } + else if ("permissions".equals(field)) { + f_permissions = StoneSerializers.nullable(StoneSerializers.list(MemberPermission.Serializer.INSTANCE)).deserialize(p); + } + else if ("initials".equals(field)) { + f_initials = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("is_inherited".equals(field)) { + f_isInherited = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("initials".equals(_field)) { - initials = getStringValue(_p); - _p.nextToken(); } - else if ("is_inherited".equals(_field)) { - isInherited = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_accessType == null) { + throw new JsonParseException(p, "Required field \"access_type\" missing."); } - else { - skipValue(_p); + if (f_group == null) { + throw new JsonParseException(p, "Required field \"group\" missing."); } + value = new GroupMembershipInfo(f_accessType, f_group, f_permissions, f_initials, f_isInherited); } - - if (accessType == null) { - throw new JsonParseException(_p, "Required field \"access_type\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (group == null) { - throw new JsonParseException(_p, "Required field \"group\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new GroupMembershipInfo(accessType, group, permissions, initials, isInherited); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/InviteeInfo.java b/src/main/java/com/dropbox/core/v2/sharing/InviteeInfo.java index 2b19e0c3e..550c37c51 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/InviteeInfo.java +++ b/src/main/java/com/dropbox/core/v2/sharing/InviteeInfo.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Information about the recipient of a shared folder invitation. @@ -38,15 +26,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=InviteeInfo.Serializer.class) -@JsonDeserialize(using=InviteeInfo.Deserializer.class) public final class InviteeInfo { // union InviteeInfo - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link InviteeInfo}. */ @@ -209,7 +191,7 @@ else if (obj instanceof InviteeInfo) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -221,71 +203,64 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(InviteeInfo.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(InviteeInfo value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case EMAIL: + public void serialize(InviteeInfo value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case EMAIL: { g.writeStartObject(); - g.writeStringField(".tag", "email"); - g.writeObjectField("email", value.emailValue); + writeTag("email", g); + g.writeFieldName("email"); + StoneSerializers.string().serialize(value.emailValue, g); g.writeEndObject(); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(InviteeInfo.class, getTagMapping(), Tag.OTHER); - } @Override - public InviteeInfo deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case EMAIL: { - String value = null; - expectField(_p, "email"); - value = getStringValue(_p); - _p.nextToken(); - return InviteeInfo.email(value); - } - case OTHER: { - return InviteeInfo.OTHER; - } + public InviteeInfo deserialize(JsonParser p) throws IOException, JsonParseException { + InviteeInfo value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("email", InviteeInfo.Tag.EMAIL); - values.put("other", InviteeInfo.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("email".equals(tag)) { + String fieldValue = null; + expectField("email", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = InviteeInfo.email(fieldValue); + } + else { + value = InviteeInfo.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/InviteeMembershipInfo.java b/src/main/java/com/dropbox/core/v2/sharing/InviteeMembershipInfo.java index 103bff8f5..5bfda68e2 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/InviteeMembershipInfo.java +++ b/src/main/java/com/dropbox/core/v2/sharing/InviteeMembershipInfo.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; @@ -29,15 +18,9 @@ /** * Information about an invited member of a shared folder. */ -@JsonSerialize(using=InviteeMembershipInfo.Serializer.class) -@JsonDeserialize(using=InviteeMembershipInfo.Deserializer.class) public class InviteeMembershipInfo extends MembershipInfo { // struct InviteeMembershipInfo - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final InviteeInfo invitee; protected final UserInfo user; @@ -193,7 +176,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -205,125 +188,98 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(InviteeMembershipInfo.class); - } - - public Serializer(boolean unwrapping) { - super(InviteeMembershipInfo.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(InviteeMembershipInfo value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("access_type", value.accessType); - g.writeObjectField("invitee", value.invitee); + public void serialize(InviteeMembershipInfo value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("access_type"); + AccessLevel.Serializer.INSTANCE.serialize(value.accessType, g); + g.writeFieldName("invitee"); + InviteeInfo.Serializer.INSTANCE.serialize(value.invitee, g); if (value.permissions != null) { - g.writeObjectField("permissions", value.permissions); + g.writeFieldName("permissions"); + StoneSerializers.nullable(StoneSerializers.list(MemberPermission.Serializer.INSTANCE)).serialize(value.permissions, g); } if (value.initials != null) { - g.writeObjectField("initials", value.initials); + g.writeFieldName("initials"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.initials, g); } - g.writeObjectField("is_inherited", value.isInherited); + g.writeFieldName("is_inherited"); + StoneSerializers.boolean_().serialize(value.isInherited, g); if (value.user != null) { - g.writeObjectField("user", value.user); + g.writeFieldName("user"); + StoneSerializers.nullable(UserInfo.Serializer.INSTANCE).serialize(value.user, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(InviteeMembershipInfo.class); - } - - public Deserializer(boolean unwrapping) { - super(InviteeMembershipInfo.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public InviteeMembershipInfo deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - AccessLevel accessType = null; - InviteeInfo invitee = null; - List permissions = null; - String initials = null; - boolean isInherited = false; - UserInfo user = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("access_type".equals(_field)) { - accessType = _p.readValueAs(AccessLevel.class); - _p.nextToken(); - } - else if ("invitee".equals(_field)) { - invitee = _p.readValueAs(InviteeInfo.class); - _p.nextToken(); - } - else if ("permissions".equals(_field)) { - expectArrayStart(_p); - permissions = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - MemberPermission _x = null; - _x = _p.readValueAs(MemberPermission.class); - _p.nextToken(); - permissions.add(_x); + public InviteeMembershipInfo deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + InviteeMembershipInfo value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + AccessLevel f_accessType = null; + InviteeInfo f_invitee = null; + List f_permissions = null; + String f_initials = null; + Boolean f_isInherited = false; + UserInfo f_user = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("access_type".equals(field)) { + f_accessType = AccessLevel.Serializer.INSTANCE.deserialize(p); + } + else if ("invitee".equals(field)) { + f_invitee = InviteeInfo.Serializer.INSTANCE.deserialize(p); + } + else if ("permissions".equals(field)) { + f_permissions = StoneSerializers.nullable(StoneSerializers.list(MemberPermission.Serializer.INSTANCE)).deserialize(p); + } + else if ("initials".equals(field)) { + f_initials = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("is_inherited".equals(field)) { + f_isInherited = StoneSerializers.boolean_().deserialize(p); + } + else if ("user".equals(field)) { + f_user = StoneSerializers.nullable(UserInfo.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("initials".equals(_field)) { - initials = getStringValue(_p); - _p.nextToken(); - } - else if ("is_inherited".equals(_field)) { - isInherited = _p.getValueAsBoolean(); - _p.nextToken(); } - else if ("user".equals(_field)) { - user = _p.readValueAs(UserInfo.class); - _p.nextToken(); + if (f_accessType == null) { + throw new JsonParseException(p, "Required field \"access_type\" missing."); } - else { - skipValue(_p); + if (f_invitee == null) { + throw new JsonParseException(p, "Required field \"invitee\" missing."); } + value = new InviteeMembershipInfo(f_accessType, f_invitee, f_permissions, f_initials, f_isInherited, f_user); } - - if (accessType == null) { - throw new JsonParseException(_p, "Required field \"access_type\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (invitee == null) { - throw new JsonParseException(_p, "Required field \"invitee\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new InviteeMembershipInfo(accessType, invitee, permissions, initials, isInherited, user); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/JobError.java b/src/main/java/com/dropbox/core/v2/sharing/JobError.java index 6737e35e8..db5f6c355 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/JobError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/JobError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Error occurred while performing an asynchronous job from {@link @@ -40,15 +28,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=JobError.Serializer.class) -@JsonDeserialize(using=JobError.Deserializer.class) public final class JobError { // union JobError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link JobError}. */ @@ -64,6 +46,11 @@ public enum Tag { * action. */ REMOVE_FOLDER_MEMBER_ERROR, // RemoveFolderMemberError + /** + * Error occurred while performing {@link + * DbxUserSharingRequests#relinquishFolderMembership(String)} action. + */ + RELINQUISH_FOLDER_MEMBERSHIP_ERROR, // RelinquishFolderMembershipError /** * Catch-all used for unknown tag values returned by the Dropbox * servers. @@ -82,11 +69,12 @@ public enum Tag { * not up to date. Consider updating your SDK version to handle the new * tags.

*/ - public static final JobError OTHER = new JobError(Tag.OTHER, null, null); + public static final JobError OTHER = new JobError(Tag.OTHER, null, null, null); private final Tag tag; private final UnshareFolderError unshareFolderErrorValue; private final RemoveFolderMemberError removeFolderMemberErrorValue; + private final RelinquishFolderMembershipError relinquishFolderMembershipErrorValue; /** * Error occurred while performing an asynchronous job from {@link @@ -95,10 +83,11 @@ public enum Tag { * * @param tag Discriminating tag for this instance. */ - private JobError(Tag tag, UnshareFolderError unshareFolderErrorValue, RemoveFolderMemberError removeFolderMemberErrorValue) { + private JobError(Tag tag, UnshareFolderError unshareFolderErrorValue, RemoveFolderMemberError removeFolderMemberErrorValue, RelinquishFolderMembershipError relinquishFolderMembershipErrorValue) { this.tag = tag; this.unshareFolderErrorValue = unshareFolderErrorValue; this.removeFolderMemberErrorValue = removeFolderMemberErrorValue; + this.relinquishFolderMembershipErrorValue = relinquishFolderMembershipErrorValue; } /** @@ -148,7 +137,7 @@ public static JobError unshareFolderError(UnshareFolderError value) { if (value == null) { throw new IllegalArgumentException("Value is null"); } - return new JobError(Tag.UNSHARE_FOLDER_ERROR, value, null); + return new JobError(Tag.UNSHARE_FOLDER_ERROR, value, null, null); } /** @@ -201,7 +190,7 @@ public static JobError removeFolderMemberError(RemoveFolderMemberError value) { if (value == null) { throw new IllegalArgumentException("Value is null"); } - return new JobError(Tag.REMOVE_FOLDER_MEMBER_ERROR, null, value); + return new JobError(Tag.REMOVE_FOLDER_MEMBER_ERROR, null, value, null); } /** @@ -226,6 +215,59 @@ public RemoveFolderMemberError getRemoveFolderMemberErrorValue() { return removeFolderMemberErrorValue; } + /** + * Returns {@code true} if this instance has the tag {@link + * Tag#RELINQUISH_FOLDER_MEMBERSHIP_ERROR}, {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link + * Tag#RELINQUISH_FOLDER_MEMBERSHIP_ERROR}, {@code false} otherwise. + */ + public boolean isRelinquishFolderMembershipError() { + return this.tag == Tag.RELINQUISH_FOLDER_MEMBERSHIP_ERROR; + } + + /** + * Returns an instance of {@code JobError} that has its tag set to {@link + * Tag#RELINQUISH_FOLDER_MEMBERSHIP_ERROR}. + * + *

Error occurred while performing {@link + * DbxUserSharingRequests#relinquishFolderMembership(String)} action.

+ * + * @param value value to assign to this instance. + * + * @return Instance of {@code JobError} with its tag set to {@link + * Tag#RELINQUISH_FOLDER_MEMBERSHIP_ERROR}. + * + * @throws IllegalArgumentException if {@code value} is {@code null}. + */ + public static JobError relinquishFolderMembershipError(RelinquishFolderMembershipError value) { + if (value == null) { + throw new IllegalArgumentException("Value is null"); + } + return new JobError(Tag.RELINQUISH_FOLDER_MEMBERSHIP_ERROR, null, null, value); + } + + /** + * Error occurred while performing {@link + * DbxUserSharingRequests#relinquishFolderMembership(String)} action. + * + *

This instance must be tagged as {@link + * Tag#RELINQUISH_FOLDER_MEMBERSHIP_ERROR}.

+ * + * @return The {@link JobError#relinquishFolderMembershipError} value + * associated with this instance if {@link + * #isRelinquishFolderMembershipError} is {@code true}. + * + * @throws IllegalStateException If {@link + * #isRelinquishFolderMembershipError} is {@code false}. + */ + public RelinquishFolderMembershipError getRelinquishFolderMembershipErrorValue() { + if (this.tag != Tag.RELINQUISH_FOLDER_MEMBERSHIP_ERROR) { + throw new IllegalStateException("Invalid tag: required Tag.RELINQUISH_FOLDER_MEMBERSHIP_ERROR, but was Tag." + tag.name()); + } + return relinquishFolderMembershipErrorValue; + } + /** * Returns {@code true} if this instance has the tag {@link Tag#OTHER}, * {@code false} otherwise. @@ -242,7 +284,8 @@ public int hashCode() { int hash = java.util.Arrays.hashCode(new Object [] { tag, unshareFolderErrorValue, - removeFolderMemberErrorValue + removeFolderMemberErrorValue, + relinquishFolderMembershipErrorValue }); return hash; } @@ -262,6 +305,8 @@ else if (obj instanceof JobError) { return (this.unshareFolderErrorValue == other.unshareFolderErrorValue) || (this.unshareFolderErrorValue.equals(other.unshareFolderErrorValue)); case REMOVE_FOLDER_MEMBER_ERROR: return (this.removeFolderMemberErrorValue == other.removeFolderMemberErrorValue) || (this.removeFolderMemberErrorValue.equals(other.removeFolderMemberErrorValue)); + case RELINQUISH_FOLDER_MEMBERSHIP_ERROR: + return (this.relinquishFolderMembershipErrorValue == other.relinquishFolderMembershipErrorValue) || (this.relinquishFolderMembershipErrorValue.equals(other.relinquishFolderMembershipErrorValue)); case OTHER: return true; default: @@ -275,7 +320,7 @@ else if (obj instanceof JobError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -287,85 +332,92 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(JobError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(JobError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case UNSHARE_FOLDER_ERROR: + public void serialize(JobError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case UNSHARE_FOLDER_ERROR: { g.writeStartObject(); - g.writeStringField(".tag", "unshare_folder_error"); - g.writeObjectField("unshare_folder_error", value.unshareFolderErrorValue); + writeTag("unshare_folder_error", g); + g.writeFieldName("unshare_folder_error"); + UnshareFolderError.Serializer.INSTANCE.serialize(value.unshareFolderErrorValue, g); g.writeEndObject(); break; - case REMOVE_FOLDER_MEMBER_ERROR: + } + case REMOVE_FOLDER_MEMBER_ERROR: { g.writeStartObject(); - g.writeStringField(".tag", "remove_folder_member_error"); - g.writeObjectField("remove_folder_member_error", value.removeFolderMemberErrorValue); + writeTag("remove_folder_member_error", g); + g.writeFieldName("remove_folder_member_error"); + RemoveFolderMemberError.Serializer.INSTANCE.serialize(value.removeFolderMemberErrorValue, g); g.writeEndObject(); break; - case OTHER: - g.writeString("other"); - break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(JobError.class, getTagMapping(), Tag.OTHER); - } - - @Override - public JobError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case UNSHARE_FOLDER_ERROR: { - UnshareFolderError value = null; - expectField(_p, "unshare_folder_error"); - value = _p.readValueAs(UnshareFolderError.class); - _p.nextToken(); - return JobError.unshareFolderError(value); } - case REMOVE_FOLDER_MEMBER_ERROR: { - RemoveFolderMemberError value = null; - expectField(_p, "remove_folder_member_error"); - value = _p.readValueAs(RemoveFolderMemberError.class); - _p.nextToken(); - return JobError.removeFolderMemberError(value); + case RELINQUISH_FOLDER_MEMBERSHIP_ERROR: { + g.writeStartObject(); + writeTag("relinquish_folder_membership_error", g); + g.writeFieldName("relinquish_folder_membership_error"); + RelinquishFolderMembershipError.Serializer.INSTANCE.serialize(value.relinquishFolderMembershipErrorValue, g); + g.writeEndObject(); + break; } - case OTHER: { - return JobError.OTHER; + default: { + g.writeString("other"); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("unshare_folder_error", JobError.Tag.UNSHARE_FOLDER_ERROR); - values.put("remove_folder_member_error", JobError.Tag.REMOVE_FOLDER_MEMBER_ERROR); - values.put("other", JobError.Tag.OTHER); - return Collections.unmodifiableMap(values); + @Override + public JobError deserialize(JsonParser p) throws IOException, JsonParseException { + JobError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("unshare_folder_error".equals(tag)) { + UnshareFolderError fieldValue = null; + expectField("unshare_folder_error", p); + fieldValue = UnshareFolderError.Serializer.INSTANCE.deserialize(p); + value = JobError.unshareFolderError(fieldValue); + } + else if ("remove_folder_member_error".equals(tag)) { + RemoveFolderMemberError fieldValue = null; + expectField("remove_folder_member_error", p); + fieldValue = RemoveFolderMemberError.Serializer.INSTANCE.deserialize(p); + value = JobError.removeFolderMemberError(fieldValue); + } + else if ("relinquish_folder_membership_error".equals(tag)) { + RelinquishFolderMembershipError fieldValue = null; + expectField("relinquish_folder_membership_error", p); + fieldValue = RelinquishFolderMembershipError.Serializer.INSTANCE.deserialize(p); + value = JobError.relinquishFolderMembershipError(fieldValue); + } + else { + value = JobError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/JobStatus.java b/src/main/java/com/dropbox/core/v2/sharing/JobStatus.java index 917a41092..9944e6dee 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/JobStatus.java +++ b/src/main/java/com/dropbox/core/v2/sharing/JobStatus.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is a tagged union. Tagged unions instances are always associated @@ -32,15 +20,9 @@ * return {@code true}. You can use {@link #tag()} to determine the tag * associated with this instance. */ -@JsonSerialize(using=JobStatus.Serializer.class) -@JsonDeserialize(using=JobStatus.Deserializer.class) public final class JobStatus { // union JobStatus - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link JobStatus}. */ @@ -203,7 +185,7 @@ else if (obj instanceof JobStatus) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -215,77 +197,77 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(JobStatus.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(JobStatus value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case IN_PROGRESS: + public void serialize(JobStatus value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case IN_PROGRESS: { g.writeString("in_progress"); break; - case COMPLETE: + } + case COMPLETE: { g.writeString("complete"); break; - case FAILED: + } + case FAILED: { g.writeStartObject(); - g.writeStringField(".tag", "failed"); - g.writeObjectField("failed", value.failedValue); + writeTag("failed", g); + g.writeFieldName("failed"); + JobError.Serializer.INSTANCE.serialize(value.failedValue, g); g.writeEndObject(); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(JobStatus.class, getTagMapping(), null); - } - - @Override - public JobStatus deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case IN_PROGRESS: { - return JobStatus.IN_PROGRESS; } - case COMPLETE: { - return JobStatus.COMPLETE; - } - case FAILED: { - JobError value = null; - expectField(_p, "failed"); - value = _p.readValueAs(JobError.class); - _p.nextToken(); - return JobStatus.failed(value); + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("complete", JobStatus.Tag.COMPLETE); - values.put("failed", JobStatus.Tag.FAILED); - return Collections.unmodifiableMap(values); + @Override + public JobStatus deserialize(JsonParser p) throws IOException, JsonParseException { + JobStatus value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("in_progress".equals(tag)) { + value = JobStatus.IN_PROGRESS; + } + else if ("complete".equals(tag)) { + value = JobStatus.COMPLETE; + } + else if ("failed".equals(tag)) { + JobError fieldValue = null; + expectField("failed", p); + fieldValue = JobError.Serializer.INSTANCE.deserialize(p); + value = JobStatus.failed(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/LinkMetadata.java b/src/main/java/com/dropbox/core/v2/sharing/LinkMetadata.java index 07ed8b0eb..35cefcb35 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/LinkMetadata.java +++ b/src/main/java/com/dropbox/core/v2/sharing/LinkMetadata.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.Date; @@ -30,15 +19,9 @@ * Metadata for a shared link. This can be either a {@link PathLinkMetadata} or * {@link CollectionLinkMetadata}. */ -@JsonSerialize(using=LinkMetadata.Serializer.class) -@JsonDeserialize(using=LinkMetadata.Deserializer.class) public class LinkMetadata { // struct LinkMetadata - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String url; protected final Visibility visibility; protected final Date expires; @@ -140,7 +123,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -152,97 +135,96 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(LinkMetadata.class); - } - - public Serializer(boolean unwrapping) { - super(LinkMetadata.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(LinkMetadata value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("url", value.url); - g.writeObjectField("visibility", value.visibility); + public void serialize(LinkMetadata value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (value instanceof PathLinkMetadata) { + PathLinkMetadata.Serializer.INSTANCE.serialize((PathLinkMetadata) value, g, collapse); + return; + } + if (value instanceof CollectionLinkMetadata) { + CollectionLinkMetadata.Serializer.INSTANCE.serialize((CollectionLinkMetadata) value, g, collapse); + return; + } + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("url"); + StoneSerializers.string().serialize(value.url, g); + g.writeFieldName("visibility"); + Visibility.Serializer.INSTANCE.serialize(value.visibility, g); if (value.expires != null) { - g.writeObjectField("expires", value.expires); + g.writeFieldName("expires"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.expires, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(LinkMetadata.class, PathLinkMetadata.class, CollectionLinkMetadata.class); - } - - public Deserializer(boolean unwrapping) { - super(LinkMetadata.class, unwrapping, PathLinkMetadata.class, CollectionLinkMetadata.class); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public LinkMetadata deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - String _subtype_tag = readEnumeratedSubtypeTag(_p); - if ("path".equals(_subtype_tag)) { - return readCollapsedStructValue(PathLinkMetadata.class, _p, _ctx); - } - if ("collection".equals(_subtype_tag)) { - return readCollapsedStructValue(CollectionLinkMetadata.class, _p, _ctx); - } - - String url = null; - Visibility visibility = null; - Date expires = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("url".equals(_field)) { - url = getStringValue(_p); - _p.nextToken(); + public LinkMetadata deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + LinkMetadata value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + if ("".equals(tag)) { + tag = null; } - else if ("visibility".equals(_field)) { - visibility = _p.readValueAs(Visibility.class); - _p.nextToken(); + } + if (tag == null) { + String f_url = null; + Visibility f_visibility = null; + Date f_expires = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("url".equals(field)) { + f_url = StoneSerializers.string().deserialize(p); + } + else if ("visibility".equals(field)) { + f_visibility = Visibility.Serializer.INSTANCE.deserialize(p); + } + else if ("expires".equals(field)) { + f_expires = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else { + skipValue(p); + } } - else if ("expires".equals(_field)) { - expires = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); + if (f_url == null) { + throw new JsonParseException(p, "Required field \"url\" missing."); } - else { - skipValue(_p); + if (f_visibility == null) { + throw new JsonParseException(p, "Required field \"visibility\" missing."); } + value = new LinkMetadata(f_url, f_visibility, f_expires); } - - if (url == null) { - throw new JsonParseException(_p, "Required field \"url\" is missing."); + else if ("".equals(tag)) { + value = LinkMetadata.Serializer.INSTANCE.deserialize(p, true); } - if (visibility == null) { - throw new JsonParseException(_p, "Required field \"visibility\" is missing."); + else if ("path".equals(tag)) { + value = PathLinkMetadata.Serializer.INSTANCE.deserialize(p, true); } - - return new LinkMetadata(url, visibility, expires); + else if ("collection".equals(tag)) { + value = CollectionLinkMetadata.Serializer.INSTANCE.deserialize(p, true); + } + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/LinkPermissions.java b/src/main/java/com/dropbox/core/v2/sharing/LinkPermissions.java index 5487c7e6a..2c3ca377f 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/LinkPermissions.java +++ b/src/main/java/com/dropbox/core/v2/sharing/LinkPermissions.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=LinkPermissions.Serializer.class) -@JsonDeserialize(using=LinkPermissions.Deserializer.class) public class LinkPermissions { // struct LinkPermissions - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final ResolvedVisibility resolvedVisibility; protected final RequestedVisibility requestedVisibility; protected final boolean canRevoke; @@ -238,7 +221,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -250,102 +233,83 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(LinkPermissions.class); - } - - public Serializer(boolean unwrapping) { - super(LinkPermissions.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(LinkPermissions value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("can_revoke", value.canRevoke); + public void serialize(LinkPermissions value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("can_revoke"); + StoneSerializers.boolean_().serialize(value.canRevoke, g); if (value.resolvedVisibility != null) { - g.writeObjectField("resolved_visibility", value.resolvedVisibility); + g.writeFieldName("resolved_visibility"); + StoneSerializers.nullable(ResolvedVisibility.Serializer.INSTANCE).serialize(value.resolvedVisibility, g); } if (value.requestedVisibility != null) { - g.writeObjectField("requested_visibility", value.requestedVisibility); + g.writeFieldName("requested_visibility"); + StoneSerializers.nullable(RequestedVisibility.Serializer.INSTANCE).serialize(value.requestedVisibility, g); } if (value.revokeFailureReason != null) { - g.writeObjectField("revoke_failure_reason", value.revokeFailureReason); + g.writeFieldName("revoke_failure_reason"); + StoneSerializers.nullable(SharedLinkAccessFailureReason.Serializer.INSTANCE).serialize(value.revokeFailureReason, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(LinkPermissions.class); - } - - public Deserializer(boolean unwrapping) { - super(LinkPermissions.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public LinkPermissions deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - Boolean canRevoke = null; - ResolvedVisibility resolvedVisibility = null; - RequestedVisibility requestedVisibility = null; - SharedLinkAccessFailureReason revokeFailureReason = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("can_revoke".equals(_field)) { - canRevoke = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("resolved_visibility".equals(_field)) { - resolvedVisibility = _p.readValueAs(ResolvedVisibility.class); - _p.nextToken(); - } - else if ("requested_visibility".equals(_field)) { - requestedVisibility = _p.readValueAs(RequestedVisibility.class); - _p.nextToken(); - } - else if ("revoke_failure_reason".equals(_field)) { - revokeFailureReason = _p.readValueAs(SharedLinkAccessFailureReason.class); - _p.nextToken(); + public LinkPermissions deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + LinkPermissions value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Boolean f_canRevoke = null; + ResolvedVisibility f_resolvedVisibility = null; + RequestedVisibility f_requestedVisibility = null; + SharedLinkAccessFailureReason f_revokeFailureReason = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("can_revoke".equals(field)) { + f_canRevoke = StoneSerializers.boolean_().deserialize(p); + } + else if ("resolved_visibility".equals(field)) { + f_resolvedVisibility = StoneSerializers.nullable(ResolvedVisibility.Serializer.INSTANCE).deserialize(p); + } + else if ("requested_visibility".equals(field)) { + f_requestedVisibility = StoneSerializers.nullable(RequestedVisibility.Serializer.INSTANCE).deserialize(p); + } + else if ("revoke_failure_reason".equals(field)) { + f_revokeFailureReason = StoneSerializers.nullable(SharedLinkAccessFailureReason.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_canRevoke == null) { + throw new JsonParseException(p, "Required field \"can_revoke\" missing."); } + value = new LinkPermissions(f_canRevoke, f_resolvedVisibility, f_requestedVisibility, f_revokeFailureReason); } - - if (canRevoke == null) { - throw new JsonParseException(_p, "Required field \"can_revoke\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new LinkPermissions(canRevoke, resolvedVisibility, requestedVisibility, revokeFailureReason); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersArgs.java b/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersArgs.java index 06104d2c3..b8aeff6a9 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersArgs.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersArgs.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=ListFolderMembersArgs.Serializer.class) -@JsonDeserialize(using=ListFolderMembersArgs.Deserializer.class) class ListFolderMembersArgs extends ListFolderMembersCursorArg { // struct ListFolderMembersArgs - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String sharedFolderId; /** @@ -156,7 +139,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -168,104 +151,73 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListFolderMembersArgs.class); - } - - public Serializer(boolean unwrapping) { - super(ListFolderMembersArgs.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(ListFolderMembersArgs value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("shared_folder_id", value.sharedFolderId); + public void serialize(ListFolderMembersArgs value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("shared_folder_id"); + StoneSerializers.string().serialize(value.sharedFolderId, g); if (value.actions != null) { - g.writeObjectField("actions", value.actions); + g.writeFieldName("actions"); + StoneSerializers.nullable(StoneSerializers.list(MemberAction.Serializer.INSTANCE)).serialize(value.actions, g); + } + g.writeFieldName("limit"); + StoneSerializers.uInt32().serialize(value.limit, g); + if (!collapse) { + g.writeEndObject(); } - g.writeObjectField("limit", value.limit); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListFolderMembersArgs.class); - } - - public Deserializer(boolean unwrapping) { - super(ListFolderMembersArgs.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public ListFolderMembersArgs deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String sharedFolderId = null; - List actions = null; - long limit = 1000L; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("shared_folder_id".equals(_field)) { - sharedFolderId = getStringValue(_p); - _p.nextToken(); - } - else if ("actions".equals(_field)) { - expectArrayStart(_p); - actions = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - MemberAction _x = null; - _x = _p.readValueAs(MemberAction.class); - _p.nextToken(); - actions.add(_x); + public ListFolderMembersArgs deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListFolderMembersArgs value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_sharedFolderId = null; + List f_actions = null; + Long f_limit = 1000L; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("shared_folder_id".equals(field)) { + f_sharedFolderId = StoneSerializers.string().deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("limit".equals(_field)) { - limit = _p.getLongValue(); - assertUnsigned(_p, limit); - if (limit > Integer.MAX_VALUE) { - throw new JsonParseException(_p, "expecting a 32-bit unsigned integer, got: " + limit); + else if ("actions".equals(field)) { + f_actions = StoneSerializers.nullable(StoneSerializers.list(MemberAction.Serializer.INSTANCE)).deserialize(p); + } + else if ("limit".equals(field)) { + f_limit = StoneSerializers.uInt32().deserialize(p); + } + else { + skipValue(p); } - _p.nextToken(); } - else { - skipValue(_p); + if (f_sharedFolderId == null) { + throw new JsonParseException(p, "Required field \"shared_folder_id\" missing."); } + value = new ListFolderMembersArgs(f_sharedFolderId, f_actions, f_limit); } - - if (sharedFolderId == null) { - throw new JsonParseException(_p, "Required field \"shared_folder_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new ListFolderMembersArgs(sharedFolderId, actions, limit); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersBuilder.java b/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersBuilder.java index f8263a6f2..f20a6687f 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersBuilder.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; @@ -15,26 +15,26 @@ * request.

*/ public class ListFolderMembersBuilder { - private final DbxUserSharingRequests sharing; + private final DbxUserSharingRequests sharing_; private final ListFolderMembersArgs.Builder listFolderMembersArgsBuilder; /** * Creates a new instance of this builder. * - * @param sharing Dropbox namespace-specific client used to issue sharing + * @param sharing_ Dropbox namespace-specific client used to issue sharing * requests. * @param listFolderMembersArgsBuilder Request argument builder. * * @return instsance of this builder */ - ListFolderMembersBuilder(DbxUserSharingRequests sharing, ListFolderMembersArgs.Builder listFolderMembersArgsBuilder) { - if (sharing == null) { - throw new NullPointerException("sharing"); + ListFolderMembersBuilder(DbxUserSharingRequests sharing_, ListFolderMembersArgs.Builder listFolderMembersArgsBuilder) { + if (sharing_ == null) { + throw new NullPointerException("sharing_"); } + this.sharing_ = sharing_; if (listFolderMembersArgsBuilder == null) { throw new NullPointerException("listFolderMembersArgsBuilder"); } - this.sharing = sharing; this.listFolderMembersArgsBuilder = listFolderMembersArgsBuilder; } @@ -78,7 +78,7 @@ public ListFolderMembersBuilder withLimit(Long limit) { * Issues the request. */ public SharedFolderMembers start() throws SharedFolderAccessErrorException, DbxException { - ListFolderMembersArgs arg = this.listFolderMembersArgsBuilder.build(); - return sharing.listFolderMembers(arg); + ListFolderMembersArgs arg_ = this.listFolderMembersArgsBuilder.build(); + return sharing_.listFolderMembers(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersContinueArg.java b/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersContinueArg.java index eb8de9a97..68441d648 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersContinueArg.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersContinueArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=ListFolderMembersContinueArg.Serializer.class) -@JsonDeserialize(using=ListFolderMembersContinueArg.Deserializer.class) class ListFolderMembersContinueArg { // struct ListFolderMembersContinueArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String cursor; /** @@ -89,7 +72,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -101,78 +84,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListFolderMembersContinueArg.class); - } - - public Serializer(boolean unwrapping) { - super(ListFolderMembersContinueArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(ListFolderMembersContinueArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("cursor", value.cursor); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListFolderMembersContinueArg.class); - } - - public Deserializer(boolean unwrapping) { - super(ListFolderMembersContinueArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(ListFolderMembersContinueArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("cursor"); + StoneSerializers.string().serialize(value.cursor, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public ListFolderMembersContinueArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String cursor = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); + public ListFolderMembersContinueArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListFolderMembersContinueArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_cursor = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("cursor".equals(field)) { + f_cursor = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_cursor == null) { + throw new JsonParseException(p, "Required field \"cursor\" missing."); } + value = new ListFolderMembersContinueArg(f_cursor); } - - if (cursor == null) { - throw new JsonParseException(_p, "Required field \"cursor\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new ListFolderMembersContinueArg(cursor); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersContinueError.java b/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersContinueError.java index f07c5fbeb..9f4765d81 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersContinueError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersContinueError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=ListFolderMembersContinueError.Serializer.class) -@JsonDeserialize(using=ListFolderMembersContinueError.Deserializer.class) public final class ListFolderMembersContinueError { // union ListFolderMembersContinueError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link ListFolderMembersContinueError}. */ @@ -215,7 +197,7 @@ else if (obj instanceof ListFolderMembersContinueError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -227,78 +209,71 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListFolderMembersContinueError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ListFolderMembersContinueError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case ACCESS_ERROR: + public void serialize(ListFolderMembersContinueError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case ACCESS_ERROR: { g.writeStartObject(); - g.writeStringField(".tag", "access_error"); - g.writeObjectField("access_error", value.accessErrorValue); + writeTag("access_error", g); + g.writeFieldName("access_error"); + SharedFolderAccessError.Serializer.INSTANCE.serialize(value.accessErrorValue, g); g.writeEndObject(); break; - case INVALID_CURSOR: + } + case INVALID_CURSOR: { g.writeString("invalid_cursor"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListFolderMembersContinueError.class, getTagMapping(), Tag.OTHER); - } @Override - public ListFolderMembersContinueError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case ACCESS_ERROR: { - SharedFolderAccessError value = null; - expectField(_p, "access_error"); - value = _p.readValueAs(SharedFolderAccessError.class); - _p.nextToken(); - return ListFolderMembersContinueError.accessError(value); - } - case INVALID_CURSOR: { - return ListFolderMembersContinueError.INVALID_CURSOR; - } - case OTHER: { - return ListFolderMembersContinueError.OTHER; - } + public ListFolderMembersContinueError deserialize(JsonParser p) throws IOException, JsonParseException { + ListFolderMembersContinueError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("access_error", ListFolderMembersContinueError.Tag.ACCESS_ERROR); - values.put("invalid_cursor", ListFolderMembersContinueError.Tag.INVALID_CURSOR); - values.put("other", ListFolderMembersContinueError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("access_error".equals(tag)) { + SharedFolderAccessError fieldValue = null; + expectField("access_error", p); + fieldValue = SharedFolderAccessError.Serializer.INSTANCE.deserialize(p); + value = ListFolderMembersContinueError.accessError(fieldValue); + } + else if ("invalid_cursor".equals(tag)) { + value = ListFolderMembersContinueError.INVALID_CURSOR; + } + else { + value = ListFolderMembersContinueError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersContinueErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersContinueErrorException.java index a0e71f329..47d191225 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersContinueErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersContinueErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersCursorArg.java b/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersCursorArg.java index a155af48a..260935fec 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersCursorArg.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ListFolderMembersCursorArg.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=ListFolderMembersCursorArg.Serializer.class) -@JsonDeserialize(using=ListFolderMembersCursorArg.Deserializer.class) public class ListFolderMembersCursorArg { // struct ListFolderMembersCursorArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List actions; protected final long limit; @@ -212,7 +195,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -224,95 +207,64 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListFolderMembersCursorArg.class); - } - - public Serializer(boolean unwrapping) { - super(ListFolderMembersCursorArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(ListFolderMembersCursorArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(ListFolderMembersCursorArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } if (value.actions != null) { - g.writeObjectField("actions", value.actions); + g.writeFieldName("actions"); + StoneSerializers.nullable(StoneSerializers.list(MemberAction.Serializer.INSTANCE)).serialize(value.actions, g); + } + g.writeFieldName("limit"); + StoneSerializers.uInt32().serialize(value.limit, g); + if (!collapse) { + g.writeEndObject(); } - g.writeObjectField("limit", value.limit); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListFolderMembersCursorArg.class); - } - - public Deserializer(boolean unwrapping) { - super(ListFolderMembersCursorArg.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public ListFolderMembersCursorArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List actions = null; - long limit = 1000L; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("actions".equals(_field)) { - expectArrayStart(_p); - actions = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - MemberAction _x = null; - _x = _p.readValueAs(MemberAction.class); - _p.nextToken(); - actions.add(_x); + public ListFolderMembersCursorArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListFolderMembersCursorArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_actions = null; + Long f_limit = 1000L; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("actions".equals(field)) { + f_actions = StoneSerializers.nullable(StoneSerializers.list(MemberAction.Serializer.INSTANCE)).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("limit".equals(_field)) { - limit = _p.getLongValue(); - assertUnsigned(_p, limit); - if (limit > Integer.MAX_VALUE) { - throw new JsonParseException(_p, "expecting a 32-bit unsigned integer, got: " + limit); + else if ("limit".equals(field)) { + f_limit = StoneSerializers.uInt32().deserialize(p); + } + else { + skipValue(p); } - _p.nextToken(); - } - else { - skipValue(_p); } + value = new ListFolderMembersCursorArg(f_actions, f_limit); } - - - return new ListFolderMembersCursorArg(actions, limit); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ListFoldersArgs.java b/src/main/java/com/dropbox/core/v2/sharing/ListFoldersArgs.java index 06481208d..de6ef074d 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ListFoldersArgs.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ListFoldersArgs.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=ListFoldersArgs.Serializer.class) -@JsonDeserialize(using=ListFoldersArgs.Deserializer.class) public class ListFoldersArgs { // struct ListFoldersArgs - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final long limit; protected final List actions; @@ -209,7 +192,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -221,95 +204,64 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListFoldersArgs.class); - } - - public Serializer(boolean unwrapping) { - super(ListFoldersArgs.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(ListFoldersArgs value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("limit", value.limit); + public void serialize(ListFoldersArgs value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("limit"); + StoneSerializers.uInt32().serialize(value.limit, g); if (value.actions != null) { - g.writeObjectField("actions", value.actions); + g.writeFieldName("actions"); + StoneSerializers.nullable(StoneSerializers.list(FolderAction.Serializer.INSTANCE)).serialize(value.actions, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListFoldersArgs.class); - } - - public Deserializer(boolean unwrapping) { - super(ListFoldersArgs.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public ListFoldersArgs deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - long limit = 1000L; - List actions = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("limit".equals(_field)) { - limit = _p.getLongValue(); - assertUnsigned(_p, limit); - if (limit > Integer.MAX_VALUE) { - throw new JsonParseException(_p, "expecting a 32-bit unsigned integer, got: " + limit); + public ListFoldersArgs deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListFoldersArgs value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Long f_limit = 1000L; + List f_actions = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("limit".equals(field)) { + f_limit = StoneSerializers.uInt32().deserialize(p); } - _p.nextToken(); - } - else if ("actions".equals(_field)) { - expectArrayStart(_p); - actions = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - FolderAction _x = null; - _x = _p.readValueAs(FolderAction.class); - _p.nextToken(); - actions.add(_x); + else if ("actions".equals(field)) { + f_actions = StoneSerializers.nullable(StoneSerializers.list(FolderAction.Serializer.INSTANCE)).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else { - skipValue(_p); } + value = new ListFoldersArgs(f_limit, f_actions); } - - - return new ListFoldersArgs(limit, actions); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ListFoldersBuilder.java b/src/main/java/com/dropbox/core/v2/sharing/ListFoldersBuilder.java index 0f45cf1b7..5070ca9da 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ListFoldersBuilder.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ListFoldersBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; @@ -16,26 +16,26 @@ * request.

*/ public class ListFoldersBuilder { - private final DbxUserSharingRequests sharing; + private final DbxUserSharingRequests sharing_; private final ListFoldersArgs.Builder listFoldersArgsBuilder; /** * Creates a new instance of this builder. * - * @param sharing Dropbox namespace-specific client used to issue sharing + * @param sharing_ Dropbox namespace-specific client used to issue sharing * requests. * @param listFoldersArgsBuilder Request argument builder. * * @return instsance of this builder */ - ListFoldersBuilder(DbxUserSharingRequests sharing, ListFoldersArgs.Builder listFoldersArgsBuilder) { - if (sharing == null) { - throw new NullPointerException("sharing"); + ListFoldersBuilder(DbxUserSharingRequests sharing_, ListFoldersArgs.Builder listFoldersArgsBuilder) { + if (sharing_ == null) { + throw new NullPointerException("sharing_"); } + this.sharing_ = sharing_; if (listFoldersArgsBuilder == null) { throw new NullPointerException("listFoldersArgsBuilder"); } - this.sharing = sharing; this.listFoldersArgsBuilder = listFoldersArgsBuilder; } @@ -78,7 +78,7 @@ public ListFoldersBuilder withActions(List actions) { * Issues the request. */ public ListFoldersResult start() throws DbxApiException, DbxException { - ListFoldersArgs arg = this.listFoldersArgsBuilder.build(); - return sharing.listFolders(arg); + ListFoldersArgs arg_ = this.listFoldersArgsBuilder.build(); + return sharing_.listFolders(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ListFoldersContinueArg.java b/src/main/java/com/dropbox/core/v2/sharing/ListFoldersContinueArg.java index f7df62aa4..22d7f515a 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ListFoldersContinueArg.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ListFoldersContinueArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=ListFoldersContinueArg.Serializer.class) -@JsonDeserialize(using=ListFoldersContinueArg.Deserializer.class) public class ListFoldersContinueArg { // struct ListFoldersContinueArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String cursor; /** @@ -86,7 +69,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -98,78 +81,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListFoldersContinueArg.class); - } - - public Serializer(boolean unwrapping) { - super(ListFoldersContinueArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(ListFoldersContinueArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("cursor", value.cursor); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListFoldersContinueArg.class); - } - - public Deserializer(boolean unwrapping) { - super(ListFoldersContinueArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(ListFoldersContinueArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("cursor"); + StoneSerializers.string().serialize(value.cursor, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public ListFoldersContinueArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String cursor = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); + public ListFoldersContinueArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListFoldersContinueArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_cursor = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("cursor".equals(field)) { + f_cursor = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_cursor == null) { + throw new JsonParseException(p, "Required field \"cursor\" missing."); } + value = new ListFoldersContinueArg(f_cursor); } - - if (cursor == null) { - throw new JsonParseException(_p, "Required field \"cursor\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new ListFoldersContinueArg(cursor); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ListFoldersContinueError.java b/src/main/java/com/dropbox/core/v2/sharing/ListFoldersContinueError.java index aa379afbc..13b2c81d8 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ListFoldersContinueError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ListFoldersContinueError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=ListFoldersContinueError.Serializer.class) -@JsonDeserialize(using=ListFoldersContinueError.Deserializer.class) public enum ListFoldersContinueError { // union ListFoldersContinueError /** @@ -43,47 +29,54 @@ public enum ListFoldersContinueError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListFoldersContinueError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ListFoldersContinueError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(ListFoldersContinueError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case INVALID_CURSOR: + case INVALID_CURSOR: { g.writeString("invalid_cursor"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListFoldersContinueError.class, getTagMapping(), ListFoldersContinueError.OTHER); - } @Override - public ListFoldersContinueError deserialize(ListFoldersContinueError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("invalid_cursor", ListFoldersContinueError.INVALID_CURSOR); - values.put("other", ListFoldersContinueError.OTHER); - return Collections.unmodifiableMap(values); + public ListFoldersContinueError deserialize(JsonParser p) throws IOException, JsonParseException { + ListFoldersContinueError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("invalid_cursor".equals(tag)) { + value = ListFoldersContinueError.INVALID_CURSOR; + } + else { + value = ListFoldersContinueError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ListFoldersContinueErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/ListFoldersContinueErrorException.java index 842c18178..1ba9d5fa5 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ListFoldersContinueErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ListFoldersContinueErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/ListFoldersResult.java b/src/main/java/com/dropbox/core/v2/sharing/ListFoldersResult.java index 6ed10a02d..ebda8941a 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ListFoldersResult.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ListFoldersResult.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; @@ -32,15 +21,9 @@ * was requested. Unmounted shared folders can be identified by the absence of * {@link SharedFolderMetadata#getPathLower}. */ -@JsonSerialize(using=ListFoldersResult.Serializer.class) -@JsonDeserialize(using=ListFoldersResult.Deserializer.class) public class ListFoldersResult { // struct ListFoldersResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List entries; protected final String cursor; @@ -145,7 +128,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -157,94 +140,67 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListFoldersResult.class); - } - - public Serializer(boolean unwrapping) { - super(ListFoldersResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(ListFoldersResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("entries", value.entries); + public void serialize(ListFoldersResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("entries"); + StoneSerializers.list(SharedFolderMetadata.Serializer.INSTANCE).serialize(value.entries, g); if (value.cursor != null) { - g.writeObjectField("cursor", value.cursor); + g.writeFieldName("cursor"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.cursor, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListFoldersResult.class); - } - - public Deserializer(boolean unwrapping) { - super(ListFoldersResult.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public ListFoldersResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List entries = null; - String cursor = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("entries".equals(_field)) { - expectArrayStart(_p); - entries = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - SharedFolderMetadata _x = null; - _x = _p.readValueAs(SharedFolderMetadata.class); - _p.nextToken(); - entries.add(_x); + public ListFoldersResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListFoldersResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_entries = null; + String f_cursor = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("entries".equals(field)) { + f_entries = StoneSerializers.list(SharedFolderMetadata.Serializer.INSTANCE).deserialize(p); + } + else if ("cursor".equals(field)) { + f_cursor = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); } - else { - skipValue(_p); + if (f_entries == null) { + throw new JsonParseException(p, "Required field \"entries\" missing."); } + value = new ListFoldersResult(f_entries, f_cursor); } - - if (entries == null) { - throw new JsonParseException(_p, "Required field \"entries\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new ListFoldersResult(entries, cursor); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ListMountableFoldersBuilder.java b/src/main/java/com/dropbox/core/v2/sharing/ListMountableFoldersBuilder.java index ac80f90eb..cc15d645b 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ListMountableFoldersBuilder.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ListMountableFoldersBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; @@ -16,26 +16,26 @@ * request.

*/ public class ListMountableFoldersBuilder { - private final DbxUserSharingRequests sharing; + private final DbxUserSharingRequests sharing_; private final ListFoldersArgs.Builder listFoldersArgsBuilder; /** * Creates a new instance of this builder. * - * @param sharing Dropbox namespace-specific client used to issue sharing + * @param sharing_ Dropbox namespace-specific client used to issue sharing * requests. * @param listFoldersArgsBuilder Request argument builder. * * @return instsance of this builder */ - ListMountableFoldersBuilder(DbxUserSharingRequests sharing, ListFoldersArgs.Builder listFoldersArgsBuilder) { - if (sharing == null) { - throw new NullPointerException("sharing"); + ListMountableFoldersBuilder(DbxUserSharingRequests sharing_, ListFoldersArgs.Builder listFoldersArgsBuilder) { + if (sharing_ == null) { + throw new NullPointerException("sharing_"); } + this.sharing_ = sharing_; if (listFoldersArgsBuilder == null) { throw new NullPointerException("listFoldersArgsBuilder"); } - this.sharing = sharing; this.listFoldersArgsBuilder = listFoldersArgsBuilder; } @@ -78,7 +78,7 @@ public ListMountableFoldersBuilder withActions(List actions) { * Issues the request. */ public ListFoldersResult start() throws DbxApiException, DbxException { - ListFoldersArgs arg = this.listFoldersArgsBuilder.build(); - return sharing.listMountableFolders(arg); + ListFoldersArgs arg_ = this.listFoldersArgsBuilder.build(); + return sharing_.listMountableFolders(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ListSharedLinksArg.java b/src/main/java/com/dropbox/core/v2/sharing/ListSharedLinksArg.java index 43123cbdb..98edf3e08 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ListSharedLinksArg.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ListSharedLinksArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=ListSharedLinksArg.Serializer.class) -@JsonDeserialize(using=ListSharedLinksArg.Deserializer.class) class ListSharedLinksArg { // struct ListSharedLinksArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String path; protected final String cursor; protected final Boolean directOnly; @@ -44,7 +27,7 @@ class ListSharedLinksArg { * * @param path See {@link DbxUserSharingRequests#listSharedLinks()} * description. Must match pattern "{@code - * ((/|id:).*)|(rev:[0-9a-f]{9,})}". + * (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}". * @param cursor The cursor returned by your last call to {@link * DbxUserSharingRequests#listSharedLinks()}. * @param directOnly See {@link DbxUserSharingRequests#listSharedLinks()} @@ -55,7 +38,7 @@ class ListSharedLinksArg { */ public ListSharedLinksArg(String path, String cursor, Boolean directOnly) { if (path != null) { - if (!java.util.regex.Pattern.matches("((/|id:).*)|(rev:[0-9a-f]{9,})", path)) { + if (!java.util.regex.Pattern.matches("(/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } } @@ -128,7 +111,7 @@ protected Builder() { * * @param path See {@link DbxUserSharingRequests#listSharedLinks()} * description. Must match pattern "{@code - * ((/|id:).*)|(rev:[0-9a-f]{9,})}". + * (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}". * * @return this builder * @@ -137,7 +120,7 @@ protected Builder() { */ public Builder withPath(String path) { if (path != null) { - if (!java.util.regex.Pattern.matches("((/|id:).*)|(rev:[0-9a-f]{9,})", path)) { + if (!java.util.regex.Pattern.matches("(/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } } @@ -212,7 +195,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -224,93 +207,74 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListSharedLinksArg.class); - } - - public Serializer(boolean unwrapping) { - super(ListSharedLinksArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(ListSharedLinksArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(ListSharedLinksArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } if (value.path != null) { - g.writeObjectField("path", value.path); + g.writeFieldName("path"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.path, g); } if (value.cursor != null) { - g.writeObjectField("cursor", value.cursor); + g.writeFieldName("cursor"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.cursor, g); } if (value.directOnly != null) { - g.writeObjectField("direct_only", value.directOnly); + g.writeFieldName("direct_only"); + StoneSerializers.nullable(StoneSerializers.boolean_()).serialize(value.directOnly, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListSharedLinksArg.class); - } - - public Deserializer(boolean unwrapping) { - super(ListSharedLinksArg.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public ListSharedLinksArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String path = null; - String cursor = null; - Boolean directOnly = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); - } - else if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); - } - else if ("direct_only".equals(_field)) { - directOnly = _p.getValueAsBoolean(); - _p.nextToken(); - } - else { - skipValue(_p); + public ListSharedLinksArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListSharedLinksArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_path = null; + String f_cursor = null; + Boolean f_directOnly = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("path".equals(field)) { + f_path = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("cursor".equals(field)) { + f_cursor = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("direct_only".equals(field)) { + f_directOnly = StoneSerializers.nullable(StoneSerializers.boolean_()).deserialize(p); + } + else { + skipValue(p); + } } + value = new ListSharedLinksArg(f_path, f_cursor, f_directOnly); } - - - return new ListSharedLinksArg(path, cursor, directOnly); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ListSharedLinksBuilder.java b/src/main/java/com/dropbox/core/v2/sharing/ListSharedLinksBuilder.java index 6e44be726..53daace5f 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ListSharedLinksBuilder.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ListSharedLinksBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; @@ -13,26 +13,26 @@ * request.

*/ public class ListSharedLinksBuilder { - private final DbxUserSharingRequests sharing; + private final DbxUserSharingRequests sharing_; private final ListSharedLinksArg.Builder listSharedLinksArgBuilder; /** * Creates a new instance of this builder. * - * @param sharing Dropbox namespace-specific client used to issue sharing + * @param sharing_ Dropbox namespace-specific client used to issue sharing * requests. * @param listSharedLinksArgBuilder Request argument builder. * * @return instsance of this builder */ - ListSharedLinksBuilder(DbxUserSharingRequests sharing, ListSharedLinksArg.Builder listSharedLinksArgBuilder) { - if (sharing == null) { - throw new NullPointerException("sharing"); + ListSharedLinksBuilder(DbxUserSharingRequests sharing_, ListSharedLinksArg.Builder listSharedLinksArgBuilder) { + if (sharing_ == null) { + throw new NullPointerException("sharing_"); } + this.sharing_ = sharing_; if (listSharedLinksArgBuilder == null) { throw new NullPointerException("listSharedLinksArgBuilder"); } - this.sharing = sharing; this.listSharedLinksArgBuilder = listSharedLinksArgBuilder; } @@ -41,7 +41,7 @@ public class ListSharedLinksBuilder { * * @param path See {@link DbxUserSharingRequests#listSharedLinks()} * description. Must match pattern "{@code - * ((/|id:).*)|(rev:[0-9a-f]{9,})}". + * (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})}". * * @return this builder * @@ -83,7 +83,7 @@ public ListSharedLinksBuilder withDirectOnly(Boolean directOnly) { * Issues the request. */ public ListSharedLinksResult start() throws ListSharedLinksErrorException, DbxException { - ListSharedLinksArg arg = this.listSharedLinksArgBuilder.build(); - return sharing.listSharedLinks(arg); + ListSharedLinksArg arg_ = this.listSharedLinksArgBuilder.build(); + return sharing_.listSharedLinks(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ListSharedLinksError.java b/src/main/java/com/dropbox/core/v2/sharing/ListSharedLinksError.java index 782ef4134..e7ece4108 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ListSharedLinksError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ListSharedLinksError.java @@ -1,31 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.dropbox.core.v2.files.LookupError; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -37,15 +25,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=ListSharedLinksError.Serializer.class) -@JsonDeserialize(using=ListSharedLinksError.Deserializer.class) public final class ListSharedLinksError { // union ListSharedLinksError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link ListSharedLinksError}. */ @@ -214,7 +196,7 @@ else if (obj instanceof ListSharedLinksError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -226,78 +208,71 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListSharedLinksError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ListSharedLinksError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case PATH: + public void serialize(ListSharedLinksError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case PATH: { g.writeStartObject(); - g.writeStringField(".tag", "path"); - g.writeObjectField("path", value.pathValue); + writeTag("path", g); + g.writeFieldName("path"); + LookupError.Serializer.INSTANCE.serialize(value.pathValue, g); g.writeEndObject(); break; - case RESET: + } + case RESET: { g.writeString("reset"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListSharedLinksError.class, getTagMapping(), Tag.OTHER); - } @Override - public ListSharedLinksError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case PATH: { - LookupError value = null; - expectField(_p, "path"); - value = _p.readValueAs(LookupError.class); - _p.nextToken(); - return ListSharedLinksError.path(value); - } - case RESET: { - return ListSharedLinksError.RESET; - } - case OTHER: { - return ListSharedLinksError.OTHER; - } + public ListSharedLinksError deserialize(JsonParser p) throws IOException, JsonParseException { + ListSharedLinksError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("path", ListSharedLinksError.Tag.PATH); - values.put("reset", ListSharedLinksError.Tag.RESET); - values.put("other", ListSharedLinksError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("path".equals(tag)) { + LookupError fieldValue = null; + expectField("path", p); + fieldValue = LookupError.Serializer.INSTANCE.deserialize(p); + value = ListSharedLinksError.path(fieldValue); + } + else if ("reset".equals(tag)) { + value = ListSharedLinksError.RESET; + } + else { + value = ListSharedLinksError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ListSharedLinksErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/ListSharedLinksErrorException.java index b4e25b666..da4729aa2 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ListSharedLinksErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ListSharedLinksErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/ListSharedLinksResult.java b/src/main/java/com/dropbox/core/v2/sharing/ListSharedLinksResult.java index 4d77772db..8ca719407 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ListSharedLinksResult.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ListSharedLinksResult.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=ListSharedLinksResult.Serializer.class) -@JsonDeserialize(using=ListSharedLinksResult.Deserializer.class) public class ListSharedLinksResult { // struct ListSharedLinksResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List links; protected final boolean hasMore; protected final String cursor; @@ -145,7 +128,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -157,103 +140,76 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListSharedLinksResult.class); - } - - public Serializer(boolean unwrapping) { - super(ListSharedLinksResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(ListSharedLinksResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("links", value.links); - g.writeObjectField("has_more", value.hasMore); + public void serialize(ListSharedLinksResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("links"); + StoneSerializers.list(SharedLinkMetadata.Serializer.INSTANCE).serialize(value.links, g); + g.writeFieldName("has_more"); + StoneSerializers.boolean_().serialize(value.hasMore, g); if (value.cursor != null) { - g.writeObjectField("cursor", value.cursor); + g.writeFieldName("cursor"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.cursor, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListSharedLinksResult.class); - } - - public Deserializer(boolean unwrapping) { - super(ListSharedLinksResult.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public ListSharedLinksResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List links = null; - Boolean hasMore = null; - String cursor = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("links".equals(_field)) { - expectArrayStart(_p); - links = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - SharedLinkMetadata _x = null; - _x = _p.readValueAs(SharedLinkMetadata.class); - _p.nextToken(); - links.add(_x); + public ListSharedLinksResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListSharedLinksResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_links = null; + Boolean f_hasMore = null; + String f_cursor = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("links".equals(field)) { + f_links = StoneSerializers.list(SharedLinkMetadata.Serializer.INSTANCE).deserialize(p); + } + else if ("has_more".equals(field)) { + f_hasMore = StoneSerializers.boolean_().deserialize(p); + } + else if ("cursor".equals(field)) { + f_cursor = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("has_more".equals(_field)) { - hasMore = _p.getValueAsBoolean(); - _p.nextToken(); } - else if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); + if (f_links == null) { + throw new JsonParseException(p, "Required field \"links\" missing."); } - else { - skipValue(_p); + if (f_hasMore == null) { + throw new JsonParseException(p, "Required field \"has_more\" missing."); } + value = new ListSharedLinksResult(f_links, f_hasMore, f_cursor); } - - if (links == null) { - throw new JsonParseException(_p, "Required field \"links\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (hasMore == null) { - throw new JsonParseException(_p, "Required field \"has_more\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new ListSharedLinksResult(links, hasMore, cursor); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/MemberAction.java b/src/main/java/com/dropbox/core/v2/sharing/MemberAction.java index 2c1f7c0fc..61ff1ab53 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/MemberAction.java +++ b/src/main/java/com/dropbox/core/v2/sharing/MemberAction.java @@ -1,36 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Actions that may be taken on members of a shared folder. */ -@JsonSerialize(using=MemberAction.Serializer.class) -@JsonDeserialize(using=MemberAction.Deserializer.class) public enum MemberAction { // union MemberAction /** @@ -58,59 +44,75 @@ public enum MemberAction { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MemberAction.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MemberAction value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(MemberAction value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case MAKE_EDITOR: + case MAKE_EDITOR: { g.writeString("make_editor"); break; - case MAKE_OWNER: + } + case MAKE_OWNER: { g.writeString("make_owner"); break; - case MAKE_VIEWER: + } + case MAKE_VIEWER: { g.writeString("make_viewer"); break; - case REMOVE: + } + case REMOVE: { g.writeString("remove"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MemberAction.class, getTagMapping(), MemberAction.OTHER); - } @Override - public MemberAction deserialize(MemberAction _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("make_editor", MemberAction.MAKE_EDITOR); - values.put("make_owner", MemberAction.MAKE_OWNER); - values.put("make_viewer", MemberAction.MAKE_VIEWER); - values.put("remove", MemberAction.REMOVE); - values.put("other", MemberAction.OTHER); - return Collections.unmodifiableMap(values); + public MemberAction deserialize(JsonParser p) throws IOException, JsonParseException { + MemberAction value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("make_editor".equals(tag)) { + value = MemberAction.MAKE_EDITOR; + } + else if ("make_owner".equals(tag)) { + value = MemberAction.MAKE_OWNER; + } + else if ("make_viewer".equals(tag)) { + value = MemberAction.MAKE_VIEWER; + } + else if ("remove".equals(tag)) { + value = MemberAction.REMOVE; + } + else { + value = MemberAction.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/MemberPermission.java b/src/main/java/com/dropbox/core/v2/sharing/MemberPermission.java index 3ddb0e5c2..79ab3d54b 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/MemberPermission.java +++ b/src/main/java/com/dropbox/core/v2/sharing/MemberPermission.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Whether the user is allowed to take the action on the associated member. */ -@JsonSerialize(using=MemberPermission.Serializer.class) -@JsonDeserialize(using=MemberPermission.Deserializer.class) public class MemberPermission { // struct MemberPermission - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final MemberAction action; protected final boolean allow; protected final PermissionDeniedReason reason; @@ -136,7 +119,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -148,95 +131,76 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MemberPermission.class); - } - - public Serializer(boolean unwrapping) { - super(MemberPermission.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(MemberPermission value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("action", value.action); - g.writeObjectField("allow", value.allow); + public void serialize(MemberPermission value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("action"); + MemberAction.Serializer.INSTANCE.serialize(value.action, g); + g.writeFieldName("allow"); + StoneSerializers.boolean_().serialize(value.allow, g); if (value.reason != null) { - g.writeObjectField("reason", value.reason); + g.writeFieldName("reason"); + StoneSerializers.nullable(PermissionDeniedReason.Serializer.INSTANCE).serialize(value.reason, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MemberPermission.class); - } - - public Deserializer(boolean unwrapping) { - super(MemberPermission.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public MemberPermission deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - MemberAction action = null; - Boolean allow = null; - PermissionDeniedReason reason = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("action".equals(_field)) { - action = _p.readValueAs(MemberAction.class); - _p.nextToken(); - } - else if ("allow".equals(_field)) { - allow = _p.getValueAsBoolean(); - _p.nextToken(); + public MemberPermission deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MemberPermission value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + MemberAction f_action = null; + Boolean f_allow = null; + PermissionDeniedReason f_reason = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("action".equals(field)) { + f_action = MemberAction.Serializer.INSTANCE.deserialize(p); + } + else if ("allow".equals(field)) { + f_allow = StoneSerializers.boolean_().deserialize(p); + } + else if ("reason".equals(field)) { + f_reason = StoneSerializers.nullable(PermissionDeniedReason.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); + } } - else if ("reason".equals(_field)) { - reason = _p.readValueAs(PermissionDeniedReason.class); - _p.nextToken(); + if (f_action == null) { + throw new JsonParseException(p, "Required field \"action\" missing."); } - else { - skipValue(_p); + if (f_allow == null) { + throw new JsonParseException(p, "Required field \"allow\" missing."); } + value = new MemberPermission(f_action, f_allow, f_reason); } - - if (action == null) { - throw new JsonParseException(_p, "Required field \"action\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (allow == null) { - throw new JsonParseException(_p, "Required field \"allow\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new MemberPermission(action, allow, reason); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/MemberPolicy.java b/src/main/java/com/dropbox/core/v2/sharing/MemberPolicy.java index 7f9393164..06e8c066d 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/MemberPolicy.java +++ b/src/main/java/com/dropbox/core/v2/sharing/MemberPolicy.java @@ -1,37 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Policy governing who can be a member of a shared folder. Only applicable to * folders owned by a user on a team. */ -@JsonSerialize(using=MemberPolicy.Serializer.class) -@JsonDeserialize(using=MemberPolicy.Deserializer.class) public enum MemberPolicy { // union MemberPolicy /** @@ -51,51 +37,61 @@ public enum MemberPolicy { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MemberPolicy.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MemberPolicy value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(MemberPolicy value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case TEAM: + case TEAM: { g.writeString("team"); break; - case ANYONE: + } + case ANYONE: { g.writeString("anyone"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MemberPolicy.class, getTagMapping(), MemberPolicy.OTHER); - } @Override - public MemberPolicy deserialize(MemberPolicy _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("team", MemberPolicy.TEAM); - values.put("anyone", MemberPolicy.ANYONE); - values.put("other", MemberPolicy.OTHER); - return Collections.unmodifiableMap(values); + public MemberPolicy deserialize(JsonParser p) throws IOException, JsonParseException { + MemberPolicy value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("team".equals(tag)) { + value = MemberPolicy.TEAM; + } + else if ("anyone".equals(tag)) { + value = MemberPolicy.ANYONE; + } + else { + value = MemberPolicy.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/MemberSelector.java b/src/main/java/com/dropbox/core/v2/sharing/MemberSelector.java index d38924230..22d3e737f 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/MemberSelector.java +++ b/src/main/java/com/dropbox/core/v2/sharing/MemberSelector.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Includes different ways to identify a member of a shared folder. @@ -38,15 +26,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=MemberSelector.Serializer.class) -@JsonDeserialize(using=MemberSelector.Deserializer.class) public final class MemberSelector { // union MemberSelector - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link MemberSelector}. */ @@ -270,7 +252,7 @@ else if (obj instanceof MemberSelector) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -282,85 +264,78 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MemberSelector.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MemberSelector value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case DROPBOX_ID: + public void serialize(MemberSelector value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case DROPBOX_ID: { g.writeStartObject(); - g.writeStringField(".tag", "dropbox_id"); - g.writeObjectField("dropbox_id", value.dropboxIdValue); + writeTag("dropbox_id", g); + g.writeFieldName("dropbox_id"); + StoneSerializers.string().serialize(value.dropboxIdValue, g); g.writeEndObject(); break; - case EMAIL: + } + case EMAIL: { g.writeStartObject(); - g.writeStringField(".tag", "email"); - g.writeObjectField("email", value.emailValue); + writeTag("email", g); + g.writeFieldName("email"); + StoneSerializers.string().serialize(value.emailValue, g); g.writeEndObject(); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MemberSelector.class, getTagMapping(), Tag.OTHER); - } @Override - public MemberSelector deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case DROPBOX_ID: { - String value = null; - expectField(_p, "dropbox_id"); - value = getStringValue(_p); - _p.nextToken(); - return MemberSelector.dropboxId(value); - } - case EMAIL: { - String value = null; - expectField(_p, "email"); - value = getStringValue(_p); - _p.nextToken(); - return MemberSelector.email(value); - } - case OTHER: { - return MemberSelector.OTHER; - } + public MemberSelector deserialize(JsonParser p) throws IOException, JsonParseException { + MemberSelector value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("dropbox_id", MemberSelector.Tag.DROPBOX_ID); - values.put("email", MemberSelector.Tag.EMAIL); - values.put("other", MemberSelector.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("dropbox_id".equals(tag)) { + String fieldValue = null; + expectField("dropbox_id", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = MemberSelector.dropboxId(fieldValue); + } + else if ("email".equals(tag)) { + String fieldValue = null; + expectField("email", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = MemberSelector.email(fieldValue); + } + else { + value = MemberSelector.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/MembershipInfo.java b/src/main/java/com/dropbox/core/v2/sharing/MembershipInfo.java index 6506d2195..4513b1957 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/MembershipInfo.java +++ b/src/main/java/com/dropbox/core/v2/sharing/MembershipInfo.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; @@ -29,15 +18,9 @@ /** * The information about a member of the shared folder. */ -@JsonSerialize(using=MembershipInfo.Serializer.class) -@JsonDeserialize(using=MembershipInfo.Deserializer.class) public class MembershipInfo { // struct MembershipInfo - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final AccessLevel accessType; protected final List permissions; protected final String initials; @@ -268,7 +251,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -280,108 +263,81 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembershipInfo.class); - } - - public Serializer(boolean unwrapping) { - super(MembershipInfo.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(MembershipInfo value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("access_type", value.accessType); + public void serialize(MembershipInfo value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("access_type"); + AccessLevel.Serializer.INSTANCE.serialize(value.accessType, g); if (value.permissions != null) { - g.writeObjectField("permissions", value.permissions); + g.writeFieldName("permissions"); + StoneSerializers.nullable(StoneSerializers.list(MemberPermission.Serializer.INSTANCE)).serialize(value.permissions, g); } if (value.initials != null) { - g.writeObjectField("initials", value.initials); + g.writeFieldName("initials"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.initials, g); + } + g.writeFieldName("is_inherited"); + StoneSerializers.boolean_().serialize(value.isInherited, g); + if (!collapse) { + g.writeEndObject(); } - g.writeObjectField("is_inherited", value.isInherited); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembershipInfo.class); - } - - public Deserializer(boolean unwrapping) { - super(MembershipInfo.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public MembershipInfo deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - AccessLevel accessType = null; - List permissions = null; - String initials = null; - boolean isInherited = false; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("access_type".equals(_field)) { - accessType = _p.readValueAs(AccessLevel.class); - _p.nextToken(); - } - else if ("permissions".equals(_field)) { - expectArrayStart(_p); - permissions = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - MemberPermission _x = null; - _x = _p.readValueAs(MemberPermission.class); - _p.nextToken(); - permissions.add(_x); + public MembershipInfo deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MembershipInfo value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + AccessLevel f_accessType = null; + List f_permissions = null; + String f_initials = null; + Boolean f_isInherited = false; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("access_type".equals(field)) { + f_accessType = AccessLevel.Serializer.INSTANCE.deserialize(p); + } + else if ("permissions".equals(field)) { + f_permissions = StoneSerializers.nullable(StoneSerializers.list(MemberPermission.Serializer.INSTANCE)).deserialize(p); + } + else if ("initials".equals(field)) { + f_initials = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("is_inherited".equals(field)) { + f_isInherited = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("initials".equals(_field)) { - initials = getStringValue(_p); - _p.nextToken(); - } - else if ("is_inherited".equals(_field)) { - isInherited = _p.getValueAsBoolean(); - _p.nextToken(); } - else { - skipValue(_p); + if (f_accessType == null) { + throw new JsonParseException(p, "Required field \"access_type\" missing."); } + value = new MembershipInfo(f_accessType, f_permissions, f_initials, f_isInherited); } - - if (accessType == null) { - throw new JsonParseException(_p, "Required field \"access_type\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new MembershipInfo(accessType, permissions, initials, isInherited); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ModifySharedLinkSettingsArgs.java b/src/main/java/com/dropbox/core/v2/sharing/ModifySharedLinkSettingsArgs.java index d11ba7b59..1b06a4a73 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ModifySharedLinkSettingsArgs.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ModifySharedLinkSettingsArgs.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=ModifySharedLinkSettingsArgs.Serializer.class) -@JsonDeserialize(using=ModifySharedLinkSettingsArgs.Deserializer.class) class ModifySharedLinkSettingsArgs { // struct ModifySharedLinkSettingsArgs - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String url; protected final SharedLinkSettings settings; protected final boolean removeExpiration; @@ -135,7 +118,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -147,93 +130,74 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ModifySharedLinkSettingsArgs.class); - } - - public Serializer(boolean unwrapping) { - super(ModifySharedLinkSettingsArgs.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(ModifySharedLinkSettingsArgs value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("url", value.url); - g.writeObjectField("settings", value.settings); - g.writeObjectField("remove_expiration", value.removeExpiration); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ModifySharedLinkSettingsArgs.class); - } - - public Deserializer(boolean unwrapping) { - super(ModifySharedLinkSettingsArgs.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(ModifySharedLinkSettingsArgs value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("url"); + StoneSerializers.string().serialize(value.url, g); + g.writeFieldName("settings"); + SharedLinkSettings.Serializer.INSTANCE.serialize(value.settings, g); + g.writeFieldName("remove_expiration"); + StoneSerializers.boolean_().serialize(value.removeExpiration, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public ModifySharedLinkSettingsArgs deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String url = null; - SharedLinkSettings settings = null; - boolean removeExpiration = false; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("url".equals(_field)) { - url = getStringValue(_p); - _p.nextToken(); - } - else if ("settings".equals(_field)) { - settings = _p.readValueAs(SharedLinkSettings.class); - _p.nextToken(); + public ModifySharedLinkSettingsArgs deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ModifySharedLinkSettingsArgs value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_url = null; + SharedLinkSettings f_settings = null; + Boolean f_removeExpiration = false; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("url".equals(field)) { + f_url = StoneSerializers.string().deserialize(p); + } + else if ("settings".equals(field)) { + f_settings = SharedLinkSettings.Serializer.INSTANCE.deserialize(p); + } + else if ("remove_expiration".equals(field)) { + f_removeExpiration = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } } - else if ("remove_expiration".equals(_field)) { - removeExpiration = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_url == null) { + throw new JsonParseException(p, "Required field \"url\" missing."); } - else { - skipValue(_p); + if (f_settings == null) { + throw new JsonParseException(p, "Required field \"settings\" missing."); } + value = new ModifySharedLinkSettingsArgs(f_url, f_settings, f_removeExpiration); } - - if (url == null) { - throw new JsonParseException(_p, "Required field \"url\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (settings == null) { - throw new JsonParseException(_p, "Required field \"settings\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new ModifySharedLinkSettingsArgs(url, settings, removeExpiration); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ModifySharedLinkSettingsError.java b/src/main/java/com/dropbox/core/v2/sharing/ModifySharedLinkSettingsError.java index 4a7ebaf68..dfb8b7613 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ModifySharedLinkSettingsError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ModifySharedLinkSettingsError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is a tagged union. Tagged unions instances are always associated @@ -32,15 +20,9 @@ * return {@code true}. You can use {@link #tag()} to determine the tag * associated with this instance. */ -@JsonSerialize(using=ModifySharedLinkSettingsError.Serializer.class) -@JsonDeserialize(using=ModifySharedLinkSettingsError.Deserializer.class) public final class ModifySharedLinkSettingsError { // union ModifySharedLinkSettingsError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link ModifySharedLinkSettingsError}. */ @@ -247,7 +229,7 @@ else if (obj instanceof ModifySharedLinkSettingsError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -259,89 +241,91 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); + return Serializer.INSTANCE.serialize(this, true); } - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ModifySharedLinkSettingsError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ModifySharedLinkSettingsError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case SHARED_LINK_NOT_FOUND: + public void serialize(ModifySharedLinkSettingsError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case SHARED_LINK_NOT_FOUND: { g.writeString("shared_link_not_found"); break; - case SHARED_LINK_ACCESS_DENIED: + } + case SHARED_LINK_ACCESS_DENIED: { g.writeString("shared_link_access_denied"); break; - case OTHER: + } + case OTHER: { g.writeString("other"); break; - case SETTINGS_ERROR: + } + case SETTINGS_ERROR: { g.writeStartObject(); - g.writeStringField(".tag", "settings_error"); - g.writeObjectField("settings_error", value.settingsErrorValue); + writeTag("settings_error", g); + g.writeFieldName("settings_error"); + SharedLinkSettingsError.Serializer.INSTANCE.serialize(value.settingsErrorValue, g); g.writeEndObject(); break; - case EMAIL_NOT_VERIFIED: + } + case EMAIL_NOT_VERIFIED: { g.writeString("email_not_verified"); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ModifySharedLinkSettingsError.class, getTagMapping(), null); - } - - @Override - public ModifySharedLinkSettingsError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case SHARED_LINK_NOT_FOUND: { - return ModifySharedLinkSettingsError.SHARED_LINK_NOT_FOUND; } - case SHARED_LINK_ACCESS_DENIED: { - return ModifySharedLinkSettingsError.SHARED_LINK_ACCESS_DENIED; - } - case OTHER: { - return ModifySharedLinkSettingsError.OTHER; - } - case SETTINGS_ERROR: { - SharedLinkSettingsError value = null; - expectField(_p, "settings_error"); - value = _p.readValueAs(SharedLinkSettingsError.class); - _p.nextToken(); - return ModifySharedLinkSettingsError.settingsError(value); - } - case EMAIL_NOT_VERIFIED: { - return ModifySharedLinkSettingsError.EMAIL_NOT_VERIFIED; + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("settings_error", ModifySharedLinkSettingsError.Tag.SETTINGS_ERROR); - values.put("email_not_verified", ModifySharedLinkSettingsError.Tag.EMAIL_NOT_VERIFIED); - return Collections.unmodifiableMap(values); + @Override + public ModifySharedLinkSettingsError deserialize(JsonParser p) throws IOException, JsonParseException { + ModifySharedLinkSettingsError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("shared_link_not_found".equals(tag)) { + value = ModifySharedLinkSettingsError.SHARED_LINK_NOT_FOUND; + } + else if ("shared_link_access_denied".equals(tag)) { + value = ModifySharedLinkSettingsError.SHARED_LINK_ACCESS_DENIED; + } + else if ("other".equals(tag)) { + value = ModifySharedLinkSettingsError.OTHER; + } + else if ("settings_error".equals(tag)) { + SharedLinkSettingsError fieldValue = null; + expectField("settings_error", p); + fieldValue = SharedLinkSettingsError.Serializer.INSTANCE.deserialize(p); + value = ModifySharedLinkSettingsError.settingsError(fieldValue); + } + else if ("email_not_verified".equals(tag)) { + value = ModifySharedLinkSettingsError.EMAIL_NOT_VERIFIED; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ModifySharedLinkSettingsErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/ModifySharedLinkSettingsErrorException.java index ddc34f94b..e7cfdcbbe 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ModifySharedLinkSettingsErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ModifySharedLinkSettingsErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/MountFolderArg.java b/src/main/java/com/dropbox/core/v2/sharing/MountFolderArg.java index c7c047922..a83789b27 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/MountFolderArg.java +++ b/src/main/java/com/dropbox/core/v2/sharing/MountFolderArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=MountFolderArg.Serializer.class) -@JsonDeserialize(using=MountFolderArg.Deserializer.class) class MountFolderArg { // struct MountFolderArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String sharedFolderId; /** @@ -88,7 +71,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -100,78 +83,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MountFolderArg.class); - } - - public Serializer(boolean unwrapping) { - super(MountFolderArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(MountFolderArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("shared_folder_id", value.sharedFolderId); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MountFolderArg.class); - } - - public Deserializer(boolean unwrapping) { - super(MountFolderArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(MountFolderArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("shared_folder_id"); + StoneSerializers.string().serialize(value.sharedFolderId, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public MountFolderArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String sharedFolderId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("shared_folder_id".equals(_field)) { - sharedFolderId = getStringValue(_p); - _p.nextToken(); + public MountFolderArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MountFolderArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_sharedFolderId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("shared_folder_id".equals(field)) { + f_sharedFolderId = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_sharedFolderId == null) { + throw new JsonParseException(p, "Required field \"shared_folder_id\" missing."); } + value = new MountFolderArg(f_sharedFolderId); } - - if (sharedFolderId == null) { - throw new JsonParseException(_p, "Required field \"shared_folder_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new MountFolderArg(sharedFolderId); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/MountFolderError.java b/src/main/java/com/dropbox/core/v2/sharing/MountFolderError.java index aa1ffe2b5..9e61675c8 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/MountFolderError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/MountFolderError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=MountFolderError.Serializer.class) -@JsonDeserialize(using=MountFolderError.Deserializer.class) public final class MountFolderError { // union MountFolderError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link MountFolderError}. */ @@ -303,7 +285,7 @@ else if (obj instanceof MountFolderError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -315,106 +297,99 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MountFolderError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MountFolderError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case ACCESS_ERROR: + public void serialize(MountFolderError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case ACCESS_ERROR: { g.writeStartObject(); - g.writeStringField(".tag", "access_error"); - g.writeObjectField("access_error", value.accessErrorValue); + writeTag("access_error", g); + g.writeFieldName("access_error"); + SharedFolderAccessError.Serializer.INSTANCE.serialize(value.accessErrorValue, g); g.writeEndObject(); break; - case INSIDE_SHARED_FOLDER: + } + case INSIDE_SHARED_FOLDER: { g.writeString("inside_shared_folder"); break; - case INSUFFICIENT_QUOTA: + } + case INSUFFICIENT_QUOTA: { g.writeString("insufficient_quota"); break; - case ALREADY_MOUNTED: + } + case ALREADY_MOUNTED: { g.writeString("already_mounted"); break; - case NO_PERMISSION: + } + case NO_PERMISSION: { g.writeString("no_permission"); break; - case NOT_MOUNTABLE: + } + case NOT_MOUNTABLE: { g.writeString("not_mountable"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MountFolderError.class, getTagMapping(), Tag.OTHER); - } @Override - public MountFolderError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case ACCESS_ERROR: { - SharedFolderAccessError value = null; - expectField(_p, "access_error"); - value = _p.readValueAs(SharedFolderAccessError.class); - _p.nextToken(); - return MountFolderError.accessError(value); - } - case INSIDE_SHARED_FOLDER: { - return MountFolderError.INSIDE_SHARED_FOLDER; - } - case INSUFFICIENT_QUOTA: { - return MountFolderError.INSUFFICIENT_QUOTA; - } - case ALREADY_MOUNTED: { - return MountFolderError.ALREADY_MOUNTED; - } - case NO_PERMISSION: { - return MountFolderError.NO_PERMISSION; - } - case NOT_MOUNTABLE: { - return MountFolderError.NOT_MOUNTABLE; - } - case OTHER: { - return MountFolderError.OTHER; - } + public MountFolderError deserialize(JsonParser p) throws IOException, JsonParseException { + MountFolderError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("access_error", MountFolderError.Tag.ACCESS_ERROR); - values.put("inside_shared_folder", MountFolderError.Tag.INSIDE_SHARED_FOLDER); - values.put("insufficient_quota", MountFolderError.Tag.INSUFFICIENT_QUOTA); - values.put("already_mounted", MountFolderError.Tag.ALREADY_MOUNTED); - values.put("no_permission", MountFolderError.Tag.NO_PERMISSION); - values.put("not_mountable", MountFolderError.Tag.NOT_MOUNTABLE); - values.put("other", MountFolderError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("access_error".equals(tag)) { + SharedFolderAccessError fieldValue = null; + expectField("access_error", p); + fieldValue = SharedFolderAccessError.Serializer.INSTANCE.deserialize(p); + value = MountFolderError.accessError(fieldValue); + } + else if ("inside_shared_folder".equals(tag)) { + value = MountFolderError.INSIDE_SHARED_FOLDER; + } + else if ("insufficient_quota".equals(tag)) { + value = MountFolderError.INSUFFICIENT_QUOTA; + } + else if ("already_mounted".equals(tag)) { + value = MountFolderError.ALREADY_MOUNTED; + } + else if ("no_permission".equals(tag)) { + value = MountFolderError.NO_PERMISSION; + } + else if ("not_mountable".equals(tag)) { + value = MountFolderError.NOT_MOUNTABLE; + } + else { + value = MountFolderError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/MountFolderErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/MountFolderErrorException.java index c1ffba44a..15c3aa52b 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/MountFolderErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/MountFolderErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/PathLinkMetadata.java b/src/main/java/com/dropbox/core/v2/sharing/PathLinkMetadata.java index 163a4bc07..211e9fb24 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/PathLinkMetadata.java +++ b/src/main/java/com/dropbox/core/v2/sharing/PathLinkMetadata.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.Date; @@ -29,15 +18,9 @@ /** * Metadata for a path-based shared link. */ -@JsonSerialize(using=PathLinkMetadata.Serializer.class) -@JsonDeserialize(using=PathLinkMetadata.Deserializer.class) public class PathLinkMetadata extends LinkMetadata { // struct PathLinkMetadata - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String path; /** @@ -115,7 +98,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -127,101 +110,89 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); + return Serializer.INSTANCE.serialize(this, true); } - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(PathLinkMetadata.class); - } - - public Serializer(boolean unwrapping) { - super(PathLinkMetadata.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(PathLinkMetadata value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeStringField(".tag", "path"); - g.writeObjectField("url", value.url); - g.writeObjectField("visibility", value.visibility); - g.writeObjectField("path", value.path); + public void serialize(PathLinkMetadata value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + writeTag("path", g); + g.writeFieldName("url"); + StoneSerializers.string().serialize(value.url, g); + g.writeFieldName("visibility"); + Visibility.Serializer.INSTANCE.serialize(value.visibility, g); + g.writeFieldName("path"); + StoneSerializers.string().serialize(value.path, g); if (value.expires != null) { - g.writeObjectField("expires", value.expires); + g.writeFieldName("expires"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.expires, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(PathLinkMetadata.class); - } - - public Deserializer(boolean unwrapping) { - super(PathLinkMetadata.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public PathLinkMetadata deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - String _subtype_tag = readEnumeratedSubtypeTag(_p, "path"); - - String url = null; - Visibility visibility = null; - String path = null; - Date expires = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("url".equals(_field)) { - url = getStringValue(_p); - _p.nextToken(); + public PathLinkMetadata deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + PathLinkMetadata value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + if ("path".equals(tag)) { + tag = null; } - else if ("visibility".equals(_field)) { - visibility = _p.readValueAs(Visibility.class); - _p.nextToken(); + } + if (tag == null) { + String f_url = null; + Visibility f_visibility = null; + String f_path = null; + Date f_expires = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("url".equals(field)) { + f_url = StoneSerializers.string().deserialize(p); + } + else if ("visibility".equals(field)) { + f_visibility = Visibility.Serializer.INSTANCE.deserialize(p); + } + else if ("path".equals(field)) { + f_path = StoneSerializers.string().deserialize(p); + } + else if ("expires".equals(field)) { + f_expires = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else { + skipValue(p); + } } - else if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); + if (f_url == null) { + throw new JsonParseException(p, "Required field \"url\" missing."); } - else if ("expires".equals(_field)) { - expires = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); + if (f_visibility == null) { + throw new JsonParseException(p, "Required field \"visibility\" missing."); } - else { - skipValue(_p); + if (f_path == null) { + throw new JsonParseException(p, "Required field \"path\" missing."); } + value = new PathLinkMetadata(f_url, f_visibility, f_path, f_expires); } - - if (url == null) { - throw new JsonParseException(_p, "Required field \"url\" is missing."); - } - if (visibility == null) { - throw new JsonParseException(_p, "Required field \"visibility\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (path == null) { - throw new JsonParseException(_p, "Required field \"path\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new PathLinkMetadata(url, visibility, path, expires); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/PendingUploadMode.java b/src/main/java/com/dropbox/core/v2/sharing/PendingUploadMode.java index 07c8d5c72..29100f93a 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/PendingUploadMode.java +++ b/src/main/java/com/dropbox/core/v2/sharing/PendingUploadMode.java @@ -1,37 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Flag to indicate pending upload default (for linking to not-yet-existing * paths). */ -@JsonSerialize(using=PendingUploadMode.Serializer.class) -@JsonDeserialize(using=PendingUploadMode.Deserializer.class) public enum PendingUploadMode { // union PendingUploadMode /** @@ -43,47 +29,60 @@ public enum PendingUploadMode { */ FOLDER; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(PendingUploadMode.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(PendingUploadMode value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(PendingUploadMode value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case FILE: + case FILE: { g.writeString("file"); break; - case FOLDER: + } + case FOLDER: { g.writeString("folder"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(PendingUploadMode.class, getTagMapping(), null); - } @Override - public PendingUploadMode deserialize(PendingUploadMode _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("file", PendingUploadMode.FILE); - values.put("folder", PendingUploadMode.FOLDER); - return Collections.unmodifiableMap(values); + public PendingUploadMode deserialize(JsonParser p) throws IOException, JsonParseException { + PendingUploadMode value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("file".equals(tag)) { + value = PendingUploadMode.FILE; + } + else if ("folder".equals(tag)) { + value = PendingUploadMode.FOLDER; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/PermissionDeniedReason.java b/src/main/java/com/dropbox/core/v2/sharing/PermissionDeniedReason.java index 12410151c..d8b19ae79 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/PermissionDeniedReason.java +++ b/src/main/java/com/dropbox/core/v2/sharing/PermissionDeniedReason.java @@ -1,36 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Possible reasons the user is denied a permission. */ -@JsonSerialize(using=PermissionDeniedReason.Serializer.class) -@JsonDeserialize(using=PermissionDeniedReason.Deserializer.class) public enum PermissionDeniedReason { // union PermissionDeniedReason /** @@ -67,67 +53,89 @@ public enum PermissionDeniedReason { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(PermissionDeniedReason.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(PermissionDeniedReason value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(PermissionDeniedReason value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case USER_NOT_SAME_TEAM_AS_OWNER: + case USER_NOT_SAME_TEAM_AS_OWNER: { g.writeString("user_not_same_team_as_owner"); break; - case USER_NOT_ALLOWED_BY_OWNER: + } + case USER_NOT_ALLOWED_BY_OWNER: { g.writeString("user_not_allowed_by_owner"); break; - case TARGET_IS_INDIRECT_MEMBER: + } + case TARGET_IS_INDIRECT_MEMBER: { g.writeString("target_is_indirect_member"); break; - case TARGET_IS_OWNER: + } + case TARGET_IS_OWNER: { g.writeString("target_is_owner"); break; - case TARGET_IS_SELF: + } + case TARGET_IS_SELF: { g.writeString("target_is_self"); break; - case TARGET_NOT_ACTIVE: + } + case TARGET_NOT_ACTIVE: { g.writeString("target_not_active"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(PermissionDeniedReason.class, getTagMapping(), PermissionDeniedReason.OTHER); - } @Override - public PermissionDeniedReason deserialize(PermissionDeniedReason _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("user_not_same_team_as_owner", PermissionDeniedReason.USER_NOT_SAME_TEAM_AS_OWNER); - values.put("user_not_allowed_by_owner", PermissionDeniedReason.USER_NOT_ALLOWED_BY_OWNER); - values.put("target_is_indirect_member", PermissionDeniedReason.TARGET_IS_INDIRECT_MEMBER); - values.put("target_is_owner", PermissionDeniedReason.TARGET_IS_OWNER); - values.put("target_is_self", PermissionDeniedReason.TARGET_IS_SELF); - values.put("target_not_active", PermissionDeniedReason.TARGET_NOT_ACTIVE); - values.put("other", PermissionDeniedReason.OTHER); - return Collections.unmodifiableMap(values); + public PermissionDeniedReason deserialize(JsonParser p) throws IOException, JsonParseException { + PermissionDeniedReason value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("user_not_same_team_as_owner".equals(tag)) { + value = PermissionDeniedReason.USER_NOT_SAME_TEAM_AS_OWNER; + } + else if ("user_not_allowed_by_owner".equals(tag)) { + value = PermissionDeniedReason.USER_NOT_ALLOWED_BY_OWNER; + } + else if ("target_is_indirect_member".equals(tag)) { + value = PermissionDeniedReason.TARGET_IS_INDIRECT_MEMBER; + } + else if ("target_is_owner".equals(tag)) { + value = PermissionDeniedReason.TARGET_IS_OWNER; + } + else if ("target_is_self".equals(tag)) { + value = PermissionDeniedReason.TARGET_IS_SELF; + } + else if ("target_not_active".equals(tag)) { + value = PermissionDeniedReason.TARGET_NOT_ACTIVE; + } + else { + value = PermissionDeniedReason.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/RelinquishFolderMembershipArg.java b/src/main/java/com/dropbox/core/v2/sharing/RelinquishFolderMembershipArg.java index 69e57b663..4a23fb277 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/RelinquishFolderMembershipArg.java +++ b/src/main/java/com/dropbox/core/v2/sharing/RelinquishFolderMembershipArg.java @@ -1,50 +1,36 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=RelinquishFolderMembershipArg.Serializer.class) -@JsonDeserialize(using=RelinquishFolderMembershipArg.Deserializer.class) class RelinquishFolderMembershipArg { // struct RelinquishFolderMembershipArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String sharedFolderId; + protected final boolean leaveACopy; /** * * @param sharedFolderId The ID for the shared folder. Must match pattern * "{@code [-_0-9a-zA-Z:]+}" and not be {@code null}. + * @param leaveACopy Keep a copy of the folder's contents upon + * relinquishing membership. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. */ - public RelinquishFolderMembershipArg(String sharedFolderId) { + public RelinquishFolderMembershipArg(String sharedFolderId, boolean leaveACopy) { if (sharedFolderId == null) { throw new IllegalArgumentException("Required value for 'sharedFolderId' is null"); } @@ -52,6 +38,20 @@ public RelinquishFolderMembershipArg(String sharedFolderId) { throw new IllegalArgumentException("String 'sharedFolderId' does not match pattern"); } this.sharedFolderId = sharedFolderId; + this.leaveACopy = leaveACopy; + } + + /** + * The default values for unset fields will be used. + * + * @param sharedFolderId The ID for the shared folder. Must match pattern + * "{@code [-_0-9a-zA-Z:]+}" and not be {@code null}. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public RelinquishFolderMembershipArg(String sharedFolderId) { + this(sharedFolderId, false); } /** @@ -63,10 +63,21 @@ public String getSharedFolderId() { return sharedFolderId; } + /** + * Keep a copy of the folder's contents upon relinquishing membership. + * + * @return value for this field, or {@code null} if not present. Defaults to + * false. + */ + public boolean getLeaveACopy() { + return leaveACopy; + } + @Override public int hashCode() { int hash = java.util.Arrays.hashCode(new Object [] { - sharedFolderId + sharedFolderId, + leaveACopy }); return hash; } @@ -79,7 +90,9 @@ public boolean equals(Object obj) { // be careful with inheritance else if (obj.getClass().equals(this.getClass())) { RelinquishFolderMembershipArg other = (RelinquishFolderMembershipArg) obj; - return (this.sharedFolderId == other.sharedFolderId) || (this.sharedFolderId.equals(other.sharedFolderId)); + return ((this.sharedFolderId == other.sharedFolderId) || (this.sharedFolderId.equals(other.sharedFolderId))) + && (this.leaveACopy == other.leaveACopy) + ; } else { return false; @@ -88,7 +101,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -100,78 +113,65 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RelinquishFolderMembershipArg.class); - } - - public Serializer(boolean unwrapping) { - super(RelinquishFolderMembershipArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(RelinquishFolderMembershipArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("shared_folder_id", value.sharedFolderId); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RelinquishFolderMembershipArg.class); - } - - public Deserializer(boolean unwrapping) { - super(RelinquishFolderMembershipArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(RelinquishFolderMembershipArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("shared_folder_id"); + StoneSerializers.string().serialize(value.sharedFolderId, g); + g.writeFieldName("leave_a_copy"); + StoneSerializers.boolean_().serialize(value.leaveACopy, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public RelinquishFolderMembershipArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String sharedFolderId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("shared_folder_id".equals(_field)) { - sharedFolderId = getStringValue(_p); - _p.nextToken(); + public RelinquishFolderMembershipArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + RelinquishFolderMembershipArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_sharedFolderId = null; + Boolean f_leaveACopy = false; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("shared_folder_id".equals(field)) { + f_sharedFolderId = StoneSerializers.string().deserialize(p); + } + else if ("leave_a_copy".equals(field)) { + f_leaveACopy = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_sharedFolderId == null) { + throw new JsonParseException(p, "Required field \"shared_folder_id\" missing."); } + value = new RelinquishFolderMembershipArg(f_sharedFolderId, f_leaveACopy); } - - if (sharedFolderId == null) { - throw new JsonParseException(_p, "Required field \"shared_folder_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new RelinquishFolderMembershipArg(sharedFolderId); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/RelinquishFolderMembershipError.java b/src/main/java/com/dropbox/core/v2/sharing/RelinquishFolderMembershipError.java index c6afba1ec..20e380778 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/RelinquishFolderMembershipError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/RelinquishFolderMembershipError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=RelinquishFolderMembershipError.Serializer.class) -@JsonDeserialize(using=RelinquishFolderMembershipError.Deserializer.class) public final class RelinquishFolderMembershipError { // union RelinquishFolderMembershipError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link RelinquishFolderMembershipError}. */ @@ -305,7 +287,7 @@ else if (obj instanceof RelinquishFolderMembershipError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -317,106 +299,99 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RelinquishFolderMembershipError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(RelinquishFolderMembershipError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case ACCESS_ERROR: + public void serialize(RelinquishFolderMembershipError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case ACCESS_ERROR: { g.writeStartObject(); - g.writeStringField(".tag", "access_error"); - g.writeObjectField("access_error", value.accessErrorValue); + writeTag("access_error", g); + g.writeFieldName("access_error"); + SharedFolderAccessError.Serializer.INSTANCE.serialize(value.accessErrorValue, g); g.writeEndObject(); break; - case FOLDER_OWNER: + } + case FOLDER_OWNER: { g.writeString("folder_owner"); break; - case MOUNTED: + } + case MOUNTED: { g.writeString("mounted"); break; - case GROUP_ACCESS: + } + case GROUP_ACCESS: { g.writeString("group_access"); break; - case TEAM_FOLDER: + } + case TEAM_FOLDER: { g.writeString("team_folder"); break; - case NO_PERMISSION: + } + case NO_PERMISSION: { g.writeString("no_permission"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RelinquishFolderMembershipError.class, getTagMapping(), Tag.OTHER); - } @Override - public RelinquishFolderMembershipError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case ACCESS_ERROR: { - SharedFolderAccessError value = null; - expectField(_p, "access_error"); - value = _p.readValueAs(SharedFolderAccessError.class); - _p.nextToken(); - return RelinquishFolderMembershipError.accessError(value); - } - case FOLDER_OWNER: { - return RelinquishFolderMembershipError.FOLDER_OWNER; - } - case MOUNTED: { - return RelinquishFolderMembershipError.MOUNTED; - } - case GROUP_ACCESS: { - return RelinquishFolderMembershipError.GROUP_ACCESS; - } - case TEAM_FOLDER: { - return RelinquishFolderMembershipError.TEAM_FOLDER; - } - case NO_PERMISSION: { - return RelinquishFolderMembershipError.NO_PERMISSION; - } - case OTHER: { - return RelinquishFolderMembershipError.OTHER; - } + public RelinquishFolderMembershipError deserialize(JsonParser p) throws IOException, JsonParseException { + RelinquishFolderMembershipError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("access_error", RelinquishFolderMembershipError.Tag.ACCESS_ERROR); - values.put("folder_owner", RelinquishFolderMembershipError.Tag.FOLDER_OWNER); - values.put("mounted", RelinquishFolderMembershipError.Tag.MOUNTED); - values.put("group_access", RelinquishFolderMembershipError.Tag.GROUP_ACCESS); - values.put("team_folder", RelinquishFolderMembershipError.Tag.TEAM_FOLDER); - values.put("no_permission", RelinquishFolderMembershipError.Tag.NO_PERMISSION); - values.put("other", RelinquishFolderMembershipError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("access_error".equals(tag)) { + SharedFolderAccessError fieldValue = null; + expectField("access_error", p); + fieldValue = SharedFolderAccessError.Serializer.INSTANCE.deserialize(p); + value = RelinquishFolderMembershipError.accessError(fieldValue); + } + else if ("folder_owner".equals(tag)) { + value = RelinquishFolderMembershipError.FOLDER_OWNER; + } + else if ("mounted".equals(tag)) { + value = RelinquishFolderMembershipError.MOUNTED; + } + else if ("group_access".equals(tag)) { + value = RelinquishFolderMembershipError.GROUP_ACCESS; + } + else if ("team_folder".equals(tag)) { + value = RelinquishFolderMembershipError.TEAM_FOLDER; + } + else if ("no_permission".equals(tag)) { + value = RelinquishFolderMembershipError.NO_PERMISSION; + } + else { + value = RelinquishFolderMembershipError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/RelinquishFolderMembershipErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/RelinquishFolderMembershipErrorException.java index 7b60fa1a3..a1e54de88 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/RelinquishFolderMembershipErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/RelinquishFolderMembershipErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/RemoveFolderMemberArg.java b/src/main/java/com/dropbox/core/v2/sharing/RemoveFolderMemberArg.java index 6eaee7ae0..5e7efa98d 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/RemoveFolderMemberArg.java +++ b/src/main/java/com/dropbox/core/v2/sharing/RemoveFolderMemberArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=RemoveFolderMemberArg.Serializer.class) -@JsonDeserialize(using=RemoveFolderMemberArg.Deserializer.class) class RemoveFolderMemberArg { // struct RemoveFolderMemberArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String sharedFolderId; protected final MemberSelector member; protected final boolean leaveACopy; @@ -126,7 +109,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -138,96 +121,77 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RemoveFolderMemberArg.class); - } - - public Serializer(boolean unwrapping) { - super(RemoveFolderMemberArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(RemoveFolderMemberArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("shared_folder_id", value.sharedFolderId); - g.writeObjectField("member", value.member); - g.writeObjectField("leave_a_copy", value.leaveACopy); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RemoveFolderMemberArg.class); - } - - public Deserializer(boolean unwrapping) { - super(RemoveFolderMemberArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(RemoveFolderMemberArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("shared_folder_id"); + StoneSerializers.string().serialize(value.sharedFolderId, g); + g.writeFieldName("member"); + MemberSelector.Serializer.INSTANCE.serialize(value.member, g); + g.writeFieldName("leave_a_copy"); + StoneSerializers.boolean_().serialize(value.leaveACopy, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public RemoveFolderMemberArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String sharedFolderId = null; - MemberSelector member = null; - Boolean leaveACopy = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("shared_folder_id".equals(_field)) { - sharedFolderId = getStringValue(_p); - _p.nextToken(); + public RemoveFolderMemberArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + RemoveFolderMemberArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_sharedFolderId = null; + MemberSelector f_member = null; + Boolean f_leaveACopy = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("shared_folder_id".equals(field)) { + f_sharedFolderId = StoneSerializers.string().deserialize(p); + } + else if ("member".equals(field)) { + f_member = MemberSelector.Serializer.INSTANCE.deserialize(p); + } + else if ("leave_a_copy".equals(field)) { + f_leaveACopy = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } } - else if ("member".equals(_field)) { - member = _p.readValueAs(MemberSelector.class); - _p.nextToken(); + if (f_sharedFolderId == null) { + throw new JsonParseException(p, "Required field \"shared_folder_id\" missing."); } - else if ("leave_a_copy".equals(_field)) { - leaveACopy = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_member == null) { + throw new JsonParseException(p, "Required field \"member\" missing."); } - else { - skipValue(_p); + if (f_leaveACopy == null) { + throw new JsonParseException(p, "Required field \"leave_a_copy\" missing."); } + value = new RemoveFolderMemberArg(f_sharedFolderId, f_member, f_leaveACopy); } - - if (sharedFolderId == null) { - throw new JsonParseException(_p, "Required field \"shared_folder_id\" is missing."); - } - if (member == null) { - throw new JsonParseException(_p, "Required field \"member\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (leaveACopy == null) { - throw new JsonParseException(_p, "Required field \"leave_a_copy\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new RemoveFolderMemberArg(sharedFolderId, member, leaveACopy); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/RemoveFolderMemberError.java b/src/main/java/com/dropbox/core/v2/sharing/RemoveFolderMemberError.java index 80cdd2493..c4f60d05d 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/RemoveFolderMemberError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/RemoveFolderMemberError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=RemoveFolderMemberError.Serializer.class) -@JsonDeserialize(using=RemoveFolderMemberError.Deserializer.class) public final class RemoveFolderMemberError { // union RemoveFolderMemberError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link RemoveFolderMemberError}. */ @@ -328,7 +310,7 @@ else if (obj instanceof RemoveFolderMemberError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -340,113 +322,106 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RemoveFolderMemberError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(RemoveFolderMemberError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case ACCESS_ERROR: + public void serialize(RemoveFolderMemberError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case ACCESS_ERROR: { g.writeStartObject(); - g.writeStringField(".tag", "access_error"); - g.writeObjectField("access_error", value.accessErrorValue); + writeTag("access_error", g); + g.writeFieldName("access_error"); + SharedFolderAccessError.Serializer.INSTANCE.serialize(value.accessErrorValue, g); g.writeEndObject(); break; - case MEMBER_ERROR: + } + case MEMBER_ERROR: { g.writeStartObject(); - g.writeStringField(".tag", "member_error"); - g.writeObjectField("member_error", value.memberErrorValue); + writeTag("member_error", g); + g.writeFieldName("member_error"); + SharedFolderMemberError.Serializer.INSTANCE.serialize(value.memberErrorValue, g); g.writeEndObject(); break; - case FOLDER_OWNER: + } + case FOLDER_OWNER: { g.writeString("folder_owner"); break; - case GROUP_ACCESS: + } + case GROUP_ACCESS: { g.writeString("group_access"); break; - case TEAM_FOLDER: + } + case TEAM_FOLDER: { g.writeString("team_folder"); break; - case NO_PERMISSION: + } + case NO_PERMISSION: { g.writeString("no_permission"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RemoveFolderMemberError.class, getTagMapping(), Tag.OTHER); - } @Override - public RemoveFolderMemberError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case ACCESS_ERROR: { - SharedFolderAccessError value = null; - expectField(_p, "access_error"); - value = _p.readValueAs(SharedFolderAccessError.class); - _p.nextToken(); - return RemoveFolderMemberError.accessError(value); - } - case MEMBER_ERROR: { - SharedFolderMemberError value = null; - expectField(_p, "member_error"); - value = _p.readValueAs(SharedFolderMemberError.class); - _p.nextToken(); - return RemoveFolderMemberError.memberError(value); - } - case FOLDER_OWNER: { - return RemoveFolderMemberError.FOLDER_OWNER; - } - case GROUP_ACCESS: { - return RemoveFolderMemberError.GROUP_ACCESS; - } - case TEAM_FOLDER: { - return RemoveFolderMemberError.TEAM_FOLDER; - } - case NO_PERMISSION: { - return RemoveFolderMemberError.NO_PERMISSION; - } - case OTHER: { - return RemoveFolderMemberError.OTHER; - } + public RemoveFolderMemberError deserialize(JsonParser p) throws IOException, JsonParseException { + RemoveFolderMemberError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("access_error", RemoveFolderMemberError.Tag.ACCESS_ERROR); - values.put("member_error", RemoveFolderMemberError.Tag.MEMBER_ERROR); - values.put("folder_owner", RemoveFolderMemberError.Tag.FOLDER_OWNER); - values.put("group_access", RemoveFolderMemberError.Tag.GROUP_ACCESS); - values.put("team_folder", RemoveFolderMemberError.Tag.TEAM_FOLDER); - values.put("no_permission", RemoveFolderMemberError.Tag.NO_PERMISSION); - values.put("other", RemoveFolderMemberError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("access_error".equals(tag)) { + SharedFolderAccessError fieldValue = null; + expectField("access_error", p); + fieldValue = SharedFolderAccessError.Serializer.INSTANCE.deserialize(p); + value = RemoveFolderMemberError.accessError(fieldValue); + } + else if ("member_error".equals(tag)) { + SharedFolderMemberError fieldValue = null; + expectField("member_error", p); + fieldValue = SharedFolderMemberError.Serializer.INSTANCE.deserialize(p); + value = RemoveFolderMemberError.memberError(fieldValue); + } + else if ("folder_owner".equals(tag)) { + value = RemoveFolderMemberError.FOLDER_OWNER; + } + else if ("group_access".equals(tag)) { + value = RemoveFolderMemberError.GROUP_ACCESS; + } + else if ("team_folder".equals(tag)) { + value = RemoveFolderMemberError.TEAM_FOLDER; + } + else if ("no_permission".equals(tag)) { + value = RemoveFolderMemberError.NO_PERMISSION; + } + else { + value = RemoveFolderMemberError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/RemoveFolderMemberErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/RemoveFolderMemberErrorException.java index 4b6b6e794..e6090900f 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/RemoveFolderMemberErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/RemoveFolderMemberErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/RequestedVisibility.java b/src/main/java/com/dropbox/core/v2/sharing/RequestedVisibility.java index 9000c07d2..c869d4a38 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/RequestedVisibility.java +++ b/src/main/java/com/dropbox/core/v2/sharing/RequestedVisibility.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * The access permission that can be requested by the caller for the shared @@ -33,8 +21,6 @@ * {@link ResolvedVisibility} for more info on the possible resolved visibility * values of shared links. */ -@JsonSerialize(using=RequestedVisibility.Serializer.class) -@JsonDeserialize(using=RequestedVisibility.Deserializer.class) public enum RequestedVisibility { // union RequestedVisibility /** @@ -51,51 +37,67 @@ public enum RequestedVisibility { */ PASSWORD; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RequestedVisibility.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(RequestedVisibility value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(RequestedVisibility value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case PUBLIC: + case PUBLIC: { g.writeString("public"); break; - case TEAM_ONLY: + } + case TEAM_ONLY: { g.writeString("team_only"); break; - case PASSWORD: + } + case PASSWORD: { g.writeString("password"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RequestedVisibility.class, getTagMapping(), null); - } @Override - public RequestedVisibility deserialize(RequestedVisibility _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("public", RequestedVisibility.PUBLIC); - values.put("team_only", RequestedVisibility.TEAM_ONLY); - values.put("password", RequestedVisibility.PASSWORD); - return Collections.unmodifiableMap(values); + public RequestedVisibility deserialize(JsonParser p) throws IOException, JsonParseException { + RequestedVisibility value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("public".equals(tag)) { + value = RequestedVisibility.PUBLIC; + } + else if ("team_only".equals(tag)) { + value = RequestedVisibility.TEAM_ONLY; + } + else if ("password".equals(tag)) { + value = RequestedVisibility.PASSWORD; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ResolvedVisibility.java b/src/main/java/com/dropbox/core/v2/sharing/ResolvedVisibility.java index 7fa03d016..8ef7a3135 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ResolvedVisibility.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ResolvedVisibility.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * The actual access permissions values of shared links after taking into @@ -32,8 +20,6 @@ * {@link RequestedVisibility} for more info on the possible visibility values * that can be set by the shared link's owner. */ -@JsonSerialize(using=ResolvedVisibility.Serializer.class) -@JsonDeserialize(using=ResolvedVisibility.Deserializer.class) public enum ResolvedVisibility { // union ResolvedVisibility /** @@ -64,60 +50,82 @@ public enum ResolvedVisibility { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ResolvedVisibility.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ResolvedVisibility value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(ResolvedVisibility value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case PUBLIC: + case PUBLIC: { g.writeString("public"); break; - case TEAM_ONLY: + } + case TEAM_ONLY: { g.writeString("team_only"); break; - case PASSWORD: + } + case PASSWORD: { g.writeString("password"); break; - case TEAM_AND_PASSWORD: + } + case TEAM_AND_PASSWORD: { g.writeString("team_and_password"); break; - case SHARED_FOLDER_ONLY: + } + case SHARED_FOLDER_ONLY: { g.writeString("shared_folder_only"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ResolvedVisibility.class, getTagMapping(), ResolvedVisibility.OTHER); - } @Override - public ResolvedVisibility deserialize(ResolvedVisibility _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("team_and_password", ResolvedVisibility.TEAM_AND_PASSWORD); - values.put("shared_folder_only", ResolvedVisibility.SHARED_FOLDER_ONLY); - values.put("other", ResolvedVisibility.OTHER); - return Collections.unmodifiableMap(values); + public ResolvedVisibility deserialize(JsonParser p) throws IOException, JsonParseException { + ResolvedVisibility value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("public".equals(tag)) { + value = ResolvedVisibility.PUBLIC; + } + else if ("team_only".equals(tag)) { + value = ResolvedVisibility.TEAM_ONLY; + } + else if ("password".equals(tag)) { + value = ResolvedVisibility.PASSWORD; + } + else if ("team_and_password".equals(tag)) { + value = ResolvedVisibility.TEAM_AND_PASSWORD; + } + else if ("shared_folder_only".equals(tag)) { + value = ResolvedVisibility.SHARED_FOLDER_ONLY; + } + else { + value = ResolvedVisibility.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/RevokeSharedLinkArg.java b/src/main/java/com/dropbox/core/v2/sharing/RevokeSharedLinkArg.java index fc5b1b33f..ad83a0ecd 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/RevokeSharedLinkArg.java +++ b/src/main/java/com/dropbox/core/v2/sharing/RevokeSharedLinkArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=RevokeSharedLinkArg.Serializer.class) -@JsonDeserialize(using=RevokeSharedLinkArg.Deserializer.class) class RevokeSharedLinkArg { // struct RevokeSharedLinkArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String url; /** @@ -84,7 +67,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -96,78 +79,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RevokeSharedLinkArg.class); - } - - public Serializer(boolean unwrapping) { - super(RevokeSharedLinkArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(RevokeSharedLinkArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("url", value.url); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RevokeSharedLinkArg.class); - } - - public Deserializer(boolean unwrapping) { - super(RevokeSharedLinkArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(RevokeSharedLinkArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("url"); + StoneSerializers.string().serialize(value.url, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public RevokeSharedLinkArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String url = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("url".equals(_field)) { - url = getStringValue(_p); - _p.nextToken(); + public RevokeSharedLinkArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + RevokeSharedLinkArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_url = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("url".equals(field)) { + f_url = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_url == null) { + throw new JsonParseException(p, "Required field \"url\" missing."); } + value = new RevokeSharedLinkArg(f_url); } - - if (url == null) { - throw new JsonParseException(_p, "Required field \"url\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new RevokeSharedLinkArg(url); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/RevokeSharedLinkError.java b/src/main/java/com/dropbox/core/v2/sharing/RevokeSharedLinkError.java index 711b453aa..71e1cfdd6 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/RevokeSharedLinkError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/RevokeSharedLinkError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=RevokeSharedLinkError.Serializer.class) -@JsonDeserialize(using=RevokeSharedLinkError.Deserializer.class) public enum RevokeSharedLinkError { // union RevokeSharedLinkError /** @@ -47,52 +33,74 @@ public enum RevokeSharedLinkError { */ SHARED_LINK_MALFORMED; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RevokeSharedLinkError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(RevokeSharedLinkError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(RevokeSharedLinkError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case SHARED_LINK_NOT_FOUND: + case SHARED_LINK_NOT_FOUND: { g.writeString("shared_link_not_found"); break; - case SHARED_LINK_ACCESS_DENIED: + } + case SHARED_LINK_ACCESS_DENIED: { g.writeString("shared_link_access_denied"); break; - case OTHER: + } + case OTHER: { g.writeString("other"); break; - case SHARED_LINK_MALFORMED: + } + case SHARED_LINK_MALFORMED: { g.writeString("shared_link_malformed"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RevokeSharedLinkError.class, getTagMapping(), null); - } @Override - public RevokeSharedLinkError deserialize(RevokeSharedLinkError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("shared_link_malformed", RevokeSharedLinkError.SHARED_LINK_MALFORMED); - return Collections.unmodifiableMap(values); + public RevokeSharedLinkError deserialize(JsonParser p) throws IOException, JsonParseException { + RevokeSharedLinkError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("shared_link_not_found".equals(tag)) { + value = RevokeSharedLinkError.SHARED_LINK_NOT_FOUND; + } + else if ("shared_link_access_denied".equals(tag)) { + value = RevokeSharedLinkError.SHARED_LINK_ACCESS_DENIED; + } + else if ("other".equals(tag)) { + value = RevokeSharedLinkError.OTHER; + } + else if ("shared_link_malformed".equals(tag)) { + value = RevokeSharedLinkError.SHARED_LINK_MALFORMED; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/RevokeSharedLinkErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/RevokeSharedLinkErrorException.java index 23679b0fa..65437517b 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/RevokeSharedLinkErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/RevokeSharedLinkErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/ShareFolderArg.java b/src/main/java/com/dropbox/core/v2/sharing/ShareFolderArg.java index ca740a1f1..e3ea83b6c 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ShareFolderArg.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ShareFolderArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=ShareFolderArg.Serializer.class) -@JsonDeserialize(using=ShareFolderArg.Deserializer.class) class ShareFolderArg { // struct ShareFolderArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String path; protected final MemberPolicy memberPolicy; protected final AclUpdatePolicy aclUpdatePolicy; @@ -45,8 +28,8 @@ class ShareFolderArg { * specifying values for all optional fields. * * @param path The path to the folder to share. If it does not exist, then - * a new one is created. Must match pattern "{@code /.*}" and not be - * {@code null}. + * a new one is created. Must match pattern "{@code /(.|[\\r\\n])*}" and + * not be {@code null}. * @param memberPolicy Who can be a member of this shared folder. Only * applicable if the current user is on a team. * @param aclUpdatePolicy Who can add and remove members of this shared @@ -63,7 +46,7 @@ public ShareFolderArg(String path, MemberPolicy memberPolicy, AclUpdatePolicy ac if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("/.*", path)) { + if (!java.util.regex.Pattern.matches("/(.|[\\r\\n])*", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -86,8 +69,8 @@ public ShareFolderArg(String path, MemberPolicy memberPolicy, AclUpdatePolicy ac * The default values for unset fields will be used. * * @param path The path to the folder to share. If it does not exist, then - * a new one is created. Must match pattern "{@code /.*}" and not be - * {@code null}. + * a new one is created. Must match pattern "{@code /(.|[\\r\\n])*}" and + * not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -153,8 +136,8 @@ public boolean getForceAsync() { * Returns a new builder for creating an instance of this class. * * @param path The path to the folder to share. If it does not exist, then - * a new one is created. Must match pattern "{@code /.*}" and not be - * {@code null}. + * a new one is created. Must match pattern "{@code /(.|[\\r\\n])*}" and + * not be {@code null}. * * @return builder for this class. * @@ -180,7 +163,7 @@ protected Builder(String path) { if (path == null) { throw new IllegalArgumentException("Required value for 'path' is null"); } - if (!java.util.regex.Pattern.matches("/.*", path)) { + if (!java.util.regex.Pattern.matches("/(.|[\\r\\n])*", path)) { throw new IllegalArgumentException("String 'path' does not match pattern"); } this.path = path; @@ -325,7 +308,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -337,102 +320,83 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ShareFolderArg.class); - } - - public Serializer(boolean unwrapping) { - super(ShareFolderArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(ShareFolderArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("path", value.path); - g.writeObjectField("member_policy", value.memberPolicy); - g.writeObjectField("acl_update_policy", value.aclUpdatePolicy); - g.writeObjectField("shared_link_policy", value.sharedLinkPolicy); - g.writeObjectField("force_async", value.forceAsync); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ShareFolderArg.class); - } - - public Deserializer(boolean unwrapping) { - super(ShareFolderArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(ShareFolderArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("path"); + StoneSerializers.string().serialize(value.path, g); + g.writeFieldName("member_policy"); + MemberPolicy.Serializer.INSTANCE.serialize(value.memberPolicy, g); + g.writeFieldName("acl_update_policy"); + AclUpdatePolicy.Serializer.INSTANCE.serialize(value.aclUpdatePolicy, g); + g.writeFieldName("shared_link_policy"); + SharedLinkPolicy.Serializer.INSTANCE.serialize(value.sharedLinkPolicy, g); + g.writeFieldName("force_async"); + StoneSerializers.boolean_().serialize(value.forceAsync, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public ShareFolderArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String path = null; - MemberPolicy memberPolicy = MemberPolicy.ANYONE; - AclUpdatePolicy aclUpdatePolicy = AclUpdatePolicy.OWNER; - SharedLinkPolicy sharedLinkPolicy = SharedLinkPolicy.ANYONE; - boolean forceAsync = false; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("path".equals(_field)) { - path = getStringValue(_p); - _p.nextToken(); - } - else if ("member_policy".equals(_field)) { - memberPolicy = _p.readValueAs(MemberPolicy.class); - _p.nextToken(); - } - else if ("acl_update_policy".equals(_field)) { - aclUpdatePolicy = _p.readValueAs(AclUpdatePolicy.class); - _p.nextToken(); - } - else if ("shared_link_policy".equals(_field)) { - sharedLinkPolicy = _p.readValueAs(SharedLinkPolicy.class); - _p.nextToken(); - } - else if ("force_async".equals(_field)) { - forceAsync = _p.getValueAsBoolean(); - _p.nextToken(); + public ShareFolderArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ShareFolderArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_path = null; + MemberPolicy f_memberPolicy = MemberPolicy.ANYONE; + AclUpdatePolicy f_aclUpdatePolicy = AclUpdatePolicy.OWNER; + SharedLinkPolicy f_sharedLinkPolicy = SharedLinkPolicy.ANYONE; + Boolean f_forceAsync = false; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("path".equals(field)) { + f_path = StoneSerializers.string().deserialize(p); + } + else if ("member_policy".equals(field)) { + f_memberPolicy = MemberPolicy.Serializer.INSTANCE.deserialize(p); + } + else if ("acl_update_policy".equals(field)) { + f_aclUpdatePolicy = AclUpdatePolicy.Serializer.INSTANCE.deserialize(p); + } + else if ("shared_link_policy".equals(field)) { + f_sharedLinkPolicy = SharedLinkPolicy.Serializer.INSTANCE.deserialize(p); + } + else if ("force_async".equals(field)) { + f_forceAsync = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_path == null) { + throw new JsonParseException(p, "Required field \"path\" missing."); } + value = new ShareFolderArg(f_path, f_memberPolicy, f_aclUpdatePolicy, f_sharedLinkPolicy, f_forceAsync); } - - if (path == null) { - throw new JsonParseException(_p, "Required field \"path\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new ShareFolderArg(path, memberPolicy, aclUpdatePolicy, sharedLinkPolicy, forceAsync); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ShareFolderBuilder.java b/src/main/java/com/dropbox/core/v2/sharing/ShareFolderBuilder.java index a3a68f803..383d6f680 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ShareFolderBuilder.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ShareFolderBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; @@ -13,26 +13,26 @@ * request.

*/ public class ShareFolderBuilder { - private final DbxUserSharingRequests sharing; + private final DbxUserSharingRequests sharing_; private final ShareFolderArg.Builder shareFolderArgBuilder; /** * Creates a new instance of this builder. * - * @param sharing Dropbox namespace-specific client used to issue sharing + * @param sharing_ Dropbox namespace-specific client used to issue sharing * requests. * @param shareFolderArgBuilder Request argument builder. * * @return instsance of this builder */ - ShareFolderBuilder(DbxUserSharingRequests sharing, ShareFolderArg.Builder shareFolderArgBuilder) { - if (sharing == null) { - throw new NullPointerException("sharing"); + ShareFolderBuilder(DbxUserSharingRequests sharing_, ShareFolderArg.Builder shareFolderArgBuilder) { + if (sharing_ == null) { + throw new NullPointerException("sharing_"); } + this.sharing_ = sharing_; if (shareFolderArgBuilder == null) { throw new NullPointerException("shareFolderArgBuilder"); } - this.sharing = sharing; this.shareFolderArgBuilder = shareFolderArgBuilder; } @@ -107,7 +107,7 @@ public ShareFolderBuilder withForceAsync(Boolean forceAsync) { * Issues the request. */ public ShareFolderLaunch start() throws ShareFolderErrorException, DbxException { - ShareFolderArg arg = this.shareFolderArgBuilder.build(); - return sharing.shareFolder(arg); + ShareFolderArg arg_ = this.shareFolderArgBuilder.build(); + return sharing_.shareFolder(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ShareFolderError.java b/src/main/java/com/dropbox/core/v2/sharing/ShareFolderError.java index c0accd7e8..d38707c7f 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ShareFolderError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ShareFolderError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=ShareFolderError.Serializer.class) -@JsonDeserialize(using=ShareFolderError.Deserializer.class) public final class ShareFolderError { // union ShareFolderError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link ShareFolderError}. */ @@ -290,7 +272,7 @@ else if (obj instanceof ShareFolderError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -302,99 +284,92 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); + return Serializer.INSTANCE.serialize(this, true); } - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ShareFolderError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ShareFolderError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case EMAIL_UNVERIFIED: + public void serialize(ShareFolderError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case EMAIL_UNVERIFIED: { g.writeString("email_unverified"); break; - case BAD_PATH: + } + case BAD_PATH: { g.writeStartObject(); - g.writeStringField(".tag", "bad_path"); - g.writeObjectField("bad_path", value.badPathValue); + writeTag("bad_path", g); + g.writeFieldName("bad_path"); + SharePathError.Serializer.INSTANCE.serialize(value.badPathValue, g); g.writeEndObject(); break; - case TEAM_POLICY_DISALLOWS_MEMBER_POLICY: + } + case TEAM_POLICY_DISALLOWS_MEMBER_POLICY: { g.writeString("team_policy_disallows_member_policy"); break; - case DISALLOWED_SHARED_LINK_POLICY: + } + case DISALLOWED_SHARED_LINK_POLICY: { g.writeString("disallowed_shared_link_policy"); break; - case NO_PERMISSION: + } + case NO_PERMISSION: { g.writeString("no_permission"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ShareFolderError.class, getTagMapping(), Tag.OTHER); - } @Override - public ShareFolderError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case EMAIL_UNVERIFIED: { - return ShareFolderError.EMAIL_UNVERIFIED; - } - case BAD_PATH: { - SharePathError value = null; - expectField(_p, "bad_path"); - value = _p.readValueAs(SharePathError.class); - _p.nextToken(); - return ShareFolderError.badPath(value); - } - case TEAM_POLICY_DISALLOWS_MEMBER_POLICY: { - return ShareFolderError.TEAM_POLICY_DISALLOWS_MEMBER_POLICY; - } - case DISALLOWED_SHARED_LINK_POLICY: { - return ShareFolderError.DISALLOWED_SHARED_LINK_POLICY; - } - case NO_PERMISSION: { - return ShareFolderError.NO_PERMISSION; - } - case OTHER: { - return ShareFolderError.OTHER; - } + public ShareFolderError deserialize(JsonParser p) throws IOException, JsonParseException { + ShareFolderError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("email_unverified", ShareFolderError.Tag.EMAIL_UNVERIFIED); - values.put("bad_path", ShareFolderError.Tag.BAD_PATH); - values.put("team_policy_disallows_member_policy", ShareFolderError.Tag.TEAM_POLICY_DISALLOWS_MEMBER_POLICY); - values.put("disallowed_shared_link_policy", ShareFolderError.Tag.DISALLOWED_SHARED_LINK_POLICY); - values.put("no_permission", ShareFolderError.Tag.NO_PERMISSION); - values.put("other", ShareFolderError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("email_unverified".equals(tag)) { + value = ShareFolderError.EMAIL_UNVERIFIED; + } + else if ("bad_path".equals(tag)) { + SharePathError fieldValue = null; + expectField("bad_path", p); + fieldValue = SharePathError.Serializer.INSTANCE.deserialize(p); + value = ShareFolderError.badPath(fieldValue); + } + else if ("team_policy_disallows_member_policy".equals(tag)) { + value = ShareFolderError.TEAM_POLICY_DISALLOWS_MEMBER_POLICY; + } + else if ("disallowed_shared_link_policy".equals(tag)) { + value = ShareFolderError.DISALLOWED_SHARED_LINK_POLICY; + } + else if ("no_permission".equals(tag)) { + value = ShareFolderError.NO_PERMISSION; + } + else { + value = ShareFolderError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ShareFolderErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/ShareFolderErrorException.java index b417c6ec6..8e44773ac 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ShareFolderErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ShareFolderErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/ShareFolderJobStatus.java b/src/main/java/com/dropbox/core/v2/sharing/ShareFolderJobStatus.java index 617fd906f..84fbd8826 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ShareFolderJobStatus.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ShareFolderJobStatus.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is a tagged union. Tagged unions instances are always associated @@ -32,15 +20,9 @@ * return {@code true}. You can use {@link #tag()} to determine the tag * associated with this instance. */ -@JsonSerialize(using=ShareFolderJobStatus.Serializer.class) -@JsonDeserialize(using=ShareFolderJobStatus.Deserializer.class) public final class ShareFolderJobStatus { // union ShareFolderJobStatus - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link ShareFolderJobStatus}. */ @@ -233,7 +215,7 @@ else if (obj instanceof ShareFolderJobStatus) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -245,82 +227,82 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ShareFolderJobStatus.class, SharedFolderMetadata.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ShareFolderJobStatus value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case IN_PROGRESS: + public void serialize(ShareFolderJobStatus value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case IN_PROGRESS: { g.writeString("in_progress"); break; - case COMPLETE: + } + case COMPLETE: { g.writeStartObject(); - g.writeStringField(".tag", "complete"); - getUnwrappingSerializer(SharedFolderMetadata.class).serialize(value.completeValue, g, provider); + writeTag("complete", g); + SharedFolderMetadata.Serializer.INSTANCE.serialize(value.completeValue, g, true); g.writeEndObject(); break; - case FAILED: + } + case FAILED: { g.writeStartObject(); - g.writeStringField(".tag", "failed"); - g.writeObjectField("failed", value.failedValue); + writeTag("failed", g); + g.writeFieldName("failed"); + ShareFolderError.Serializer.INSTANCE.serialize(value.failedValue, g); g.writeEndObject(); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ShareFolderJobStatus.class, getTagMapping(), null, SharedFolderMetadata.class); - } - - @Override - public ShareFolderJobStatus deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case IN_PROGRESS: { - return ShareFolderJobStatus.IN_PROGRESS; } - case COMPLETE: { - SharedFolderMetadata value = null; - value = readCollapsedStructValue(SharedFolderMetadata.class, _p, _ctx); - return ShareFolderJobStatus.complete(value); - } - case FAILED: { - ShareFolderError value = null; - expectField(_p, "failed"); - value = _p.readValueAs(ShareFolderError.class); - _p.nextToken(); - return ShareFolderJobStatus.failed(value); + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("complete", ShareFolderJobStatus.Tag.COMPLETE); - values.put("failed", ShareFolderJobStatus.Tag.FAILED); - return Collections.unmodifiableMap(values); + @Override + public ShareFolderJobStatus deserialize(JsonParser p) throws IOException, JsonParseException { + ShareFolderJobStatus value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("in_progress".equals(tag)) { + value = ShareFolderJobStatus.IN_PROGRESS; + } + else if ("complete".equals(tag)) { + SharedFolderMetadata fieldValue = null; + fieldValue = SharedFolderMetadata.Serializer.INSTANCE.deserialize(p, true); + value = ShareFolderJobStatus.complete(fieldValue); + } + else if ("failed".equals(tag)) { + ShareFolderError fieldValue = null; + expectField("failed", p); + fieldValue = ShareFolderError.Serializer.INSTANCE.deserialize(p); + value = ShareFolderJobStatus.failed(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/ShareFolderLaunch.java b/src/main/java/com/dropbox/core/v2/sharing/ShareFolderLaunch.java index 17d936126..25bf0f7f4 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/ShareFolderLaunch.java +++ b/src/main/java/com/dropbox/core/v2/sharing/ShareFolderLaunch.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is a tagged union. Tagged unions instances are always associated @@ -32,15 +20,9 @@ * return {@code true}. You can use {@link #tag()} to determine the tag * associated with this instance. */ -@JsonSerialize(using=ShareFolderLaunch.Serializer.class) -@JsonDeserialize(using=ShareFolderLaunch.Deserializer.class) public final class ShareFolderLaunch { // union ShareFolderLaunch - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link ShareFolderLaunch}. */ @@ -219,7 +201,7 @@ else if (obj instanceof ShareFolderLaunch) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -231,75 +213,75 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ShareFolderLaunch.class, SharedFolderMetadata.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ShareFolderLaunch value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case ASYNC_JOB_ID: + public void serialize(ShareFolderLaunch value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case ASYNC_JOB_ID: { g.writeStartObject(); - g.writeStringField(".tag", "async_job_id"); - g.writeObjectField("async_job_id", value.asyncJobIdValue); + writeTag("async_job_id", g); + g.writeFieldName("async_job_id"); + StoneSerializers.string().serialize(value.asyncJobIdValue, g); g.writeEndObject(); break; - case COMPLETE: + } + case COMPLETE: { g.writeStartObject(); - g.writeStringField(".tag", "complete"); - getUnwrappingSerializer(SharedFolderMetadata.class).serialize(value.completeValue, g, provider); + writeTag("complete", g); + SharedFolderMetadata.Serializer.INSTANCE.serialize(value.completeValue, g, true); g.writeEndObject(); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ShareFolderLaunch.class, getTagMapping(), null, SharedFolderMetadata.class); - } - - @Override - public ShareFolderLaunch deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case ASYNC_JOB_ID: { - String value = null; - expectField(_p, "async_job_id"); - value = getStringValue(_p); - _p.nextToken(); - return ShareFolderLaunch.asyncJobId(value); } - case COMPLETE: { - SharedFolderMetadata value = null; - value = readCollapsedStructValue(SharedFolderMetadata.class, _p, _ctx); - return ShareFolderLaunch.complete(value); + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("complete", ShareFolderLaunch.Tag.COMPLETE); - return Collections.unmodifiableMap(values); + @Override + public ShareFolderLaunch deserialize(JsonParser p) throws IOException, JsonParseException { + ShareFolderLaunch value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("async_job_id".equals(tag)) { + String fieldValue = null; + expectField("async_job_id", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = ShareFolderLaunch.asyncJobId(fieldValue); + } + else if ("complete".equals(tag)) { + SharedFolderMetadata fieldValue = null; + fieldValue = SharedFolderMetadata.Serializer.INSTANCE.deserialize(p, true); + value = ShareFolderLaunch.complete(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/SharePathError.java b/src/main/java/com/dropbox/core/v2/sharing/SharePathError.java index d744122a6..98d451159 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/SharePathError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/SharePathError.java @@ -1,80 +1,134 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=SharePathError.Serializer.class) -@JsonDeserialize(using=SharePathError.Deserializer.class) -public enum SharePathError { +/** + * This class is an open tagged union. Tagged unions instances are always + * associated to a specific tag. This means only one of the {@code isAbc()} + * methods will return {@code true}. You can use {@link #tag()} to determine the + * tag associated with this instance. + * + *

Open unions may be extended in the future with additional tags. If a new + * tag is introduced that this SDK does not recognized, the {@link #OTHER} value + * will be used.

+ */ +public final class SharePathError { // union SharePathError + + /** + * Discriminating tag type for {@link SharePathError}. + */ + public enum Tag { + /** + * A file is at the specified path. + */ + IS_FILE, + /** + * We do not support sharing a folder inside a shared folder. + */ + INSIDE_SHARED_FOLDER, + /** + * We do not support shared folders that contain shared folders. + */ + CONTAINS_SHARED_FOLDER, + /** + * We do not support sharing an app folder. + */ + IS_APP_FOLDER, + /** + * We do not support sharing a folder inside an app folder. + */ + INSIDE_APP_FOLDER, + /** + * A public folder can't be shared this way. Use a public link instead. + */ + IS_PUBLIC_FOLDER, + /** + * A folder inside a public folder can't be shared this way. Use a + * public link instead. + */ + INSIDE_PUBLIC_FOLDER, + /** + * Folder is already shared. Contains metadata about the existing shared + * folder. + */ + ALREADY_SHARED, // SharedFolderMetadata + /** + * Path is not valid. + */ + INVALID_PATH, + /** + * We do not support sharing a Mac OS X package. + */ + IS_OSX_PACKAGE, + /** + * We do not support sharing a folder inside a Mac OS X package. + */ + INSIDE_OSX_PACKAGE, + /** + * Catch-all used for unknown tag values returned by the Dropbox + * servers. + * + *

Receiving a catch-all value typically indicates this SDK version + * is not up to date. Consider updating your SDK version to handle the + * new tags.

+ */ + OTHER; // *catch_all + } + /** * A file is at the specified path. */ - IS_FILE, + public static final SharePathError IS_FILE = new SharePathError(Tag.IS_FILE, null); /** * We do not support sharing a folder inside a shared folder. */ - INSIDE_SHARED_FOLDER, + public static final SharePathError INSIDE_SHARED_FOLDER = new SharePathError(Tag.INSIDE_SHARED_FOLDER, null); /** * We do not support shared folders that contain shared folders. */ - CONTAINS_SHARED_FOLDER, + public static final SharePathError CONTAINS_SHARED_FOLDER = new SharePathError(Tag.CONTAINS_SHARED_FOLDER, null); /** * We do not support sharing an app folder. */ - IS_APP_FOLDER, + public static final SharePathError IS_APP_FOLDER = new SharePathError(Tag.IS_APP_FOLDER, null); /** * We do not support sharing a folder inside an app folder. */ - INSIDE_APP_FOLDER, + public static final SharePathError INSIDE_APP_FOLDER = new SharePathError(Tag.INSIDE_APP_FOLDER, null); /** * A public folder can't be shared this way. Use a public link instead. */ - IS_PUBLIC_FOLDER, + public static final SharePathError IS_PUBLIC_FOLDER = new SharePathError(Tag.IS_PUBLIC_FOLDER, null); /** * A folder inside a public folder can't be shared this way. Use a public * link instead. */ - INSIDE_PUBLIC_FOLDER, - /** - * Folder is already shared. - */ - ALREADY_SHARED, + public static final SharePathError INSIDE_PUBLIC_FOLDER = new SharePathError(Tag.INSIDE_PUBLIC_FOLDER, null); /** * Path is not valid. */ - INVALID_PATH, + public static final SharePathError INVALID_PATH = new SharePathError(Tag.INVALID_PATH, null); /** * We do not support sharing a Mac OS X package. */ - IS_OSX_PACKAGE, + public static final SharePathError IS_OSX_PACKAGE = new SharePathError(Tag.IS_OSX_PACKAGE, null); /** * We do not support sharing a folder inside a Mac OS X package. */ - INSIDE_OSX_PACKAGE, + public static final SharePathError INSIDE_OSX_PACKAGE = new SharePathError(Tag.INSIDE_OSX_PACKAGE, null); /** * Catch-all used for unknown tag values returned by the Dropbox servers. * @@ -82,89 +136,403 @@ public enum SharePathError { * not up to date. Consider updating your SDK version to handle the new * tags.

*/ - OTHER; // *catch_all + public static final SharePathError OTHER = new SharePathError(Tag.OTHER, null); + + private final Tag tag; + private final SharedFolderMetadata alreadySharedValue; + + /** + * + * @param tag Discriminating tag for this instance. + */ + private SharePathError(Tag tag, SharedFolderMetadata alreadySharedValue) { + this.tag = tag; + this.alreadySharedValue = alreadySharedValue; + } + + /** + * Returns the tag for this instance. + * + *

This class is a tagged union. Tagged unions instances are always + * associated to a specific tag. This means only one of the {@code isXyz()} + * methods will return {@code true}. Callers are recommended to use the tag + * value in a {@code switch} statement to properly handle the different + * values for this {@code SharePathError}.

+ * + *

If a tag returned by the server is unrecognized by this SDK, the + * {@link Tag#OTHER} value will be used.

+ * + * @return the tag for this instance. + */ + public Tag tag() { + return tag; + } + + /** + * Returns {@code true} if this instance has the tag {@link Tag#IS_FILE}, + * {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link Tag#IS_FILE}, + * {@code false} otherwise. + */ + public boolean isIsFile() { + return this.tag == Tag.IS_FILE; + } + + /** + * Returns {@code true} if this instance has the tag {@link + * Tag#INSIDE_SHARED_FOLDER}, {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link + * Tag#INSIDE_SHARED_FOLDER}, {@code false} otherwise. + */ + public boolean isInsideSharedFolder() { + return this.tag == Tag.INSIDE_SHARED_FOLDER; + } + + /** + * Returns {@code true} if this instance has the tag {@link + * Tag#CONTAINS_SHARED_FOLDER}, {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link + * Tag#CONTAINS_SHARED_FOLDER}, {@code false} otherwise. + */ + public boolean isContainsSharedFolder() { + return this.tag == Tag.CONTAINS_SHARED_FOLDER; + } + + /** + * Returns {@code true} if this instance has the tag {@link + * Tag#IS_APP_FOLDER}, {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link + * Tag#IS_APP_FOLDER}, {@code false} otherwise. + */ + public boolean isIsAppFolder() { + return this.tag == Tag.IS_APP_FOLDER; + } + + /** + * Returns {@code true} if this instance has the tag {@link + * Tag#INSIDE_APP_FOLDER}, {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link + * Tag#INSIDE_APP_FOLDER}, {@code false} otherwise. + */ + public boolean isInsideAppFolder() { + return this.tag == Tag.INSIDE_APP_FOLDER; + } + + /** + * Returns {@code true} if this instance has the tag {@link + * Tag#IS_PUBLIC_FOLDER}, {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link + * Tag#IS_PUBLIC_FOLDER}, {@code false} otherwise. + */ + public boolean isIsPublicFolder() { + return this.tag == Tag.IS_PUBLIC_FOLDER; + } + + /** + * Returns {@code true} if this instance has the tag {@link + * Tag#INSIDE_PUBLIC_FOLDER}, {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link + * Tag#INSIDE_PUBLIC_FOLDER}, {@code false} otherwise. + */ + public boolean isInsidePublicFolder() { + return this.tag == Tag.INSIDE_PUBLIC_FOLDER; + } - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); + /** + * Returns {@code true} if this instance has the tag {@link + * Tag#ALREADY_SHARED}, {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link + * Tag#ALREADY_SHARED}, {@code false} otherwise. + */ + public boolean isAlreadyShared() { + return this.tag == Tag.ALREADY_SHARED; + } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; + /** + * Returns an instance of {@code SharePathError} that has its tag set to + * {@link Tag#ALREADY_SHARED}. + * + *

Folder is already shared. Contains metadata about the existing shared + * folder.

+ * + * @param value value to assign to this instance. + * + * @return Instance of {@code SharePathError} with its tag set to {@link + * Tag#ALREADY_SHARED}. + * + * @throws IllegalArgumentException if {@code value} is {@code null}. + */ + public static SharePathError alreadyShared(SharedFolderMetadata value) { + if (value == null) { + throw new IllegalArgumentException("Value is null"); + } + return new SharePathError(Tag.ALREADY_SHARED, value); + } - public Serializer() { - super(SharePathError.class); + /** + * Folder is already shared. Contains metadata about the existing shared + * folder. + * + *

This instance must be tagged as {@link Tag#ALREADY_SHARED}.

+ * + * @return The {@link SharePathError#alreadyShared} value associated with + * this instance if {@link #isAlreadyShared} is {@code true}. + * + * @throws IllegalStateException If {@link #isAlreadyShared} is {@code + * false}. + */ + public SharedFolderMetadata getAlreadySharedValue() { + if (this.tag != Tag.ALREADY_SHARED) { + throw new IllegalStateException("Invalid tag: required Tag.ALREADY_SHARED, but was Tag." + tag.name()); } + return alreadySharedValue; + } - @Override - public void serialize(SharePathError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value) { + /** + * Returns {@code true} if this instance has the tag {@link + * Tag#INVALID_PATH}, {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link + * Tag#INVALID_PATH}, {@code false} otherwise. + */ + public boolean isInvalidPath() { + return this.tag == Tag.INVALID_PATH; + } + + /** + * Returns {@code true} if this instance has the tag {@link + * Tag#IS_OSX_PACKAGE}, {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link + * Tag#IS_OSX_PACKAGE}, {@code false} otherwise. + */ + public boolean isIsOsxPackage() { + return this.tag == Tag.IS_OSX_PACKAGE; + } + + /** + * Returns {@code true} if this instance has the tag {@link + * Tag#INSIDE_OSX_PACKAGE}, {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link + * Tag#INSIDE_OSX_PACKAGE}, {@code false} otherwise. + */ + public boolean isInsideOsxPackage() { + return this.tag == Tag.INSIDE_OSX_PACKAGE; + } + + /** + * Returns {@code true} if this instance has the tag {@link Tag#OTHER}, + * {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link Tag#OTHER}, + * {@code false} otherwise. + */ + public boolean isOther() { + return this.tag == Tag.OTHER; + } + + @Override + public int hashCode() { + int hash = java.util.Arrays.hashCode(new Object [] { + tag, + alreadySharedValue + }); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + else if (obj instanceof SharePathError) { + SharePathError other = (SharePathError) obj; + if (this.tag != other.tag) { + return false; + } + switch (tag) { case IS_FILE: + return true; + case INSIDE_SHARED_FOLDER: + return true; + case CONTAINS_SHARED_FOLDER: + return true; + case IS_APP_FOLDER: + return true; + case INSIDE_APP_FOLDER: + return true; + case IS_PUBLIC_FOLDER: + return true; + case INSIDE_PUBLIC_FOLDER: + return true; + case ALREADY_SHARED: + return (this.alreadySharedValue == other.alreadySharedValue) || (this.alreadySharedValue.equals(other.alreadySharedValue)); + case INVALID_PATH: + return true; + case IS_OSX_PACKAGE: + return true; + case INSIDE_OSX_PACKAGE: + return true; + case OTHER: + return true; + default: + return false; + } + } + else { + return false; + } + } + + @Override + public String toString() { + return Serializer.INSTANCE.serialize(this, false); + } + + /** + * Returns a String representation of this object formatted for easier + * readability. + * + *

The returned String may contain newlines.

+ * + * @return Formatted, multiline String representation of this object + */ + public String toStringMultiline() { + return Serializer.INSTANCE.serialize(this, true); + } + + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); + + @Override + public void serialize(SharePathError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case IS_FILE: { g.writeString("is_file"); break; - case INSIDE_SHARED_FOLDER: + } + case INSIDE_SHARED_FOLDER: { g.writeString("inside_shared_folder"); break; - case CONTAINS_SHARED_FOLDER: + } + case CONTAINS_SHARED_FOLDER: { g.writeString("contains_shared_folder"); break; - case IS_APP_FOLDER: + } + case IS_APP_FOLDER: { g.writeString("is_app_folder"); break; - case INSIDE_APP_FOLDER: + } + case INSIDE_APP_FOLDER: { g.writeString("inside_app_folder"); break; - case IS_PUBLIC_FOLDER: + } + case IS_PUBLIC_FOLDER: { g.writeString("is_public_folder"); break; - case INSIDE_PUBLIC_FOLDER: + } + case INSIDE_PUBLIC_FOLDER: { g.writeString("inside_public_folder"); break; - case ALREADY_SHARED: - g.writeString("already_shared"); + } + case ALREADY_SHARED: { + g.writeStartObject(); + writeTag("already_shared", g); + SharedFolderMetadata.Serializer.INSTANCE.serialize(value.alreadySharedValue, g, true); + g.writeEndObject(); break; - case INVALID_PATH: + } + case INVALID_PATH: { g.writeString("invalid_path"); break; - case IS_OSX_PACKAGE: + } + case IS_OSX_PACKAGE: { g.writeString("is_osx_package"); break; - case INSIDE_OSX_PACKAGE: + } + case INSIDE_OSX_PACKAGE: { g.writeString("inside_osx_package"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SharePathError.class, getTagMapping(), SharePathError.OTHER); - } @Override - public SharePathError deserialize(SharePathError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("is_file", SharePathError.IS_FILE); - values.put("inside_shared_folder", SharePathError.INSIDE_SHARED_FOLDER); - values.put("contains_shared_folder", SharePathError.CONTAINS_SHARED_FOLDER); - values.put("is_app_folder", SharePathError.IS_APP_FOLDER); - values.put("inside_app_folder", SharePathError.INSIDE_APP_FOLDER); - values.put("is_public_folder", SharePathError.IS_PUBLIC_FOLDER); - values.put("inside_public_folder", SharePathError.INSIDE_PUBLIC_FOLDER); - values.put("already_shared", SharePathError.ALREADY_SHARED); - values.put("invalid_path", SharePathError.INVALID_PATH); - values.put("is_osx_package", SharePathError.IS_OSX_PACKAGE); - values.put("inside_osx_package", SharePathError.INSIDE_OSX_PACKAGE); - values.put("other", SharePathError.OTHER); - return Collections.unmodifiableMap(values); + public SharePathError deserialize(JsonParser p) throws IOException, JsonParseException { + SharePathError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("is_file".equals(tag)) { + value = SharePathError.IS_FILE; + } + else if ("inside_shared_folder".equals(tag)) { + value = SharePathError.INSIDE_SHARED_FOLDER; + } + else if ("contains_shared_folder".equals(tag)) { + value = SharePathError.CONTAINS_SHARED_FOLDER; + } + else if ("is_app_folder".equals(tag)) { + value = SharePathError.IS_APP_FOLDER; + } + else if ("inside_app_folder".equals(tag)) { + value = SharePathError.INSIDE_APP_FOLDER; + } + else if ("is_public_folder".equals(tag)) { + value = SharePathError.IS_PUBLIC_FOLDER; + } + else if ("inside_public_folder".equals(tag)) { + value = SharePathError.INSIDE_PUBLIC_FOLDER; + } + else if ("already_shared".equals(tag)) { + SharedFolderMetadata fieldValue = null; + fieldValue = SharedFolderMetadata.Serializer.INSTANCE.deserialize(p, true); + value = SharePathError.alreadyShared(fieldValue); + } + else if ("invalid_path".equals(tag)) { + value = SharePathError.INVALID_PATH; + } + else if ("is_osx_package".equals(tag)) { + value = SharePathError.IS_OSX_PACKAGE; + } + else if ("inside_osx_package".equals(tag)) { + value = SharePathError.INSIDE_OSX_PACKAGE; + } + else { + value = SharePathError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/SharedFolderAccessError.java b/src/main/java/com/dropbox/core/v2/sharing/SharedFolderAccessError.java index 158a1012b..64e080990 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/SharedFolderAccessError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/SharedFolderAccessError.java @@ -1,36 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * There is an error accessing the shared folder. */ -@JsonSerialize(using=SharedFolderAccessError.Serializer.class) -@JsonDeserialize(using=SharedFolderAccessError.Deserializer.class) public enum SharedFolderAccessError { // union SharedFolderAccessError /** @@ -58,59 +44,75 @@ public enum SharedFolderAccessError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SharedFolderAccessError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(SharedFolderAccessError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(SharedFolderAccessError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case INVALID_ID: + case INVALID_ID: { g.writeString("invalid_id"); break; - case NOT_A_MEMBER: + } + case NOT_A_MEMBER: { g.writeString("not_a_member"); break; - case EMAIL_UNVERIFIED: + } + case EMAIL_UNVERIFIED: { g.writeString("email_unverified"); break; - case UNMOUNTED: + } + case UNMOUNTED: { g.writeString("unmounted"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SharedFolderAccessError.class, getTagMapping(), SharedFolderAccessError.OTHER); - } @Override - public SharedFolderAccessError deserialize(SharedFolderAccessError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("invalid_id", SharedFolderAccessError.INVALID_ID); - values.put("not_a_member", SharedFolderAccessError.NOT_A_MEMBER); - values.put("email_unverified", SharedFolderAccessError.EMAIL_UNVERIFIED); - values.put("unmounted", SharedFolderAccessError.UNMOUNTED); - values.put("other", SharedFolderAccessError.OTHER); - return Collections.unmodifiableMap(values); + public SharedFolderAccessError deserialize(JsonParser p) throws IOException, JsonParseException { + SharedFolderAccessError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("invalid_id".equals(tag)) { + value = SharedFolderAccessError.INVALID_ID; + } + else if ("not_a_member".equals(tag)) { + value = SharedFolderAccessError.NOT_A_MEMBER; + } + else if ("email_unverified".equals(tag)) { + value = SharedFolderAccessError.EMAIL_UNVERIFIED; + } + else if ("unmounted".equals(tag)) { + value = SharedFolderAccessError.UNMOUNTED; + } + else { + value = SharedFolderAccessError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/SharedFolderAccessErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/SharedFolderAccessErrorException.java index c07ec0783..20de3ee3c 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/SharedFolderAccessErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/SharedFolderAccessErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/SharedFolderMemberError.java b/src/main/java/com/dropbox/core/v2/sharing/SharedFolderMemberError.java index a7cdff0bb..1aae36d50 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/SharedFolderMemberError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/SharedFolderMemberError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=SharedFolderMemberError.Serializer.class) -@JsonDeserialize(using=SharedFolderMemberError.Deserializer.class) public enum SharedFolderMemberError { // union SharedFolderMemberError /** @@ -47,51 +33,61 @@ public enum SharedFolderMemberError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SharedFolderMemberError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(SharedFolderMemberError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(SharedFolderMemberError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case INVALID_DROPBOX_ID: + case INVALID_DROPBOX_ID: { g.writeString("invalid_dropbox_id"); break; - case NOT_A_MEMBER: + } + case NOT_A_MEMBER: { g.writeString("not_a_member"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SharedFolderMemberError.class, getTagMapping(), SharedFolderMemberError.OTHER); - } @Override - public SharedFolderMemberError deserialize(SharedFolderMemberError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("invalid_dropbox_id", SharedFolderMemberError.INVALID_DROPBOX_ID); - values.put("not_a_member", SharedFolderMemberError.NOT_A_MEMBER); - values.put("other", SharedFolderMemberError.OTHER); - return Collections.unmodifiableMap(values); + public SharedFolderMemberError deserialize(JsonParser p) throws IOException, JsonParseException { + SharedFolderMemberError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("invalid_dropbox_id".equals(tag)) { + value = SharedFolderMemberError.INVALID_DROPBOX_ID; + } + else if ("not_a_member".equals(tag)) { + value = SharedFolderMemberError.NOT_A_MEMBER; + } + else { + value = SharedFolderMemberError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/SharedFolderMembers.java b/src/main/java/com/dropbox/core/v2/sharing/SharedFolderMembers.java index 67c48904d..0e281ff32 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/SharedFolderMembers.java +++ b/src/main/java/com/dropbox/core/v2/sharing/SharedFolderMembers.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; @@ -29,15 +18,9 @@ /** * Shared folder user and group membership. */ -@JsonSerialize(using=SharedFolderMembers.Serializer.class) -@JsonDeserialize(using=SharedFolderMembers.Deserializer.class) public class SharedFolderMembers { // struct SharedFolderMembers - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List users; protected final List groups; protected final List invitees; @@ -181,7 +164,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -193,128 +176,85 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SharedFolderMembers.class); - } - - public Serializer(boolean unwrapping) { - super(SharedFolderMembers.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(SharedFolderMembers value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("users", value.users); - g.writeObjectField("groups", value.groups); - g.writeObjectField("invitees", value.invitees); + public void serialize(SharedFolderMembers value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("users"); + StoneSerializers.list(UserMembershipInfo.Serializer.INSTANCE).serialize(value.users, g); + g.writeFieldName("groups"); + StoneSerializers.list(GroupMembershipInfo.Serializer.INSTANCE).serialize(value.groups, g); + g.writeFieldName("invitees"); + StoneSerializers.list(InviteeMembershipInfo.Serializer.INSTANCE).serialize(value.invitees, g); if (value.cursor != null) { - g.writeObjectField("cursor", value.cursor); + g.writeFieldName("cursor"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.cursor, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SharedFolderMembers.class); - } - - public Deserializer(boolean unwrapping) { - super(SharedFolderMembers.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public SharedFolderMembers deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List users = null; - List groups = null; - List invitees = null; - String cursor = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("users".equals(_field)) { - expectArrayStart(_p); - users = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - UserMembershipInfo _x = null; - _x = _p.readValueAs(UserMembershipInfo.class); - _p.nextToken(); - users.add(_x); + public SharedFolderMembers deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + SharedFolderMembers value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_users = null; + List f_groups = null; + List f_invitees = null; + String f_cursor = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("users".equals(field)) { + f_users = StoneSerializers.list(UserMembershipInfo.Serializer.INSTANCE).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("groups".equals(_field)) { - expectArrayStart(_p); - groups = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - GroupMembershipInfo _x = null; - _x = _p.readValueAs(GroupMembershipInfo.class); - _p.nextToken(); - groups.add(_x); + else if ("groups".equals(field)) { + f_groups = StoneSerializers.list(GroupMembershipInfo.Serializer.INSTANCE).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("invitees".equals(_field)) { - expectArrayStart(_p); - invitees = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - InviteeMembershipInfo _x = null; - _x = _p.readValueAs(InviteeMembershipInfo.class); - _p.nextToken(); - invitees.add(_x); + else if ("invitees".equals(field)) { + f_invitees = StoneSerializers.list(InviteeMembershipInfo.Serializer.INSTANCE).deserialize(p); + } + else if ("cursor".equals(field)) { + f_cursor = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); + if (f_users == null) { + throw new JsonParseException(p, "Required field \"users\" missing."); } - else { - skipValue(_p); + if (f_groups == null) { + throw new JsonParseException(p, "Required field \"groups\" missing."); } + if (f_invitees == null) { + throw new JsonParseException(p, "Required field \"invitees\" missing."); + } + value = new SharedFolderMembers(f_users, f_groups, f_invitees, f_cursor); } - - if (users == null) { - throw new JsonParseException(_p, "Required field \"users\" is missing."); - } - if (groups == null) { - throw new JsonParseException(_p, "Required field \"groups\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (invitees == null) { - throw new JsonParseException(_p, "Required field \"invitees\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new SharedFolderMembers(users, groups, invitees, cursor); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/SharedFolderMetadata.java b/src/main/java/com/dropbox/core/v2/sharing/SharedFolderMetadata.java index 071a6f6c0..162772f4b 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/SharedFolderMetadata.java +++ b/src/main/java/com/dropbox/core/v2/sharing/SharedFolderMetadata.java @@ -1,28 +1,17 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.dropbox.core.v2.users.Team; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.Date; @@ -31,15 +20,9 @@ /** * The metadata which includes basic information about the shared folder. */ -@JsonSerialize(using=SharedFolderMetadata.Serializer.class) -@JsonDeserialize(using=SharedFolderMetadata.Deserializer.class) public class SharedFolderMetadata extends SharedFolderMetadataBase { // struct SharedFolderMetadata - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String pathLower; protected final String name; protected final String sharedFolderId; @@ -325,7 +308,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -337,163 +320,136 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); + return Serializer.INSTANCE.serialize(this, true); } - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SharedFolderMetadata.class); - } - - public Serializer(boolean unwrapping) { - super(SharedFolderMetadata.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(SharedFolderMetadata value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("access_type", value.accessType); - g.writeObjectField("is_team_folder", value.isTeamFolder); - g.writeObjectField("policy", value.policy); - g.writeObjectField("name", value.name); - g.writeObjectField("shared_folder_id", value.sharedFolderId); - g.writeObjectField("time_invited", value.timeInvited); + public void serialize(SharedFolderMetadata value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("access_type"); + AccessLevel.Serializer.INSTANCE.serialize(value.accessType, g); + g.writeFieldName("is_team_folder"); + StoneSerializers.boolean_().serialize(value.isTeamFolder, g); + g.writeFieldName("policy"); + FolderPolicy.Serializer.INSTANCE.serialize(value.policy, g); + g.writeFieldName("name"); + StoneSerializers.string().serialize(value.name, g); + g.writeFieldName("shared_folder_id"); + StoneSerializers.string().serialize(value.sharedFolderId, g); + g.writeFieldName("time_invited"); + StoneSerializers.timestamp().serialize(value.timeInvited, g); if (value.ownerTeam != null) { - g.writeObjectField("owner_team", value.ownerTeam); + g.writeFieldName("owner_team"); + StoneSerializers.nullable(Team.Serializer.INSTANCE).serialize(value.ownerTeam, g); } if (value.parentSharedFolderId != null) { - g.writeObjectField("parent_shared_folder_id", value.parentSharedFolderId); + g.writeFieldName("parent_shared_folder_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.parentSharedFolderId, g); } if (value.pathLower != null) { - g.writeObjectField("path_lower", value.pathLower); + g.writeFieldName("path_lower"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.pathLower, g); } if (value.permissions != null) { - g.writeObjectField("permissions", value.permissions); + g.writeFieldName("permissions"); + StoneSerializers.nullable(StoneSerializers.list(FolderPermission.Serializer.INSTANCE)).serialize(value.permissions, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SharedFolderMetadata.class); - } - - public Deserializer(boolean unwrapping) { - super(SharedFolderMetadata.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public SharedFolderMetadata deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - AccessLevel accessType = null; - Boolean isTeamFolder = null; - FolderPolicy policy = null; - String name = null; - String sharedFolderId = null; - Date timeInvited = null; - Team ownerTeam = null; - String parentSharedFolderId = null; - String pathLower = null; - List permissions = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("access_type".equals(_field)) { - accessType = _p.readValueAs(AccessLevel.class); - _p.nextToken(); - } - else if ("is_team_folder".equals(_field)) { - isTeamFolder = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("policy".equals(_field)) { - policy = _p.readValueAs(FolderPolicy.class); - _p.nextToken(); - } - else if ("name".equals(_field)) { - name = getStringValue(_p); - _p.nextToken(); - } - else if ("shared_folder_id".equals(_field)) { - sharedFolderId = getStringValue(_p); - _p.nextToken(); + public SharedFolderMetadata deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + SharedFolderMetadata value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + AccessLevel f_accessType = null; + Boolean f_isTeamFolder = null; + FolderPolicy f_policy = null; + String f_name = null; + String f_sharedFolderId = null; + Date f_timeInvited = null; + Team f_ownerTeam = null; + String f_parentSharedFolderId = null; + String f_pathLower = null; + List f_permissions = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("access_type".equals(field)) { + f_accessType = AccessLevel.Serializer.INSTANCE.deserialize(p); + } + else if ("is_team_folder".equals(field)) { + f_isTeamFolder = StoneSerializers.boolean_().deserialize(p); + } + else if ("policy".equals(field)) { + f_policy = FolderPolicy.Serializer.INSTANCE.deserialize(p); + } + else if ("name".equals(field)) { + f_name = StoneSerializers.string().deserialize(p); + } + else if ("shared_folder_id".equals(field)) { + f_sharedFolderId = StoneSerializers.string().deserialize(p); + } + else if ("time_invited".equals(field)) { + f_timeInvited = StoneSerializers.timestamp().deserialize(p); + } + else if ("owner_team".equals(field)) { + f_ownerTeam = StoneSerializers.nullable(Team.Serializer.INSTANCE).deserialize(p); + } + else if ("parent_shared_folder_id".equals(field)) { + f_parentSharedFolderId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("path_lower".equals(field)) { + f_pathLower = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("permissions".equals(field)) { + f_permissions = StoneSerializers.nullable(StoneSerializers.list(FolderPermission.Serializer.INSTANCE)).deserialize(p); + } + else { + skipValue(p); + } } - else if ("time_invited".equals(_field)) { - timeInvited = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); + if (f_accessType == null) { + throw new JsonParseException(p, "Required field \"access_type\" missing."); } - else if ("owner_team".equals(_field)) { - ownerTeam = _p.readValueAs(Team.class); - _p.nextToken(); + if (f_isTeamFolder == null) { + throw new JsonParseException(p, "Required field \"is_team_folder\" missing."); } - else if ("parent_shared_folder_id".equals(_field)) { - parentSharedFolderId = getStringValue(_p); - _p.nextToken(); + if (f_policy == null) { + throw new JsonParseException(p, "Required field \"policy\" missing."); } - else if ("path_lower".equals(_field)) { - pathLower = getStringValue(_p); - _p.nextToken(); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } - else if ("permissions".equals(_field)) { - expectArrayStart(_p); - permissions = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - FolderPermission _x = null; - _x = _p.readValueAs(FolderPermission.class); - _p.nextToken(); - permissions.add(_x); - } - expectArrayEnd(_p); - _p.nextToken(); + if (f_sharedFolderId == null) { + throw new JsonParseException(p, "Required field \"shared_folder_id\" missing."); } - else { - skipValue(_p); + if (f_timeInvited == null) { + throw new JsonParseException(p, "Required field \"time_invited\" missing."); } + value = new SharedFolderMetadata(f_accessType, f_isTeamFolder, f_policy, f_name, f_sharedFolderId, f_timeInvited, f_ownerTeam, f_parentSharedFolderId, f_pathLower, f_permissions); } - - if (accessType == null) { - throw new JsonParseException(_p, "Required field \"access_type\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (isTeamFolder == null) { - throw new JsonParseException(_p, "Required field \"is_team_folder\" is missing."); - } - if (policy == null) { - throw new JsonParseException(_p, "Required field \"policy\" is missing."); - } - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); + if (!collapsed) { + expectEndObject(p); } - if (sharedFolderId == null) { - throw new JsonParseException(_p, "Required field \"shared_folder_id\" is missing."); - } - if (timeInvited == null) { - throw new JsonParseException(_p, "Required field \"time_invited\" is missing."); - } - - return new SharedFolderMetadata(accessType, isTeamFolder, policy, name, sharedFolderId, timeInvited, ownerTeam, parentSharedFolderId, pathLower, permissions); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/SharedFolderMetadataBase.java b/src/main/java/com/dropbox/core/v2/sharing/SharedFolderMetadataBase.java index f9ee5b869..eba4fa450 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/SharedFolderMetadataBase.java +++ b/src/main/java/com/dropbox/core/v2/sharing/SharedFolderMetadataBase.java @@ -1,43 +1,26 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.dropbox.core.v2.users.Team; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Properties of the shared folder. */ -@JsonSerialize(using=SharedFolderMetadataBase.Serializer.class) -@JsonDeserialize(using=SharedFolderMetadataBase.Deserializer.class) public class SharedFolderMetadataBase { // struct SharedFolderMetadataBase - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final AccessLevel accessType; protected final boolean isTeamFolder; protected final FolderPolicy policy; @@ -275,7 +258,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -287,112 +270,93 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SharedFolderMetadataBase.class); - } - - public Serializer(boolean unwrapping) { - super(SharedFolderMetadataBase.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(SharedFolderMetadataBase value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("access_type", value.accessType); - g.writeObjectField("is_team_folder", value.isTeamFolder); - g.writeObjectField("policy", value.policy); + public void serialize(SharedFolderMetadataBase value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("access_type"); + AccessLevel.Serializer.INSTANCE.serialize(value.accessType, g); + g.writeFieldName("is_team_folder"); + StoneSerializers.boolean_().serialize(value.isTeamFolder, g); + g.writeFieldName("policy"); + FolderPolicy.Serializer.INSTANCE.serialize(value.policy, g); if (value.ownerTeam != null) { - g.writeObjectField("owner_team", value.ownerTeam); + g.writeFieldName("owner_team"); + StoneSerializers.nullable(Team.Serializer.INSTANCE).serialize(value.ownerTeam, g); } if (value.parentSharedFolderId != null) { - g.writeObjectField("parent_shared_folder_id", value.parentSharedFolderId); + g.writeFieldName("parent_shared_folder_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.parentSharedFolderId, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SharedFolderMetadataBase.class); - } - - public Deserializer(boolean unwrapping) { - super(SharedFolderMetadataBase.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public SharedFolderMetadataBase deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - AccessLevel accessType = null; - Boolean isTeamFolder = null; - FolderPolicy policy = null; - Team ownerTeam = null; - String parentSharedFolderId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("access_type".equals(_field)) { - accessType = _p.readValueAs(AccessLevel.class); - _p.nextToken(); - } - else if ("is_team_folder".equals(_field)) { - isTeamFolder = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("policy".equals(_field)) { - policy = _p.readValueAs(FolderPolicy.class); - _p.nextToken(); + public SharedFolderMetadataBase deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + SharedFolderMetadataBase value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + AccessLevel f_accessType = null; + Boolean f_isTeamFolder = null; + FolderPolicy f_policy = null; + Team f_ownerTeam = null; + String f_parentSharedFolderId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("access_type".equals(field)) { + f_accessType = AccessLevel.Serializer.INSTANCE.deserialize(p); + } + else if ("is_team_folder".equals(field)) { + f_isTeamFolder = StoneSerializers.boolean_().deserialize(p); + } + else if ("policy".equals(field)) { + f_policy = FolderPolicy.Serializer.INSTANCE.deserialize(p); + } + else if ("owner_team".equals(field)) { + f_ownerTeam = StoneSerializers.nullable(Team.Serializer.INSTANCE).deserialize(p); + } + else if ("parent_shared_folder_id".equals(field)) { + f_parentSharedFolderId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } - else if ("owner_team".equals(_field)) { - ownerTeam = _p.readValueAs(Team.class); - _p.nextToken(); + if (f_accessType == null) { + throw new JsonParseException(p, "Required field \"access_type\" missing."); } - else if ("parent_shared_folder_id".equals(_field)) { - parentSharedFolderId = getStringValue(_p); - _p.nextToken(); + if (f_isTeamFolder == null) { + throw new JsonParseException(p, "Required field \"is_team_folder\" missing."); } - else { - skipValue(_p); + if (f_policy == null) { + throw new JsonParseException(p, "Required field \"policy\" missing."); } + value = new SharedFolderMetadataBase(f_accessType, f_isTeamFolder, f_policy, f_ownerTeam, f_parentSharedFolderId); } - - if (accessType == null) { - throw new JsonParseException(_p, "Required field \"access_type\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (isTeamFolder == null) { - throw new JsonParseException(_p, "Required field \"is_team_folder\" is missing."); + if (!collapsed) { + expectEndObject(p); } - if (policy == null) { - throw new JsonParseException(_p, "Required field \"policy\" is missing."); - } - - return new SharedFolderMetadataBase(accessType, isTeamFolder, policy, ownerTeam, parentSharedFolderId); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/SharedLinkAccessFailureReason.java b/src/main/java/com/dropbox/core/v2/sharing/SharedLinkAccessFailureReason.java index 834ceec51..e21f69006 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/SharedLinkAccessFailureReason.java +++ b/src/main/java/com/dropbox/core/v2/sharing/SharedLinkAccessFailureReason.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=SharedLinkAccessFailureReason.Serializer.class) -@JsonDeserialize(using=SharedLinkAccessFailureReason.Deserializer.class) public enum SharedLinkAccessFailureReason { // union SharedLinkAccessFailureReason /** @@ -55,63 +41,82 @@ public enum SharedLinkAccessFailureReason { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SharedLinkAccessFailureReason.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(SharedLinkAccessFailureReason value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(SharedLinkAccessFailureReason value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case LOGIN_REQUIRED: + case LOGIN_REQUIRED: { g.writeString("login_required"); break; - case EMAIL_VERIFY_REQUIRED: + } + case EMAIL_VERIFY_REQUIRED: { g.writeString("email_verify_required"); break; - case PASSWORD_REQUIRED: + } + case PASSWORD_REQUIRED: { g.writeString("password_required"); break; - case TEAM_ONLY: + } + case TEAM_ONLY: { g.writeString("team_only"); break; - case OWNER_ONLY: + } + case OWNER_ONLY: { g.writeString("owner_only"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SharedLinkAccessFailureReason.class, getTagMapping(), SharedLinkAccessFailureReason.OTHER); - } @Override - public SharedLinkAccessFailureReason deserialize(SharedLinkAccessFailureReason _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("login_required", SharedLinkAccessFailureReason.LOGIN_REQUIRED); - values.put("email_verify_required", SharedLinkAccessFailureReason.EMAIL_VERIFY_REQUIRED); - values.put("password_required", SharedLinkAccessFailureReason.PASSWORD_REQUIRED); - values.put("team_only", SharedLinkAccessFailureReason.TEAM_ONLY); - values.put("owner_only", SharedLinkAccessFailureReason.OWNER_ONLY); - values.put("other", SharedLinkAccessFailureReason.OTHER); - return Collections.unmodifiableMap(values); + public SharedLinkAccessFailureReason deserialize(JsonParser p) throws IOException, JsonParseException { + SharedLinkAccessFailureReason value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("login_required".equals(tag)) { + value = SharedLinkAccessFailureReason.LOGIN_REQUIRED; + } + else if ("email_verify_required".equals(tag)) { + value = SharedLinkAccessFailureReason.EMAIL_VERIFY_REQUIRED; + } + else if ("password_required".equals(tag)) { + value = SharedLinkAccessFailureReason.PASSWORD_REQUIRED; + } + else if ("team_only".equals(tag)) { + value = SharedLinkAccessFailureReason.TEAM_ONLY; + } + else if ("owner_only".equals(tag)) { + value = SharedLinkAccessFailureReason.OWNER_ONLY; + } + else { + value = SharedLinkAccessFailureReason.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/SharedLinkError.java b/src/main/java/com/dropbox/core/v2/sharing/SharedLinkError.java index dde74e1cb..f5e8fcb7a 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/SharedLinkError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/SharedLinkError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=SharedLinkError.Serializer.class) -@JsonDeserialize(using=SharedLinkError.Deserializer.class) public enum SharedLinkError { // union SharedLinkError /** @@ -43,51 +29,61 @@ public enum SharedLinkError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SharedLinkError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(SharedLinkError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(SharedLinkError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case SHARED_LINK_NOT_FOUND: + case SHARED_LINK_NOT_FOUND: { g.writeString("shared_link_not_found"); break; - case SHARED_LINK_ACCESS_DENIED: + } + case SHARED_LINK_ACCESS_DENIED: { g.writeString("shared_link_access_denied"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SharedLinkError.class, getTagMapping(), SharedLinkError.OTHER); - } @Override - public SharedLinkError deserialize(SharedLinkError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("shared_link_not_found", SharedLinkError.SHARED_LINK_NOT_FOUND); - values.put("shared_link_access_denied", SharedLinkError.SHARED_LINK_ACCESS_DENIED); - values.put("other", SharedLinkError.OTHER); - return Collections.unmodifiableMap(values); + public SharedLinkError deserialize(JsonParser p) throws IOException, JsonParseException { + SharedLinkError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("shared_link_not_found".equals(tag)) { + value = SharedLinkError.SHARED_LINK_NOT_FOUND; + } + else if ("shared_link_access_denied".equals(tag)) { + value = SharedLinkError.SHARED_LINK_ACCESS_DENIED; + } + else { + value = SharedLinkError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/SharedLinkErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/SharedLinkErrorException.java index 82518e339..49efeb857 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/SharedLinkErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/SharedLinkErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/SharedLinkMetadata.java b/src/main/java/com/dropbox/core/v2/sharing/SharedLinkMetadata.java index 9e0ac9a05..0870e25c6 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/SharedLinkMetadata.java +++ b/src/main/java/com/dropbox/core/v2/sharing/SharedLinkMetadata.java @@ -1,28 +1,17 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.dropbox.core.v2.users.Team; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.Date; @@ -30,15 +19,9 @@ /** * The metadata of a shared link */ -@JsonSerialize(using=SharedLinkMetadata.Serializer.class) -@JsonDeserialize(using=SharedLinkMetadata.Deserializer.class) public class SharedLinkMetadata { // struct SharedLinkMetadata - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String url; protected final String id; protected final String name; @@ -377,7 +360,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -389,138 +372,137 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SharedLinkMetadata.class); - } - - public Serializer(boolean unwrapping) { - super(SharedLinkMetadata.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(SharedLinkMetadata value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("url", value.url); - g.writeObjectField("name", value.name); - g.writeObjectField("link_permissions", value.linkPermissions); + public void serialize(SharedLinkMetadata value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (value instanceof FileLinkMetadata) { + FileLinkMetadata.Serializer.INSTANCE.serialize((FileLinkMetadata) value, g, collapse); + return; + } + if (value instanceof FolderLinkMetadata) { + FolderLinkMetadata.Serializer.INSTANCE.serialize((FolderLinkMetadata) value, g, collapse); + return; + } + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("url"); + StoneSerializers.string().serialize(value.url, g); + g.writeFieldName("name"); + StoneSerializers.string().serialize(value.name, g); + g.writeFieldName("link_permissions"); + LinkPermissions.Serializer.INSTANCE.serialize(value.linkPermissions, g); if (value.id != null) { - g.writeObjectField("id", value.id); + g.writeFieldName("id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.id, g); } if (value.expires != null) { - g.writeObjectField("expires", value.expires); + g.writeFieldName("expires"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.expires, g); } if (value.pathLower != null) { - g.writeObjectField("path_lower", value.pathLower); + g.writeFieldName("path_lower"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.pathLower, g); } if (value.teamMemberInfo != null) { - g.writeObjectField("team_member_info", value.teamMemberInfo); + g.writeFieldName("team_member_info"); + StoneSerializers.nullable(TeamMemberInfo.Serializer.INSTANCE).serialize(value.teamMemberInfo, g); } if (value.contentOwnerTeamInfo != null) { - g.writeObjectField("content_owner_team_info", value.contentOwnerTeamInfo); + g.writeFieldName("content_owner_team_info"); + StoneSerializers.nullable(Team.Serializer.INSTANCE).serialize(value.contentOwnerTeamInfo, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SharedLinkMetadata.class, FileLinkMetadata.class, FolderLinkMetadata.class); - } - - public Deserializer(boolean unwrapping) { - super(SharedLinkMetadata.class, unwrapping, FileLinkMetadata.class, FolderLinkMetadata.class); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public SharedLinkMetadata deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - String _subtype_tag = readEnumeratedSubtypeTag(_p); - if ("file".equals(_subtype_tag)) { - return readCollapsedStructValue(FileLinkMetadata.class, _p, _ctx); - } - if ("folder".equals(_subtype_tag)) { - return readCollapsedStructValue(FolderLinkMetadata.class, _p, _ctx); - } - - String url = null; - String name = null; - LinkPermissions linkPermissions = null; - String id = null; - Date expires = null; - String pathLower = null; - TeamMemberInfo teamMemberInfo = null; - Team contentOwnerTeamInfo = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("url".equals(_field)) { - url = getStringValue(_p); - _p.nextToken(); - } - else if ("name".equals(_field)) { - name = getStringValue(_p); - _p.nextToken(); - } - else if ("link_permissions".equals(_field)) { - linkPermissions = _p.readValueAs(LinkPermissions.class); - _p.nextToken(); - } - else if ("id".equals(_field)) { - id = getStringValue(_p); - _p.nextToken(); + public SharedLinkMetadata deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + SharedLinkMetadata value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + if ("".equals(tag)) { + tag = null; } - else if ("expires".equals(_field)) { - expires = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); - } - else if ("path_lower".equals(_field)) { - pathLower = getStringValue(_p); - _p.nextToken(); + } + if (tag == null) { + String f_url = null; + String f_name = null; + LinkPermissions f_linkPermissions = null; + String f_id = null; + Date f_expires = null; + String f_pathLower = null; + TeamMemberInfo f_teamMemberInfo = null; + Team f_contentOwnerTeamInfo = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("url".equals(field)) { + f_url = StoneSerializers.string().deserialize(p); + } + else if ("name".equals(field)) { + f_name = StoneSerializers.string().deserialize(p); + } + else if ("link_permissions".equals(field)) { + f_linkPermissions = LinkPermissions.Serializer.INSTANCE.deserialize(p); + } + else if ("id".equals(field)) { + f_id = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("expires".equals(field)) { + f_expires = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else if ("path_lower".equals(field)) { + f_pathLower = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("team_member_info".equals(field)) { + f_teamMemberInfo = StoneSerializers.nullable(TeamMemberInfo.Serializer.INSTANCE).deserialize(p); + } + else if ("content_owner_team_info".equals(field)) { + f_contentOwnerTeamInfo = StoneSerializers.nullable(Team.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); + } } - else if ("team_member_info".equals(_field)) { - teamMemberInfo = _p.readValueAs(TeamMemberInfo.class); - _p.nextToken(); + if (f_url == null) { + throw new JsonParseException(p, "Required field \"url\" missing."); } - else if ("content_owner_team_info".equals(_field)) { - contentOwnerTeamInfo = _p.readValueAs(Team.class); - _p.nextToken(); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } - else { - skipValue(_p); + if (f_linkPermissions == null) { + throw new JsonParseException(p, "Required field \"link_permissions\" missing."); } + value = new SharedLinkMetadata(f_url, f_name, f_linkPermissions, f_id, f_expires, f_pathLower, f_teamMemberInfo, f_contentOwnerTeamInfo); } - - if (url == null) { - throw new JsonParseException(_p, "Required field \"url\" is missing."); + else if ("".equals(tag)) { + value = SharedLinkMetadata.Serializer.INSTANCE.deserialize(p, true); } - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); + else if ("file".equals(tag)) { + value = FileLinkMetadata.Serializer.INSTANCE.deserialize(p, true); } - if (linkPermissions == null) { - throw new JsonParseException(_p, "Required field \"link_permissions\" is missing."); + else if ("folder".equals(tag)) { + value = FolderLinkMetadata.Serializer.INSTANCE.deserialize(p, true); } - - return new SharedLinkMetadata(url, name, linkPermissions, id, expires, pathLower, teamMemberInfo, contentOwnerTeamInfo); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/SharedLinkPolicy.java b/src/main/java/com/dropbox/core/v2/sharing/SharedLinkPolicy.java index 4d362ed19..d802de6fe 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/SharedLinkPolicy.java +++ b/src/main/java/com/dropbox/core/v2/sharing/SharedLinkPolicy.java @@ -1,36 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Policy governing who can view shared links. */ -@JsonSerialize(using=SharedLinkPolicy.Serializer.class) -@JsonDeserialize(using=SharedLinkPolicy.Deserializer.class) public enum SharedLinkPolicy { // union SharedLinkPolicy /** @@ -46,51 +32,61 @@ public enum SharedLinkPolicy { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SharedLinkPolicy.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(SharedLinkPolicy value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(SharedLinkPolicy value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case ANYONE: + case ANYONE: { g.writeString("anyone"); break; - case MEMBERS: + } + case MEMBERS: { g.writeString("members"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SharedLinkPolicy.class, getTagMapping(), SharedLinkPolicy.OTHER); - } @Override - public SharedLinkPolicy deserialize(SharedLinkPolicy _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("anyone", SharedLinkPolicy.ANYONE); - values.put("members", SharedLinkPolicy.MEMBERS); - values.put("other", SharedLinkPolicy.OTHER); - return Collections.unmodifiableMap(values); + public SharedLinkPolicy deserialize(JsonParser p) throws IOException, JsonParseException { + SharedLinkPolicy value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("anyone".equals(tag)) { + value = SharedLinkPolicy.ANYONE; + } + else if ("members".equals(tag)) { + value = SharedLinkPolicy.MEMBERS; + } + else { + value = SharedLinkPolicy.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/SharedLinkSettings.java b/src/main/java/com/dropbox/core/v2/sharing/SharedLinkSettings.java index a212c0a10..d64caad93 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/SharedLinkSettings.java +++ b/src/main/java/com/dropbox/core/v2/sharing/SharedLinkSettings.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.Date; -@JsonSerialize(using=SharedLinkSettings.Serializer.class) -@JsonDeserialize(using=SharedLinkSettings.Deserializer.class) public class SharedLinkSettings { // struct SharedLinkSettings - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final RequestedVisibility requestedVisibility; protected final String linkPassword; protected final Date expires; @@ -198,7 +181,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -210,93 +193,74 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SharedLinkSettings.class); - } - - public Serializer(boolean unwrapping) { - super(SharedLinkSettings.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(SharedLinkSettings value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(SharedLinkSettings value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } if (value.requestedVisibility != null) { - g.writeObjectField("requested_visibility", value.requestedVisibility); + g.writeFieldName("requested_visibility"); + StoneSerializers.nullable(RequestedVisibility.Serializer.INSTANCE).serialize(value.requestedVisibility, g); } if (value.linkPassword != null) { - g.writeObjectField("link_password", value.linkPassword); + g.writeFieldName("link_password"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.linkPassword, g); } if (value.expires != null) { - g.writeObjectField("expires", value.expires); + g.writeFieldName("expires"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.expires, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SharedLinkSettings.class); - } - - public Deserializer(boolean unwrapping) { - super(SharedLinkSettings.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public SharedLinkSettings deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - RequestedVisibility requestedVisibility = null; - String linkPassword = null; - Date expires = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("requested_visibility".equals(_field)) { - requestedVisibility = _p.readValueAs(RequestedVisibility.class); - _p.nextToken(); - } - else if ("link_password".equals(_field)) { - linkPassword = getStringValue(_p); - _p.nextToken(); - } - else if ("expires".equals(_field)) { - expires = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); - } - else { - skipValue(_p); + public SharedLinkSettings deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + SharedLinkSettings value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + RequestedVisibility f_requestedVisibility = null; + String f_linkPassword = null; + Date f_expires = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("requested_visibility".equals(field)) { + f_requestedVisibility = StoneSerializers.nullable(RequestedVisibility.Serializer.INSTANCE).deserialize(p); + } + else if ("link_password".equals(field)) { + f_linkPassword = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("expires".equals(field)) { + f_expires = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else { + skipValue(p); + } } + value = new SharedLinkSettings(f_requestedVisibility, f_linkPassword, f_expires); } - - - return new SharedLinkSettings(requestedVisibility, linkPassword, expires); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/SharedLinkSettingsError.java b/src/main/java/com/dropbox/core/v2/sharing/SharedLinkSettingsError.java index 25c9b034e..91049990e 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/SharedLinkSettingsError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/SharedLinkSettingsError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=SharedLinkSettingsError.Serializer.class) -@JsonDeserialize(using=SharedLinkSettingsError.Deserializer.class) public enum SharedLinkSettingsError { // union SharedLinkSettingsError /** @@ -46,47 +32,60 @@ public enum SharedLinkSettingsError { */ NOT_AUTHORIZED; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SharedLinkSettingsError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(SharedLinkSettingsError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(SharedLinkSettingsError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case INVALID_SETTINGS: + case INVALID_SETTINGS: { g.writeString("invalid_settings"); break; - case NOT_AUTHORIZED: + } + case NOT_AUTHORIZED: { g.writeString("not_authorized"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SharedLinkSettingsError.class, getTagMapping(), null); - } @Override - public SharedLinkSettingsError deserialize(SharedLinkSettingsError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("invalid_settings", SharedLinkSettingsError.INVALID_SETTINGS); - values.put("not_authorized", SharedLinkSettingsError.NOT_AUTHORIZED); - return Collections.unmodifiableMap(values); + public SharedLinkSettingsError deserialize(JsonParser p) throws IOException, JsonParseException { + SharedLinkSettingsError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("invalid_settings".equals(tag)) { + value = SharedLinkSettingsError.INVALID_SETTINGS; + } + else if ("not_authorized".equals(tag)) { + value = SharedLinkSettingsError.NOT_AUTHORIZED; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/TeamMemberInfo.java b/src/main/java/com/dropbox/core/v2/sharing/TeamMemberInfo.java index 441bcb6f5..f355c2672 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/TeamMemberInfo.java +++ b/src/main/java/com/dropbox/core/v2/sharing/TeamMemberInfo.java @@ -1,43 +1,26 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.dropbox.core.v2.users.Team; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Information about a team member. */ -@JsonSerialize(using=TeamMemberInfo.Serializer.class) -@JsonDeserialize(using=TeamMemberInfo.Deserializer.class) public class TeamMemberInfo { // struct TeamMemberInfo - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final Team teamInfo; protected final String displayName; protected final String memberId; @@ -142,7 +125,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -154,95 +137,76 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(TeamMemberInfo.class); - } - - public Serializer(boolean unwrapping) { - super(TeamMemberInfo.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(TeamMemberInfo value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("team_info", value.teamInfo); - g.writeObjectField("display_name", value.displayName); + public void serialize(TeamMemberInfo value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("team_info"); + Team.Serializer.INSTANCE.serialize(value.teamInfo, g); + g.writeFieldName("display_name"); + StoneSerializers.string().serialize(value.displayName, g); if (value.memberId != null) { - g.writeObjectField("member_id", value.memberId); + g.writeFieldName("member_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.memberId, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(TeamMemberInfo.class); - } - - public Deserializer(boolean unwrapping) { - super(TeamMemberInfo.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public TeamMemberInfo deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - Team teamInfo = null; - String displayName = null; - String memberId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("team_info".equals(_field)) { - teamInfo = _p.readValueAs(Team.class); - _p.nextToken(); - } - else if ("display_name".equals(_field)) { - displayName = getStringValue(_p); - _p.nextToken(); + public TeamMemberInfo deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + TeamMemberInfo value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Team f_teamInfo = null; + String f_displayName = null; + String f_memberId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("team_info".equals(field)) { + f_teamInfo = Team.Serializer.INSTANCE.deserialize(p); + } + else if ("display_name".equals(field)) { + f_displayName = StoneSerializers.string().deserialize(p); + } + else if ("member_id".equals(field)) { + f_memberId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } - else if ("member_id".equals(_field)) { - memberId = getStringValue(_p); - _p.nextToken(); + if (f_teamInfo == null) { + throw new JsonParseException(p, "Required field \"team_info\" missing."); } - else { - skipValue(_p); + if (f_displayName == null) { + throw new JsonParseException(p, "Required field \"display_name\" missing."); } + value = new TeamMemberInfo(f_teamInfo, f_displayName, f_memberId); } - - if (teamInfo == null) { - throw new JsonParseException(_p, "Required field \"team_info\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (displayName == null) { - throw new JsonParseException(_p, "Required field \"display_name\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new TeamMemberInfo(teamInfo, displayName, memberId); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/TransferFolderArg.java b/src/main/java/com/dropbox/core/v2/sharing/TransferFolderArg.java index e50b467fd..975e63483 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/TransferFolderArg.java +++ b/src/main/java/com/dropbox/core/v2/sharing/TransferFolderArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=TransferFolderArg.Serializer.class) -@JsonDeserialize(using=TransferFolderArg.Deserializer.class) class TransferFolderArg { // struct TransferFolderArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String sharedFolderId; protected final String toDropboxId; @@ -110,7 +93,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -122,87 +105,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(TransferFolderArg.class); - } - - public Serializer(boolean unwrapping) { - super(TransferFolderArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(TransferFolderArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("shared_folder_id", value.sharedFolderId); - g.writeObjectField("to_dropbox_id", value.toDropboxId); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(TransferFolderArg.class); - } - - public Deserializer(boolean unwrapping) { - super(TransferFolderArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(TransferFolderArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("shared_folder_id"); + StoneSerializers.string().serialize(value.sharedFolderId, g); + g.writeFieldName("to_dropbox_id"); + StoneSerializers.string().serialize(value.toDropboxId, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public TransferFolderArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String sharedFolderId = null; - String toDropboxId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("shared_folder_id".equals(_field)) { - sharedFolderId = getStringValue(_p); - _p.nextToken(); + public TransferFolderArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + TransferFolderArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_sharedFolderId = null; + String f_toDropboxId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("shared_folder_id".equals(field)) { + f_sharedFolderId = StoneSerializers.string().deserialize(p); + } + else if ("to_dropbox_id".equals(field)) { + f_toDropboxId = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else if ("to_dropbox_id".equals(_field)) { - toDropboxId = getStringValue(_p); - _p.nextToken(); + if (f_sharedFolderId == null) { + throw new JsonParseException(p, "Required field \"shared_folder_id\" missing."); } - else { - skipValue(_p); + if (f_toDropboxId == null) { + throw new JsonParseException(p, "Required field \"to_dropbox_id\" missing."); } + value = new TransferFolderArg(f_sharedFolderId, f_toDropboxId); } - - if (sharedFolderId == null) { - throw new JsonParseException(_p, "Required field \"shared_folder_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (toDropboxId == null) { - throw new JsonParseException(_p, "Required field \"to_dropbox_id\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new TransferFolderArg(sharedFolderId, toDropboxId); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/TransferFolderError.java b/src/main/java/com/dropbox/core/v2/sharing/TransferFolderError.java index ea74bc44a..73753425f 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/TransferFolderError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/TransferFolderError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=TransferFolderError.Serializer.class) -@JsonDeserialize(using=TransferFolderError.Deserializer.class) public final class TransferFolderError { // union TransferFolderError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link TransferFolderError}. */ @@ -61,7 +43,7 @@ public enum Tag { */ NEW_OWNER_NOT_A_MEMBER, /** - * The new designated owner does not have the shared folder mounted. + * The new designated owner has not added the folder to their Dropbox. */ NEW_OWNER_UNMOUNTED, /** @@ -97,7 +79,7 @@ public enum Tag { */ public static final TransferFolderError NEW_OWNER_NOT_A_MEMBER = new TransferFolderError(Tag.NEW_OWNER_NOT_A_MEMBER, null); /** - * The new designated owner does not have the shared folder mounted. + * The new designated owner has not added the folder to their Dropbox. */ public static final TransferFolderError NEW_OWNER_UNMOUNTED = new TransferFolderError(Tag.NEW_OWNER_UNMOUNTED, null); /** @@ -320,7 +302,7 @@ else if (obj instanceof TransferFolderError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -332,113 +314,106 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(TransferFolderError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(TransferFolderError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case ACCESS_ERROR: + public void serialize(TransferFolderError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case ACCESS_ERROR: { g.writeStartObject(); - g.writeStringField(".tag", "access_error"); - g.writeObjectField("access_error", value.accessErrorValue); + writeTag("access_error", g); + g.writeFieldName("access_error"); + SharedFolderAccessError.Serializer.INSTANCE.serialize(value.accessErrorValue, g); g.writeEndObject(); break; - case INVALID_DROPBOX_ID: + } + case INVALID_DROPBOX_ID: { g.writeString("invalid_dropbox_id"); break; - case NEW_OWNER_NOT_A_MEMBER: + } + case NEW_OWNER_NOT_A_MEMBER: { g.writeString("new_owner_not_a_member"); break; - case NEW_OWNER_UNMOUNTED: + } + case NEW_OWNER_UNMOUNTED: { g.writeString("new_owner_unmounted"); break; - case NEW_OWNER_EMAIL_UNVERIFIED: + } + case NEW_OWNER_EMAIL_UNVERIFIED: { g.writeString("new_owner_email_unverified"); break; - case TEAM_FOLDER: + } + case TEAM_FOLDER: { g.writeString("team_folder"); break; - case NO_PERMISSION: + } + case NO_PERMISSION: { g.writeString("no_permission"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(TransferFolderError.class, getTagMapping(), Tag.OTHER); - } @Override - public TransferFolderError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case ACCESS_ERROR: { - SharedFolderAccessError value = null; - expectField(_p, "access_error"); - value = _p.readValueAs(SharedFolderAccessError.class); - _p.nextToken(); - return TransferFolderError.accessError(value); - } - case INVALID_DROPBOX_ID: { - return TransferFolderError.INVALID_DROPBOX_ID; - } - case NEW_OWNER_NOT_A_MEMBER: { - return TransferFolderError.NEW_OWNER_NOT_A_MEMBER; - } - case NEW_OWNER_UNMOUNTED: { - return TransferFolderError.NEW_OWNER_UNMOUNTED; - } - case NEW_OWNER_EMAIL_UNVERIFIED: { - return TransferFolderError.NEW_OWNER_EMAIL_UNVERIFIED; - } - case TEAM_FOLDER: { - return TransferFolderError.TEAM_FOLDER; - } - case NO_PERMISSION: { - return TransferFolderError.NO_PERMISSION; - } - case OTHER: { - return TransferFolderError.OTHER; - } + public TransferFolderError deserialize(JsonParser p) throws IOException, JsonParseException { + TransferFolderError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("access_error", TransferFolderError.Tag.ACCESS_ERROR); - values.put("invalid_dropbox_id", TransferFolderError.Tag.INVALID_DROPBOX_ID); - values.put("new_owner_not_a_member", TransferFolderError.Tag.NEW_OWNER_NOT_A_MEMBER); - values.put("new_owner_unmounted", TransferFolderError.Tag.NEW_OWNER_UNMOUNTED); - values.put("new_owner_email_unverified", TransferFolderError.Tag.NEW_OWNER_EMAIL_UNVERIFIED); - values.put("team_folder", TransferFolderError.Tag.TEAM_FOLDER); - values.put("no_permission", TransferFolderError.Tag.NO_PERMISSION); - values.put("other", TransferFolderError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("access_error".equals(tag)) { + SharedFolderAccessError fieldValue = null; + expectField("access_error", p); + fieldValue = SharedFolderAccessError.Serializer.INSTANCE.deserialize(p); + value = TransferFolderError.accessError(fieldValue); + } + else if ("invalid_dropbox_id".equals(tag)) { + value = TransferFolderError.INVALID_DROPBOX_ID; + } + else if ("new_owner_not_a_member".equals(tag)) { + value = TransferFolderError.NEW_OWNER_NOT_A_MEMBER; + } + else if ("new_owner_unmounted".equals(tag)) { + value = TransferFolderError.NEW_OWNER_UNMOUNTED; + } + else if ("new_owner_email_unverified".equals(tag)) { + value = TransferFolderError.NEW_OWNER_EMAIL_UNVERIFIED; + } + else if ("team_folder".equals(tag)) { + value = TransferFolderError.TEAM_FOLDER; + } + else if ("no_permission".equals(tag)) { + value = TransferFolderError.NO_PERMISSION; + } + else { + value = TransferFolderError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/TransferFolderErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/TransferFolderErrorException.java index 3b0b41cab..fa07f9732 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/TransferFolderErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/TransferFolderErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/UnmountFolderArg.java b/src/main/java/com/dropbox/core/v2/sharing/UnmountFolderArg.java index aeaa7b88b..611c01824 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/UnmountFolderArg.java +++ b/src/main/java/com/dropbox/core/v2/sharing/UnmountFolderArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=UnmountFolderArg.Serializer.class) -@JsonDeserialize(using=UnmountFolderArg.Deserializer.class) class UnmountFolderArg { // struct UnmountFolderArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String sharedFolderId; /** @@ -88,7 +71,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -100,78 +83,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UnmountFolderArg.class); - } - - public Serializer(boolean unwrapping) { - super(UnmountFolderArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(UnmountFolderArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("shared_folder_id", value.sharedFolderId); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UnmountFolderArg.class); - } - - public Deserializer(boolean unwrapping) { - super(UnmountFolderArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(UnmountFolderArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("shared_folder_id"); + StoneSerializers.string().serialize(value.sharedFolderId, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public UnmountFolderArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String sharedFolderId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("shared_folder_id".equals(_field)) { - sharedFolderId = getStringValue(_p); - _p.nextToken(); + public UnmountFolderArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + UnmountFolderArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_sharedFolderId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("shared_folder_id".equals(field)) { + f_sharedFolderId = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_sharedFolderId == null) { + throw new JsonParseException(p, "Required field \"shared_folder_id\" missing."); } + value = new UnmountFolderArg(f_sharedFolderId); } - - if (sharedFolderId == null) { - throw new JsonParseException(_p, "Required field \"shared_folder_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new UnmountFolderArg(sharedFolderId); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/UnmountFolderError.java b/src/main/java/com/dropbox/core/v2/sharing/UnmountFolderError.java index 91b3335a2..ea25dabd0 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/UnmountFolderError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/UnmountFolderError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=UnmountFolderError.Serializer.class) -@JsonDeserialize(using=UnmountFolderError.Deserializer.class) public final class UnmountFolderError { // union UnmountFolderError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link UnmountFolderError}. */ @@ -237,7 +219,7 @@ else if (obj instanceof UnmountFolderError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -249,85 +231,78 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UnmountFolderError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(UnmountFolderError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case ACCESS_ERROR: + public void serialize(UnmountFolderError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case ACCESS_ERROR: { g.writeStartObject(); - g.writeStringField(".tag", "access_error"); - g.writeObjectField("access_error", value.accessErrorValue); + writeTag("access_error", g); + g.writeFieldName("access_error"); + SharedFolderAccessError.Serializer.INSTANCE.serialize(value.accessErrorValue, g); g.writeEndObject(); break; - case NO_PERMISSION: + } + case NO_PERMISSION: { g.writeString("no_permission"); break; - case NOT_UNMOUNTABLE: + } + case NOT_UNMOUNTABLE: { g.writeString("not_unmountable"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UnmountFolderError.class, getTagMapping(), Tag.OTHER); - } @Override - public UnmountFolderError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case ACCESS_ERROR: { - SharedFolderAccessError value = null; - expectField(_p, "access_error"); - value = _p.readValueAs(SharedFolderAccessError.class); - _p.nextToken(); - return UnmountFolderError.accessError(value); - } - case NO_PERMISSION: { - return UnmountFolderError.NO_PERMISSION; - } - case NOT_UNMOUNTABLE: { - return UnmountFolderError.NOT_UNMOUNTABLE; - } - case OTHER: { - return UnmountFolderError.OTHER; - } + public UnmountFolderError deserialize(JsonParser p) throws IOException, JsonParseException { + UnmountFolderError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("access_error", UnmountFolderError.Tag.ACCESS_ERROR); - values.put("no_permission", UnmountFolderError.Tag.NO_PERMISSION); - values.put("not_unmountable", UnmountFolderError.Tag.NOT_UNMOUNTABLE); - values.put("other", UnmountFolderError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("access_error".equals(tag)) { + SharedFolderAccessError fieldValue = null; + expectField("access_error", p); + fieldValue = SharedFolderAccessError.Serializer.INSTANCE.deserialize(p); + value = UnmountFolderError.accessError(fieldValue); + } + else if ("no_permission".equals(tag)) { + value = UnmountFolderError.NO_PERMISSION; + } + else if ("not_unmountable".equals(tag)) { + value = UnmountFolderError.NOT_UNMOUNTABLE; + } + else { + value = UnmountFolderError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/UnmountFolderErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/UnmountFolderErrorException.java index e88997953..4a6fe5db4 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/UnmountFolderErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/UnmountFolderErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/UnshareFolderArg.java b/src/main/java/com/dropbox/core/v2/sharing/UnshareFolderArg.java index 52bb15ce0..65429ed71 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/UnshareFolderArg.java +++ b/src/main/java/com/dropbox/core/v2/sharing/UnshareFolderArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=UnshareFolderArg.Serializer.class) -@JsonDeserialize(using=UnshareFolderArg.Deserializer.class) class UnshareFolderArg { // struct UnshareFolderArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String sharedFolderId; protected final boolean leaveACopy; @@ -122,7 +105,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -134,84 +117,65 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UnshareFolderArg.class); - } - - public Serializer(boolean unwrapping) { - super(UnshareFolderArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(UnshareFolderArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("shared_folder_id", value.sharedFolderId); - g.writeObjectField("leave_a_copy", value.leaveACopy); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UnshareFolderArg.class); - } - - public Deserializer(boolean unwrapping) { - super(UnshareFolderArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(UnshareFolderArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("shared_folder_id"); + StoneSerializers.string().serialize(value.sharedFolderId, g); + g.writeFieldName("leave_a_copy"); + StoneSerializers.boolean_().serialize(value.leaveACopy, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public UnshareFolderArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String sharedFolderId = null; - boolean leaveACopy = false; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("shared_folder_id".equals(_field)) { - sharedFolderId = getStringValue(_p); - _p.nextToken(); - } - else if ("leave_a_copy".equals(_field)) { - leaveACopy = _p.getValueAsBoolean(); - _p.nextToken(); + public UnshareFolderArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + UnshareFolderArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_sharedFolderId = null; + Boolean f_leaveACopy = false; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("shared_folder_id".equals(field)) { + f_sharedFolderId = StoneSerializers.string().deserialize(p); + } + else if ("leave_a_copy".equals(field)) { + f_leaveACopy = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_sharedFolderId == null) { + throw new JsonParseException(p, "Required field \"shared_folder_id\" missing."); } + value = new UnshareFolderArg(f_sharedFolderId, f_leaveACopy); } - - if (sharedFolderId == null) { - throw new JsonParseException(_p, "Required field \"shared_folder_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new UnshareFolderArg(sharedFolderId, leaveACopy); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/UnshareFolderError.java b/src/main/java/com/dropbox/core/v2/sharing/UnshareFolderError.java index 76e9b4253..709a51d25 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/UnshareFolderError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/UnshareFolderError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=UnshareFolderError.Serializer.class) -@JsonDeserialize(using=UnshareFolderError.Deserializer.class) public final class UnshareFolderError { // union UnshareFolderError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link UnshareFolderError}. */ @@ -233,7 +215,7 @@ else if (obj instanceof UnshareFolderError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -245,85 +227,78 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UnshareFolderError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(UnshareFolderError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case ACCESS_ERROR: + public void serialize(UnshareFolderError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case ACCESS_ERROR: { g.writeStartObject(); - g.writeStringField(".tag", "access_error"); - g.writeObjectField("access_error", value.accessErrorValue); + writeTag("access_error", g); + g.writeFieldName("access_error"); + SharedFolderAccessError.Serializer.INSTANCE.serialize(value.accessErrorValue, g); g.writeEndObject(); break; - case TEAM_FOLDER: + } + case TEAM_FOLDER: { g.writeString("team_folder"); break; - case NO_PERMISSION: + } + case NO_PERMISSION: { g.writeString("no_permission"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UnshareFolderError.class, getTagMapping(), Tag.OTHER); - } @Override - public UnshareFolderError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case ACCESS_ERROR: { - SharedFolderAccessError value = null; - expectField(_p, "access_error"); - value = _p.readValueAs(SharedFolderAccessError.class); - _p.nextToken(); - return UnshareFolderError.accessError(value); - } - case TEAM_FOLDER: { - return UnshareFolderError.TEAM_FOLDER; - } - case NO_PERMISSION: { - return UnshareFolderError.NO_PERMISSION; - } - case OTHER: { - return UnshareFolderError.OTHER; - } + public UnshareFolderError deserialize(JsonParser p) throws IOException, JsonParseException { + UnshareFolderError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("access_error", UnshareFolderError.Tag.ACCESS_ERROR); - values.put("team_folder", UnshareFolderError.Tag.TEAM_FOLDER); - values.put("no_permission", UnshareFolderError.Tag.NO_PERMISSION); - values.put("other", UnshareFolderError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("access_error".equals(tag)) { + SharedFolderAccessError fieldValue = null; + expectField("access_error", p); + fieldValue = SharedFolderAccessError.Serializer.INSTANCE.deserialize(p); + value = UnshareFolderError.accessError(fieldValue); + } + else if ("team_folder".equals(tag)) { + value = UnshareFolderError.TEAM_FOLDER; + } + else if ("no_permission".equals(tag)) { + value = UnshareFolderError.NO_PERMISSION; + } + else { + value = UnshareFolderError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/UnshareFolderErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/UnshareFolderErrorException.java index 9207b6014..46bffc496 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/UnshareFolderErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/UnshareFolderErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderMemberArg.java b/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderMemberArg.java index c9c94d110..04c7b08c3 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderMemberArg.java +++ b/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderMemberArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=UpdateFolderMemberArg.Serializer.class) -@JsonDeserialize(using=UpdateFolderMemberArg.Deserializer.class) class UpdateFolderMemberArg { // struct UpdateFolderMemberArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String sharedFolderId; protected final MemberSelector member; protected final AccessLevel accessLevel; @@ -131,7 +114,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -143,96 +126,77 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UpdateFolderMemberArg.class); - } - - public Serializer(boolean unwrapping) { - super(UpdateFolderMemberArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(UpdateFolderMemberArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("shared_folder_id", value.sharedFolderId); - g.writeObjectField("member", value.member); - g.writeObjectField("access_level", value.accessLevel); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UpdateFolderMemberArg.class); - } - - public Deserializer(boolean unwrapping) { - super(UpdateFolderMemberArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(UpdateFolderMemberArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("shared_folder_id"); + StoneSerializers.string().serialize(value.sharedFolderId, g); + g.writeFieldName("member"); + MemberSelector.Serializer.INSTANCE.serialize(value.member, g); + g.writeFieldName("access_level"); + AccessLevel.Serializer.INSTANCE.serialize(value.accessLevel, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public UpdateFolderMemberArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String sharedFolderId = null; - MemberSelector member = null; - AccessLevel accessLevel = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("shared_folder_id".equals(_field)) { - sharedFolderId = getStringValue(_p); - _p.nextToken(); + public UpdateFolderMemberArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + UpdateFolderMemberArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_sharedFolderId = null; + MemberSelector f_member = null; + AccessLevel f_accessLevel = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("shared_folder_id".equals(field)) { + f_sharedFolderId = StoneSerializers.string().deserialize(p); + } + else if ("member".equals(field)) { + f_member = MemberSelector.Serializer.INSTANCE.deserialize(p); + } + else if ("access_level".equals(field)) { + f_accessLevel = AccessLevel.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else if ("member".equals(_field)) { - member = _p.readValueAs(MemberSelector.class); - _p.nextToken(); + if (f_sharedFolderId == null) { + throw new JsonParseException(p, "Required field \"shared_folder_id\" missing."); } - else if ("access_level".equals(_field)) { - accessLevel = _p.readValueAs(AccessLevel.class); - _p.nextToken(); + if (f_member == null) { + throw new JsonParseException(p, "Required field \"member\" missing."); } - else { - skipValue(_p); + if (f_accessLevel == null) { + throw new JsonParseException(p, "Required field \"access_level\" missing."); } + value = new UpdateFolderMemberArg(f_sharedFolderId, f_member, f_accessLevel); } - - if (sharedFolderId == null) { - throw new JsonParseException(_p, "Required field \"shared_folder_id\" is missing."); - } - if (member == null) { - throw new JsonParseException(_p, "Required field \"member\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (accessLevel == null) { - throw new JsonParseException(_p, "Required field \"access_level\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new UpdateFolderMemberArg(sharedFolderId, member, accessLevel); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderMemberError.java b/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderMemberError.java index 36d428b06..06b9f9733 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderMemberError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderMemberError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=UpdateFolderMemberError.Serializer.class) -@JsonDeserialize(using=UpdateFolderMemberError.Deserializer.class) public final class UpdateFolderMemberError { // union UpdateFolderMemberError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link UpdateFolderMemberError}. */ @@ -289,7 +271,7 @@ else if (obj instanceof UpdateFolderMemberError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -301,99 +283,92 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UpdateFolderMemberError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(UpdateFolderMemberError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case ACCESS_ERROR: + public void serialize(UpdateFolderMemberError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case ACCESS_ERROR: { g.writeStartObject(); - g.writeStringField(".tag", "access_error"); - g.writeObjectField("access_error", value.accessErrorValue); + writeTag("access_error", g); + g.writeFieldName("access_error"); + SharedFolderAccessError.Serializer.INSTANCE.serialize(value.accessErrorValue, g); g.writeEndObject(); break; - case MEMBER_ERROR: + } + case MEMBER_ERROR: { g.writeStartObject(); - g.writeStringField(".tag", "member_error"); - g.writeObjectField("member_error", value.memberErrorValue); + writeTag("member_error", g); + g.writeFieldName("member_error"); + SharedFolderMemberError.Serializer.INSTANCE.serialize(value.memberErrorValue, g); g.writeEndObject(); break; - case INSUFFICIENT_PLAN: + } + case INSUFFICIENT_PLAN: { g.writeString("insufficient_plan"); break; - case NO_PERMISSION: + } + case NO_PERMISSION: { g.writeString("no_permission"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UpdateFolderMemberError.class, getTagMapping(), Tag.OTHER); - } @Override - public UpdateFolderMemberError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case ACCESS_ERROR: { - SharedFolderAccessError value = null; - expectField(_p, "access_error"); - value = _p.readValueAs(SharedFolderAccessError.class); - _p.nextToken(); - return UpdateFolderMemberError.accessError(value); - } - case MEMBER_ERROR: { - SharedFolderMemberError value = null; - expectField(_p, "member_error"); - value = _p.readValueAs(SharedFolderMemberError.class); - _p.nextToken(); - return UpdateFolderMemberError.memberError(value); - } - case INSUFFICIENT_PLAN: { - return UpdateFolderMemberError.INSUFFICIENT_PLAN; - } - case NO_PERMISSION: { - return UpdateFolderMemberError.NO_PERMISSION; - } - case OTHER: { - return UpdateFolderMemberError.OTHER; - } + public UpdateFolderMemberError deserialize(JsonParser p) throws IOException, JsonParseException { + UpdateFolderMemberError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("access_error", UpdateFolderMemberError.Tag.ACCESS_ERROR); - values.put("member_error", UpdateFolderMemberError.Tag.MEMBER_ERROR); - values.put("insufficient_plan", UpdateFolderMemberError.Tag.INSUFFICIENT_PLAN); - values.put("no_permission", UpdateFolderMemberError.Tag.NO_PERMISSION); - values.put("other", UpdateFolderMemberError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("access_error".equals(tag)) { + SharedFolderAccessError fieldValue = null; + expectField("access_error", p); + fieldValue = SharedFolderAccessError.Serializer.INSTANCE.deserialize(p); + value = UpdateFolderMemberError.accessError(fieldValue); + } + else if ("member_error".equals(tag)) { + SharedFolderMemberError fieldValue = null; + expectField("member_error", p); + fieldValue = SharedFolderMemberError.Serializer.INSTANCE.deserialize(p); + value = UpdateFolderMemberError.memberError(fieldValue); + } + else if ("insufficient_plan".equals(tag)) { + value = UpdateFolderMemberError.INSUFFICIENT_PLAN; + } + else if ("no_permission".equals(tag)) { + value = UpdateFolderMemberError.NO_PERMISSION; + } + else { + value = UpdateFolderMemberError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderMemberErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderMemberErrorException.java index 79437f894..2cba20962 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderMemberErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderMemberErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderPolicyArg.java b/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderPolicyArg.java index 85346148d..13eec5afc 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderPolicyArg.java +++ b/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderPolicyArg.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * If any of the policy's are unset, then they retain their current setting. */ -@JsonSerialize(using=UpdateFolderPolicyArg.Serializer.class) -@JsonDeserialize(using=UpdateFolderPolicyArg.Deserializer.class) class UpdateFolderPolicyArg { // struct UpdateFolderPolicyArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String sharedFolderId; protected final MemberPolicy memberPolicy; protected final AclUpdatePolicy aclUpdatePolicy; @@ -249,7 +232,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -261,102 +244,83 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UpdateFolderPolicyArg.class); - } - - public Serializer(boolean unwrapping) { - super(UpdateFolderPolicyArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(UpdateFolderPolicyArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("shared_folder_id", value.sharedFolderId); + public void serialize(UpdateFolderPolicyArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("shared_folder_id"); + StoneSerializers.string().serialize(value.sharedFolderId, g); if (value.memberPolicy != null) { - g.writeObjectField("member_policy", value.memberPolicy); + g.writeFieldName("member_policy"); + StoneSerializers.nullable(MemberPolicy.Serializer.INSTANCE).serialize(value.memberPolicy, g); } if (value.aclUpdatePolicy != null) { - g.writeObjectField("acl_update_policy", value.aclUpdatePolicy); + g.writeFieldName("acl_update_policy"); + StoneSerializers.nullable(AclUpdatePolicy.Serializer.INSTANCE).serialize(value.aclUpdatePolicy, g); } if (value.sharedLinkPolicy != null) { - g.writeObjectField("shared_link_policy", value.sharedLinkPolicy); + g.writeFieldName("shared_link_policy"); + StoneSerializers.nullable(SharedLinkPolicy.Serializer.INSTANCE).serialize(value.sharedLinkPolicy, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UpdateFolderPolicyArg.class); - } - - public Deserializer(boolean unwrapping) { - super(UpdateFolderPolicyArg.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public UpdateFolderPolicyArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String sharedFolderId = null; - MemberPolicy memberPolicy = null; - AclUpdatePolicy aclUpdatePolicy = null; - SharedLinkPolicy sharedLinkPolicy = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("shared_folder_id".equals(_field)) { - sharedFolderId = getStringValue(_p); - _p.nextToken(); - } - else if ("member_policy".equals(_field)) { - memberPolicy = _p.readValueAs(MemberPolicy.class); - _p.nextToken(); - } - else if ("acl_update_policy".equals(_field)) { - aclUpdatePolicy = _p.readValueAs(AclUpdatePolicy.class); - _p.nextToken(); - } - else if ("shared_link_policy".equals(_field)) { - sharedLinkPolicy = _p.readValueAs(SharedLinkPolicy.class); - _p.nextToken(); + public UpdateFolderPolicyArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + UpdateFolderPolicyArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_sharedFolderId = null; + MemberPolicy f_memberPolicy = null; + AclUpdatePolicy f_aclUpdatePolicy = null; + SharedLinkPolicy f_sharedLinkPolicy = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("shared_folder_id".equals(field)) { + f_sharedFolderId = StoneSerializers.string().deserialize(p); + } + else if ("member_policy".equals(field)) { + f_memberPolicy = StoneSerializers.nullable(MemberPolicy.Serializer.INSTANCE).deserialize(p); + } + else if ("acl_update_policy".equals(field)) { + f_aclUpdatePolicy = StoneSerializers.nullable(AclUpdatePolicy.Serializer.INSTANCE).deserialize(p); + } + else if ("shared_link_policy".equals(field)) { + f_sharedLinkPolicy = StoneSerializers.nullable(SharedLinkPolicy.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_sharedFolderId == null) { + throw new JsonParseException(p, "Required field \"shared_folder_id\" missing."); } + value = new UpdateFolderPolicyArg(f_sharedFolderId, f_memberPolicy, f_aclUpdatePolicy, f_sharedLinkPolicy); } - - if (sharedFolderId == null) { - throw new JsonParseException(_p, "Required field \"shared_folder_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new UpdateFolderPolicyArg(sharedFolderId, memberPolicy, aclUpdatePolicy, sharedLinkPolicy); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderPolicyBuilder.java b/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderPolicyBuilder.java index 4ab83277a..3fe524652 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderPolicyBuilder.java +++ b/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderPolicyBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; @@ -13,26 +13,26 @@ * request.

*/ public class UpdateFolderPolicyBuilder { - private final DbxUserSharingRequests sharing; + private final DbxUserSharingRequests sharing_; private final UpdateFolderPolicyArg.Builder updateFolderPolicyArgBuilder; /** * Creates a new instance of this builder. * - * @param sharing Dropbox namespace-specific client used to issue sharing + * @param sharing_ Dropbox namespace-specific client used to issue sharing * requests. * @param updateFolderPolicyArgBuilder Request argument builder. * * @return instsance of this builder */ - UpdateFolderPolicyBuilder(DbxUserSharingRequests sharing, UpdateFolderPolicyArg.Builder updateFolderPolicyArgBuilder) { - if (sharing == null) { - throw new NullPointerException("sharing"); + UpdateFolderPolicyBuilder(DbxUserSharingRequests sharing_, UpdateFolderPolicyArg.Builder updateFolderPolicyArgBuilder) { + if (sharing_ == null) { + throw new NullPointerException("sharing_"); } + this.sharing_ = sharing_; if (updateFolderPolicyArgBuilder == null) { throw new NullPointerException("updateFolderPolicyArgBuilder"); } - this.sharing = sharing; this.updateFolderPolicyArgBuilder = updateFolderPolicyArgBuilder; } @@ -80,7 +80,7 @@ public UpdateFolderPolicyBuilder withSharedLinkPolicy(SharedLinkPolicy sharedLin * Issues the request. */ public SharedFolderMetadata start() throws UpdateFolderPolicyErrorException, DbxException { - UpdateFolderPolicyArg arg = this.updateFolderPolicyArgBuilder.build(); - return sharing.updateFolderPolicy(arg); + UpdateFolderPolicyArg arg_ = this.updateFolderPolicyArgBuilder.build(); + return sharing_.updateFolderPolicy(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderPolicyError.java b/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderPolicyError.java index 97a387972..12f25db46 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderPolicyError.java +++ b/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderPolicyError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=UpdateFolderPolicyError.Serializer.class) -@JsonDeserialize(using=UpdateFolderPolicyError.Deserializer.class) public final class UpdateFolderPolicyError { // union UpdateFolderPolicyError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link UpdateFolderPolicyError}. */ @@ -264,7 +246,7 @@ else if (obj instanceof UpdateFolderPolicyError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -276,92 +258,85 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UpdateFolderPolicyError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(UpdateFolderPolicyError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case ACCESS_ERROR: + public void serialize(UpdateFolderPolicyError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case ACCESS_ERROR: { g.writeStartObject(); - g.writeStringField(".tag", "access_error"); - g.writeObjectField("access_error", value.accessErrorValue); + writeTag("access_error", g); + g.writeFieldName("access_error"); + SharedFolderAccessError.Serializer.INSTANCE.serialize(value.accessErrorValue, g); g.writeEndObject(); break; - case NOT_ON_TEAM: + } + case NOT_ON_TEAM: { g.writeString("not_on_team"); break; - case TEAM_POLICY_DISALLOWS_MEMBER_POLICY: + } + case TEAM_POLICY_DISALLOWS_MEMBER_POLICY: { g.writeString("team_policy_disallows_member_policy"); break; - case DISALLOWED_SHARED_LINK_POLICY: + } + case DISALLOWED_SHARED_LINK_POLICY: { g.writeString("disallowed_shared_link_policy"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UpdateFolderPolicyError.class, getTagMapping(), Tag.OTHER); - } @Override - public UpdateFolderPolicyError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case ACCESS_ERROR: { - SharedFolderAccessError value = null; - expectField(_p, "access_error"); - value = _p.readValueAs(SharedFolderAccessError.class); - _p.nextToken(); - return UpdateFolderPolicyError.accessError(value); - } - case NOT_ON_TEAM: { - return UpdateFolderPolicyError.NOT_ON_TEAM; - } - case TEAM_POLICY_DISALLOWS_MEMBER_POLICY: { - return UpdateFolderPolicyError.TEAM_POLICY_DISALLOWS_MEMBER_POLICY; - } - case DISALLOWED_SHARED_LINK_POLICY: { - return UpdateFolderPolicyError.DISALLOWED_SHARED_LINK_POLICY; - } - case OTHER: { - return UpdateFolderPolicyError.OTHER; - } + public UpdateFolderPolicyError deserialize(JsonParser p) throws IOException, JsonParseException { + UpdateFolderPolicyError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("access_error", UpdateFolderPolicyError.Tag.ACCESS_ERROR); - values.put("not_on_team", UpdateFolderPolicyError.Tag.NOT_ON_TEAM); - values.put("team_policy_disallows_member_policy", UpdateFolderPolicyError.Tag.TEAM_POLICY_DISALLOWS_MEMBER_POLICY); - values.put("disallowed_shared_link_policy", UpdateFolderPolicyError.Tag.DISALLOWED_SHARED_LINK_POLICY); - values.put("other", UpdateFolderPolicyError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("access_error".equals(tag)) { + SharedFolderAccessError fieldValue = null; + expectField("access_error", p); + fieldValue = SharedFolderAccessError.Serializer.INSTANCE.deserialize(p); + value = UpdateFolderPolicyError.accessError(fieldValue); + } + else if ("not_on_team".equals(tag)) { + value = UpdateFolderPolicyError.NOT_ON_TEAM; + } + else if ("team_policy_disallows_member_policy".equals(tag)) { + value = UpdateFolderPolicyError.TEAM_POLICY_DISALLOWS_MEMBER_POLICY; + } + else if ("disallowed_shared_link_policy".equals(tag)) { + value = UpdateFolderPolicyError.DISALLOWED_SHARED_LINK_POLICY; + } + else { + value = UpdateFolderPolicyError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderPolicyErrorException.java b/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderPolicyErrorException.java index 8f08217d9..2678e9b8c 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderPolicyErrorException.java +++ b/src/main/java/com/dropbox/core/v2/sharing/UpdateFolderPolicyErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; diff --git a/src/main/java/com/dropbox/core/v2/sharing/UserInfo.java b/src/main/java/com/dropbox/core/v2/sharing/UserInfo.java index d3b3562a6..3bc5c59fa 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/UserInfo.java +++ b/src/main/java/com/dropbox/core/v2/sharing/UserInfo.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; @@ -31,15 +20,9 @@ * com.dropbox.core.v2.users.DbxUserUsersRequests#getAccountBatch(java.util.List)} * to obtain more detailed information. */ -@JsonSerialize(using=UserInfo.Serializer.class) -@JsonDeserialize(using=UserInfo.Deserializer.class) public class UserInfo { // struct UserInfo - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String accountId; protected final boolean sameTeam; protected final String teamMemberId; @@ -153,7 +136,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -165,95 +148,76 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UserInfo.class); - } - - public Serializer(boolean unwrapping) { - super(UserInfo.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(UserInfo value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("account_id", value.accountId); - g.writeObjectField("same_team", value.sameTeam); + public void serialize(UserInfo value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("account_id"); + StoneSerializers.string().serialize(value.accountId, g); + g.writeFieldName("same_team"); + StoneSerializers.boolean_().serialize(value.sameTeam, g); if (value.teamMemberId != null) { - g.writeObjectField("team_member_id", value.teamMemberId); + g.writeFieldName("team_member_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.teamMemberId, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UserInfo.class); - } - - public Deserializer(boolean unwrapping) { - super(UserInfo.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public UserInfo deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String accountId = null; - Boolean sameTeam = null; - String teamMemberId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("account_id".equals(_field)) { - accountId = getStringValue(_p); - _p.nextToken(); - } - else if ("same_team".equals(_field)) { - sameTeam = _p.getValueAsBoolean(); - _p.nextToken(); + public UserInfo deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + UserInfo value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_accountId = null; + Boolean f_sameTeam = null; + String f_teamMemberId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("account_id".equals(field)) { + f_accountId = StoneSerializers.string().deserialize(p); + } + else if ("same_team".equals(field)) { + f_sameTeam = StoneSerializers.boolean_().deserialize(p); + } + else if ("team_member_id".equals(field)) { + f_teamMemberId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } - else if ("team_member_id".equals(_field)) { - teamMemberId = getStringValue(_p); - _p.nextToken(); + if (f_accountId == null) { + throw new JsonParseException(p, "Required field \"account_id\" missing."); } - else { - skipValue(_p); + if (f_sameTeam == null) { + throw new JsonParseException(p, "Required field \"same_team\" missing."); } + value = new UserInfo(f_accountId, f_sameTeam, f_teamMemberId); } - - if (accountId == null) { - throw new JsonParseException(_p, "Required field \"account_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (sameTeam == null) { - throw new JsonParseException(_p, "Required field \"same_team\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new UserInfo(accountId, sameTeam, teamMemberId); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/UserMembershipInfo.java b/src/main/java/com/dropbox/core/v2/sharing/UserMembershipInfo.java index baed8ad25..cde87a420 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/UserMembershipInfo.java +++ b/src/main/java/com/dropbox/core/v2/sharing/UserMembershipInfo.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel */ +/* This file was generated from sharing_folders.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; @@ -29,15 +18,9 @@ /** * The information about a user member of the shared folder. */ -@JsonSerialize(using=UserMembershipInfo.Serializer.class) -@JsonDeserialize(using=UserMembershipInfo.Deserializer.class) public class UserMembershipInfo extends MembershipInfo { // struct UserMembershipInfo - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final UserInfo user; /** @@ -167,7 +150,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -179,117 +162,90 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UserMembershipInfo.class); - } - - public Serializer(boolean unwrapping) { - super(UserMembershipInfo.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(UserMembershipInfo value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("access_type", value.accessType); - g.writeObjectField("user", value.user); + public void serialize(UserMembershipInfo value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("access_type"); + AccessLevel.Serializer.INSTANCE.serialize(value.accessType, g); + g.writeFieldName("user"); + UserInfo.Serializer.INSTANCE.serialize(value.user, g); if (value.permissions != null) { - g.writeObjectField("permissions", value.permissions); + g.writeFieldName("permissions"); + StoneSerializers.nullable(StoneSerializers.list(MemberPermission.Serializer.INSTANCE)).serialize(value.permissions, g); } if (value.initials != null) { - g.writeObjectField("initials", value.initials); + g.writeFieldName("initials"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.initials, g); + } + g.writeFieldName("is_inherited"); + StoneSerializers.boolean_().serialize(value.isInherited, g); + if (!collapse) { + g.writeEndObject(); } - g.writeObjectField("is_inherited", value.isInherited); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UserMembershipInfo.class); - } - - public Deserializer(boolean unwrapping) { - super(UserMembershipInfo.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public UserMembershipInfo deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - AccessLevel accessType = null; - UserInfo user = null; - List permissions = null; - String initials = null; - boolean isInherited = false; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("access_type".equals(_field)) { - accessType = _p.readValueAs(AccessLevel.class); - _p.nextToken(); - } - else if ("user".equals(_field)) { - user = _p.readValueAs(UserInfo.class); - _p.nextToken(); - } - else if ("permissions".equals(_field)) { - expectArrayStart(_p); - permissions = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - MemberPermission _x = null; - _x = _p.readValueAs(MemberPermission.class); - _p.nextToken(); - permissions.add(_x); + public UserMembershipInfo deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + UserMembershipInfo value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + AccessLevel f_accessType = null; + UserInfo f_user = null; + List f_permissions = null; + String f_initials = null; + Boolean f_isInherited = false; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("access_type".equals(field)) { + f_accessType = AccessLevel.Serializer.INSTANCE.deserialize(p); + } + else if ("user".equals(field)) { + f_user = UserInfo.Serializer.INSTANCE.deserialize(p); + } + else if ("permissions".equals(field)) { + f_permissions = StoneSerializers.nullable(StoneSerializers.list(MemberPermission.Serializer.INSTANCE)).deserialize(p); + } + else if ("initials".equals(field)) { + f_initials = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("is_inherited".equals(field)) { + f_isInherited = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("initials".equals(_field)) { - initials = getStringValue(_p); - _p.nextToken(); } - else if ("is_inherited".equals(_field)) { - isInherited = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_accessType == null) { + throw new JsonParseException(p, "Required field \"access_type\" missing."); } - else { - skipValue(_p); + if (f_user == null) { + throw new JsonParseException(p, "Required field \"user\" missing."); } + value = new UserMembershipInfo(f_accessType, f_user, f_permissions, f_initials, f_isInherited); } - - if (accessType == null) { - throw new JsonParseException(_p, "Required field \"access_type\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (user == null) { - throw new JsonParseException(_p, "Required field \"user\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new UserMembershipInfo(accessType, user, permissions, initials, isInherited); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/Visibility.java b/src/main/java/com/dropbox/core/v2/sharing/Visibility.java index 2509009a0..ebc4cba74 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/Visibility.java +++ b/src/main/java/com/dropbox/core/v2/sharing/Visibility.java @@ -1,38 +1,24 @@ /* DO NOT EDIT */ -/* This file was generated from shared_links.babel */ +/* This file was generated from shared_links.stone */ package com.dropbox.core.v2.sharing; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Who can access a shared link. The most open visibility is {@link * Visibility#PUBLIC}. The default depends on many aspects, such as team and * user preferences and shared folder settings. */ -@JsonSerialize(using=Visibility.Serializer.class) -@JsonDeserialize(using=Visibility.Deserializer.class) public enum Visibility { // union Visibility /** @@ -63,63 +49,82 @@ public enum Visibility { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(Visibility.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(Visibility value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(Visibility value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case PUBLIC: + case PUBLIC: { g.writeString("public"); break; - case TEAM_ONLY: + } + case TEAM_ONLY: { g.writeString("team_only"); break; - case PASSWORD: + } + case PASSWORD: { g.writeString("password"); break; - case TEAM_AND_PASSWORD: + } + case TEAM_AND_PASSWORD: { g.writeString("team_and_password"); break; - case SHARED_FOLDER_ONLY: + } + case SHARED_FOLDER_ONLY: { g.writeString("shared_folder_only"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(Visibility.class, getTagMapping(), Visibility.OTHER); - } @Override - public Visibility deserialize(Visibility _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("public", Visibility.PUBLIC); - values.put("team_only", Visibility.TEAM_ONLY); - values.put("password", Visibility.PASSWORD); - values.put("team_and_password", Visibility.TEAM_AND_PASSWORD); - values.put("shared_folder_only", Visibility.SHARED_FOLDER_ONLY); - values.put("other", Visibility.OTHER); - return Collections.unmodifiableMap(values); + public Visibility deserialize(JsonParser p) throws IOException, JsonParseException { + Visibility value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("public".equals(tag)) { + value = Visibility.PUBLIC; + } + else if ("team_only".equals(tag)) { + value = Visibility.TEAM_ONLY; + } + else if ("password".equals(tag)) { + value = Visibility.PASSWORD; + } + else if ("team_and_password".equals(tag)) { + value = Visibility.TEAM_AND_PASSWORD; + } + else if ("shared_folder_only".equals(tag)) { + value = Visibility.SHARED_FOLDER_ONLY; + } + else { + value = Visibility.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/sharing/package-info.java b/src/main/java/com/dropbox/core/v2/sharing/package-info.java index 296aa3300..e20db3c5d 100644 --- a/src/main/java/com/dropbox/core/v2/sharing/package-info.java +++ b/src/main/java/com/dropbox/core/v2/sharing/package-info.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from sharing_folders.babel, shared_links.babel */ +/* This file was generated from sharing_folders.stone, shared_links.stone */ /** * This namespace contains endpoints and data types for creating and managing diff --git a/src/main/java/com/dropbox/core/v2/team/ActiveWebSession.java b/src/main/java/com/dropbox/core/v2/team/ActiveWebSession.java index c6062b3eb..08a80d03c 100644 --- a/src/main/java/com/dropbox/core/v2/team/ActiveWebSession.java +++ b/src/main/java/com/dropbox/core/v2/team/ActiveWebSession.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.Date; @@ -29,15 +18,9 @@ /** * Information on active web sessions */ -@JsonSerialize(using=ActiveWebSession.Serializer.class) -@JsonDeserialize(using=ActiveWebSession.Deserializer.class) public class ActiveWebSession extends DeviceSession { // struct ActiveWebSession - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String userAgent; protected final String os; protected final String browser; @@ -218,7 +201,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -230,137 +213,118 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ActiveWebSession.class); - } - - public Serializer(boolean unwrapping) { - super(ActiveWebSession.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(ActiveWebSession value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("session_id", value.sessionId); - g.writeObjectField("user_agent", value.userAgent); - g.writeObjectField("os", value.os); - g.writeObjectField("browser", value.browser); + public void serialize(ActiveWebSession value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("session_id"); + StoneSerializers.string().serialize(value.sessionId, g); + g.writeFieldName("user_agent"); + StoneSerializers.string().serialize(value.userAgent, g); + g.writeFieldName("os"); + StoneSerializers.string().serialize(value.os, g); + g.writeFieldName("browser"); + StoneSerializers.string().serialize(value.browser, g); if (value.ipAddress != null) { - g.writeObjectField("ip_address", value.ipAddress); + g.writeFieldName("ip_address"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.ipAddress, g); } if (value.country != null) { - g.writeObjectField("country", value.country); + g.writeFieldName("country"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.country, g); } if (value.created != null) { - g.writeObjectField("created", value.created); + g.writeFieldName("created"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.created, g); } if (value.updated != null) { - g.writeObjectField("updated", value.updated); + g.writeFieldName("updated"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.updated, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ActiveWebSession.class); - } - - public Deserializer(boolean unwrapping) { - super(ActiveWebSession.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public ActiveWebSession deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String sessionId = null; - String userAgent = null; - String os = null; - String browser = null; - String ipAddress = null; - String country = null; - Date created = null; - Date updated = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("session_id".equals(_field)) { - sessionId = getStringValue(_p); - _p.nextToken(); - } - else if ("user_agent".equals(_field)) { - userAgent = getStringValue(_p); - _p.nextToken(); - } - else if ("os".equals(_field)) { - os = getStringValue(_p); - _p.nextToken(); - } - else if ("browser".equals(_field)) { - browser = getStringValue(_p); - _p.nextToken(); - } - else if ("ip_address".equals(_field)) { - ipAddress = getStringValue(_p); - _p.nextToken(); + public ActiveWebSession deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ActiveWebSession value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_sessionId = null; + String f_userAgent = null; + String f_os = null; + String f_browser = null; + String f_ipAddress = null; + String f_country = null; + Date f_created = null; + Date f_updated = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("session_id".equals(field)) { + f_sessionId = StoneSerializers.string().deserialize(p); + } + else if ("user_agent".equals(field)) { + f_userAgent = StoneSerializers.string().deserialize(p); + } + else if ("os".equals(field)) { + f_os = StoneSerializers.string().deserialize(p); + } + else if ("browser".equals(field)) { + f_browser = StoneSerializers.string().deserialize(p); + } + else if ("ip_address".equals(field)) { + f_ipAddress = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("country".equals(field)) { + f_country = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("created".equals(field)) { + f_created = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else if ("updated".equals(field)) { + f_updated = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else { + skipValue(p); + } } - else if ("country".equals(_field)) { - country = getStringValue(_p); - _p.nextToken(); + if (f_sessionId == null) { + throw new JsonParseException(p, "Required field \"session_id\" missing."); } - else if ("created".equals(_field)) { - created = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); + if (f_userAgent == null) { + throw new JsonParseException(p, "Required field \"user_agent\" missing."); } - else if ("updated".equals(_field)) { - updated = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); + if (f_os == null) { + throw new JsonParseException(p, "Required field \"os\" missing."); } - else { - skipValue(_p); + if (f_browser == null) { + throw new JsonParseException(p, "Required field \"browser\" missing."); } + value = new ActiveWebSession(f_sessionId, f_userAgent, f_os, f_browser, f_ipAddress, f_country, f_created, f_updated); } - - if (sessionId == null) { - throw new JsonParseException(_p, "Required field \"session_id\" is missing."); - } - if (userAgent == null) { - throw new JsonParseException(_p, "Required field \"user_agent\" is missing."); - } - if (os == null) { - throw new JsonParseException(_p, "Required field \"os\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (browser == null) { - throw new JsonParseException(_p, "Required field \"browser\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new ActiveWebSession(sessionId, userAgent, os, browser, ipAddress, country, created, updated); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/AddPropertyTemplateArg.java b/src/main/java/com/dropbox/core/v2/team/AddPropertyTemplateArg.java index 26c7d6150..7d5d28fc7 100644 --- a/src/main/java/com/dropbox/core/v2/team/AddPropertyTemplateArg.java +++ b/src/main/java/com/dropbox/core/v2/team/AddPropertyTemplateArg.java @@ -1,13 +1,10 @@ /* DO NOT EDIT */ -/* This file was generated from team_property_templates.babel */ +/* This file was generated from team_property_templates.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.dropbox.core.v2.properties.PropertyFieldTemplate; import com.dropbox.core.v2.properties.PropertyGroupTemplate; @@ -15,15 +12,7 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; @@ -31,15 +20,9 @@ /** * Arguments for adding property templates. */ -@JsonSerialize(using=AddPropertyTemplateArg.Serializer.class) -@JsonDeserialize(using=AddPropertyTemplateArg.Deserializer.class) -class AddPropertyTemplateArg extends PropertyGroupTemplate { +public class AddPropertyTemplateArg extends PropertyGroupTemplate { // struct AddPropertyTemplateArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Arguments for adding property templates. @@ -87,7 +70,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -99,104 +82,77 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(AddPropertyTemplateArg.class); - } - - public Serializer(boolean unwrapping) { - super(AddPropertyTemplateArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(AddPropertyTemplateArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("name", value.name); - g.writeObjectField("description", value.description); - g.writeObjectField("fields", value.fields); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(AddPropertyTemplateArg.class); - } - - public Deserializer(boolean unwrapping) { - super(AddPropertyTemplateArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(AddPropertyTemplateArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("name"); + StoneSerializers.string().serialize(value.name, g); + g.writeFieldName("description"); + StoneSerializers.string().serialize(value.description, g); + g.writeFieldName("fields"); + StoneSerializers.list(PropertyFieldTemplate.Serializer.INSTANCE).serialize(value.fields, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public AddPropertyTemplateArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String name = null; - String description = null; - List fields = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("name".equals(_field)) { - name = getStringValue(_p); - _p.nextToken(); + public AddPropertyTemplateArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + AddPropertyTemplateArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_name = null; + String f_description = null; + List f_fields = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("name".equals(field)) { + f_name = StoneSerializers.string().deserialize(p); + } + else if ("description".equals(field)) { + f_description = StoneSerializers.string().deserialize(p); + } + else if ("fields".equals(field)) { + f_fields = StoneSerializers.list(PropertyFieldTemplate.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); + } } - else if ("description".equals(_field)) { - description = getStringValue(_p); - _p.nextToken(); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } - else if ("fields".equals(_field)) { - expectArrayStart(_p); - fields = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - PropertyFieldTemplate _x = null; - _x = _p.readValueAs(PropertyFieldTemplate.class); - _p.nextToken(); - fields.add(_x); - } - expectArrayEnd(_p); - _p.nextToken(); + if (f_description == null) { + throw new JsonParseException(p, "Required field \"description\" missing."); } - else { - skipValue(_p); + if (f_fields == null) { + throw new JsonParseException(p, "Required field \"fields\" missing."); } + value = new AddPropertyTemplateArg(f_name, f_description, f_fields); } - - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); - } - if (description == null) { - throw new JsonParseException(_p, "Required field \"description\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (fields == null) { - throw new JsonParseException(_p, "Required field \"fields\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new AddPropertyTemplateArg(name, description, fields); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/AddPropertyTemplateResult.java b/src/main/java/com/dropbox/core/v2/team/AddPropertyTemplateResult.java index b62144f4c..25017a2ce 100644 --- a/src/main/java/com/dropbox/core/v2/team/AddPropertyTemplateResult.java +++ b/src/main/java/com/dropbox/core/v2/team/AddPropertyTemplateResult.java @@ -1,47 +1,29 @@ /* DO NOT EDIT */ -/* This file was generated from team_property_templates.babel */ +/* This file was generated from team_property_templates.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=AddPropertyTemplateResult.Serializer.class) -@JsonDeserialize(using=AddPropertyTemplateResult.Deserializer.class) public class AddPropertyTemplateResult { // struct AddPropertyTemplateResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String templateId; /** * - * @param templateId An identifier for property template added by {@link - * DbxTeamTeamRequests#propertiesTemplateAdd(String,String,java.util.List)}. - * Must have length of at least 1, match pattern "{@code (/|ptid:).*}", - * and not be {@code null}. + * @param templateId An identifier for property template added by {@code + * propertiesTemplateAdd}. Must have length of at least 1, match pattern + * "{@code (/|ptid:).*}", and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -60,8 +42,8 @@ public AddPropertyTemplateResult(String templateId) { } /** - * An identifier for property template added by {@link - * DbxTeamTeamRequests#propertiesTemplateAdd(String,String,java.util.List)}. + * An identifier for property template added by {@code + * propertiesTemplateAdd}. * * @return value for this field, never {@code null}. */ @@ -94,7 +76,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -106,78 +88,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(AddPropertyTemplateResult.class); - } - - public Serializer(boolean unwrapping) { - super(AddPropertyTemplateResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(AddPropertyTemplateResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("template_id", value.templateId); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(AddPropertyTemplateResult.class); - } - - public Deserializer(boolean unwrapping) { - super(AddPropertyTemplateResult.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(AddPropertyTemplateResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("template_id"); + StoneSerializers.string().serialize(value.templateId, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public AddPropertyTemplateResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String templateId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("template_id".equals(_field)) { - templateId = getStringValue(_p); - _p.nextToken(); + public AddPropertyTemplateResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + AddPropertyTemplateResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_templateId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("template_id".equals(field)) { + f_templateId = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_templateId == null) { + throw new JsonParseException(p, "Required field \"template_id\" missing."); } + value = new AddPropertyTemplateResult(f_templateId); } - - if (templateId == null) { - throw new JsonParseException(_p, "Required field \"template_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new AddPropertyTemplateResult(templateId); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/AdminTier.java b/src/main/java/com/dropbox/core/v2/team/AdminTier.java index 7ffa569c2..64d18e459 100644 --- a/src/main/java/com/dropbox/core/v2/team/AdminTier.java +++ b/src/main/java/com/dropbox/core/v2/team/AdminTier.java @@ -1,36 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Describes which team-related admin permissions a user has. */ -@JsonSerialize(using=AdminTier.Serializer.class) -@JsonDeserialize(using=AdminTier.Deserializer.class) public enum AdminTier { // union AdminTier /** @@ -50,55 +36,74 @@ public enum AdminTier { */ MEMBER_ONLY; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(AdminTier.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(AdminTier value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(AdminTier value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case TEAM_ADMIN: + case TEAM_ADMIN: { g.writeString("team_admin"); break; - case USER_MANAGEMENT_ADMIN: + } + case USER_MANAGEMENT_ADMIN: { g.writeString("user_management_admin"); break; - case SUPPORT_ADMIN: + } + case SUPPORT_ADMIN: { g.writeString("support_admin"); break; - case MEMBER_ONLY: + } + case MEMBER_ONLY: { g.writeString("member_only"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(AdminTier.class, getTagMapping(), null); - } @Override - public AdminTier deserialize(AdminTier _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("team_admin", AdminTier.TEAM_ADMIN); - values.put("user_management_admin", AdminTier.USER_MANAGEMENT_ADMIN); - values.put("support_admin", AdminTier.SUPPORT_ADMIN); - values.put("member_only", AdminTier.MEMBER_ONLY); - return Collections.unmodifiableMap(values); + public AdminTier deserialize(JsonParser p) throws IOException, JsonParseException { + AdminTier value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("team_admin".equals(tag)) { + value = AdminTier.TEAM_ADMIN; + } + else if ("user_management_admin".equals(tag)) { + value = AdminTier.USER_MANAGEMENT_ADMIN; + } + else if ("support_admin".equals(tag)) { + value = AdminTier.SUPPORT_ADMIN; + } + else if ("member_only".equals(tag)) { + value = AdminTier.MEMBER_ONLY; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/AlphaGroupCreateArg.java b/src/main/java/com/dropbox/core/v2/team/AlphaGroupCreateArg.java new file mode 100644 index 000000000..7ef11866f --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/team/AlphaGroupCreateArg.java @@ -0,0 +1,254 @@ +/* DO NOT EDIT */ +/* This file was generated from team_groups.stone */ + +package com.dropbox.core.v2.team; + +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; +import com.dropbox.core.v2.teamcommon.GroupManagementType; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + +import java.io.IOException; + +public class AlphaGroupCreateArg extends GroupCreateArg { + // struct AlphaGroupCreateArg + + protected final GroupManagementType groupManagementType; + + /** + * Use {@link newBuilder} to create instances of this class without + * specifying values for all optional fields. + * + * @param groupName Group name. Must not be {@code null}. + * @param groupExternalId The creator of a team can associate an arbitrary + * external ID to the group. + * @param groupManagementType Whether the team can be managed by selected + * users, or only by team admins. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public AlphaGroupCreateArg(String groupName, String groupExternalId, GroupManagementType groupManagementType) { + super(groupName, groupExternalId); + if (groupManagementType == null) { + throw new IllegalArgumentException("Required value for 'groupManagementType' is null"); + } + this.groupManagementType = groupManagementType; + } + + /** + * The default values for unset fields will be used. + * + * @param groupName Group name. Must not be {@code null}. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public AlphaGroupCreateArg(String groupName) { + this(groupName, null, GroupManagementType.COMPANY_MANAGED); + } + + /** + * Whether the team can be managed by selected users, or only by team admins + * + * @return value for this field, or {@code null} if not present. Defaults to + * GroupManagementType.COMPANY_MANAGED. + */ + public GroupManagementType getGroupManagementType() { + return groupManagementType; + } + + /** + * Returns a new builder for creating an instance of this class. + * + * @param groupName Group name. Must not be {@code null}. + * + * @return builder for this class. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public static Builder newBuilder(String groupName) { + return new Builder(groupName); + } + + /** + * Builder for {@link AlphaGroupCreateArg}. + */ + public static class Builder { + protected final String groupName; + + protected String groupExternalId; + protected GroupManagementType groupManagementType; + + protected Builder(String groupName) { + if (groupName == null) { + throw new IllegalArgumentException("Required value for 'groupName' is null"); + } + this.groupName = groupName; + this.groupExternalId = null; + this.groupManagementType = GroupManagementType.COMPANY_MANAGED; + } + + /** + * Set value for optional field. + * + * @param groupExternalId The creator of a team can associate an + * arbitrary external ID to the group. + * + * @return this builder + */ + public Builder withGroupExternalId(String groupExternalId) { + this.groupExternalId = groupExternalId; + return this; + } + + /** + * Set value for optional field. + * + *

If left unset or set to {@code null}, defaults to {@code + * GroupManagementType.COMPANY_MANAGED}.

+ * + * @param groupManagementType Whether the team can be managed by + * selected users, or only by team admins. Defaults to {@code + * GroupManagementType.COMPANY_MANAGED} when set to {@code null}. + * + * @return this builder + */ + public Builder withGroupManagementType(GroupManagementType groupManagementType) { + if (groupManagementType != null) { + this.groupManagementType = groupManagementType; + } + else { + this.groupManagementType = GroupManagementType.COMPANY_MANAGED; + } + return this; + } + + /** + * Builds an instance of {@link AlphaGroupCreateArg} configured with + * this builder's values + * + * @return new instance of {@link AlphaGroupCreateArg} + */ + public AlphaGroupCreateArg build() { + return new AlphaGroupCreateArg(groupName, groupExternalId, groupManagementType); + } + } + + @Override + public int hashCode() { + int hash = java.util.Arrays.hashCode(new Object [] { + groupManagementType + }); + hash = (31 * super.hashCode()) + hash; + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + // be careful with inheritance + else if (obj.getClass().equals(this.getClass())) { + AlphaGroupCreateArg other = (AlphaGroupCreateArg) obj; + return ((this.groupName == other.groupName) || (this.groupName.equals(other.groupName))) + && ((this.groupExternalId == other.groupExternalId) || (this.groupExternalId != null && this.groupExternalId.equals(other.groupExternalId))) + && ((this.groupManagementType == other.groupManagementType) || (this.groupManagementType.equals(other.groupManagementType))) + ; + } + else { + return false; + } + } + + @Override + public String toString() { + return Serializer.INSTANCE.serialize(this, false); + } + + /** + * Returns a String representation of this object formatted for easier + * readability. + * + *

The returned String may contain newlines.

+ * + * @return Formatted, multiline String representation of this object + */ + public String toStringMultiline() { + return Serializer.INSTANCE.serialize(this, true); + } + + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); + + @Override + public void serialize(AlphaGroupCreateArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("group_name"); + StoneSerializers.string().serialize(value.groupName, g); + if (value.groupExternalId != null) { + g.writeFieldName("group_external_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.groupExternalId, g); + } + g.writeFieldName("group_management_type"); + GroupManagementType.Serializer.INSTANCE.serialize(value.groupManagementType, g); + if (!collapse) { + g.writeEndObject(); + } + } + + @Override + public AlphaGroupCreateArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + AlphaGroupCreateArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_groupName = null; + String f_groupExternalId = null; + GroupManagementType f_groupManagementType = GroupManagementType.COMPANY_MANAGED; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("group_name".equals(field)) { + f_groupName = StoneSerializers.string().deserialize(p); + } + else if ("group_external_id".equals(field)) { + f_groupExternalId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("group_management_type".equals(field)) { + f_groupManagementType = GroupManagementType.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } + } + if (f_groupName == null) { + throw new JsonParseException(p, "Required field \"group_name\" missing."); + } + value = new AlphaGroupCreateArg(f_groupName, f_groupExternalId, f_groupManagementType); + } + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; + } + } +} diff --git a/src/main/java/com/dropbox/core/v2/team/AlphaGroupFullInfo.java b/src/main/java/com/dropbox/core/v2/team/AlphaGroupFullInfo.java new file mode 100644 index 000000000..21ec20d51 --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/team/AlphaGroupFullInfo.java @@ -0,0 +1,320 @@ +/* DO NOT EDIT */ +/* This file was generated from team_groups.stone */ + +package com.dropbox.core.v2.team; + +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; +import com.dropbox.core.v2.teamcommon.AlphaGroupSummary; +import com.dropbox.core.v2.teamcommon.GroupManagementType; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + +import java.io.IOException; +import java.util.List; + +/** + * Full description of a group. + */ +public class AlphaGroupFullInfo extends AlphaGroupSummary { + // struct AlphaGroupFullInfo + + protected final List members; + protected final long created; + + /** + * Full description of a group. + * + *

Use {@link newBuilder} to create instances of this class without + * specifying values for all optional fields.

+ * + * @param groupName Must not be {@code null}. + * @param groupId Must not be {@code null}. + * @param groupManagementType Who is allowed to manage the group. Must not + * be {@code null}. + * @param created The group creation time as a UTC timestamp in + * milliseconds since the Unix epoch. + * @param groupExternalId External ID of group. This is an arbitrary ID + * that an admin can attach to a group. + * @param memberCount The number of members in the group. + * @param members List of group members. Must not contain a {@code null} + * item. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public AlphaGroupFullInfo(String groupName, String groupId, GroupManagementType groupManagementType, long created, String groupExternalId, Long memberCount, List members) { + super(groupName, groupId, groupManagementType, groupExternalId, memberCount); + if (members != null) { + for (GroupMemberInfo x : members) { + if (x == null) { + throw new IllegalArgumentException("An item in list 'members' is null"); + } + } + } + this.members = members; + this.created = created; + } + + /** + * Full description of a group. + * + *

The default values for unset fields will be used.

+ * + * @param groupName Must not be {@code null}. + * @param groupId Must not be {@code null}. + * @param groupManagementType Who is allowed to manage the group. Must not + * be {@code null}. + * @param created The group creation time as a UTC timestamp in + * milliseconds since the Unix epoch. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public AlphaGroupFullInfo(String groupName, String groupId, GroupManagementType groupManagementType, long created) { + this(groupName, groupId, groupManagementType, created, null, null, null); + } + + /** + * List of group members. + * + * @return value for this field, or {@code null} if not present. + */ + public List getMembers() { + return members; + } + + /** + * The group creation time as a UTC timestamp in milliseconds since the Unix + * epoch. + * + * @return value for this field. + */ + public long getCreated() { + return created; + } + + /** + * Returns a new builder for creating an instance of this class. + * + * @param groupName Must not be {@code null}. + * @param groupId Must not be {@code null}. + * @param groupManagementType Who is allowed to manage the group. Must not + * be {@code null}. + * @param created The group creation time as a UTC timestamp in + * milliseconds since the Unix epoch. + * + * @return builder for this class. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public static Builder newBuilder(String groupName, String groupId, GroupManagementType groupManagementType, long created) { + return new Builder(groupName, groupId, groupManagementType, created); + } + + /** + * Builder for {@link AlphaGroupFullInfo}. + */ + public static class Builder extends AlphaGroupSummary.Builder { + protected final long created; + + protected List members; + + protected Builder(String groupName, String groupId, GroupManagementType groupManagementType, long created) { + super(groupName, groupId, groupManagementType); + this.created = created; + this.members = null; + } + + /** + * Set value for optional field. + * + * @param members List of group members. Must not contain a {@code + * null} item. + * + * @return this builder + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public Builder withMembers(List members) { + if (members != null) { + for (GroupMemberInfo x : members) { + if (x == null) { + throw new IllegalArgumentException("An item in list 'members' is null"); + } + } + } + this.members = members; + return this; + } + + /** + * Builds an instance of {@link AlphaGroupFullInfo} configured with this + * builder's values + * + * @return new instance of {@link AlphaGroupFullInfo} + */ + public AlphaGroupFullInfo build() { + return new AlphaGroupFullInfo(groupName, groupId, groupManagementType, created, groupExternalId, memberCount, members); + } + } + + @Override + public int hashCode() { + int hash = java.util.Arrays.hashCode(new Object [] { + members, + created + }); + hash = (31 * super.hashCode()) + hash; + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + // be careful with inheritance + else if (obj.getClass().equals(this.getClass())) { + AlphaGroupFullInfo other = (AlphaGroupFullInfo) obj; + return ((this.groupName == other.groupName) || (this.groupName.equals(other.groupName))) + && ((this.groupId == other.groupId) || (this.groupId.equals(other.groupId))) + && ((this.groupManagementType == other.groupManagementType) || (this.groupManagementType.equals(other.groupManagementType))) + && (this.created == other.created) + && ((this.groupExternalId == other.groupExternalId) || (this.groupExternalId != null && this.groupExternalId.equals(other.groupExternalId))) + && ((this.memberCount == other.memberCount) || (this.memberCount != null && this.memberCount.equals(other.memberCount))) + && ((this.members == other.members) || (this.members != null && this.members.equals(other.members))) + ; + } + else { + return false; + } + } + + @Override + public String toString() { + return Serializer.INSTANCE.serialize(this, false); + } + + /** + * Returns a String representation of this object formatted for easier + * readability. + * + *

The returned String may contain newlines.

+ * + * @return Formatted, multiline String representation of this object + */ + public String toStringMultiline() { + return Serializer.INSTANCE.serialize(this, true); + } + + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); + + @Override + public void serialize(AlphaGroupFullInfo value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("group_name"); + StoneSerializers.string().serialize(value.groupName, g); + g.writeFieldName("group_id"); + StoneSerializers.string().serialize(value.groupId, g); + g.writeFieldName("group_management_type"); + GroupManagementType.Serializer.INSTANCE.serialize(value.groupManagementType, g); + g.writeFieldName("created"); + StoneSerializers.uInt64().serialize(value.created, g); + if (value.groupExternalId != null) { + g.writeFieldName("group_external_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.groupExternalId, g); + } + if (value.memberCount != null) { + g.writeFieldName("member_count"); + StoneSerializers.nullable(StoneSerializers.uInt32()).serialize(value.memberCount, g); + } + if (value.members != null) { + g.writeFieldName("members"); + StoneSerializers.nullable(StoneSerializers.list(GroupMemberInfo.Serializer.INSTANCE)).serialize(value.members, g); + } + if (!collapse) { + g.writeEndObject(); + } + } + + @Override + public AlphaGroupFullInfo deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + AlphaGroupFullInfo value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_groupName = null; + String f_groupId = null; + GroupManagementType f_groupManagementType = null; + Long f_created = null; + String f_groupExternalId = null; + Long f_memberCount = null; + List f_members = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("group_name".equals(field)) { + f_groupName = StoneSerializers.string().deserialize(p); + } + else if ("group_id".equals(field)) { + f_groupId = StoneSerializers.string().deserialize(p); + } + else if ("group_management_type".equals(field)) { + f_groupManagementType = GroupManagementType.Serializer.INSTANCE.deserialize(p); + } + else if ("created".equals(field)) { + f_created = StoneSerializers.uInt64().deserialize(p); + } + else if ("group_external_id".equals(field)) { + f_groupExternalId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("member_count".equals(field)) { + f_memberCount = StoneSerializers.nullable(StoneSerializers.uInt32()).deserialize(p); + } + else if ("members".equals(field)) { + f_members = StoneSerializers.nullable(StoneSerializers.list(GroupMemberInfo.Serializer.INSTANCE)).deserialize(p); + } + else { + skipValue(p); + } + } + if (f_groupName == null) { + throw new JsonParseException(p, "Required field \"group_name\" missing."); + } + if (f_groupId == null) { + throw new JsonParseException(p, "Required field \"group_id\" missing."); + } + if (f_groupManagementType == null) { + throw new JsonParseException(p, "Required field \"group_management_type\" missing."); + } + if (f_created == null) { + throw new JsonParseException(p, "Required field \"created\" missing."); + } + value = new AlphaGroupFullInfo(f_groupName, f_groupId, f_groupManagementType, f_created, f_groupExternalId, f_memberCount, f_members); + } + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; + } + } +} diff --git a/src/main/java/com/dropbox/core/v2/team/AlphaGroupUpdateArgs.java b/src/main/java/com/dropbox/core/v2/team/AlphaGroupUpdateArgs.java new file mode 100644 index 000000000..ae430fa77 --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/team/AlphaGroupUpdateArgs.java @@ -0,0 +1,247 @@ +/* DO NOT EDIT */ +/* This file was generated from team_groups.stone */ + +package com.dropbox.core.v2.team; + +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; +import com.dropbox.core.v2.teamcommon.GroupManagementType; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + +import java.io.IOException; + +public class AlphaGroupUpdateArgs extends GroupUpdateArgs { + // struct AlphaGroupUpdateArgs + + protected final GroupManagementType newGroupManagementType; + + /** + * Use {@link newBuilder} to create instances of this class without + * specifying values for all optional fields. + * + * @param group Specify a group. Must not be {@code null}. + * @param returnMembers Whether to return the list of members in the group. + * Note that the default value will cause all the group members to be + * returned in the response. This may take a long time for large groups. + * @param newGroupName Optional argument. Set group name to this if + * provided. + * @param newGroupExternalId Optional argument. New group external ID. If + * the argument is None, the group's external_id won't be updated. If + * the argument is empty string, the group's external id will be + * cleared. + * @param newGroupManagementType Set new group management type, if + * provided. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public AlphaGroupUpdateArgs(GroupSelector group, boolean returnMembers, String newGroupName, String newGroupExternalId, GroupManagementType newGroupManagementType) { + super(group, returnMembers, newGroupName, newGroupExternalId); + this.newGroupManagementType = newGroupManagementType; + } + + /** + * The default values for unset fields will be used. + * + * @param group Specify a group. Must not be {@code null}. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public AlphaGroupUpdateArgs(GroupSelector group) { + this(group, true, null, null, null); + } + + /** + * Set new group management type, if provided. + * + * @return value for this field, or {@code null} if not present. + */ + public GroupManagementType getNewGroupManagementType() { + return newGroupManagementType; + } + + /** + * Returns a new builder for creating an instance of this class. + * + * @param group Specify a group. Must not be {@code null}. + * + * @return builder for this class. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public static Builder newBuilder(GroupSelector group) { + return new Builder(group); + } + + /** + * Builder for {@link AlphaGroupUpdateArgs}. + */ + public static class Builder extends GroupUpdateArgs.Builder { + + protected GroupManagementType newGroupManagementType; + + protected Builder(GroupSelector group) { + super(group); + this.newGroupManagementType = null; + } + + /** + * Set value for optional field. + * + * @param newGroupManagementType Set new group management type, if + * provided. + * + * @return this builder + */ + public Builder withNewGroupManagementType(GroupManagementType newGroupManagementType) { + this.newGroupManagementType = newGroupManagementType; + return this; + } + + /** + * Builds an instance of {@link AlphaGroupUpdateArgs} configured with + * this builder's values + * + * @return new instance of {@link AlphaGroupUpdateArgs} + */ + public AlphaGroupUpdateArgs build() { + return new AlphaGroupUpdateArgs(group, returnMembers, newGroupName, newGroupExternalId, newGroupManagementType); + } + } + + @Override + public int hashCode() { + int hash = java.util.Arrays.hashCode(new Object [] { + newGroupManagementType + }); + hash = (31 * super.hashCode()) + hash; + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + // be careful with inheritance + else if (obj.getClass().equals(this.getClass())) { + AlphaGroupUpdateArgs other = (AlphaGroupUpdateArgs) obj; + return ((this.group == other.group) || (this.group.equals(other.group))) + && (this.returnMembers == other.returnMembers) + && ((this.newGroupName == other.newGroupName) || (this.newGroupName != null && this.newGroupName.equals(other.newGroupName))) + && ((this.newGroupExternalId == other.newGroupExternalId) || (this.newGroupExternalId != null && this.newGroupExternalId.equals(other.newGroupExternalId))) + && ((this.newGroupManagementType == other.newGroupManagementType) || (this.newGroupManagementType != null && this.newGroupManagementType.equals(other.newGroupManagementType))) + ; + } + else { + return false; + } + } + + @Override + public String toString() { + return Serializer.INSTANCE.serialize(this, false); + } + + /** + * Returns a String representation of this object formatted for easier + * readability. + * + *

The returned String may contain newlines.

+ * + * @return Formatted, multiline String representation of this object + */ + public String toStringMultiline() { + return Serializer.INSTANCE.serialize(this, true); + } + + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); + + @Override + public void serialize(AlphaGroupUpdateArgs value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("group"); + GroupSelector.Serializer.INSTANCE.serialize(value.group, g); + g.writeFieldName("return_members"); + StoneSerializers.boolean_().serialize(value.returnMembers, g); + if (value.newGroupName != null) { + g.writeFieldName("new_group_name"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.newGroupName, g); + } + if (value.newGroupExternalId != null) { + g.writeFieldName("new_group_external_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.newGroupExternalId, g); + } + if (value.newGroupManagementType != null) { + g.writeFieldName("new_group_management_type"); + StoneSerializers.nullable(GroupManagementType.Serializer.INSTANCE).serialize(value.newGroupManagementType, g); + } + if (!collapse) { + g.writeEndObject(); + } + } + + @Override + public AlphaGroupUpdateArgs deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + AlphaGroupUpdateArgs value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + GroupSelector f_group = null; + Boolean f_returnMembers = true; + String f_newGroupName = null; + String f_newGroupExternalId = null; + GroupManagementType f_newGroupManagementType = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("group".equals(field)) { + f_group = GroupSelector.Serializer.INSTANCE.deserialize(p); + } + else if ("return_members".equals(field)) { + f_returnMembers = StoneSerializers.boolean_().deserialize(p); + } + else if ("new_group_name".equals(field)) { + f_newGroupName = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("new_group_external_id".equals(field)) { + f_newGroupExternalId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("new_group_management_type".equals(field)) { + f_newGroupManagementType = StoneSerializers.nullable(GroupManagementType.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); + } + } + if (f_group == null) { + throw new JsonParseException(p, "Required field \"group\" missing."); + } + value = new AlphaGroupUpdateArgs(f_group, f_returnMembers, f_newGroupName, f_newGroupExternalId, f_newGroupManagementType); + } + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; + } + } +} diff --git a/src/main/java/com/dropbox/core/v2/team/AlphaGroupsGetInfoItem.java b/src/main/java/com/dropbox/core/v2/team/AlphaGroupsGetInfoItem.java new file mode 100644 index 000000000..a84edb7d3 --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/team/AlphaGroupsGetInfoItem.java @@ -0,0 +1,290 @@ +/* DO NOT EDIT */ +/* This file was generated from team_groups.stone */ + +package com.dropbox.core.v2.team; + +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + +import java.io.IOException; + +/** + * This class is a tagged union. Tagged unions instances are always associated + * to a specific tag. This means only one of the {@code isAbc()} methods will + * return {@code true}. You can use {@link #tag()} to determine the tag + * associated with this instance. + */ +public final class AlphaGroupsGetInfoItem { + // union AlphaGroupsGetInfoItem + + /** + * Discriminating tag type for {@link AlphaGroupsGetInfoItem}. + */ + public enum Tag { + /** + * An ID that was provided as a parameter to {@code alphaGroupsGetInfo}, + * and did not match a corresponding group. The ID can be a group ID, or + * an external ID, depending on how the method was called. + */ + ID_NOT_FOUND, // String + /** + * Info about a group. + */ + GROUP_INFO; // AlphaGroupFullInfo + } + + private final Tag tag; + private final String idNotFoundValue; + private final AlphaGroupFullInfo groupInfoValue; + + /** + * + * @param tag Discriminating tag for this instance. + */ + private AlphaGroupsGetInfoItem(Tag tag, String idNotFoundValue, AlphaGroupFullInfo groupInfoValue) { + this.tag = tag; + this.idNotFoundValue = idNotFoundValue; + this.groupInfoValue = groupInfoValue; + } + + /** + * Returns the tag for this instance. + * + *

This class is a tagged union. Tagged unions instances are always + * associated to a specific tag. This means only one of the {@code isXyz()} + * methods will return {@code true}. Callers are recommended to use the tag + * value in a {@code switch} statement to properly handle the different + * values for this {@code AlphaGroupsGetInfoItem}.

+ * + * @return the tag for this instance. + */ + public Tag tag() { + return tag; + } + + /** + * Returns {@code true} if this instance has the tag {@link + * Tag#ID_NOT_FOUND}, {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link + * Tag#ID_NOT_FOUND}, {@code false} otherwise. + */ + public boolean isIdNotFound() { + return this.tag == Tag.ID_NOT_FOUND; + } + + /** + * Returns an instance of {@code AlphaGroupsGetInfoItem} that has its tag + * set to {@link Tag#ID_NOT_FOUND}. + * + *

An ID that was provided as a parameter to {@code alphaGroupsGetInfo}, + * and did not match a corresponding group. The ID can be a group ID, or an + * external ID, depending on how the method was called.

+ * + * @param value value to assign to this instance. + * + * @return Instance of {@code AlphaGroupsGetInfoItem} with its tag set to + * {@link Tag#ID_NOT_FOUND}. + * + * @throws IllegalArgumentException if {@code value} is {@code null}. + */ + public static AlphaGroupsGetInfoItem idNotFound(String value) { + if (value == null) { + throw new IllegalArgumentException("Value is null"); + } + return new AlphaGroupsGetInfoItem(Tag.ID_NOT_FOUND, value, null); + } + + /** + * An ID that was provided as a parameter to {@code alphaGroupsGetInfo}, and + * did not match a corresponding group. The ID can be a group ID, or an + * external ID, depending on how the method was called. + * + *

This instance must be tagged as {@link Tag#ID_NOT_FOUND}.

+ * + * @return The {@link AlphaGroupsGetInfoItem#idNotFound} value associated + * with this instance if {@link #isIdNotFound} is {@code true}. + * + * @throws IllegalStateException If {@link #isIdNotFound} is {@code false}. + */ + public String getIdNotFoundValue() { + if (this.tag != Tag.ID_NOT_FOUND) { + throw new IllegalStateException("Invalid tag: required Tag.ID_NOT_FOUND, but was Tag." + tag.name()); + } + return idNotFoundValue; + } + + /** + * Returns {@code true} if this instance has the tag {@link Tag#GROUP_INFO}, + * {@code false} otherwise. + * + * @return {@code true} if this instance is tagged as {@link + * Tag#GROUP_INFO}, {@code false} otherwise. + */ + public boolean isGroupInfo() { + return this.tag == Tag.GROUP_INFO; + } + + /** + * Returns an instance of {@code AlphaGroupsGetInfoItem} that has its tag + * set to {@link Tag#GROUP_INFO}. + * + *

Info about a group.

+ * + * @param value value to assign to this instance. + * + * @return Instance of {@code AlphaGroupsGetInfoItem} with its tag set to + * {@link Tag#GROUP_INFO}. + * + * @throws IllegalArgumentException if {@code value} is {@code null}. + */ + public static AlphaGroupsGetInfoItem groupInfo(AlphaGroupFullInfo value) { + if (value == null) { + throw new IllegalArgumentException("Value is null"); + } + return new AlphaGroupsGetInfoItem(Tag.GROUP_INFO, null, value); + } + + /** + * Info about a group. + * + *

This instance must be tagged as {@link Tag#GROUP_INFO}.

+ * + * @return The {@link AlphaGroupsGetInfoItem#groupInfo} value associated + * with this instance if {@link #isGroupInfo} is {@code true}. + * + * @throws IllegalStateException If {@link #isGroupInfo} is {@code false}. + */ + public AlphaGroupFullInfo getGroupInfoValue() { + if (this.tag != Tag.GROUP_INFO) { + throw new IllegalStateException("Invalid tag: required Tag.GROUP_INFO, but was Tag." + tag.name()); + } + return groupInfoValue; + } + + @Override + public int hashCode() { + int hash = java.util.Arrays.hashCode(new Object [] { + tag, + idNotFoundValue, + groupInfoValue + }); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + else if (obj instanceof AlphaGroupsGetInfoItem) { + AlphaGroupsGetInfoItem other = (AlphaGroupsGetInfoItem) obj; + if (this.tag != other.tag) { + return false; + } + switch (tag) { + case ID_NOT_FOUND: + return (this.idNotFoundValue == other.idNotFoundValue) || (this.idNotFoundValue.equals(other.idNotFoundValue)); + case GROUP_INFO: + return (this.groupInfoValue == other.groupInfoValue) || (this.groupInfoValue.equals(other.groupInfoValue)); + default: + return false; + } + } + else { + return false; + } + } + + @Override + public String toString() { + return Serializer.INSTANCE.serialize(this, false); + } + + /** + * Returns a String representation of this object formatted for easier + * readability. + * + *

The returned String may contain newlines.

+ * + * @return Formatted, multiline String representation of this object + */ + public String toStringMultiline() { + return Serializer.INSTANCE.serialize(this, true); + } + + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); + + @Override + public void serialize(AlphaGroupsGetInfoItem value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case ID_NOT_FOUND: { + g.writeStartObject(); + writeTag("id_not_found", g); + g.writeFieldName("id_not_found"); + StoneSerializers.string().serialize(value.idNotFoundValue, g); + g.writeEndObject(); + break; + } + case GROUP_INFO: { + g.writeStartObject(); + writeTag("group_info", g); + AlphaGroupFullInfo.Serializer.INSTANCE.serialize(value.groupInfoValue, g, true); + g.writeEndObject(); + break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); + } + } + } + + @Override + public AlphaGroupsGetInfoItem deserialize(JsonParser p) throws IOException, JsonParseException { + AlphaGroupsGetInfoItem value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("id_not_found".equals(tag)) { + String fieldValue = null; + expectField("id_not_found", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = AlphaGroupsGetInfoItem.idNotFound(fieldValue); + } + else if ("group_info".equals(tag)) { + AlphaGroupFullInfo fieldValue = null; + fieldValue = AlphaGroupFullInfo.Serializer.INSTANCE.deserialize(p, true); + value = AlphaGroupsGetInfoItem.groupInfo(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; + } + } +} diff --git a/src/main/java/com/dropbox/core/v2/team/AlphaGroupsListResult.java b/src/main/java/com/dropbox/core/v2/team/AlphaGroupsListResult.java new file mode 100644 index 000000000..bca229e87 --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/team/AlphaGroupsListResult.java @@ -0,0 +1,199 @@ +/* DO NOT EDIT */ +/* This file was generated from team_groups.stone */ + +package com.dropbox.core.v2.team; + +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; +import com.dropbox.core.v2.teamcommon.AlphaGroupSummary; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + +import java.io.IOException; +import java.util.List; + +public class AlphaGroupsListResult { + // struct AlphaGroupsListResult + + protected final List groups; + protected final String cursor; + protected final boolean hasMore; + + /** + * + * @param groups Must not contain a {@code null} item and not be {@code + * null}. + * @param cursor Pass the cursor into {@code alphaGroupsListContinue} to + * obtain the additional groups. Must not be {@code null}. + * @param hasMore Is true if there are additional groups that have not been + * returned yet. An additional call to {@code alphaGroupsListContinue} + * can retrieve them. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public AlphaGroupsListResult(List groups, String cursor, boolean hasMore) { + if (groups == null) { + throw new IllegalArgumentException("Required value for 'groups' is null"); + } + for (AlphaGroupSummary x : groups) { + if (x == null) { + throw new IllegalArgumentException("An item in list 'groups' is null"); + } + } + this.groups = groups; + if (cursor == null) { + throw new IllegalArgumentException("Required value for 'cursor' is null"); + } + this.cursor = cursor; + this.hasMore = hasMore; + } + + /** + * + * @return value for this field, never {@code null}. + */ + public List getGroups() { + return groups; + } + + /** + * Pass the cursor into {@code alphaGroupsListContinue} to obtain the + * additional groups. + * + * @return value for this field, never {@code null}. + */ + public String getCursor() { + return cursor; + } + + /** + * Is true if there are additional groups that have not been returned yet. + * An additional call to {@code alphaGroupsListContinue} can retrieve them. + * + * @return value for this field. + */ + public boolean getHasMore() { + return hasMore; + } + + @Override + public int hashCode() { + int hash = java.util.Arrays.hashCode(new Object [] { + groups, + cursor, + hasMore + }); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + // be careful with inheritance + else if (obj.getClass().equals(this.getClass())) { + AlphaGroupsListResult other = (AlphaGroupsListResult) obj; + return ((this.groups == other.groups) || (this.groups.equals(other.groups))) + && ((this.cursor == other.cursor) || (this.cursor.equals(other.cursor))) + && (this.hasMore == other.hasMore) + ; + } + else { + return false; + } + } + + @Override + public String toString() { + return Serializer.INSTANCE.serialize(this, false); + } + + /** + * Returns a String representation of this object formatted for easier + * readability. + * + *

The returned String may contain newlines.

+ * + * @return Formatted, multiline String representation of this object + */ + public String toStringMultiline() { + return Serializer.INSTANCE.serialize(this, true); + } + + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); + + @Override + public void serialize(AlphaGroupsListResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("groups"); + StoneSerializers.list(AlphaGroupSummary.Serializer.INSTANCE).serialize(value.groups, g); + g.writeFieldName("cursor"); + StoneSerializers.string().serialize(value.cursor, g); + g.writeFieldName("has_more"); + StoneSerializers.boolean_().serialize(value.hasMore, g); + if (!collapse) { + g.writeEndObject(); + } + } + + @Override + public AlphaGroupsListResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + AlphaGroupsListResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_groups = null; + String f_cursor = null; + Boolean f_hasMore = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("groups".equals(field)) { + f_groups = StoneSerializers.list(AlphaGroupSummary.Serializer.INSTANCE).deserialize(p); + } + else if ("cursor".equals(field)) { + f_cursor = StoneSerializers.string().deserialize(p); + } + else if ("has_more".equals(field)) { + f_hasMore = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } + } + if (f_groups == null) { + throw new JsonParseException(p, "Required field \"groups\" missing."); + } + if (f_cursor == null) { + throw new JsonParseException(p, "Required field \"cursor\" missing."); + } + if (f_hasMore == null) { + throw new JsonParseException(p, "Required field \"has_more\" missing."); + } + value = new AlphaGroupsListResult(f_groups, f_cursor, f_hasMore); + } + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; + } + } +} diff --git a/src/main/java/com/dropbox/core/v2/team/ApiApp.java b/src/main/java/com/dropbox/core/v2/team/ApiApp.java index f6363d6ee..e44ff3261 100644 --- a/src/main/java/com/dropbox/core/v2/team/ApiApp.java +++ b/src/main/java/com/dropbox/core/v2/team/ApiApp.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.Date; @@ -29,15 +18,9 @@ /** * Information on linked third party applications */ -@JsonSerialize(using=ApiApp.Serializer.class) -@JsonDeserialize(using=ApiApp.Deserializer.class) public class ApiApp { // struct ApiApp - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String appId; protected final String appName; protected final String publisher; @@ -275,7 +258,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -287,120 +270,101 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ApiApp.class); - } - - public Serializer(boolean unwrapping) { - super(ApiApp.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(ApiApp value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("app_id", value.appId); - g.writeObjectField("app_name", value.appName); - g.writeObjectField("is_app_folder", value.isAppFolder); + public void serialize(ApiApp value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("app_id"); + StoneSerializers.string().serialize(value.appId, g); + g.writeFieldName("app_name"); + StoneSerializers.string().serialize(value.appName, g); + g.writeFieldName("is_app_folder"); + StoneSerializers.boolean_().serialize(value.isAppFolder, g); if (value.publisher != null) { - g.writeObjectField("publisher", value.publisher); + g.writeFieldName("publisher"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.publisher, g); } if (value.publisherUrl != null) { - g.writeObjectField("publisher_url", value.publisherUrl); + g.writeFieldName("publisher_url"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.publisherUrl, g); } if (value.linked != null) { - g.writeObjectField("linked", value.linked); + g.writeFieldName("linked"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.linked, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ApiApp.class); - } - - public Deserializer(boolean unwrapping) { - super(ApiApp.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public ApiApp deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String appId = null; - String appName = null; - Boolean isAppFolder = null; - String publisher = null; - String publisherUrl = null; - Date linked = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("app_id".equals(_field)) { - appId = getStringValue(_p); - _p.nextToken(); - } - else if ("app_name".equals(_field)) { - appName = getStringValue(_p); - _p.nextToken(); - } - else if ("is_app_folder".equals(_field)) { - isAppFolder = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("publisher".equals(_field)) { - publisher = getStringValue(_p); - _p.nextToken(); + public ApiApp deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ApiApp value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_appId = null; + String f_appName = null; + Boolean f_isAppFolder = null; + String f_publisher = null; + String f_publisherUrl = null; + Date f_linked = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("app_id".equals(field)) { + f_appId = StoneSerializers.string().deserialize(p); + } + else if ("app_name".equals(field)) { + f_appName = StoneSerializers.string().deserialize(p); + } + else if ("is_app_folder".equals(field)) { + f_isAppFolder = StoneSerializers.boolean_().deserialize(p); + } + else if ("publisher".equals(field)) { + f_publisher = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("publisher_url".equals(field)) { + f_publisherUrl = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("linked".equals(field)) { + f_linked = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else { + skipValue(p); + } } - else if ("publisher_url".equals(_field)) { - publisherUrl = getStringValue(_p); - _p.nextToken(); + if (f_appId == null) { + throw new JsonParseException(p, "Required field \"app_id\" missing."); } - else if ("linked".equals(_field)) { - linked = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); + if (f_appName == null) { + throw new JsonParseException(p, "Required field \"app_name\" missing."); } - else { - skipValue(_p); + if (f_isAppFolder == null) { + throw new JsonParseException(p, "Required field \"is_app_folder\" missing."); } + value = new ApiApp(f_appId, f_appName, f_isAppFolder, f_publisher, f_publisherUrl, f_linked); } - - if (appId == null) { - throw new JsonParseException(_p, "Required field \"app_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (appName == null) { - throw new JsonParseException(_p, "Required field \"app_name\" is missing."); - } - if (isAppFolder == null) { - throw new JsonParseException(_p, "Required field \"is_app_folder\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new ApiApp(appId, appName, isAppFolder, publisher, publisherUrl, linked); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/BaseDfbReport.java b/src/main/java/com/dropbox/core/v2/team/BaseDfbReport.java index 67b641520..f618d167a 100644 --- a/src/main/java/com/dropbox/core/v2/team/BaseDfbReport.java +++ b/src/main/java/com/dropbox/core/v2/team/BaseDfbReport.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from team_reports.babel */ +/* This file was generated from team_reports.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Base report structure. */ -@JsonSerialize(using=BaseDfbReport.Serializer.class) -@JsonDeserialize(using=BaseDfbReport.Deserializer.class) public class BaseDfbReport { // struct BaseDfbReport - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String startDate; /** @@ -89,7 +72,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -101,78 +84,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(BaseDfbReport.class); - } - - public Serializer(boolean unwrapping) { - super(BaseDfbReport.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(BaseDfbReport value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("start_date", value.startDate); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(BaseDfbReport.class); - } - - public Deserializer(boolean unwrapping) { - super(BaseDfbReport.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(BaseDfbReport value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("start_date"); + StoneSerializers.string().serialize(value.startDate, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public BaseDfbReport deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String startDate = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("start_date".equals(_field)) { - startDate = getStringValue(_p); - _p.nextToken(); + public BaseDfbReport deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + BaseDfbReport value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_startDate = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("start_date".equals(field)) { + f_startDate = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_startDate == null) { + throw new JsonParseException(p, "Required field \"start_date\" missing."); } + value = new BaseDfbReport(f_startDate); } - - if (startDate == null) { - throw new JsonParseException(_p, "Required field \"start_date\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new BaseDfbReport(startDate); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/DateRange.java b/src/main/java/com/dropbox/core/v2/team/DateRange.java index 363d575af..6cb80806a 100644 --- a/src/main/java/com/dropbox/core/v2/team/DateRange.java +++ b/src/main/java/com/dropbox/core/v2/team/DateRange.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from team_reports.babel */ +/* This file was generated from team_reports.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.Date; @@ -29,15 +18,9 @@ /** * Input arguments that can be provided for most reports. */ -@JsonSerialize(using=DateRange.Serializer.class) -@JsonDeserialize(using=DateRange.Deserializer.class) public class DateRange { // struct DateRange - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final Date startDate; protected final Date endDate; @@ -167,7 +150,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -179,85 +162,66 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(DateRange.class); - } - - public Serializer(boolean unwrapping) { - super(DateRange.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(DateRange value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(DateRange value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } if (value.startDate != null) { - g.writeObjectField("start_date", value.startDate); + g.writeFieldName("start_date"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.startDate, g); } if (value.endDate != null) { - g.writeObjectField("end_date", value.endDate); + g.writeFieldName("end_date"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.endDate, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(DateRange.class); - } - - public Deserializer(boolean unwrapping) { - super(DateRange.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public DateRange deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - Date startDate = null; - Date endDate = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("start_date".equals(_field)) { - startDate = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); - } - else if ("end_date".equals(_field)) { - endDate = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); - } - else { - skipValue(_p); + public DateRange deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + DateRange value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Date f_startDate = null; + Date f_endDate = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("start_date".equals(field)) { + f_startDate = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else if ("end_date".equals(field)) { + f_endDate = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else { + skipValue(p); + } } + value = new DateRange(f_startDate, f_endDate); } - - - return new DateRange(startDate, endDate); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/DateRangeError.java b/src/main/java/com/dropbox/core/v2/team/DateRangeError.java index 06dd66209..8f8c5f04e 100644 --- a/src/main/java/com/dropbox/core/v2/team/DateRangeError.java +++ b/src/main/java/com/dropbox/core/v2/team/DateRangeError.java @@ -1,36 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_reports.babel */ +/* This file was generated from team_reports.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Errors that can originate from problems in input arguments to reports. */ -@JsonSerialize(using=DateRangeError.Serializer.class) -@JsonDeserialize(using=DateRangeError.Deserializer.class) public enum DateRangeError { // union DateRangeError /** @@ -38,43 +24,47 @@ public enum DateRangeError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(DateRangeError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(DateRangeError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(DateRangeError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case OTHER: + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(DateRangeError.class, getTagMapping(), DateRangeError.OTHER); - } @Override - public DateRangeError deserialize(DateRangeError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("other", DateRangeError.OTHER); - return Collections.unmodifiableMap(values); + public DateRangeError deserialize(JsonParser p) throws IOException, JsonParseException { + DateRangeError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else { + value = DateRangeError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/DateRangeErrorException.java b/src/main/java/com/dropbox/core/v2/team/DateRangeErrorException.java index 9d9725333..3b35c9185 100644 --- a/src/main/java/com/dropbox/core/v2/team/DateRangeErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/DateRangeErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_reports.babel */ +/* This file was generated from team_reports.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/DbxTeamTeamRequests.java b/src/main/java/com/dropbox/core/v2/team/DbxTeamTeamRequests.java index 3214477dd..dc7c550e9 100644 --- a/src/main/java/com/dropbox/core/v2/team/DbxTeamTeamRequests.java +++ b/src/main/java/com/dropbox/core/v2/team/DbxTeamTeamRequests.java @@ -1,26 +1,17 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel, team_property_templates.babel, team_members.babel, team_linked_apps.babel, team_reports.babel, team_groups.babel, team_common.babel, team.babel */ +/* This file was generated from team_devices.stone, team_property_templates.stone, team_members.stone, team_groups.stone, team_linked_apps.stone, team_reports.stone, team.stone */ package com.dropbox.core.v2.team; import com.dropbox.core.DbxApiException; import com.dropbox.core.DbxException; -import com.dropbox.core.DbxRequestUtil; +import com.dropbox.core.DbxWrappedException; import com.dropbox.core.http.HttpRequestor; -import com.dropbox.core.json.JsonUtil; import com.dropbox.core.v2.DbxRawClientV2; import com.dropbox.core.v2.async.LaunchEmptyResult; import com.dropbox.core.v2.async.PollArg; import com.dropbox.core.v2.async.PollEmptyResult; import com.dropbox.core.v2.async.PollErrorException; -import com.dropbox.core.v2.properties.GetPropertyTemplateArg; -import com.dropbox.core.v2.properties.GetPropertyTemplateResult; -import com.dropbox.core.v2.properties.ListPropertyTemplateIds; -import com.dropbox.core.v2.properties.ModifyPropertyTemplateErrorException; -import com.dropbox.core.v2.properties.PropertyTemplateErrorException; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JavaType; import java.util.HashMap; import java.util.List; @@ -52,11 +43,12 @@ ListMemberDevicesResult devicesListMemberDevices(ListMemberDevicesArg listMember "2/team/devices/list_member_devices", listMemberDevicesArg, false, - JsonUtil.createType(ListMemberDevicesResult.class), - JsonUtil.createType(ListMemberDevicesError.class)); + ListMemberDevicesArg.Serializer.INSTANCE, + ListMemberDevicesResult.Serializer.INSTANCE, + ListMemberDevicesError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new ListMemberDevicesErrorException(ew.getRequestId(), ew.getUserMessage(), (ListMemberDevicesError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new ListMemberDevicesErrorException(ex.getRequestId(), ex.getUserMessage(), (ListMemberDevicesError) ex.getErrorValue()); } } @@ -88,8 +80,8 @@ public ListMemberDevicesResult devicesListMemberDevices(String teamMemberId) thr * preconditions. */ public DevicesListMemberDevicesBuilder devicesListMemberDevicesBuilder(String teamMemberId) { - ListMemberDevicesArg.Builder argBuilder = ListMemberDevicesArg.newBuilder(teamMemberId); - return new DevicesListMemberDevicesBuilder(this, argBuilder); + ListMemberDevicesArg.Builder argBuilder_ = ListMemberDevicesArg.newBuilder(teamMemberId); + return new DevicesListMemberDevicesBuilder(this, argBuilder_); } // @@ -106,11 +98,12 @@ ListMembersDevicesResult devicesListMembersDevices(ListMembersDevicesArg listMem "2/team/devices/list_members_devices", listMembersDevicesArg, false, - JsonUtil.createType(ListMembersDevicesResult.class), - JsonUtil.createType(ListMembersDevicesError.class)); + ListMembersDevicesArg.Serializer.INSTANCE, + ListMembersDevicesResult.Serializer.INSTANCE, + ListMembersDevicesError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new ListMembersDevicesErrorException(ew.getRequestId(), ew.getUserMessage(), (ListMembersDevicesError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new ListMembersDevicesErrorException(ex.getRequestId(), ex.getUserMessage(), (ListMembersDevicesError) ex.getErrorValue()); } } @@ -132,8 +125,8 @@ public ListMembersDevicesResult devicesListMembersDevices() throws ListMembersDe * the request. */ public DevicesListMembersDevicesBuilder devicesListMembersDevicesBuilder() { - ListMembersDevicesArg.Builder argBuilder = ListMembersDevicesArg.newBuilder(); - return new DevicesListMembersDevicesBuilder(this, argBuilder); + ListMembersDevicesArg.Builder argBuilder_ = ListMembersDevicesArg.newBuilder(); + return new DevicesListMembersDevicesBuilder(this, argBuilder_); } // @@ -154,11 +147,12 @@ ListTeamDevicesResult devicesListTeamDevices(ListTeamDevicesArg listTeamDevicesA "2/team/devices/list_team_devices", listTeamDevicesArg, false, - JsonUtil.createType(ListTeamDevicesResult.class), - JsonUtil.createType(ListTeamDevicesError.class)); + ListTeamDevicesArg.Serializer.INSTANCE, + ListTeamDevicesResult.Serializer.INSTANCE, + ListTeamDevicesError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new ListTeamDevicesErrorException(ew.getRequestId(), ew.getUserMessage(), (ListTeamDevicesError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new ListTeamDevicesErrorException(ex.getRequestId(), ex.getUserMessage(), (ListTeamDevicesError) ex.getErrorValue()); } } @@ -188,8 +182,8 @@ public ListTeamDevicesResult devicesListTeamDevices() throws ListTeamDevicesErro */ @Deprecated public DevicesListTeamDevicesBuilder devicesListTeamDevicesBuilder() { - ListTeamDevicesArg.Builder argBuilder = ListTeamDevicesArg.newBuilder(); - return new DevicesListTeamDevicesBuilder(this, argBuilder); + ListTeamDevicesArg.Builder argBuilder_ = ListTeamDevicesArg.newBuilder(); + return new DevicesListTeamDevicesBuilder(this, argBuilder_); } // @@ -206,11 +200,12 @@ public void devicesRevokeDeviceSession(RevokeDeviceSessionArg revokeDeviceSessio "2/team/devices/revoke_device_session", revokeDeviceSessionArg, false, - JsonUtil.createType(Void.class), - JsonUtil.createType(RevokeDeviceSessionError.class)); + RevokeDeviceSessionArg.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.void_(), + RevokeDeviceSessionError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new RevokeDeviceSessionErrorException(ew.getRequestId(), ew.getUserMessage(), (RevokeDeviceSessionError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new RevokeDeviceSessionErrorException(ex.getRequestId(), ex.getUserMessage(), (RevokeDeviceSessionError) ex.getErrorValue()); } } @@ -228,11 +223,12 @@ RevokeDeviceSessionBatchResult devicesRevokeDeviceSessionBatch(RevokeDeviceSessi "2/team/devices/revoke_device_session_batch", revokeDeviceSessionBatchArg, false, - JsonUtil.createType(RevokeDeviceSessionBatchResult.class), - JsonUtil.createType(RevokeDeviceSessionBatchError.class)); + RevokeDeviceSessionBatchArg.Serializer.INSTANCE, + RevokeDeviceSessionBatchResult.Serializer.INSTANCE, + RevokeDeviceSessionBatchError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new RevokeDeviceSessionBatchErrorException(ew.getRequestId(), ew.getUserMessage(), (RevokeDeviceSessionBatchError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new RevokeDeviceSessionBatchErrorException(ex.getRequestId(), ex.getUserMessage(), (RevokeDeviceSessionBatchError) ex.getErrorValue()); } } @@ -263,11 +259,12 @@ public TeamGetInfoResult getInfo() throws DbxException { "2/team/get_info", null, false, - JsonUtil.createType(TeamGetInfoResult.class), - JsonUtil.createType(Void.class)); + com.dropbox.core.stone.StoneSerializers.void_(), + TeamGetInfoResult.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.void_()); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new DbxApiException(ew.getRequestId(), ew.getUserMessage(), "Unexpected error response for \"get_info\": ew.errValue"); + catch (DbxWrappedException ex) { + throw new DbxApiException(ex.getRequestId(), ex.getUserMessage(), "Unexpected error response for \"get_info\":" + ex.getErrorValue()); } } @@ -288,11 +285,12 @@ GroupFullInfo groupsCreate(GroupCreateArg groupCreateArg) throws GroupCreateErro "2/team/groups/create", groupCreateArg, false, - JsonUtil.createType(GroupFullInfo.class), - JsonUtil.createType(GroupCreateError.class)); + GroupCreateArg.Serializer.INSTANCE, + GroupFullInfo.Serializer.INSTANCE, + GroupCreateError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new GroupCreateErrorException(ew.getRequestId(), ew.getUserMessage(), (GroupCreateError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new GroupCreateErrorException(ex.getRequestId(), ex.getUserMessage(), (GroupCreateError) ex.getErrorValue()); } } @@ -317,8 +315,8 @@ public GroupFullInfo groupsCreate(String groupName) throws GroupCreateErrorExcep * member management * * @param groupName Group name. Must not be {@code null}. - * @param groupExternalId Optional argument. The creator of a team can - * associate an arbitrary external ID to the group. + * @param groupExternalId The creator of a team can associate an arbitrary + * external ID to the group. * * @return Full description of a group. * @@ -353,11 +351,12 @@ public LaunchEmptyResult groupsDelete(GroupSelector groupSelector) throws GroupD "2/team/groups/delete", groupSelector, false, - JsonUtil.createType(LaunchEmptyResult.class), - JsonUtil.createType(GroupDeleteError.class)); + GroupSelector.Serializer.INSTANCE, + LaunchEmptyResult.Serializer.INSTANCE, + GroupDeleteError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new GroupDeleteErrorException(ew.getRequestId(), ew.getUserMessage(), (GroupDeleteError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new GroupDeleteErrorException(ex.getRequestId(), ex.getUserMessage(), (GroupDeleteError) ex.getErrorValue()); } } @@ -378,11 +377,12 @@ public List groupsGetInfo(GroupsSelector groupsSelector) thro "2/team/groups/get_info", groupsSelector, false, - JsonUtil.createType(new TypeReference>() {}), - JsonUtil.createType(GroupsGetInfoError.class)); + GroupsSelector.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.list(GroupsGetInfoItem.Serializer.INSTANCE), + GroupsGetInfoError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new GroupsGetInfoErrorException(ew.getRequestId(), ew.getUserMessage(), (GroupsGetInfoError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new GroupsGetInfoErrorException(ex.getRequestId(), ex.getUserMessage(), (GroupsGetInfoError) ex.getErrorValue()); } } @@ -411,11 +411,12 @@ PollEmptyResult groupsJobStatusGet(PollArg pollArg) throws GroupsPollErrorExcept "2/team/groups/job_status/get", pollArg, false, - JsonUtil.createType(PollEmptyResult.class), - JsonUtil.createType(GroupsPollError.class)); + PollArg.Serializer.INSTANCE, + PollEmptyResult.Serializer.INSTANCE, + GroupsPollError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new GroupsPollErrorException(ew.getRequestId(), ew.getUserMessage(), (GroupsPollError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new GroupsPollErrorException(ex.getRequestId(), ex.getUserMessage(), (GroupsPollError) ex.getErrorValue()); } } @@ -457,11 +458,12 @@ GroupsListResult groupsList(GroupsListArg groupsListArg) throws DbxException { "2/team/groups/list", groupsListArg, false, - JsonUtil.createType(GroupsListResult.class), - JsonUtil.createType(Void.class)); + GroupsListArg.Serializer.INSTANCE, + GroupsListResult.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.void_()); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new DbxApiException(ew.getRequestId(), ew.getUserMessage(), "Unexpected error response for \"groups/list\": ew.errValue"); + catch (DbxWrappedException ex) { + throw new DbxApiException(ex.getRequestId(), ex.getUserMessage(), "Unexpected error response for \"groups/list\":" + ex.getErrorValue()); } } @@ -512,11 +514,12 @@ GroupsListResult groupsListContinue(GroupsListContinueArg groupsListContinueArg) "2/team/groups/list/continue", groupsListContinueArg, false, - JsonUtil.createType(GroupsListResult.class), - JsonUtil.createType(GroupsListContinueError.class)); + GroupsListContinueArg.Serializer.INSTANCE, + GroupsListResult.Serializer.INSTANCE, + GroupsListContinueError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new GroupsListContinueErrorException(ew.getRequestId(), ew.getUserMessage(), (GroupsListContinueError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new GroupsListContinueErrorException(ex.getRequestId(), ex.getUserMessage(), (GroupsListContinueError) ex.getErrorValue()); } } @@ -557,11 +560,12 @@ GroupMembersChangeResult groupsMembersAdd(GroupMembersAddArg groupMembersAddArg) "2/team/groups/members/add", groupMembersAddArg, false, - JsonUtil.createType(GroupMembersChangeResult.class), - JsonUtil.createType(GroupMembersAddError.class)); + GroupMembersAddArg.Serializer.INSTANCE, + GroupMembersChangeResult.Serializer.INSTANCE, + GroupMembersAddError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new GroupMembersAddErrorException(ew.getRequestId(), ew.getUserMessage(), (GroupMembersAddError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new GroupMembersAddErrorException(ex.getRequestId(), ex.getUserMessage(), (GroupMembersAddError) ex.getErrorValue()); } } @@ -617,6 +621,109 @@ public GroupMembersChangeResult groupsMembersAdd(GroupSelector group, List The {@code limit} request parameter will default to {@code 1000L} + * (see {@link #groupsMembersList(GroupSelector,long)}).

+ * + * @param group The group whose members are to be listed. Must not be + * {@code null}. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public GroupsMembersListResult groupsMembersList(GroupSelector group) throws GroupSelectorErrorException, DbxException { + GroupsMembersListArg arg = new GroupsMembersListArg(group); + return groupsMembersList(arg); + } + + /** + * Lists members of a group. Permission : Team Information + * + * @param group The group whose members are to be listed. Must not be + * {@code null}. + * @param limit Number of results to return per call. Must be greater than + * or equal to 1 and be less than or equal to 1000. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public GroupsMembersListResult groupsMembersList(GroupSelector group, long limit) throws GroupSelectorErrorException, DbxException { + if (limit < 1L) { + throw new IllegalArgumentException("Number 'limit' is smaller than 1L"); + } + if (limit > 1000L) { + throw new IllegalArgumentException("Number 'limit' is larger than 1000L"); + } + GroupsMembersListArg arg = new GroupsMembersListArg(group, limit); + return groupsMembersList(arg); + } + + // + // route team/groups/members/list/continue + // + + /** + * Once a cursor has been retrieved from {@link + * DbxTeamTeamRequests#groupsMembersList(GroupSelector)}, use this to + * paginate through all members of the group. Permission : Team information + * + */ + GroupsMembersListResult groupsMembersListContinue(GroupsMembersListContinueArg groupsMembersListContinueArg) throws GroupsMembersListContinueErrorException, DbxException { + try { + return client.rpcStyle(client.getHost().getApi(), + "2/team/groups/members/list/continue", + groupsMembersListContinueArg, + false, + GroupsMembersListContinueArg.Serializer.INSTANCE, + GroupsMembersListResult.Serializer.INSTANCE, + GroupsMembersListContinueError.Serializer.INSTANCE); + } + catch (DbxWrappedException ex) { + throw new GroupsMembersListContinueErrorException(ex.getRequestId(), ex.getUserMessage(), (GroupsMembersListContinueError) ex.getErrorValue()); + } + } + + /** + * Once a cursor has been retrieved from {@link + * DbxTeamTeamRequests#groupsMembersList(GroupSelector)}, use this to + * paginate through all members of the group. Permission : Team information + * + * @param cursor Indicates from what point to get the next set of groups. + * Must not be {@code null}. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public GroupsMembersListResult groupsMembersListContinue(String cursor) throws GroupsMembersListContinueErrorException, DbxException { + GroupsMembersListContinueArg arg = new GroupsMembersListContinueArg(cursor); + return groupsMembersListContinue(arg); + } + // // route team/groups/members/remove // @@ -639,11 +746,12 @@ GroupMembersChangeResult groupsMembersRemove(GroupMembersRemoveArg groupMembersR "2/team/groups/members/remove", groupMembersRemoveArg, false, - JsonUtil.createType(GroupMembersChangeResult.class), - JsonUtil.createType(GroupMembersRemoveError.class)); + GroupMembersRemoveArg.Serializer.INSTANCE, + GroupMembersChangeResult.Serializer.INSTANCE, + GroupMembersRemoveError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new GroupMembersRemoveErrorException(ew.getRequestId(), ew.getUserMessage(), (GroupMembersRemoveError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new GroupMembersRemoveErrorException(ex.getRequestId(), ex.getUserMessage(), (GroupMembersRemoveError) ex.getErrorValue()); } } @@ -717,11 +825,12 @@ List groupsMembersSetAccessType(GroupMembersSetAccessTypeArg "2/team/groups/members/set_access_type", groupMembersSetAccessTypeArg, false, - JsonUtil.createType(new TypeReference>() {}), - JsonUtil.createType(GroupMemberSetAccessTypeError.class)); + GroupMembersSetAccessTypeArg.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.list(GroupsGetInfoItem.Serializer.INSTANCE), + GroupMemberSetAccessTypeError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new GroupMemberSetAccessTypeErrorException(ew.getRequestId(), ew.getUserMessage(), (GroupMemberSetAccessTypeError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new GroupMemberSetAccessTypeErrorException(ex.getRequestId(), ex.getUserMessage(), (GroupMemberSetAccessTypeError) ex.getErrorValue()); } } @@ -786,11 +895,12 @@ GroupFullInfo groupsUpdate(GroupUpdateArgs groupUpdateArgs) throws GroupUpdateEr "2/team/groups/update", groupUpdateArgs, false, - JsonUtil.createType(GroupFullInfo.class), - JsonUtil.createType(GroupUpdateError.class)); + GroupUpdateArgs.Serializer.INSTANCE, + GroupFullInfo.Serializer.INSTANCE, + GroupUpdateError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new GroupUpdateErrorException(ew.getRequestId(), ew.getUserMessage(), (GroupUpdateError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new GroupUpdateErrorException(ex.getRequestId(), ex.getUserMessage(), (GroupUpdateError) ex.getErrorValue()); } } @@ -826,8 +936,8 @@ public GroupFullInfo groupsUpdate(GroupSelector group) throws GroupUpdateErrorEx * preconditions. */ public GroupsUpdateBuilder groupsUpdateBuilder(GroupSelector group) { - GroupUpdateArgs.Builder argBuilder = GroupUpdateArgs.newBuilder(group); - return new GroupsUpdateBuilder(this, argBuilder); + GroupUpdateArgs.Builder argBuilder_ = GroupUpdateArgs.newBuilder(group); + return new GroupsUpdateBuilder(this, argBuilder_); } // @@ -845,11 +955,12 @@ ListMemberAppsResult linkedAppsListMemberLinkedApps(ListMemberAppsArg listMember "2/team/linked_apps/list_member_linked_apps", listMemberAppsArg, false, - JsonUtil.createType(ListMemberAppsResult.class), - JsonUtil.createType(ListMemberAppsError.class)); + ListMemberAppsArg.Serializer.INSTANCE, + ListMemberAppsResult.Serializer.INSTANCE, + ListMemberAppsError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new ListMemberAppsErrorException(ew.getRequestId(), ew.getUserMessage(), (ListMemberAppsError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new ListMemberAppsErrorException(ex.getRequestId(), ex.getUserMessage(), (ListMemberAppsError) ex.getErrorValue()); } } @@ -887,11 +998,12 @@ ListMembersAppsResult linkedAppsListMembersLinkedApps(ListMembersAppsArg listMem "2/team/linked_apps/list_members_linked_apps", listMembersAppsArg, false, - JsonUtil.createType(ListMembersAppsResult.class), - JsonUtil.createType(ListMembersAppsError.class)); + ListMembersAppsArg.Serializer.INSTANCE, + ListMembersAppsResult.Serializer.INSTANCE, + ListMembersAppsError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new ListMembersAppsErrorException(ew.getRequestId(), ew.getUserMessage(), (ListMembersAppsError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new ListMembersAppsErrorException(ex.getRequestId(), ex.getUserMessage(), (ListMembersAppsError) ex.getErrorValue()); } } @@ -949,11 +1061,12 @@ ListTeamAppsResult linkedAppsListTeamLinkedApps(ListTeamAppsArg listTeamAppsArg) "2/team/linked_apps/list_team_linked_apps", listTeamAppsArg, false, - JsonUtil.createType(ListTeamAppsResult.class), - JsonUtil.createType(ListTeamAppsError.class)); + ListTeamAppsArg.Serializer.INSTANCE, + ListTeamAppsResult.Serializer.INSTANCE, + ListTeamAppsError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new ListTeamAppsErrorException(ew.getRequestId(), ew.getUserMessage(), (ListTeamAppsError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new ListTeamAppsErrorException(ex.getRequestId(), ex.getUserMessage(), (ListTeamAppsError) ex.getErrorValue()); } } @@ -1009,11 +1122,12 @@ void linkedAppsRevokeLinkedApp(RevokeLinkedApiAppArg revokeLinkedApiAppArg) thro "2/team/linked_apps/revoke_linked_app", revokeLinkedApiAppArg, false, - JsonUtil.createType(Void.class), - JsonUtil.createType(RevokeLinkedAppError.class)); + RevokeLinkedApiAppArg.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.void_(), + RevokeLinkedAppError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new RevokeLinkedAppErrorException(ew.getRequestId(), ew.getUserMessage(), (RevokeLinkedAppError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new RevokeLinkedAppErrorException(ex.getRequestId(), ex.getUserMessage(), (RevokeLinkedAppError) ex.getErrorValue()); } } @@ -1067,11 +1181,12 @@ RevokeLinkedAppBatchResult linkedAppsRevokeLinkedAppBatch(RevokeLinkedApiAppBatc "2/team/linked_apps/revoke_linked_app_batch", revokeLinkedApiAppBatchArg, false, - JsonUtil.createType(RevokeLinkedAppBatchResult.class), - JsonUtil.createType(RevokeLinkedAppBatchError.class)); + RevokeLinkedApiAppBatchArg.Serializer.INSTANCE, + RevokeLinkedAppBatchResult.Serializer.INSTANCE, + RevokeLinkedAppBatchError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new RevokeLinkedAppBatchErrorException(ew.getRequestId(), ew.getUserMessage(), (RevokeLinkedAppBatchError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new RevokeLinkedAppBatchErrorException(ex.getRequestId(), ex.getUserMessage(), (RevokeLinkedAppBatchError) ex.getErrorValue()); } } @@ -1113,11 +1228,12 @@ MembersAddLaunch membersAdd(MembersAddArg membersAddArg) throws DbxException { "2/team/members/add", membersAddArg, false, - JsonUtil.createType(MembersAddLaunch.class), - JsonUtil.createType(Void.class)); + MembersAddArg.Serializer.INSTANCE, + MembersAddLaunch.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.void_()); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new DbxApiException(ew.getRequestId(), ew.getUserMessage(), "Unexpected error response for \"members/add\": ew.errValue"); + catch (DbxWrappedException ex) { + throw new DbxApiException(ex.getRequestId(), ex.getUserMessage(), "Unexpected error response for \"members/add\":" + ex.getErrorValue()); } } @@ -1191,11 +1307,12 @@ MembersAddJobStatus membersAddJobStatusGet(PollArg pollArg) throws PollErrorExce "2/team/members/add/job_status/get", pollArg, false, - JsonUtil.createType(MembersAddJobStatus.class), - JsonUtil.createType(com.dropbox.core.v2.async.PollError.class)); + PollArg.Serializer.INSTANCE, + MembersAddJobStatus.Serializer.INSTANCE, + com.dropbox.core.v2.async.PollError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new PollErrorException(ew.getRequestId(), ew.getUserMessage(), (com.dropbox.core.v2.async.PollError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new PollErrorException(ex.getRequestId(), ex.getUserMessage(), (com.dropbox.core.v2.async.PollError) ex.getErrorValue()); } } @@ -1233,11 +1350,12 @@ List membersGetInfo(MembersGetInfoArgs membersGetInfoArgs) t "2/team/members/get_info", membersGetInfoArgs, false, - JsonUtil.createType(new TypeReference>() {}), - JsonUtil.createType(MembersGetInfoError.class)); + MembersGetInfoArgs.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.list(MembersGetInfoItem.Serializer.INSTANCE), + MembersGetInfoError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new MembersGetInfoErrorException(ew.getRequestId(), ew.getUserMessage(), (MembersGetInfoError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new MembersGetInfoErrorException(ex.getRequestId(), ex.getUserMessage(), (MembersGetInfoError) ex.getErrorValue()); } } @@ -1272,11 +1390,12 @@ MembersListResult membersList(MembersListArg membersListArg) throws MembersListE "2/team/members/list", membersListArg, false, - JsonUtil.createType(MembersListResult.class), - JsonUtil.createType(MembersListError.class)); + MembersListArg.Serializer.INSTANCE, + MembersListResult.Serializer.INSTANCE, + MembersListError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new MembersListErrorException(ew.getRequestId(), ew.getUserMessage(), (MembersListError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new MembersListErrorException(ex.getRequestId(), ex.getUserMessage(), (MembersListError) ex.getErrorValue()); } } @@ -1327,11 +1446,12 @@ MembersListResult membersListContinue(MembersListContinueArg membersListContinue "2/team/members/list/continue", membersListContinueArg, false, - JsonUtil.createType(MembersListResult.class), - JsonUtil.createType(MembersListContinueError.class)); + MembersListContinueArg.Serializer.INSTANCE, + MembersListResult.Serializer.INSTANCE, + MembersListContinueError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new MembersListContinueErrorException(ew.getRequestId(), ew.getUserMessage(), (MembersListContinueError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new MembersListContinueErrorException(ex.getRequestId(), ex.getUserMessage(), (MembersListContinueError) ex.getErrorValue()); } } @@ -1378,11 +1498,12 @@ LaunchEmptyResult membersRemove(MembersRemoveArg membersRemoveArg) throws Member "2/team/members/remove", membersRemoveArg, false, - JsonUtil.createType(LaunchEmptyResult.class), - JsonUtil.createType(MembersRemoveError.class)); + MembersRemoveArg.Serializer.INSTANCE, + LaunchEmptyResult.Serializer.INSTANCE, + MembersRemoveError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new MembersRemoveErrorException(ew.getRequestId(), ew.getUserMessage(), (MembersRemoveError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new MembersRemoveErrorException(ex.getRequestId(), ex.getUserMessage(), (MembersRemoveError) ex.getErrorValue()); } } @@ -1438,8 +1559,8 @@ public LaunchEmptyResult membersRemove(UserSelectorArg user) throws MembersRemov * preconditions. */ public MembersRemoveBuilder membersRemoveBuilder(UserSelectorArg user) { - MembersRemoveArg.Builder argBuilder = MembersRemoveArg.newBuilder(user); - return new MembersRemoveBuilder(this, argBuilder); + MembersRemoveArg.Builder argBuilder_ = MembersRemoveArg.newBuilder(user); + return new MembersRemoveBuilder(this, argBuilder_); } // @@ -1465,11 +1586,12 @@ PollEmptyResult membersRemoveJobStatusGet(PollArg pollArg) throws PollErrorExcep "2/team/members/remove/job_status/get", pollArg, false, - JsonUtil.createType(PollEmptyResult.class), - JsonUtil.createType(com.dropbox.core.v2.async.PollError.class)); + PollArg.Serializer.INSTANCE, + PollEmptyResult.Serializer.INSTANCE, + com.dropbox.core.v2.async.PollError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new PollErrorException(ew.getRequestId(), ew.getUserMessage(), (com.dropbox.core.v2.async.PollError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new PollErrorException(ex.getRequestId(), ex.getUserMessage(), (com.dropbox.core.v2.async.PollError) ex.getErrorValue()); } } @@ -1514,11 +1636,12 @@ public void membersSendWelcomeEmail(UserSelectorArg userSelectorArg) throws Memb "2/team/members/send_welcome_email", userSelectorArg, false, - JsonUtil.createType(Void.class), - JsonUtil.createType(MembersSendWelcomeError.class)); + UserSelectorArg.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.void_(), + MembersSendWelcomeError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new MembersSendWelcomeErrorException(ew.getRequestId(), ew.getUserMessage(), (MembersSendWelcomeError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new MembersSendWelcomeErrorException(ex.getRequestId(), ex.getUserMessage(), (MembersSendWelcomeError) ex.getErrorValue()); } } @@ -1538,11 +1661,12 @@ MembersSetPermissionsResult membersSetAdminPermissions(MembersSetPermissionsArg "2/team/members/set_admin_permissions", membersSetPermissionsArg, false, - JsonUtil.createType(MembersSetPermissionsResult.class), - JsonUtil.createType(MembersSetPermissionsError.class)); + MembersSetPermissionsArg.Serializer.INSTANCE, + MembersSetPermissionsResult.Serializer.INSTANCE, + MembersSetPermissionsError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new MembersSetPermissionsErrorException(ew.getRequestId(), ew.getUserMessage(), (MembersSetPermissionsError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new MembersSetPermissionsErrorException(ex.getRequestId(), ex.getUserMessage(), (MembersSetPermissionsError) ex.getErrorValue()); } } @@ -1581,11 +1705,12 @@ TeamMemberInfo membersSetProfile(MembersSetProfileArg membersSetProfileArg) thro "2/team/members/set_profile", membersSetProfileArg, false, - JsonUtil.createType(TeamMemberInfo.class), - JsonUtil.createType(MembersSetProfileError.class)); + MembersSetProfileArg.Serializer.INSTANCE, + TeamMemberInfo.Serializer.INSTANCE, + MembersSetProfileError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new MembersSetProfileErrorException(ew.getRequestId(), ew.getUserMessage(), (MembersSetProfileError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new MembersSetProfileErrorException(ex.getRequestId(), ex.getUserMessage(), (MembersSetProfileError) ex.getErrorValue()); } } @@ -1618,8 +1743,8 @@ public TeamMemberInfo membersSetProfile(UserSelectorArg user) throws MembersSetP * preconditions. */ public MembersSetProfileBuilder membersSetProfileBuilder(UserSelectorArg user) { - MembersSetProfileArg.Builder argBuilder = MembersSetProfileArg.newBuilder(user); - return new MembersSetProfileBuilder(this, argBuilder); + MembersSetProfileArg.Builder argBuilder_ = MembersSetProfileArg.newBuilder(user); + return new MembersSetProfileBuilder(this, argBuilder_); } // @@ -1640,11 +1765,12 @@ void membersSuspend(MembersDeactivateArg membersDeactivateArg) throws MembersSus "2/team/members/suspend", membersDeactivateArg, false, - JsonUtil.createType(Void.class), - JsonUtil.createType(MembersSuspendError.class)); + MembersDeactivateArg.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.void_(), + MembersSuspendError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new MembersSuspendErrorException(ew.getRequestId(), ew.getUserMessage(), (MembersSuspendError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new MembersSuspendErrorException(ex.getRequestId(), ex.getUserMessage(), (MembersSuspendError) ex.getErrorValue()); } } @@ -1703,11 +1829,12 @@ void membersUnsuspend(MembersUnsuspendArg membersUnsuspendArg) throws MembersUns "2/team/members/unsuspend", membersUnsuspendArg, false, - JsonUtil.createType(Void.class), - JsonUtil.createType(MembersUnsuspendError.class)); + MembersUnsuspendArg.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.void_(), + MembersUnsuspendError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new MembersUnsuspendErrorException(ew.getRequestId(), ew.getUserMessage(), (MembersUnsuspendError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new MembersUnsuspendErrorException(ex.getRequestId(), ex.getUserMessage(), (MembersUnsuspendError) ex.getErrorValue()); } } @@ -1726,176 +1853,6 @@ public void membersUnsuspend(UserSelectorArg user) throws MembersUnsuspendErrorE membersUnsuspend(arg); } - // - // route team/properties/template/add - // - - /** - * Add a property template. See route files/properties/add to add properties - * to a file. - * - * @param addPropertyTemplateArg Arguments for adding property templates. - */ - AddPropertyTemplateResult propertiesTemplateAdd(AddPropertyTemplateArg addPropertyTemplateArg) throws ModifyPropertyTemplateErrorException, DbxException { - try { - return client.rpcStyle(client.getHost().getApi(), - "2/team/properties/template/add", - addPropertyTemplateArg, - false, - JsonUtil.createType(AddPropertyTemplateResult.class), - JsonUtil.createType(com.dropbox.core.v2.properties.ModifyPropertyTemplateError.class)); - } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new ModifyPropertyTemplateErrorException(ew.getRequestId(), ew.getUserMessage(), (com.dropbox.core.v2.properties.ModifyPropertyTemplateError) ew.getErrorValue()); - } - } - - /** - * Add a property template. See route files/properties/add to add properties - * to a file. - * - * @param name A display name for the property template. Property template - * names can be up to 256 bytes. Must not be {@code null}. - * @param description Description for new property template. Property - * template descriptions can be up to 1024 bytes. Must not be {@code - * null}. - * @param fields This is a list of custom properties associated with a - * property template. There can be up to 64 properties in a single - * property template. Must not contain a {@code null} item and not be - * {@code null}. - * - * @throws IllegalArgumentException If any argument does not meet its - * preconditions. - */ - public AddPropertyTemplateResult propertiesTemplateAdd(String name, String description, List fields) throws ModifyPropertyTemplateErrorException, DbxException { - AddPropertyTemplateArg arg = new AddPropertyTemplateArg(name, description, fields); - return propertiesTemplateAdd(arg); - } - - // - // route team/properties/template/get - // - - /** - * Get the schema for a specified template. - * - * - * @return The Property template for the specified template. - */ - GetPropertyTemplateResult propertiesTemplateGet(GetPropertyTemplateArg getPropertyTemplateArg) throws PropertyTemplateErrorException, DbxException { - try { - return client.rpcStyle(client.getHost().getApi(), - "2/team/properties/template/get", - getPropertyTemplateArg, - false, - JsonUtil.createType(GetPropertyTemplateResult.class), - JsonUtil.createType(com.dropbox.core.v2.properties.PropertyTemplateError.class)); - } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new PropertyTemplateErrorException(ew.getRequestId(), ew.getUserMessage(), (com.dropbox.core.v2.properties.PropertyTemplateError) ew.getErrorValue()); - } - } - - /** - * Get the schema for a specified template. - * - * @param templateId An identifier for property template added by route - * properties/template/add. Must have length of at least 1, match - * pattern "{@code (/|ptid:).*}", and not be {@code null}. - * - * @return The Property template for the specified template. - * - * @throws IllegalArgumentException If any argument does not meet its - * preconditions. - */ - public GetPropertyTemplateResult propertiesTemplateGet(String templateId) throws PropertyTemplateErrorException, DbxException { - GetPropertyTemplateArg arg = new GetPropertyTemplateArg(templateId); - return propertiesTemplateGet(arg); - } - - // - // route team/properties/template/list - // - - /** - * Get the property template identifiers for a team. To get the schema of - * each template use {@link - * DbxTeamTeamRequests#propertiesTemplateGet(String)}. - */ - public ListPropertyTemplateIds propertiesTemplateList() throws PropertyTemplateErrorException, DbxException { - try { - return client.rpcStyle(client.getHost().getApi(), - "2/team/properties/template/list", - null, - false, - JsonUtil.createType(ListPropertyTemplateIds.class), - JsonUtil.createType(com.dropbox.core.v2.properties.PropertyTemplateError.class)); - } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new PropertyTemplateErrorException(ew.getRequestId(), ew.getUserMessage(), (com.dropbox.core.v2.properties.PropertyTemplateError) ew.getErrorValue()); - } - } - - // - // route team/properties/template/update - // - - /** - * Update a property template. This route can update the template name, the - * template description and add optional properties to templates. - * - */ - UpdatePropertyTemplateResult propertiesTemplateUpdate(UpdatePropertyTemplateArg updatePropertyTemplateArg) throws ModifyPropertyTemplateErrorException, DbxException { - try { - return client.rpcStyle(client.getHost().getApi(), - "2/team/properties/template/update", - updatePropertyTemplateArg, - false, - JsonUtil.createType(UpdatePropertyTemplateResult.class), - JsonUtil.createType(com.dropbox.core.v2.properties.ModifyPropertyTemplateError.class)); - } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new ModifyPropertyTemplateErrorException(ew.getRequestId(), ew.getUserMessage(), (com.dropbox.core.v2.properties.ModifyPropertyTemplateError) ew.getErrorValue()); - } - } - - /** - * Update a property template. This route can update the template name, the - * template description and add optional properties to templates. - * - * @param templateId An identifier for property template added by {@link - * DbxTeamTeamRequests#propertiesTemplateAdd(String,String,List)}. Must - * have length of at least 1, match pattern "{@code (/|ptid:).*}", and - * not be {@code null}. - * - * @throws IllegalArgumentException If any argument does not meet its - * preconditions. - */ - public UpdatePropertyTemplateResult propertiesTemplateUpdate(String templateId) throws ModifyPropertyTemplateErrorException, DbxException { - UpdatePropertyTemplateArg arg = new UpdatePropertyTemplateArg(templateId); - return propertiesTemplateUpdate(arg); - } - - /** - * Update a property template. This route can update the template name, the - * template description and add optional properties to templates. - * - * @param templateId An identifier for property template added by {@link - * DbxTeamTeamRequests#propertiesTemplateAdd(String,String,List)}. Must - * have length of at least 1, match pattern "{@code (/|ptid:).*}", and - * not be {@code null}. - * - * @return Request builder for configuring request parameters and completing - * the request. - * - * @throws IllegalArgumentException If any argument does not meet its - * preconditions. - */ - public PropertiesTemplateUpdateBuilder propertiesTemplateUpdateBuilder(String templateId) { - UpdatePropertyTemplateArg.Builder argBuilder = UpdatePropertyTemplateArg.newBuilder(templateId); - return new PropertiesTemplateUpdateBuilder(this, argBuilder); - } - // // route team/reports/get_activity // @@ -1915,11 +1872,12 @@ GetActivityReport reportsGetActivity(DateRange dateRange) throws DateRangeErrorE "2/team/reports/get_activity", dateRange, false, - JsonUtil.createType(GetActivityReport.class), - JsonUtil.createType(DateRangeError.class)); + DateRange.Serializer.INSTANCE, + GetActivityReport.Serializer.INSTANCE, + DateRangeError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new DateRangeErrorException(ew.getRequestId(), ew.getUserMessage(), (DateRangeError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new DateRangeErrorException(ex.getRequestId(), ex.getUserMessage(), (DateRangeError) ex.getErrorValue()); } } @@ -1942,8 +1900,8 @@ public GetActivityReport reportsGetActivity() throws DateRangeErrorException, Db * the request. */ public ReportsGetActivityBuilder reportsGetActivityBuilder() { - DateRange.Builder argBuilder = DateRange.newBuilder(); - return new ReportsGetActivityBuilder(this, argBuilder); + DateRange.Builder argBuilder_ = DateRange.newBuilder(); + return new ReportsGetActivityBuilder(this, argBuilder_); } // @@ -1966,11 +1924,12 @@ GetDevicesReport reportsGetDevices(DateRange dateRange) throws DateRangeErrorExc "2/team/reports/get_devices", dateRange, false, - JsonUtil.createType(GetDevicesReport.class), - JsonUtil.createType(DateRangeError.class)); + DateRange.Serializer.INSTANCE, + GetDevicesReport.Serializer.INSTANCE, + DateRangeError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new DateRangeErrorException(ew.getRequestId(), ew.getUserMessage(), (DateRangeError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new DateRangeErrorException(ex.getRequestId(), ex.getUserMessage(), (DateRangeError) ex.getErrorValue()); } } @@ -1994,8 +1953,8 @@ public GetDevicesReport reportsGetDevices() throws DateRangeErrorException, DbxE * the request. */ public ReportsGetDevicesBuilder reportsGetDevicesBuilder() { - DateRange.Builder argBuilder = DateRange.newBuilder(); - return new ReportsGetDevicesBuilder(this, argBuilder); + DateRange.Builder argBuilder_ = DateRange.newBuilder(); + return new ReportsGetDevicesBuilder(this, argBuilder_); } // @@ -2017,11 +1976,12 @@ GetMembershipReport reportsGetMembership(DateRange dateRange) throws DateRangeEr "2/team/reports/get_membership", dateRange, false, - JsonUtil.createType(GetMembershipReport.class), - JsonUtil.createType(DateRangeError.class)); + DateRange.Serializer.INSTANCE, + GetMembershipReport.Serializer.INSTANCE, + DateRangeError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new DateRangeErrorException(ew.getRequestId(), ew.getUserMessage(), (DateRangeError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new DateRangeErrorException(ex.getRequestId(), ex.getUserMessage(), (DateRangeError) ex.getErrorValue()); } } @@ -2044,8 +2004,8 @@ public GetMembershipReport reportsGetMembership() throws DateRangeErrorException * the request. */ public ReportsGetMembershipBuilder reportsGetMembershipBuilder() { - DateRange.Builder argBuilder = DateRange.newBuilder(); - return new ReportsGetMembershipBuilder(this, argBuilder); + DateRange.Builder argBuilder_ = DateRange.newBuilder(); + return new ReportsGetMembershipBuilder(this, argBuilder_); } // @@ -2067,11 +2027,12 @@ GetStorageReport reportsGetStorage(DateRange dateRange) throws DateRangeErrorExc "2/team/reports/get_storage", dateRange, false, - JsonUtil.createType(GetStorageReport.class), - JsonUtil.createType(DateRangeError.class)); + DateRange.Serializer.INSTANCE, + GetStorageReport.Serializer.INSTANCE, + DateRangeError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new DateRangeErrorException(ew.getRequestId(), ew.getUserMessage(), (DateRangeError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new DateRangeErrorException(ex.getRequestId(), ex.getUserMessage(), (DateRangeError) ex.getErrorValue()); } } @@ -2094,7 +2055,7 @@ public GetStorageReport reportsGetStorage() throws DateRangeErrorException, DbxE * the request. */ public ReportsGetStorageBuilder reportsGetStorageBuilder() { - DateRange.Builder argBuilder = DateRange.newBuilder(); - return new ReportsGetStorageBuilder(this, argBuilder); + DateRange.Builder argBuilder_ = DateRange.newBuilder(); + return new ReportsGetStorageBuilder(this, argBuilder_); } } diff --git a/src/main/java/com/dropbox/core/v2/team/DesktopClientSession.java b/src/main/java/com/dropbox/core/v2/team/DesktopClientSession.java index 8e165a9a2..6f651917e 100644 --- a/src/main/java/com/dropbox/core/v2/team/DesktopClientSession.java +++ b/src/main/java/com/dropbox/core/v2/team/DesktopClientSession.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.Date; @@ -29,15 +18,9 @@ /** * Information about linked Dropbox desktop client sessions */ -@JsonSerialize(using=DesktopClientSession.Serializer.class) -@JsonDeserialize(using=DesktopClientSession.Deserializer.class) public class DesktopClientSession extends DeviceSession { // struct DesktopClientSession - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String hostName; protected final DesktopPlatform clientType; protected final String clientVersion; @@ -263,7 +246,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -275,155 +258,136 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(DesktopClientSession.class); - } - - public Serializer(boolean unwrapping) { - super(DesktopClientSession.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(DesktopClientSession value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("session_id", value.sessionId); - g.writeObjectField("host_name", value.hostName); - g.writeObjectField("client_type", value.clientType); - g.writeObjectField("client_version", value.clientVersion); - g.writeObjectField("platform", value.platform); - g.writeObjectField("is_delete_on_unlink_supported", value.isDeleteOnUnlinkSupported); + public void serialize(DesktopClientSession value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("session_id"); + StoneSerializers.string().serialize(value.sessionId, g); + g.writeFieldName("host_name"); + StoneSerializers.string().serialize(value.hostName, g); + g.writeFieldName("client_type"); + DesktopPlatform.Serializer.INSTANCE.serialize(value.clientType, g); + g.writeFieldName("client_version"); + StoneSerializers.string().serialize(value.clientVersion, g); + g.writeFieldName("platform"); + StoneSerializers.string().serialize(value.platform, g); + g.writeFieldName("is_delete_on_unlink_supported"); + StoneSerializers.boolean_().serialize(value.isDeleteOnUnlinkSupported, g); if (value.ipAddress != null) { - g.writeObjectField("ip_address", value.ipAddress); + g.writeFieldName("ip_address"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.ipAddress, g); } if (value.country != null) { - g.writeObjectField("country", value.country); + g.writeFieldName("country"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.country, g); } if (value.created != null) { - g.writeObjectField("created", value.created); + g.writeFieldName("created"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.created, g); } if (value.updated != null) { - g.writeObjectField("updated", value.updated); + g.writeFieldName("updated"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.updated, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(DesktopClientSession.class); - } - - public Deserializer(boolean unwrapping) { - super(DesktopClientSession.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public DesktopClientSession deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String sessionId = null; - String hostName = null; - DesktopPlatform clientType = null; - String clientVersion = null; - String platform = null; - Boolean isDeleteOnUnlinkSupported = null; - String ipAddress = null; - String country = null; - Date created = null; - Date updated = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("session_id".equals(_field)) { - sessionId = getStringValue(_p); - _p.nextToken(); - } - else if ("host_name".equals(_field)) { - hostName = getStringValue(_p); - _p.nextToken(); - } - else if ("client_type".equals(_field)) { - clientType = _p.readValueAs(DesktopPlatform.class); - _p.nextToken(); - } - else if ("client_version".equals(_field)) { - clientVersion = getStringValue(_p); - _p.nextToken(); - } - else if ("platform".equals(_field)) { - platform = getStringValue(_p); - _p.nextToken(); + public DesktopClientSession deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + DesktopClientSession value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_sessionId = null; + String f_hostName = null; + DesktopPlatform f_clientType = null; + String f_clientVersion = null; + String f_platform = null; + Boolean f_isDeleteOnUnlinkSupported = null; + String f_ipAddress = null; + String f_country = null; + Date f_created = null; + Date f_updated = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("session_id".equals(field)) { + f_sessionId = StoneSerializers.string().deserialize(p); + } + else if ("host_name".equals(field)) { + f_hostName = StoneSerializers.string().deserialize(p); + } + else if ("client_type".equals(field)) { + f_clientType = DesktopPlatform.Serializer.INSTANCE.deserialize(p); + } + else if ("client_version".equals(field)) { + f_clientVersion = StoneSerializers.string().deserialize(p); + } + else if ("platform".equals(field)) { + f_platform = StoneSerializers.string().deserialize(p); + } + else if ("is_delete_on_unlink_supported".equals(field)) { + f_isDeleteOnUnlinkSupported = StoneSerializers.boolean_().deserialize(p); + } + else if ("ip_address".equals(field)) { + f_ipAddress = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("country".equals(field)) { + f_country = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("created".equals(field)) { + f_created = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else if ("updated".equals(field)) { + f_updated = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else { + skipValue(p); + } } - else if ("is_delete_on_unlink_supported".equals(_field)) { - isDeleteOnUnlinkSupported = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_sessionId == null) { + throw new JsonParseException(p, "Required field \"session_id\" missing."); } - else if ("ip_address".equals(_field)) { - ipAddress = getStringValue(_p); - _p.nextToken(); + if (f_hostName == null) { + throw new JsonParseException(p, "Required field \"host_name\" missing."); } - else if ("country".equals(_field)) { - country = getStringValue(_p); - _p.nextToken(); + if (f_clientType == null) { + throw new JsonParseException(p, "Required field \"client_type\" missing."); } - else if ("created".equals(_field)) { - created = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); + if (f_clientVersion == null) { + throw new JsonParseException(p, "Required field \"client_version\" missing."); } - else if ("updated".equals(_field)) { - updated = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); + if (f_platform == null) { + throw new JsonParseException(p, "Required field \"platform\" missing."); } - else { - skipValue(_p); + if (f_isDeleteOnUnlinkSupported == null) { + throw new JsonParseException(p, "Required field \"is_delete_on_unlink_supported\" missing."); } + value = new DesktopClientSession(f_sessionId, f_hostName, f_clientType, f_clientVersion, f_platform, f_isDeleteOnUnlinkSupported, f_ipAddress, f_country, f_created, f_updated); } - - if (sessionId == null) { - throw new JsonParseException(_p, "Required field \"session_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (hostName == null) { - throw new JsonParseException(_p, "Required field \"host_name\" is missing."); - } - if (clientType == null) { - throw new JsonParseException(_p, "Required field \"client_type\" is missing."); - } - if (clientVersion == null) { - throw new JsonParseException(_p, "Required field \"client_version\" is missing."); + if (!collapsed) { + expectEndObject(p); } - if (platform == null) { - throw new JsonParseException(_p, "Required field \"platform\" is missing."); - } - if (isDeleteOnUnlinkSupported == null) { - throw new JsonParseException(_p, "Required field \"is_delete_on_unlink_supported\" is missing."); - } - - return new DesktopClientSession(sessionId, hostName, clientType, clientVersion, platform, isDeleteOnUnlinkSupported, ipAddress, country, created, updated); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/DesktopPlatform.java b/src/main/java/com/dropbox/core/v2/team/DesktopPlatform.java index 17b24b341..1d9d61f68 100644 --- a/src/main/java/com/dropbox/core/v2/team/DesktopPlatform.java +++ b/src/main/java/com/dropbox/core/v2/team/DesktopPlatform.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=DesktopPlatform.Serializer.class) -@JsonDeserialize(using=DesktopPlatform.Deserializer.class) public enum DesktopPlatform { // union DesktopPlatform /** @@ -47,55 +33,68 @@ public enum DesktopPlatform { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(DesktopPlatform.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(DesktopPlatform value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(DesktopPlatform value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case WINDOWS: + case WINDOWS: { g.writeString("windows"); break; - case MAC: + } + case MAC: { g.writeString("mac"); break; - case LINUX: + } + case LINUX: { g.writeString("linux"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(DesktopPlatform.class, getTagMapping(), DesktopPlatform.OTHER); - } @Override - public DesktopPlatform deserialize(DesktopPlatform _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("windows", DesktopPlatform.WINDOWS); - values.put("mac", DesktopPlatform.MAC); - values.put("linux", DesktopPlatform.LINUX); - values.put("other", DesktopPlatform.OTHER); - return Collections.unmodifiableMap(values); + public DesktopPlatform deserialize(JsonParser p) throws IOException, JsonParseException { + DesktopPlatform value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("windows".equals(tag)) { + value = DesktopPlatform.WINDOWS; + } + else if ("mac".equals(tag)) { + value = DesktopPlatform.MAC; + } + else if ("linux".equals(tag)) { + value = DesktopPlatform.LINUX; + } + else { + value = DesktopPlatform.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/DeviceSession.java b/src/main/java/com/dropbox/core/v2/team/DeviceSession.java index daad87c3c..bf8e77509 100644 --- a/src/main/java/com/dropbox/core/v2/team/DeviceSession.java +++ b/src/main/java/com/dropbox/core/v2/team/DeviceSession.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.Date; -@JsonSerialize(using=DeviceSession.Serializer.class) -@JsonDeserialize(using=DeviceSession.Deserializer.class) public class DeviceSession { // struct DeviceSession - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String sessionId; protected final String ipAddress; protected final String country; @@ -254,7 +237,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -266,110 +249,91 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(DeviceSession.class); - } - - public Serializer(boolean unwrapping) { - super(DeviceSession.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(DeviceSession value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("session_id", value.sessionId); + public void serialize(DeviceSession value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("session_id"); + StoneSerializers.string().serialize(value.sessionId, g); if (value.ipAddress != null) { - g.writeObjectField("ip_address", value.ipAddress); + g.writeFieldName("ip_address"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.ipAddress, g); } if (value.country != null) { - g.writeObjectField("country", value.country); + g.writeFieldName("country"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.country, g); } if (value.created != null) { - g.writeObjectField("created", value.created); + g.writeFieldName("created"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.created, g); } if (value.updated != null) { - g.writeObjectField("updated", value.updated); + g.writeFieldName("updated"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.updated, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(DeviceSession.class); - } - - public Deserializer(boolean unwrapping) { - super(DeviceSession.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public DeviceSession deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String sessionId = null; - String ipAddress = null; - String country = null; - Date created = null; - Date updated = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("session_id".equals(_field)) { - sessionId = getStringValue(_p); - _p.nextToken(); - } - else if ("ip_address".equals(_field)) { - ipAddress = getStringValue(_p); - _p.nextToken(); - } - else if ("country".equals(_field)) { - country = getStringValue(_p); - _p.nextToken(); - } - else if ("created".equals(_field)) { - created = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); - } - else if ("updated".equals(_field)) { - updated = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); + public DeviceSession deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + DeviceSession value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_sessionId = null; + String f_ipAddress = null; + String f_country = null; + Date f_created = null; + Date f_updated = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("session_id".equals(field)) { + f_sessionId = StoneSerializers.string().deserialize(p); + } + else if ("ip_address".equals(field)) { + f_ipAddress = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("country".equals(field)) { + f_country = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("created".equals(field)) { + f_created = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else if ("updated".equals(field)) { + f_updated = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_sessionId == null) { + throw new JsonParseException(p, "Required field \"session_id\" missing."); } + value = new DeviceSession(f_sessionId, f_ipAddress, f_country, f_created, f_updated); } - - if (sessionId == null) { - throw new JsonParseException(_p, "Required field \"session_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new DeviceSession(sessionId, ipAddress, country, created, updated); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/DeviceSessionArg.java b/src/main/java/com/dropbox/core/v2/team/DeviceSessionArg.java index e1f2d679f..ba09453b4 100644 --- a/src/main/java/com/dropbox/core/v2/team/DeviceSessionArg.java +++ b/src/main/java/com/dropbox/core/v2/team/DeviceSessionArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=DeviceSessionArg.Serializer.class) -@JsonDeserialize(using=DeviceSessionArg.Deserializer.class) public class DeviceSessionArg { // struct DeviceSessionArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String sessionId; protected final String teamMemberId; @@ -103,7 +86,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -115,87 +98,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(DeviceSessionArg.class); - } - - public Serializer(boolean unwrapping) { - super(DeviceSessionArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(DeviceSessionArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("session_id", value.sessionId); - g.writeObjectField("team_member_id", value.teamMemberId); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(DeviceSessionArg.class); - } - - public Deserializer(boolean unwrapping) { - super(DeviceSessionArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(DeviceSessionArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("session_id"); + StoneSerializers.string().serialize(value.sessionId, g); + g.writeFieldName("team_member_id"); + StoneSerializers.string().serialize(value.teamMemberId, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public DeviceSessionArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String sessionId = null; - String teamMemberId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("session_id".equals(_field)) { - sessionId = getStringValue(_p); - _p.nextToken(); + public DeviceSessionArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + DeviceSessionArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_sessionId = null; + String f_teamMemberId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("session_id".equals(field)) { + f_sessionId = StoneSerializers.string().deserialize(p); + } + else if ("team_member_id".equals(field)) { + f_teamMemberId = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else if ("team_member_id".equals(_field)) { - teamMemberId = getStringValue(_p); - _p.nextToken(); + if (f_sessionId == null) { + throw new JsonParseException(p, "Required field \"session_id\" missing."); } - else { - skipValue(_p); + if (f_teamMemberId == null) { + throw new JsonParseException(p, "Required field \"team_member_id\" missing."); } + value = new DeviceSessionArg(f_sessionId, f_teamMemberId); } - - if (sessionId == null) { - throw new JsonParseException(_p, "Required field \"session_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (teamMemberId == null) { - throw new JsonParseException(_p, "Required field \"team_member_id\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new DeviceSessionArg(sessionId, teamMemberId); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/DevicesActive.java b/src/main/java/com/dropbox/core/v2/team/DevicesActive.java index 30fa75352..35e554c92 100644 --- a/src/main/java/com/dropbox/core/v2/team/DevicesActive.java +++ b/src/main/java/com/dropbox/core/v2/team/DevicesActive.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from team_reports.babel */ +/* This file was generated from team_reports.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; @@ -31,15 +20,9 @@ * number of devices active within a time window, ending with that day. If there * is no data for a day, then the value will be None. */ -@JsonSerialize(using=DevicesActive.Serializer.class) -@JsonDeserialize(using=DevicesActive.Deserializer.class) public class DevicesActive { // struct DevicesActive - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List windows; protected final List macos; protected final List linux; @@ -83,7 +66,6 @@ public DevicesActive(List windows, List macos, List linux, Lis if (x == null) { throw new IllegalArgumentException("An item in list 'windows' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'windows': type Nullable"); } this.windows = windows; if (macos == null) { @@ -93,7 +75,6 @@ public DevicesActive(List windows, List macos, List linux, Lis if (x == null) { throw new IllegalArgumentException("An item in list 'macos' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'macos': type Nullable"); } this.macos = macos; if (linux == null) { @@ -103,7 +84,6 @@ public DevicesActive(List windows, List macos, List linux, Lis if (x == null) { throw new IllegalArgumentException("An item in list 'linux' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'linux': type Nullable"); } this.linux = linux; if (ios == null) { @@ -113,7 +93,6 @@ public DevicesActive(List windows, List macos, List linux, Lis if (x == null) { throw new IllegalArgumentException("An item in list 'ios' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'ios': type Nullable"); } this.ios = ios; if (android == null) { @@ -123,7 +102,6 @@ public DevicesActive(List windows, List macos, List linux, Lis if (x == null) { throw new IllegalArgumentException("An item in list 'android' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'android': type Nullable"); } this.android = android; if (other == null) { @@ -133,7 +111,6 @@ public DevicesActive(List windows, List macos, List linux, Lis if (x == null) { throw new IllegalArgumentException("An item in list 'other' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'other': type Nullable"); } this.other = other; if (total == null) { @@ -143,7 +120,6 @@ public DevicesActive(List windows, List macos, List linux, Lis if (x == null) { throw new IllegalArgumentException("An item in list 'total' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'total': type Nullable"); } this.total = total; } @@ -250,7 +226,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -262,195 +238,113 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(DevicesActive.class); - } - - public Serializer(boolean unwrapping) { - super(DevicesActive.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(DevicesActive value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("windows", value.windows); - g.writeObjectField("macos", value.macos); - g.writeObjectField("linux", value.linux); - g.writeObjectField("ios", value.ios); - g.writeObjectField("android", value.android); - g.writeObjectField("other", value.other); - g.writeObjectField("total", value.total); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(DevicesActive.class); - } - - public Deserializer(boolean unwrapping) { - super(DevicesActive.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(DevicesActive value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("windows"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.windows, g); + g.writeFieldName("macos"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.macos, g); + g.writeFieldName("linux"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.linux, g); + g.writeFieldName("ios"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.ios, g); + g.writeFieldName("android"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.android, g); + g.writeFieldName("other"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.other, g); + g.writeFieldName("total"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.total, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public DevicesActive deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List windows = null; - List macos = null; - List linux = null; - List ios = null; - List android = null; - List other = null; - List total = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("windows".equals(_field)) { - expectArrayStart(_p); - windows = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - windows.add(_x); + public DevicesActive deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + DevicesActive value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_windows = null; + List f_macos = null; + List f_linux = null; + List f_ios = null; + List f_android = null; + List f_other = null; + List f_total = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("windows".equals(field)) { + f_windows = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("macos".equals(_field)) { - expectArrayStart(_p); - macos = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - macos.add(_x); + else if ("macos".equals(field)) { + f_macos = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("linux".equals(_field)) { - expectArrayStart(_p); - linux = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - linux.add(_x); + else if ("linux".equals(field)) { + f_linux = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("ios".equals(_field)) { - expectArrayStart(_p); - ios = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - ios.add(_x); + else if ("ios".equals(field)) { + f_ios = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("android".equals(_field)) { - expectArrayStart(_p); - android = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - android.add(_x); + else if ("android".equals(field)) { + f_android = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("other".equals(_field)) { - expectArrayStart(_p); - other = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - other.add(_x); + else if ("other".equals(field)) { + f_other = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("total".equals(_field)) { - expectArrayStart(_p); - total = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - total.add(_x); + else if ("total".equals(field)) { + f_total = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else { - skipValue(_p); + if (f_windows == null) { + throw new JsonParseException(p, "Required field \"windows\" missing."); } + if (f_macos == null) { + throw new JsonParseException(p, "Required field \"macos\" missing."); + } + if (f_linux == null) { + throw new JsonParseException(p, "Required field \"linux\" missing."); + } + if (f_ios == null) { + throw new JsonParseException(p, "Required field \"ios\" missing."); + } + if (f_android == null) { + throw new JsonParseException(p, "Required field \"android\" missing."); + } + if (f_other == null) { + throw new JsonParseException(p, "Required field \"other\" missing."); + } + if (f_total == null) { + throw new JsonParseException(p, "Required field \"total\" missing."); + } + value = new DevicesActive(f_windows, f_macos, f_linux, f_ios, f_android, f_other, f_total); } - - if (windows == null) { - throw new JsonParseException(_p, "Required field \"windows\" is missing."); - } - if (macos == null) { - throw new JsonParseException(_p, "Required field \"macos\" is missing."); - } - if (linux == null) { - throw new JsonParseException(_p, "Required field \"linux\" is missing."); - } - if (ios == null) { - throw new JsonParseException(_p, "Required field \"ios\" is missing."); - } - if (android == null) { - throw new JsonParseException(_p, "Required field \"android\" is missing."); - } - if (other == null) { - throw new JsonParseException(_p, "Required field \"other\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (total == null) { - throw new JsonParseException(_p, "Required field \"total\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new DevicesActive(windows, macos, linux, ios, android, other, total); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/DevicesListMemberDevicesBuilder.java b/src/main/java/com/dropbox/core/v2/team/DevicesListMemberDevicesBuilder.java index 773d606fd..79e0cf793 100644 --- a/src/main/java/com/dropbox/core/v2/team/DevicesListMemberDevicesBuilder.java +++ b/src/main/java/com/dropbox/core/v2/team/DevicesListMemberDevicesBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; @@ -13,26 +13,26 @@ * request.

*/ public class DevicesListMemberDevicesBuilder { - private final DbxTeamTeamRequests team; + private final DbxTeamTeamRequests team_; private final ListMemberDevicesArg.Builder listMemberDevicesArgBuilder; /** * Creates a new instance of this builder. * - * @param team Dropbox namespace-specific client used to issue team + * @param team_ Dropbox namespace-specific client used to issue team * requests. * @param listMemberDevicesArgBuilder Request argument builder. * * @return instsance of this builder */ - DevicesListMemberDevicesBuilder(DbxTeamTeamRequests team, ListMemberDevicesArg.Builder listMemberDevicesArgBuilder) { - if (team == null) { - throw new NullPointerException("team"); + DevicesListMemberDevicesBuilder(DbxTeamTeamRequests team_, ListMemberDevicesArg.Builder listMemberDevicesArgBuilder) { + if (team_ == null) { + throw new NullPointerException("team_"); } + this.team_ = team_; if (listMemberDevicesArgBuilder == null) { throw new NullPointerException("listMemberDevicesArgBuilder"); } - this.team = team; this.listMemberDevicesArgBuilder = listMemberDevicesArgBuilder; } @@ -85,7 +85,7 @@ public DevicesListMemberDevicesBuilder withIncludeMobileClients(Boolean includeM * Issues the request. */ public ListMemberDevicesResult start() throws ListMemberDevicesErrorException, DbxException { - ListMemberDevicesArg arg = this.listMemberDevicesArgBuilder.build(); - return team.devicesListMemberDevices(arg); + ListMemberDevicesArg arg_ = this.listMemberDevicesArgBuilder.build(); + return team_.devicesListMemberDevices(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/team/DevicesListMembersDevicesBuilder.java b/src/main/java/com/dropbox/core/v2/team/DevicesListMembersDevicesBuilder.java index f56a3ffec..c99d63516 100644 --- a/src/main/java/com/dropbox/core/v2/team/DevicesListMembersDevicesBuilder.java +++ b/src/main/java/com/dropbox/core/v2/team/DevicesListMembersDevicesBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; @@ -13,26 +13,26 @@ * request.

*/ public class DevicesListMembersDevicesBuilder { - private final DbxTeamTeamRequests team; + private final DbxTeamTeamRequests team_; private final ListMembersDevicesArg.Builder listMembersDevicesArgBuilder; /** * Creates a new instance of this builder. * - * @param team Dropbox namespace-specific client used to issue team + * @param team_ Dropbox namespace-specific client used to issue team * requests. * @param listMembersDevicesArgBuilder Request argument builder. * * @return instsance of this builder */ - DevicesListMembersDevicesBuilder(DbxTeamTeamRequests team, ListMembersDevicesArg.Builder listMembersDevicesArgBuilder) { - if (team == null) { - throw new NullPointerException("team"); + DevicesListMembersDevicesBuilder(DbxTeamTeamRequests team_, ListMembersDevicesArg.Builder listMembersDevicesArgBuilder) { + if (team_ == null) { + throw new NullPointerException("team_"); } + this.team_ = team_; if (listMembersDevicesArgBuilder == null) { throw new NullPointerException("listMembersDevicesArgBuilder"); } - this.team = team; this.listMembersDevicesArgBuilder = listMembersDevicesArgBuilder; } @@ -101,7 +101,7 @@ public DevicesListMembersDevicesBuilder withIncludeMobileClients(Boolean include * Issues the request. */ public ListMembersDevicesResult start() throws ListMembersDevicesErrorException, DbxException { - ListMembersDevicesArg arg = this.listMembersDevicesArgBuilder.build(); - return team.devicesListMembersDevices(arg); + ListMembersDevicesArg arg_ = this.listMembersDevicesArgBuilder.build(); + return team_.devicesListMembersDevices(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/team/DevicesListTeamDevicesBuilder.java b/src/main/java/com/dropbox/core/v2/team/DevicesListTeamDevicesBuilder.java index 2c7b6d0ee..27ee23ae2 100644 --- a/src/main/java/com/dropbox/core/v2/team/DevicesListTeamDevicesBuilder.java +++ b/src/main/java/com/dropbox/core/v2/team/DevicesListTeamDevicesBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; @@ -13,26 +13,26 @@ * request.

*/ public class DevicesListTeamDevicesBuilder { - private final DbxTeamTeamRequests team; + private final DbxTeamTeamRequests team_; private final ListTeamDevicesArg.Builder listTeamDevicesArgBuilder; /** * Creates a new instance of this builder. * - * @param team Dropbox namespace-specific client used to issue team + * @param team_ Dropbox namespace-specific client used to issue team * requests. * @param listTeamDevicesArgBuilder Request argument builder. * * @return instsance of this builder */ - DevicesListTeamDevicesBuilder(DbxTeamTeamRequests team, ListTeamDevicesArg.Builder listTeamDevicesArgBuilder) { - if (team == null) { - throw new NullPointerException("team"); + DevicesListTeamDevicesBuilder(DbxTeamTeamRequests team_, ListTeamDevicesArg.Builder listTeamDevicesArgBuilder) { + if (team_ == null) { + throw new NullPointerException("team_"); } + this.team_ = team_; if (listTeamDevicesArgBuilder == null) { throw new NullPointerException("listTeamDevicesArgBuilder"); } - this.team = team; this.listTeamDevicesArgBuilder = listTeamDevicesArgBuilder; } @@ -100,8 +100,9 @@ public DevicesListTeamDevicesBuilder withIncludeMobileClients(Boolean includeMob /** * Issues the request. */ + @SuppressWarnings("deprecation") public ListTeamDevicesResult start() throws ListTeamDevicesErrorException, DbxException { - ListTeamDevicesArg arg = this.listTeamDevicesArgBuilder.build(); - return team.devicesListTeamDevices(arg); + ListTeamDevicesArg arg_ = this.listTeamDevicesArgBuilder.build(); + return team_.devicesListTeamDevices(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/team/GetActivityReport.java b/src/main/java/com/dropbox/core/v2/team/GetActivityReport.java index 52d830056..dc646c8d1 100644 --- a/src/main/java/com/dropbox/core/v2/team/GetActivityReport.java +++ b/src/main/java/com/dropbox/core/v2/team/GetActivityReport.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from team_reports.babel */ +/* This file was generated from team_reports.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; @@ -31,15 +20,9 @@ * of values, one value per day. If there is no data for a day, then the value * will be None. */ -@JsonSerialize(using=GetActivityReport.Serializer.class) -@JsonDeserialize(using=GetActivityReport.Deserializer.class) public class GetActivityReport extends BaseDfbReport { // struct GetActivityReport - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List adds; protected final List edits; protected final List deletes; @@ -114,7 +97,6 @@ public GetActivityReport(String startDate, List adds, List edits, Li if (x == null) { throw new IllegalArgumentException("An item in list 'adds' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'adds': type Nullable"); } this.adds = adds; if (edits == null) { @@ -124,7 +106,6 @@ public GetActivityReport(String startDate, List adds, List edits, Li if (x == null) { throw new IllegalArgumentException("An item in list 'edits' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'edits': type Nullable"); } this.edits = edits; if (deletes == null) { @@ -134,7 +115,6 @@ public GetActivityReport(String startDate, List adds, List edits, Li if (x == null) { throw new IllegalArgumentException("An item in list 'deletes' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'deletes': type Nullable"); } this.deletes = deletes; if (activeUsers28Day == null) { @@ -144,7 +124,6 @@ public GetActivityReport(String startDate, List adds, List edits, Li if (x == null) { throw new IllegalArgumentException("An item in list 'activeUsers28Day' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'activeUsers28Day': type Nullable"); } this.activeUsers28Day = activeUsers28Day; if (activeUsers7Day == null) { @@ -154,7 +133,6 @@ public GetActivityReport(String startDate, List adds, List edits, Li if (x == null) { throw new IllegalArgumentException("An item in list 'activeUsers7Day' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'activeUsers7Day': type Nullable"); } this.activeUsers7Day = activeUsers7Day; if (activeUsers1Day == null) { @@ -164,7 +142,6 @@ public GetActivityReport(String startDate, List adds, List edits, Li if (x == null) { throw new IllegalArgumentException("An item in list 'activeUsers1Day' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'activeUsers1Day': type Nullable"); } this.activeUsers1Day = activeUsers1Day; if (activeSharedFolders28Day == null) { @@ -174,7 +151,6 @@ public GetActivityReport(String startDate, List adds, List edits, Li if (x == null) { throw new IllegalArgumentException("An item in list 'activeSharedFolders28Day' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'activeSharedFolders28Day': type Nullable"); } this.activeSharedFolders28Day = activeSharedFolders28Day; if (activeSharedFolders7Day == null) { @@ -184,7 +160,6 @@ public GetActivityReport(String startDate, List adds, List edits, Li if (x == null) { throw new IllegalArgumentException("An item in list 'activeSharedFolders7Day' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'activeSharedFolders7Day': type Nullable"); } this.activeSharedFolders7Day = activeSharedFolders7Day; if (activeSharedFolders1Day == null) { @@ -194,7 +169,6 @@ public GetActivityReport(String startDate, List adds, List edits, Li if (x == null) { throw new IllegalArgumentException("An item in list 'activeSharedFolders1Day' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'activeSharedFolders1Day': type Nullable"); } this.activeSharedFolders1Day = activeSharedFolders1Day; if (sharedLinksCreated == null) { @@ -204,7 +178,6 @@ public GetActivityReport(String startDate, List adds, List edits, Li if (x == null) { throw new IllegalArgumentException("An item in list 'sharedLinksCreated' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'sharedLinksCreated': type Nullable"); } this.sharedLinksCreated = sharedLinksCreated; if (sharedLinksViewedByTeam == null) { @@ -214,7 +187,6 @@ public GetActivityReport(String startDate, List adds, List edits, Li if (x == null) { throw new IllegalArgumentException("An item in list 'sharedLinksViewedByTeam' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'sharedLinksViewedByTeam': type Nullable"); } this.sharedLinksViewedByTeam = sharedLinksViewedByTeam; if (sharedLinksViewedByOutsideUser == null) { @@ -224,7 +196,6 @@ public GetActivityReport(String startDate, List adds, List edits, Li if (x == null) { throw new IllegalArgumentException("An item in list 'sharedLinksViewedByOutsideUser' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'sharedLinksViewedByOutsideUser': type Nullable"); } this.sharedLinksViewedByOutsideUser = sharedLinksViewedByOutsideUser; if (sharedLinksViewedByNotLoggedIn == null) { @@ -234,7 +205,6 @@ public GetActivityReport(String startDate, List adds, List edits, Li if (x == null) { throw new IllegalArgumentException("An item in list 'sharedLinksViewedByNotLoggedIn' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'sharedLinksViewedByNotLoggedIn': type Nullable"); } this.sharedLinksViewedByNotLoggedIn = sharedLinksViewedByNotLoggedIn; if (sharedLinksViewedTotal == null) { @@ -244,7 +214,6 @@ public GetActivityReport(String startDate, List adds, List edits, Li if (x == null) { throw new IllegalArgumentException("An item in list 'sharedLinksViewedTotal' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'sharedLinksViewedTotal': type Nullable"); } this.sharedLinksViewedTotal = sharedLinksViewedTotal; } @@ -435,7 +404,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -447,330 +416,185 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetActivityReport.class); - } - - public Serializer(boolean unwrapping) { - super(GetActivityReport.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GetActivityReport value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("start_date", value.startDate); - g.writeObjectField("adds", value.adds); - g.writeObjectField("edits", value.edits); - g.writeObjectField("deletes", value.deletes); - g.writeObjectField("active_users_28_day", value.activeUsers28Day); - g.writeObjectField("active_users_7_day", value.activeUsers7Day); - g.writeObjectField("active_users_1_day", value.activeUsers1Day); - g.writeObjectField("active_shared_folders_28_day", value.activeSharedFolders28Day); - g.writeObjectField("active_shared_folders_7_day", value.activeSharedFolders7Day); - g.writeObjectField("active_shared_folders_1_day", value.activeSharedFolders1Day); - g.writeObjectField("shared_links_created", value.sharedLinksCreated); - g.writeObjectField("shared_links_viewed_by_team", value.sharedLinksViewedByTeam); - g.writeObjectField("shared_links_viewed_by_outside_user", value.sharedLinksViewedByOutsideUser); - g.writeObjectField("shared_links_viewed_by_not_logged_in", value.sharedLinksViewedByNotLoggedIn); - g.writeObjectField("shared_links_viewed_total", value.sharedLinksViewedTotal); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetActivityReport.class); - } - - public Deserializer(boolean unwrapping) { - super(GetActivityReport.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GetActivityReport value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("start_date"); + StoneSerializers.string().serialize(value.startDate, g); + g.writeFieldName("adds"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.adds, g); + g.writeFieldName("edits"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.edits, g); + g.writeFieldName("deletes"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.deletes, g); + g.writeFieldName("active_users_28_day"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.activeUsers28Day, g); + g.writeFieldName("active_users_7_day"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.activeUsers7Day, g); + g.writeFieldName("active_users_1_day"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.activeUsers1Day, g); + g.writeFieldName("active_shared_folders_28_day"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.activeSharedFolders28Day, g); + g.writeFieldName("active_shared_folders_7_day"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.activeSharedFolders7Day, g); + g.writeFieldName("active_shared_folders_1_day"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.activeSharedFolders1Day, g); + g.writeFieldName("shared_links_created"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.sharedLinksCreated, g); + g.writeFieldName("shared_links_viewed_by_team"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.sharedLinksViewedByTeam, g); + g.writeFieldName("shared_links_viewed_by_outside_user"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.sharedLinksViewedByOutsideUser, g); + g.writeFieldName("shared_links_viewed_by_not_logged_in"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.sharedLinksViewedByNotLoggedIn, g); + g.writeFieldName("shared_links_viewed_total"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.sharedLinksViewedTotal, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GetActivityReport deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String startDate = null; - List adds = null; - List edits = null; - List deletes = null; - List activeUsers28Day = null; - List activeUsers7Day = null; - List activeUsers1Day = null; - List activeSharedFolders28Day = null; - List activeSharedFolders7Day = null; - List activeSharedFolders1Day = null; - List sharedLinksCreated = null; - List sharedLinksViewedByTeam = null; - List sharedLinksViewedByOutsideUser = null; - List sharedLinksViewedByNotLoggedIn = null; - List sharedLinksViewedTotal = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("start_date".equals(_field)) { - startDate = getStringValue(_p); - _p.nextToken(); - } - else if ("adds".equals(_field)) { - expectArrayStart(_p); - adds = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - adds.add(_x); + public GetActivityReport deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GetActivityReport value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_startDate = null; + List f_adds = null; + List f_edits = null; + List f_deletes = null; + List f_activeUsers28Day = null; + List f_activeUsers7Day = null; + List f_activeUsers1Day = null; + List f_activeSharedFolders28Day = null; + List f_activeSharedFolders7Day = null; + List f_activeSharedFolders1Day = null; + List f_sharedLinksCreated = null; + List f_sharedLinksViewedByTeam = null; + List f_sharedLinksViewedByOutsideUser = null; + List f_sharedLinksViewedByNotLoggedIn = null; + List f_sharedLinksViewedTotal = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("start_date".equals(field)) { + f_startDate = StoneSerializers.string().deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("edits".equals(_field)) { - expectArrayStart(_p); - edits = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - edits.add(_x); + else if ("adds".equals(field)) { + f_adds = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("deletes".equals(_field)) { - expectArrayStart(_p); - deletes = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - deletes.add(_x); + else if ("edits".equals(field)) { + f_edits = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("active_users_28_day".equals(_field)) { - expectArrayStart(_p); - activeUsers28Day = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - activeUsers28Day.add(_x); + else if ("deletes".equals(field)) { + f_deletes = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("active_users_7_day".equals(_field)) { - expectArrayStart(_p); - activeUsers7Day = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - activeUsers7Day.add(_x); + else if ("active_users_28_day".equals(field)) { + f_activeUsers28Day = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("active_users_1_day".equals(_field)) { - expectArrayStart(_p); - activeUsers1Day = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - activeUsers1Day.add(_x); + else if ("active_users_7_day".equals(field)) { + f_activeUsers7Day = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("active_shared_folders_28_day".equals(_field)) { - expectArrayStart(_p); - activeSharedFolders28Day = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - activeSharedFolders28Day.add(_x); + else if ("active_users_1_day".equals(field)) { + f_activeUsers1Day = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("active_shared_folders_7_day".equals(_field)) { - expectArrayStart(_p); - activeSharedFolders7Day = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - activeSharedFolders7Day.add(_x); + else if ("active_shared_folders_28_day".equals(field)) { + f_activeSharedFolders28Day = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("active_shared_folders_1_day".equals(_field)) { - expectArrayStart(_p); - activeSharedFolders1Day = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - activeSharedFolders1Day.add(_x); + else if ("active_shared_folders_7_day".equals(field)) { + f_activeSharedFolders7Day = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("shared_links_created".equals(_field)) { - expectArrayStart(_p); - sharedLinksCreated = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - sharedLinksCreated.add(_x); + else if ("active_shared_folders_1_day".equals(field)) { + f_activeSharedFolders1Day = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("shared_links_viewed_by_team".equals(_field)) { - expectArrayStart(_p); - sharedLinksViewedByTeam = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - sharedLinksViewedByTeam.add(_x); + else if ("shared_links_created".equals(field)) { + f_sharedLinksCreated = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("shared_links_viewed_by_outside_user".equals(_field)) { - expectArrayStart(_p); - sharedLinksViewedByOutsideUser = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - sharedLinksViewedByOutsideUser.add(_x); + else if ("shared_links_viewed_by_team".equals(field)) { + f_sharedLinksViewedByTeam = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("shared_links_viewed_by_not_logged_in".equals(_field)) { - expectArrayStart(_p); - sharedLinksViewedByNotLoggedIn = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - sharedLinksViewedByNotLoggedIn.add(_x); + else if ("shared_links_viewed_by_outside_user".equals(field)) { + f_sharedLinksViewedByOutsideUser = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("shared_links_viewed_total".equals(_field)) { - expectArrayStart(_p); - sharedLinksViewedTotal = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - sharedLinksViewedTotal.add(_x); + else if ("shared_links_viewed_by_not_logged_in".equals(field)) { + f_sharedLinksViewedByNotLoggedIn = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); + } + else if ("shared_links_viewed_total".equals(field)) { + f_sharedLinksViewedTotal = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else { - skipValue(_p); + if (f_startDate == null) { + throw new JsonParseException(p, "Required field \"start_date\" missing."); } + if (f_adds == null) { + throw new JsonParseException(p, "Required field \"adds\" missing."); + } + if (f_edits == null) { + throw new JsonParseException(p, "Required field \"edits\" missing."); + } + if (f_deletes == null) { + throw new JsonParseException(p, "Required field \"deletes\" missing."); + } + if (f_activeUsers28Day == null) { + throw new JsonParseException(p, "Required field \"active_users_28_day\" missing."); + } + if (f_activeUsers7Day == null) { + throw new JsonParseException(p, "Required field \"active_users_7_day\" missing."); + } + if (f_activeUsers1Day == null) { + throw new JsonParseException(p, "Required field \"active_users_1_day\" missing."); + } + if (f_activeSharedFolders28Day == null) { + throw new JsonParseException(p, "Required field \"active_shared_folders_28_day\" missing."); + } + if (f_activeSharedFolders7Day == null) { + throw new JsonParseException(p, "Required field \"active_shared_folders_7_day\" missing."); + } + if (f_activeSharedFolders1Day == null) { + throw new JsonParseException(p, "Required field \"active_shared_folders_1_day\" missing."); + } + if (f_sharedLinksCreated == null) { + throw new JsonParseException(p, "Required field \"shared_links_created\" missing."); + } + if (f_sharedLinksViewedByTeam == null) { + throw new JsonParseException(p, "Required field \"shared_links_viewed_by_team\" missing."); + } + if (f_sharedLinksViewedByOutsideUser == null) { + throw new JsonParseException(p, "Required field \"shared_links_viewed_by_outside_user\" missing."); + } + if (f_sharedLinksViewedByNotLoggedIn == null) { + throw new JsonParseException(p, "Required field \"shared_links_viewed_by_not_logged_in\" missing."); + } + if (f_sharedLinksViewedTotal == null) { + throw new JsonParseException(p, "Required field \"shared_links_viewed_total\" missing."); + } + value = new GetActivityReport(f_startDate, f_adds, f_edits, f_deletes, f_activeUsers28Day, f_activeUsers7Day, f_activeUsers1Day, f_activeSharedFolders28Day, f_activeSharedFolders7Day, f_activeSharedFolders1Day, f_sharedLinksCreated, f_sharedLinksViewedByTeam, f_sharedLinksViewedByOutsideUser, f_sharedLinksViewedByNotLoggedIn, f_sharedLinksViewedTotal); } - - if (startDate == null) { - throw new JsonParseException(_p, "Required field \"start_date\" is missing."); - } - if (adds == null) { - throw new JsonParseException(_p, "Required field \"adds\" is missing."); - } - if (edits == null) { - throw new JsonParseException(_p, "Required field \"edits\" is missing."); - } - if (deletes == null) { - throw new JsonParseException(_p, "Required field \"deletes\" is missing."); - } - if (activeUsers28Day == null) { - throw new JsonParseException(_p, "Required field \"active_users_28_day\" is missing."); - } - if (activeUsers7Day == null) { - throw new JsonParseException(_p, "Required field \"active_users_7_day\" is missing."); - } - if (activeUsers1Day == null) { - throw new JsonParseException(_p, "Required field \"active_users_1_day\" is missing."); - } - if (activeSharedFolders28Day == null) { - throw new JsonParseException(_p, "Required field \"active_shared_folders_28_day\" is missing."); - } - if (activeSharedFolders7Day == null) { - throw new JsonParseException(_p, "Required field \"active_shared_folders_7_day\" is missing."); - } - if (activeSharedFolders1Day == null) { - throw new JsonParseException(_p, "Required field \"active_shared_folders_1_day\" is missing."); - } - if (sharedLinksCreated == null) { - throw new JsonParseException(_p, "Required field \"shared_links_created\" is missing."); - } - if (sharedLinksViewedByTeam == null) { - throw new JsonParseException(_p, "Required field \"shared_links_viewed_by_team\" is missing."); - } - if (sharedLinksViewedByOutsideUser == null) { - throw new JsonParseException(_p, "Required field \"shared_links_viewed_by_outside_user\" is missing."); - } - if (sharedLinksViewedByNotLoggedIn == null) { - throw new JsonParseException(_p, "Required field \"shared_links_viewed_by_not_logged_in\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (sharedLinksViewedTotal == null) { - throw new JsonParseException(_p, "Required field \"shared_links_viewed_total\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new GetActivityReport(startDate, adds, edits, deletes, activeUsers28Day, activeUsers7Day, activeUsers1Day, activeSharedFolders28Day, activeSharedFolders7Day, activeSharedFolders1Day, sharedLinksCreated, sharedLinksViewedByTeam, sharedLinksViewedByOutsideUser, sharedLinksViewedByNotLoggedIn, sharedLinksViewedTotal); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GetDevicesReport.java b/src/main/java/com/dropbox/core/v2/team/GetDevicesReport.java index 0616dbaba..25181ed34 100644 --- a/src/main/java/com/dropbox/core/v2/team/GetDevicesReport.java +++ b/src/main/java/com/dropbox/core/v2/team/GetDevicesReport.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from team_reports.babel */ +/* This file was generated from team_reports.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; @@ -31,15 +20,9 @@ * array of values, one value per day. If there is no data for a day, then the * value will be None. */ -@JsonSerialize(using=GetDevicesReport.Serializer.class) -@JsonDeserialize(using=GetDevicesReport.Deserializer.class) public class GetDevicesReport extends BaseDfbReport { // struct GetDevicesReport - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final DevicesActive active1Day; protected final DevicesActive active7Day; protected final DevicesActive active28Day; @@ -137,7 +120,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -149,105 +132,86 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetDevicesReport.class); - } - - public Serializer(boolean unwrapping) { - super(GetDevicesReport.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GetDevicesReport value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("start_date", value.startDate); - g.writeObjectField("active_1_day", value.active1Day); - g.writeObjectField("active_7_day", value.active7Day); - g.writeObjectField("active_28_day", value.active28Day); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetDevicesReport.class); - } - - public Deserializer(boolean unwrapping) { - super(GetDevicesReport.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GetDevicesReport value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("start_date"); + StoneSerializers.string().serialize(value.startDate, g); + g.writeFieldName("active_1_day"); + DevicesActive.Serializer.INSTANCE.serialize(value.active1Day, g); + g.writeFieldName("active_7_day"); + DevicesActive.Serializer.INSTANCE.serialize(value.active7Day, g); + g.writeFieldName("active_28_day"); + DevicesActive.Serializer.INSTANCE.serialize(value.active28Day, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GetDevicesReport deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String startDate = null; - DevicesActive active1Day = null; - DevicesActive active7Day = null; - DevicesActive active28Day = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("start_date".equals(_field)) { - startDate = getStringValue(_p); - _p.nextToken(); + public GetDevicesReport deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GetDevicesReport value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_startDate = null; + DevicesActive f_active1Day = null; + DevicesActive f_active7Day = null; + DevicesActive f_active28Day = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("start_date".equals(field)) { + f_startDate = StoneSerializers.string().deserialize(p); + } + else if ("active_1_day".equals(field)) { + f_active1Day = DevicesActive.Serializer.INSTANCE.deserialize(p); + } + else if ("active_7_day".equals(field)) { + f_active7Day = DevicesActive.Serializer.INSTANCE.deserialize(p); + } + else if ("active_28_day".equals(field)) { + f_active28Day = DevicesActive.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else if ("active_1_day".equals(_field)) { - active1Day = _p.readValueAs(DevicesActive.class); - _p.nextToken(); + if (f_startDate == null) { + throw new JsonParseException(p, "Required field \"start_date\" missing."); } - else if ("active_7_day".equals(_field)) { - active7Day = _p.readValueAs(DevicesActive.class); - _p.nextToken(); + if (f_active1Day == null) { + throw new JsonParseException(p, "Required field \"active_1_day\" missing."); } - else if ("active_28_day".equals(_field)) { - active28Day = _p.readValueAs(DevicesActive.class); - _p.nextToken(); + if (f_active7Day == null) { + throw new JsonParseException(p, "Required field \"active_7_day\" missing."); } - else { - skipValue(_p); + if (f_active28Day == null) { + throw new JsonParseException(p, "Required field \"active_28_day\" missing."); } + value = new GetDevicesReport(f_startDate, f_active1Day, f_active7Day, f_active28Day); } - - if (startDate == null) { - throw new JsonParseException(_p, "Required field \"start_date\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (active1Day == null) { - throw new JsonParseException(_p, "Required field \"active_1_day\" is missing."); + if (!collapsed) { + expectEndObject(p); } - if (active7Day == null) { - throw new JsonParseException(_p, "Required field \"active_7_day\" is missing."); - } - if (active28Day == null) { - throw new JsonParseException(_p, "Required field \"active_28_day\" is missing."); - } - - return new GetDevicesReport(startDate, active1Day, active7Day, active28Day); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GetMembershipReport.java b/src/main/java/com/dropbox/core/v2/team/GetMembershipReport.java index ef57247c1..adf743b09 100644 --- a/src/main/java/com/dropbox/core/v2/team/GetMembershipReport.java +++ b/src/main/java/com/dropbox/core/v2/team/GetMembershipReport.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from team_reports.babel */ +/* This file was generated from team_reports.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; @@ -31,15 +20,9 @@ * of values, one value per day. If there is no data for a day, then the value * will be None. */ -@JsonSerialize(using=GetMembershipReport.Serializer.class) -@JsonDeserialize(using=GetMembershipReport.Deserializer.class) public class GetMembershipReport extends BaseDfbReport { // struct GetMembershipReport - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List teamSize; protected final List pendingInvites; protected final List membersJoined; @@ -78,7 +61,6 @@ public GetMembershipReport(String startDate, List teamSize, List pen if (x == null) { throw new IllegalArgumentException("An item in list 'teamSize' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'teamSize': type Nullable"); } this.teamSize = teamSize; if (pendingInvites == null) { @@ -88,7 +70,6 @@ public GetMembershipReport(String startDate, List teamSize, List pen if (x == null) { throw new IllegalArgumentException("An item in list 'pendingInvites' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'pendingInvites': type Nullable"); } this.pendingInvites = pendingInvites; if (membersJoined == null) { @@ -98,7 +79,6 @@ public GetMembershipReport(String startDate, List teamSize, List pen if (x == null) { throw new IllegalArgumentException("An item in list 'membersJoined' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'membersJoined': type Nullable"); } this.membersJoined = membersJoined; if (suspendedMembers == null) { @@ -108,7 +88,6 @@ public GetMembershipReport(String startDate, List teamSize, List pen if (x == null) { throw new IllegalArgumentException("An item in list 'suspendedMembers' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'suspendedMembers': type Nullable"); } this.suspendedMembers = suspendedMembers; if (licenses == null) { @@ -118,7 +97,6 @@ public GetMembershipReport(String startDate, List teamSize, List pen if (x == null) { throw new IllegalArgumentException("An item in list 'licenses' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'licenses': type Nullable"); } this.licenses = licenses; } @@ -204,7 +182,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -216,168 +194,104 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetMembershipReport.class); - } - - public Serializer(boolean unwrapping) { - super(GetMembershipReport.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GetMembershipReport value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("start_date", value.startDate); - g.writeObjectField("team_size", value.teamSize); - g.writeObjectField("pending_invites", value.pendingInvites); - g.writeObjectField("members_joined", value.membersJoined); - g.writeObjectField("suspended_members", value.suspendedMembers); - g.writeObjectField("licenses", value.licenses); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetMembershipReport.class); - } - - public Deserializer(boolean unwrapping) { - super(GetMembershipReport.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GetMembershipReport value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("start_date"); + StoneSerializers.string().serialize(value.startDate, g); + g.writeFieldName("team_size"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.teamSize, g); + g.writeFieldName("pending_invites"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.pendingInvites, g); + g.writeFieldName("members_joined"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.membersJoined, g); + g.writeFieldName("suspended_members"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.suspendedMembers, g); + g.writeFieldName("licenses"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.licenses, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GetMembershipReport deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String startDate = null; - List teamSize = null; - List pendingInvites = null; - List membersJoined = null; - List suspendedMembers = null; - List licenses = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("start_date".equals(_field)) { - startDate = getStringValue(_p); - _p.nextToken(); - } - else if ("team_size".equals(_field)) { - expectArrayStart(_p); - teamSize = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - teamSize.add(_x); + public GetMembershipReport deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GetMembershipReport value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_startDate = null; + List f_teamSize = null; + List f_pendingInvites = null; + List f_membersJoined = null; + List f_suspendedMembers = null; + List f_licenses = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("start_date".equals(field)) { + f_startDate = StoneSerializers.string().deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("pending_invites".equals(_field)) { - expectArrayStart(_p); - pendingInvites = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - pendingInvites.add(_x); + else if ("team_size".equals(field)) { + f_teamSize = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("members_joined".equals(_field)) { - expectArrayStart(_p); - membersJoined = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - membersJoined.add(_x); + else if ("pending_invites".equals(field)) { + f_pendingInvites = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("suspended_members".equals(_field)) { - expectArrayStart(_p); - suspendedMembers = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - suspendedMembers.add(_x); + else if ("members_joined".equals(field)) { + f_membersJoined = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("licenses".equals(_field)) { - expectArrayStart(_p); - licenses = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - licenses.add(_x); + else if ("suspended_members".equals(field)) { + f_suspendedMembers = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); + } + else if ("licenses".equals(field)) { + f_licenses = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else { - skipValue(_p); + if (f_startDate == null) { + throw new JsonParseException(p, "Required field \"start_date\" missing."); } + if (f_teamSize == null) { + throw new JsonParseException(p, "Required field \"team_size\" missing."); + } + if (f_pendingInvites == null) { + throw new JsonParseException(p, "Required field \"pending_invites\" missing."); + } + if (f_membersJoined == null) { + throw new JsonParseException(p, "Required field \"members_joined\" missing."); + } + if (f_suspendedMembers == null) { + throw new JsonParseException(p, "Required field \"suspended_members\" missing."); + } + if (f_licenses == null) { + throw new JsonParseException(p, "Required field \"licenses\" missing."); + } + value = new GetMembershipReport(f_startDate, f_teamSize, f_pendingInvites, f_membersJoined, f_suspendedMembers, f_licenses); } - - if (startDate == null) { - throw new JsonParseException(_p, "Required field \"start_date\" is missing."); - } - if (teamSize == null) { - throw new JsonParseException(_p, "Required field \"team_size\" is missing."); - } - if (pendingInvites == null) { - throw new JsonParseException(_p, "Required field \"pending_invites\" is missing."); - } - if (membersJoined == null) { - throw new JsonParseException(_p, "Required field \"members_joined\" is missing."); - } - if (suspendedMembers == null) { - throw new JsonParseException(_p, "Required field \"suspended_members\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (licenses == null) { - throw new JsonParseException(_p, "Required field \"licenses\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new GetMembershipReport(startDate, teamSize, pendingInvites, membersJoined, suspendedMembers, licenses); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GetStorageReport.java b/src/main/java/com/dropbox/core/v2/team/GetStorageReport.java index cf48dabd0..f421fed32 100644 --- a/src/main/java/com/dropbox/core/v2/team/GetStorageReport.java +++ b/src/main/java/com/dropbox/core/v2/team/GetStorageReport.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from team_reports.babel */ +/* This file was generated from team_reports.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; @@ -31,15 +20,9 @@ * values, one value per day. If there is no data for a day, then the value will * be None. */ -@JsonSerialize(using=GetStorageReport.Serializer.class) -@JsonDeserialize(using=GetStorageReport.Deserializer.class) public class GetStorageReport extends BaseDfbReport { // struct GetStorageReport - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List totalUsage; protected final List sharedUsage; protected final List unsharedUsage; @@ -85,7 +68,6 @@ public GetStorageReport(String startDate, List totalUsage, List shar if (x == null) { throw new IllegalArgumentException("An item in list 'totalUsage' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'totalUsage': type Nullable"); } this.totalUsage = totalUsage; if (sharedUsage == null) { @@ -95,7 +77,6 @@ public GetStorageReport(String startDate, List totalUsage, List shar if (x == null) { throw new IllegalArgumentException("An item in list 'sharedUsage' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'sharedUsage': type Nullable"); } this.sharedUsage = sharedUsage; if (unsharedUsage == null) { @@ -105,7 +86,6 @@ public GetStorageReport(String startDate, List totalUsage, List shar if (x == null) { throw new IllegalArgumentException("An item in list 'unsharedUsage' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'unsharedUsage': type Nullable"); } this.unsharedUsage = unsharedUsage; if (sharedFolders == null) { @@ -115,7 +95,6 @@ public GetStorageReport(String startDate, List totalUsage, List shar if (x == null) { throw new IllegalArgumentException("An item in list 'sharedFolders' is null"); } - throw new RuntimeException("XXX Don't know how to validate an item in list 'sharedFolders': type Nullable"); } this.sharedFolders = sharedFolders; if (memberStorageMap == null) { @@ -223,7 +202,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -235,175 +214,104 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetStorageReport.class); - } - - public Serializer(boolean unwrapping) { - super(GetStorageReport.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GetStorageReport value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("start_date", value.startDate); - g.writeObjectField("total_usage", value.totalUsage); - g.writeObjectField("shared_usage", value.sharedUsage); - g.writeObjectField("unshared_usage", value.unsharedUsage); - g.writeObjectField("shared_folders", value.sharedFolders); - g.writeObjectField("member_storage_map", value.memberStorageMap); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetStorageReport.class); - } - - public Deserializer(boolean unwrapping) { - super(GetStorageReport.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GetStorageReport value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("start_date"); + StoneSerializers.string().serialize(value.startDate, g); + g.writeFieldName("total_usage"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.totalUsage, g); + g.writeFieldName("shared_usage"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.sharedUsage, g); + g.writeFieldName("unshared_usage"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.unsharedUsage, g); + g.writeFieldName("shared_folders"); + StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).serialize(value.sharedFolders, g); + g.writeFieldName("member_storage_map"); + StoneSerializers.list(StoneSerializers.list(StorageBucket.Serializer.INSTANCE)).serialize(value.memberStorageMap, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GetStorageReport deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String startDate = null; - List totalUsage = null; - List sharedUsage = null; - List unsharedUsage = null; - List sharedFolders = null; - List> memberStorageMap = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("start_date".equals(_field)) { - startDate = getStringValue(_p); - _p.nextToken(); - } - else if ("total_usage".equals(_field)) { - expectArrayStart(_p); - totalUsage = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - totalUsage.add(_x); + public GetStorageReport deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GetStorageReport value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_startDate = null; + List f_totalUsage = null; + List f_sharedUsage = null; + List f_unsharedUsage = null; + List f_sharedFolders = null; + List> f_memberStorageMap = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("start_date".equals(field)) { + f_startDate = StoneSerializers.string().deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("shared_usage".equals(_field)) { - expectArrayStart(_p); - sharedUsage = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - sharedUsage.add(_x); + else if ("total_usage".equals(field)) { + f_totalUsage = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("unshared_usage".equals(_field)) { - expectArrayStart(_p); - unsharedUsage = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - unsharedUsage.add(_x); + else if ("shared_usage".equals(field)) { + f_sharedUsage = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("shared_folders".equals(_field)) { - expectArrayStart(_p); - sharedFolders = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - Long _x = null; - _x = _p.getLongValue(); - assertUnsigned(_p, _x); - _p.nextToken(); - sharedFolders.add(_x); + else if ("unshared_usage".equals(field)) { + f_unsharedUsage = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("member_storage_map".equals(_field)) { - expectArrayStart(_p); - memberStorageMap = new java.util.ArrayList>(); - while (!isArrayEnd(_p)) { - List _x = null; - expectArrayStart(_p); - _x = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - StorageBucket _x1 = null; - _x1 = _p.readValueAs(StorageBucket.class); - _p.nextToken(); - _x.add(_x1); - } - expectArrayEnd(_p); - _p.nextToken(); - memberStorageMap.add(_x); + else if ("shared_folders".equals(field)) { + f_sharedFolders = StoneSerializers.list(StoneSerializers.nullable(StoneSerializers.uInt64())).deserialize(p); + } + else if ("member_storage_map".equals(field)) { + f_memberStorageMap = StoneSerializers.list(StoneSerializers.list(StorageBucket.Serializer.INSTANCE)).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else { - skipValue(_p); + if (f_startDate == null) { + throw new JsonParseException(p, "Required field \"start_date\" missing."); } + if (f_totalUsage == null) { + throw new JsonParseException(p, "Required field \"total_usage\" missing."); + } + if (f_sharedUsage == null) { + throw new JsonParseException(p, "Required field \"shared_usage\" missing."); + } + if (f_unsharedUsage == null) { + throw new JsonParseException(p, "Required field \"unshared_usage\" missing."); + } + if (f_sharedFolders == null) { + throw new JsonParseException(p, "Required field \"shared_folders\" missing."); + } + if (f_memberStorageMap == null) { + throw new JsonParseException(p, "Required field \"member_storage_map\" missing."); + } + value = new GetStorageReport(f_startDate, f_totalUsage, f_sharedUsage, f_unsharedUsage, f_sharedFolders, f_memberStorageMap); } - - if (startDate == null) { - throw new JsonParseException(_p, "Required field \"start_date\" is missing."); - } - if (totalUsage == null) { - throw new JsonParseException(_p, "Required field \"total_usage\" is missing."); - } - if (sharedUsage == null) { - throw new JsonParseException(_p, "Required field \"shared_usage\" is missing."); - } - if (unsharedUsage == null) { - throw new JsonParseException(_p, "Required field \"unshared_usage\" is missing."); - } - if (sharedFolders == null) { - throw new JsonParseException(_p, "Required field \"shared_folders\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (memberStorageMap == null) { - throw new JsonParseException(_p, "Required field \"member_storage_map\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new GetStorageReport(startDate, totalUsage, sharedUsage, unsharedUsage, sharedFolders, memberStorageMap); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupAccessType.java b/src/main/java/com/dropbox/core/v2/team/GroupAccessType.java index 8ccb544a5..772286352 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupAccessType.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupAccessType.java @@ -1,36 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Role of a user in group. */ -@JsonSerialize(using=GroupAccessType.Serializer.class) -@JsonDeserialize(using=GroupAccessType.Deserializer.class) public enum GroupAccessType { // union GroupAccessType /** @@ -38,51 +24,64 @@ public enum GroupAccessType { */ MEMBER, /** - * A group owner can rename the group, and add/remove members. + * User can rename the group, and add/remove members. */ OWNER; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupAccessType.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GroupAccessType value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(GroupAccessType value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case MEMBER: + case MEMBER: { g.writeString("member"); break; - case OWNER: + } + case OWNER: { g.writeString("owner"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupAccessType.class, getTagMapping(), null); - } @Override - public GroupAccessType deserialize(GroupAccessType _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("member", GroupAccessType.MEMBER); - values.put("owner", GroupAccessType.OWNER); - return Collections.unmodifiableMap(values); + public GroupAccessType deserialize(JsonParser p) throws IOException, JsonParseException { + GroupAccessType value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("member".equals(tag)) { + value = GroupAccessType.MEMBER; + } + else if ("owner".equals(tag)) { + value = GroupAccessType.OWNER; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupCreateArg.java b/src/main/java/com/dropbox/core/v2/team/GroupCreateArg.java index cf87b6a3f..dec1fdf78 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupCreateArg.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupCreateArg.java @@ -1,47 +1,30 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=GroupCreateArg.Serializer.class) -@JsonDeserialize(using=GroupCreateArg.Deserializer.class) -class GroupCreateArg { +public class GroupCreateArg { // struct GroupCreateArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String groupName; protected final String groupExternalId; /** * * @param groupName Group name. Must not be {@code null}. - * @param groupExternalId Optional argument. The creator of a team can - * associate an arbitrary external ID to the group. + * @param groupExternalId The creator of a team can associate an arbitrary + * external ID to the group. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -76,8 +59,8 @@ public String getGroupName() { } /** - * Optional argument. The creator of a team can associate an arbitrary - * external ID to the group. + * The creator of a team can associate an arbitrary external ID to the + * group. * * @return value for this field, or {@code null} if not present. */ @@ -113,7 +96,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -125,86 +108,67 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupCreateArg.class); - } - - public Serializer(boolean unwrapping) { - super(GroupCreateArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(GroupCreateArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("group_name", value.groupName); + public void serialize(GroupCreateArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("group_name"); + StoneSerializers.string().serialize(value.groupName, g); if (value.groupExternalId != null) { - g.writeObjectField("group_external_id", value.groupExternalId); + g.writeFieldName("group_external_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.groupExternalId, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupCreateArg.class); - } - - public Deserializer(boolean unwrapping) { - super(GroupCreateArg.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public GroupCreateArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String groupName = null; - String groupExternalId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("group_name".equals(_field)) { - groupName = getStringValue(_p); - _p.nextToken(); - } - else if ("group_external_id".equals(_field)) { - groupExternalId = getStringValue(_p); - _p.nextToken(); + public GroupCreateArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GroupCreateArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_groupName = null; + String f_groupExternalId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("group_name".equals(field)) { + f_groupName = StoneSerializers.string().deserialize(p); + } + else if ("group_external_id".equals(field)) { + f_groupExternalId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_groupName == null) { + throw new JsonParseException(p, "Required field \"group_name\" missing."); } + value = new GroupCreateArg(f_groupName, f_groupExternalId); } - - if (groupName == null) { - throw new JsonParseException(_p, "Required field \"group_name\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new GroupCreateArg(groupName, groupExternalId); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupCreateError.java b/src/main/java/com/dropbox/core/v2/team/GroupCreateError.java index 16c864ade..9b738332a 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupCreateError.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupCreateError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=GroupCreateError.Serializer.class) -@JsonDeserialize(using=GroupCreateError.Deserializer.class) public enum GroupCreateError { // union GroupCreateError /** @@ -51,55 +37,68 @@ public enum GroupCreateError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupCreateError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GroupCreateError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(GroupCreateError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case GROUP_NAME_ALREADY_USED: + case GROUP_NAME_ALREADY_USED: { g.writeString("group_name_already_used"); break; - case GROUP_NAME_INVALID: + } + case GROUP_NAME_INVALID: { g.writeString("group_name_invalid"); break; - case EXTERNAL_ID_ALREADY_IN_USE: + } + case EXTERNAL_ID_ALREADY_IN_USE: { g.writeString("external_id_already_in_use"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupCreateError.class, getTagMapping(), GroupCreateError.OTHER); - } @Override - public GroupCreateError deserialize(GroupCreateError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("group_name_already_used", GroupCreateError.GROUP_NAME_ALREADY_USED); - values.put("group_name_invalid", GroupCreateError.GROUP_NAME_INVALID); - values.put("external_id_already_in_use", GroupCreateError.EXTERNAL_ID_ALREADY_IN_USE); - values.put("other", GroupCreateError.OTHER); - return Collections.unmodifiableMap(values); + public GroupCreateError deserialize(JsonParser p) throws IOException, JsonParseException { + GroupCreateError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("group_name_already_used".equals(tag)) { + value = GroupCreateError.GROUP_NAME_ALREADY_USED; + } + else if ("group_name_invalid".equals(tag)) { + value = GroupCreateError.GROUP_NAME_INVALID; + } + else if ("external_id_already_in_use".equals(tag)) { + value = GroupCreateError.EXTERNAL_ID_ALREADY_IN_USE; + } + else { + value = GroupCreateError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupCreateErrorException.java b/src/main/java/com/dropbox/core/v2/team/GroupCreateErrorException.java index 0f4816d5e..a32d665ad 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupCreateErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupCreateErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/GroupDeleteError.java b/src/main/java/com/dropbox/core/v2/team/GroupDeleteError.java index 76483114f..b2f4ada07 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupDeleteError.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupDeleteError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=GroupDeleteError.Serializer.class) -@JsonDeserialize(using=GroupDeleteError.Deserializer.class) public enum GroupDeleteError { // union GroupDeleteError /** @@ -40,49 +26,67 @@ public enum GroupDeleteError { */ GROUP_ALREADY_DELETED; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupDeleteError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GroupDeleteError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(GroupDeleteError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case GROUP_NOT_FOUND: + case GROUP_NOT_FOUND: { g.writeString("group_not_found"); break; - case OTHER: + } + case OTHER: { g.writeString("other"); break; - case GROUP_ALREADY_DELETED: + } + case GROUP_ALREADY_DELETED: { g.writeString("group_already_deleted"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupDeleteError.class, getTagMapping(), null); - } @Override - public GroupDeleteError deserialize(GroupDeleteError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("group_already_deleted", GroupDeleteError.GROUP_ALREADY_DELETED); - return Collections.unmodifiableMap(values); + public GroupDeleteError deserialize(JsonParser p) throws IOException, JsonParseException { + GroupDeleteError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("group_not_found".equals(tag)) { + value = GroupDeleteError.GROUP_NOT_FOUND; + } + else if ("other".equals(tag)) { + value = GroupDeleteError.OTHER; + } + else if ("group_already_deleted".equals(tag)) { + value = GroupDeleteError.GROUP_ALREADY_DELETED; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupDeleteErrorException.java b/src/main/java/com/dropbox/core/v2/team/GroupDeleteErrorException.java index 3ab8bd87e..6c35590ed 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupDeleteErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupDeleteErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/GroupFullInfo.java b/src/main/java/com/dropbox/core/v2/team/GroupFullInfo.java index 86197ae99..ce6aad04a 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupFullInfo.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupFullInfo.java @@ -1,27 +1,17 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; +import com.dropbox.core.v2.teamcommon.GroupSummary; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; @@ -29,15 +19,9 @@ /** * Full description of a group. */ -@JsonSerialize(using=GroupFullInfo.Serializer.class) -@JsonDeserialize(using=GroupFullInfo.Deserializer.class) public class GroupFullInfo extends GroupSummary { // struct GroupFullInfo - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List members; protected final long created; @@ -207,7 +191,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -219,133 +203,101 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupFullInfo.class); - } - - public Serializer(boolean unwrapping) { - super(GroupFullInfo.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(GroupFullInfo value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("group_name", value.groupName); - g.writeObjectField("group_id", value.groupId); - g.writeObjectField("created", value.created); + public void serialize(GroupFullInfo value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("group_name"); + StoneSerializers.string().serialize(value.groupName, g); + g.writeFieldName("group_id"); + StoneSerializers.string().serialize(value.groupId, g); + g.writeFieldName("created"); + StoneSerializers.uInt64().serialize(value.created, g); if (value.groupExternalId != null) { - g.writeObjectField("group_external_id", value.groupExternalId); + g.writeFieldName("group_external_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.groupExternalId, g); } if (value.memberCount != null) { - g.writeObjectField("member_count", value.memberCount); + g.writeFieldName("member_count"); + StoneSerializers.nullable(StoneSerializers.uInt32()).serialize(value.memberCount, g); } if (value.members != null) { - g.writeObjectField("members", value.members); + g.writeFieldName("members"); + StoneSerializers.nullable(StoneSerializers.list(GroupMemberInfo.Serializer.INSTANCE)).serialize(value.members, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupFullInfo.class); - } - - public Deserializer(boolean unwrapping) { - super(GroupFullInfo.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public GroupFullInfo deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String groupName = null; - String groupId = null; - Long created = null; - String groupExternalId = null; - Long memberCount = null; - List members = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("group_name".equals(_field)) { - groupName = getStringValue(_p); - _p.nextToken(); - } - else if ("group_id".equals(_field)) { - groupId = getStringValue(_p); - _p.nextToken(); - } - else if ("created".equals(_field)) { - created = _p.getLongValue(); - assertUnsigned(_p, created); - _p.nextToken(); - } - else if ("group_external_id".equals(_field)) { - groupExternalId = getStringValue(_p); - _p.nextToken(); - } - else if ("member_count".equals(_field)) { - memberCount = _p.getLongValue(); - assertUnsigned(_p, memberCount); - if (memberCount > Integer.MAX_VALUE) { - throw new JsonParseException(_p, "expecting a 32-bit unsigned integer, got: " + memberCount); + public GroupFullInfo deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GroupFullInfo value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_groupName = null; + String f_groupId = null; + Long f_created = null; + String f_groupExternalId = null; + Long f_memberCount = null; + List f_members = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("group_name".equals(field)) { + f_groupName = StoneSerializers.string().deserialize(p); } - _p.nextToken(); - } - else if ("members".equals(_field)) { - expectArrayStart(_p); - members = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - GroupMemberInfo _x = null; - _x = _p.readValueAs(GroupMemberInfo.class); - _p.nextToken(); - members.add(_x); + else if ("group_id".equals(field)) { + f_groupId = StoneSerializers.string().deserialize(p); + } + else if ("created".equals(field)) { + f_created = StoneSerializers.uInt64().deserialize(p); + } + else if ("group_external_id".equals(field)) { + f_groupExternalId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("member_count".equals(field)) { + f_memberCount = StoneSerializers.nullable(StoneSerializers.uInt32()).deserialize(p); + } + else if ("members".equals(field)) { + f_members = StoneSerializers.nullable(StoneSerializers.list(GroupMemberInfo.Serializer.INSTANCE)).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else { - skipValue(_p); + if (f_groupName == null) { + throw new JsonParseException(p, "Required field \"group_name\" missing."); } + if (f_groupId == null) { + throw new JsonParseException(p, "Required field \"group_id\" missing."); + } + if (f_created == null) { + throw new JsonParseException(p, "Required field \"created\" missing."); + } + value = new GroupFullInfo(f_groupName, f_groupId, f_created, f_groupExternalId, f_memberCount, f_members); } - - if (groupName == null) { - throw new JsonParseException(_p, "Required field \"group_name\" is missing."); - } - if (groupId == null) { - throw new JsonParseException(_p, "Required field \"group_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (created == null) { - throw new JsonParseException(_p, "Required field \"created\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new GroupFullInfo(groupName, groupId, created, groupExternalId, memberCount, members); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupMemberInfo.java b/src/main/java/com/dropbox/core/v2/team/GroupMemberInfo.java index b7ca5a43a..f0ee132ca 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupMemberInfo.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupMemberInfo.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Profile of group member, and role in group. */ -@JsonSerialize(using=GroupMemberInfo.Serializer.class) -@JsonDeserialize(using=GroupMemberInfo.Deserializer.class) public class GroupMemberInfo { // struct GroupMemberInfo - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final MemberProfile profile; protected final GroupAccessType accessType; @@ -107,7 +90,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -119,87 +102,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupMemberInfo.class); - } - - public Serializer(boolean unwrapping) { - super(GroupMemberInfo.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GroupMemberInfo value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("profile", value.profile); - g.writeObjectField("access_type", value.accessType); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupMemberInfo.class); - } - - public Deserializer(boolean unwrapping) { - super(GroupMemberInfo.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GroupMemberInfo value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("profile"); + MemberProfile.Serializer.INSTANCE.serialize(value.profile, g); + g.writeFieldName("access_type"); + GroupAccessType.Serializer.INSTANCE.serialize(value.accessType, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GroupMemberInfo deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - MemberProfile profile = null; - GroupAccessType accessType = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("profile".equals(_field)) { - profile = _p.readValueAs(MemberProfile.class); - _p.nextToken(); + public GroupMemberInfo deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GroupMemberInfo value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + MemberProfile f_profile = null; + GroupAccessType f_accessType = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("profile".equals(field)) { + f_profile = MemberProfile.Serializer.INSTANCE.deserialize(p); + } + else if ("access_type".equals(field)) { + f_accessType = GroupAccessType.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else if ("access_type".equals(_field)) { - accessType = _p.readValueAs(GroupAccessType.class); - _p.nextToken(); + if (f_profile == null) { + throw new JsonParseException(p, "Required field \"profile\" missing."); } - else { - skipValue(_p); + if (f_accessType == null) { + throw new JsonParseException(p, "Required field \"access_type\" missing."); } + value = new GroupMemberInfo(f_profile, f_accessType); } - - if (profile == null) { - throw new JsonParseException(_p, "Required field \"profile\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (accessType == null) { - throw new JsonParseException(_p, "Required field \"access_type\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new GroupMemberInfo(profile, accessType); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupMemberSelector.java b/src/main/java/com/dropbox/core/v2/team/GroupMemberSelector.java index bcea94b8a..b2b744c47 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupMemberSelector.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupMemberSelector.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Argument for selecting a group and a single user. */ -@JsonSerialize(using=GroupMemberSelector.Serializer.class) -@JsonDeserialize(using=GroupMemberSelector.Deserializer.class) public class GroupMemberSelector { // struct GroupMemberSelector - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final GroupSelector group; protected final UserSelectorArg user; @@ -108,7 +91,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -120,87 +103,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupMemberSelector.class); - } - - public Serializer(boolean unwrapping) { - super(GroupMemberSelector.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GroupMemberSelector value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("group", value.group); - g.writeObjectField("user", value.user); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupMemberSelector.class); - } - - public Deserializer(boolean unwrapping) { - super(GroupMemberSelector.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GroupMemberSelector value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("group"); + GroupSelector.Serializer.INSTANCE.serialize(value.group, g); + g.writeFieldName("user"); + UserSelectorArg.Serializer.INSTANCE.serialize(value.user, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GroupMemberSelector deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - GroupSelector group = null; - UserSelectorArg user = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("group".equals(_field)) { - group = _p.readValueAs(GroupSelector.class); - _p.nextToken(); + public GroupMemberSelector deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GroupMemberSelector value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + GroupSelector f_group = null; + UserSelectorArg f_user = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("group".equals(field)) { + f_group = GroupSelector.Serializer.INSTANCE.deserialize(p); + } + else if ("user".equals(field)) { + f_user = UserSelectorArg.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else if ("user".equals(_field)) { - user = _p.readValueAs(UserSelectorArg.class); - _p.nextToken(); + if (f_group == null) { + throw new JsonParseException(p, "Required field \"group\" missing."); } - else { - skipValue(_p); + if (f_user == null) { + throw new JsonParseException(p, "Required field \"user\" missing."); } + value = new GroupMemberSelector(f_group, f_user); } - - if (group == null) { - throw new JsonParseException(_p, "Required field \"group\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (user == null) { - throw new JsonParseException(_p, "Required field \"user\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new GroupMemberSelector(group, user); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupMemberSelectorError.java b/src/main/java/com/dropbox/core/v2/team/GroupMemberSelectorError.java index f3f4584ea..63089edb1 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupMemberSelectorError.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupMemberSelectorError.java @@ -1,37 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Error that can be raised when {@link GroupMemberSelector} is used, and the * user is required to be a member of the specified group. */ -@JsonSerialize(using=GroupMemberSelectorError.Serializer.class) -@JsonDeserialize(using=GroupMemberSelectorError.Deserializer.class) public enum GroupMemberSelectorError { // union GroupMemberSelectorError /** @@ -44,49 +30,67 @@ public enum GroupMemberSelectorError { */ MEMBER_NOT_IN_GROUP; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupMemberSelectorError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GroupMemberSelectorError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(GroupMemberSelectorError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case GROUP_NOT_FOUND: + case GROUP_NOT_FOUND: { g.writeString("group_not_found"); break; - case OTHER: + } + case OTHER: { g.writeString("other"); break; - case MEMBER_NOT_IN_GROUP: + } + case MEMBER_NOT_IN_GROUP: { g.writeString("member_not_in_group"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupMemberSelectorError.class, getTagMapping(), null); - } @Override - public GroupMemberSelectorError deserialize(GroupMemberSelectorError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("member_not_in_group", GroupMemberSelectorError.MEMBER_NOT_IN_GROUP); - return Collections.unmodifiableMap(values); + public GroupMemberSelectorError deserialize(JsonParser p) throws IOException, JsonParseException { + GroupMemberSelectorError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("group_not_found".equals(tag)) { + value = GroupMemberSelectorError.GROUP_NOT_FOUND; + } + else if ("other".equals(tag)) { + value = GroupMemberSelectorError.OTHER; + } + else if ("member_not_in_group".equals(tag)) { + value = GroupMemberSelectorError.MEMBER_NOT_IN_GROUP; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupMemberSetAccessTypeError.java b/src/main/java/com/dropbox/core/v2/team/GroupMemberSetAccessTypeError.java index 9653db484..f0843fe8c 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupMemberSetAccessTypeError.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupMemberSetAccessTypeError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=GroupMemberSetAccessTypeError.Serializer.class) -@JsonDeserialize(using=GroupMemberSetAccessTypeError.Deserializer.class) public enum GroupMemberSetAccessTypeError { // union GroupMemberSetAccessTypeError /** @@ -44,52 +30,74 @@ public enum GroupMemberSetAccessTypeError { */ USER_CANNOT_BE_MANAGER_OF_COMPANY_MANAGED_GROUP; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupMemberSetAccessTypeError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GroupMemberSetAccessTypeError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(GroupMemberSetAccessTypeError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case GROUP_NOT_FOUND: + case GROUP_NOT_FOUND: { g.writeString("group_not_found"); break; - case OTHER: + } + case OTHER: { g.writeString("other"); break; - case MEMBER_NOT_IN_GROUP: + } + case MEMBER_NOT_IN_GROUP: { g.writeString("member_not_in_group"); break; - case USER_CANNOT_BE_MANAGER_OF_COMPANY_MANAGED_GROUP: + } + case USER_CANNOT_BE_MANAGER_OF_COMPANY_MANAGED_GROUP: { g.writeString("user_cannot_be_manager_of_company_managed_group"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupMemberSetAccessTypeError.class, getTagMapping(), null); - } @Override - public GroupMemberSetAccessTypeError deserialize(GroupMemberSetAccessTypeError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("user_cannot_be_manager_of_company_managed_group", GroupMemberSetAccessTypeError.USER_CANNOT_BE_MANAGER_OF_COMPANY_MANAGED_GROUP); - return Collections.unmodifiableMap(values); + public GroupMemberSetAccessTypeError deserialize(JsonParser p) throws IOException, JsonParseException { + GroupMemberSetAccessTypeError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("group_not_found".equals(tag)) { + value = GroupMemberSetAccessTypeError.GROUP_NOT_FOUND; + } + else if ("other".equals(tag)) { + value = GroupMemberSetAccessTypeError.OTHER; + } + else if ("member_not_in_group".equals(tag)) { + value = GroupMemberSetAccessTypeError.MEMBER_NOT_IN_GROUP; + } + else if ("user_cannot_be_manager_of_company_managed_group".equals(tag)) { + value = GroupMemberSetAccessTypeError.USER_CANNOT_BE_MANAGER_OF_COMPANY_MANAGED_GROUP; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupMemberSetAccessTypeErrorException.java b/src/main/java/com/dropbox/core/v2/team/GroupMemberSetAccessTypeErrorException.java index 3ab3f02f0..7cb2f0279 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupMemberSetAccessTypeErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupMemberSetAccessTypeErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/GroupMembersAddArg.java b/src/main/java/com/dropbox/core/v2/team/GroupMembersAddArg.java index 57dd790f8..0a2de37d7 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupMembersAddArg.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupMembersAddArg.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=GroupMembersAddArg.Serializer.class) -@JsonDeserialize(using=GroupMembersAddArg.Deserializer.class) class GroupMembersAddArg extends IncludeMembersArg { // struct GroupMembersAddArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final GroupSelector group; protected final List members; @@ -131,7 +114,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -143,101 +126,74 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupMembersAddArg.class); - } - - public Serializer(boolean unwrapping) { - super(GroupMembersAddArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GroupMembersAddArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("group", value.group); - g.writeObjectField("members", value.members); - g.writeObjectField("return_members", value.returnMembers); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupMembersAddArg.class); - } - - public Deserializer(boolean unwrapping) { - super(GroupMembersAddArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GroupMembersAddArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("group"); + GroupSelector.Serializer.INSTANCE.serialize(value.group, g); + g.writeFieldName("members"); + StoneSerializers.list(MemberAccess.Serializer.INSTANCE).serialize(value.members, g); + g.writeFieldName("return_members"); + StoneSerializers.boolean_().serialize(value.returnMembers, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GroupMembersAddArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - GroupSelector group = null; - List members = null; - boolean returnMembers = true; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("group".equals(_field)) { - group = _p.readValueAs(GroupSelector.class); - _p.nextToken(); - } - else if ("members".equals(_field)) { - expectArrayStart(_p); - members = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - MemberAccess _x = null; - _x = _p.readValueAs(MemberAccess.class); - _p.nextToken(); - members.add(_x); + public GroupMembersAddArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GroupMembersAddArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + GroupSelector f_group = null; + List f_members = null; + Boolean f_returnMembers = true; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("group".equals(field)) { + f_group = GroupSelector.Serializer.INSTANCE.deserialize(p); + } + else if ("members".equals(field)) { + f_members = StoneSerializers.list(MemberAccess.Serializer.INSTANCE).deserialize(p); + } + else if ("return_members".equals(field)) { + f_returnMembers = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else if ("return_members".equals(_field)) { - returnMembers = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_group == null) { + throw new JsonParseException(p, "Required field \"group\" missing."); } - else { - skipValue(_p); + if (f_members == null) { + throw new JsonParseException(p, "Required field \"members\" missing."); } + value = new GroupMembersAddArg(f_group, f_members, f_returnMembers); } - - if (group == null) { - throw new JsonParseException(_p, "Required field \"group\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (members == null) { - throw new JsonParseException(_p, "Required field \"members\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new GroupMembersAddArg(group, members, returnMembers); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupMembersAddError.java b/src/main/java/com/dropbox/core/v2/team/GroupMembersAddError.java index e9fb1c97a..a4434b2b7 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupMembersAddError.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupMembersAddError.java @@ -1,31 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * This class is a tagged union. Tagged unions instances are always associated @@ -33,15 +21,9 @@ * return {@code true}. You can use {@link #tag()} to determine the tag * associated with this instance. */ -@JsonSerialize(using=GroupMembersAddError.Serializer.class) -@JsonDeserialize(using=GroupMembersAddError.Deserializer.class) public final class GroupMembersAddError { // union GroupMembersAddError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link GroupMembersAddError}. */ @@ -74,7 +56,8 @@ public enum Tag { */ USERS_NOT_FOUND, // List /** - * A suspended user cannot be added to a group as owner. + * A suspended user cannot be added to a group as {@link + * GroupAccessType#OWNER}. */ USER_MUST_BE_ACTIVE_TO_BE_OWNER, /** @@ -99,7 +82,8 @@ public enum Tag { */ public static final GroupMembersAddError GROUP_NOT_IN_TEAM = new GroupMembersAddError(Tag.GROUP_NOT_IN_TEAM, null, null, null); /** - * A suspended user cannot be added to a group as owner. + * A suspended user cannot be added to a group as {@link + * GroupAccessType#OWNER}. */ public static final GroupMembersAddError USER_MUST_BE_ACTIVE_TO_BE_OWNER = new GroupMembersAddError(Tag.USER_MUST_BE_ACTIVE_TO_BE_OWNER, null, null, null); @@ -418,7 +402,7 @@ else if (obj instanceof GroupMembersAddError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -430,149 +414,126 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupMembersAddError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GroupMembersAddError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case GROUP_NOT_FOUND: + public void serialize(GroupMembersAddError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case GROUP_NOT_FOUND: { g.writeString("group_not_found"); break; - case OTHER: + } + case OTHER: { g.writeString("other"); break; - case DUPLICATE_USER: + } + case DUPLICATE_USER: { g.writeString("duplicate_user"); break; - case GROUP_NOT_IN_TEAM: + } + case GROUP_NOT_IN_TEAM: { g.writeString("group_not_in_team"); break; - case MEMBERS_NOT_IN_TEAM: + } + case MEMBERS_NOT_IN_TEAM: { g.writeStartObject(); - g.writeStringField(".tag", "members_not_in_team"); - g.writeObjectField("members_not_in_team", value.membersNotInTeamValue); + writeTag("members_not_in_team", g); + g.writeFieldName("members_not_in_team"); + StoneSerializers.list(StoneSerializers.string()).serialize(value.membersNotInTeamValue, g); g.writeEndObject(); break; - case USERS_NOT_FOUND: + } + case USERS_NOT_FOUND: { g.writeStartObject(); - g.writeStringField(".tag", "users_not_found"); - g.writeObjectField("users_not_found", value.usersNotFoundValue); + writeTag("users_not_found", g); + g.writeFieldName("users_not_found"); + StoneSerializers.list(StoneSerializers.string()).serialize(value.usersNotFoundValue, g); g.writeEndObject(); break; - case USER_MUST_BE_ACTIVE_TO_BE_OWNER: + } + case USER_MUST_BE_ACTIVE_TO_BE_OWNER: { g.writeString("user_must_be_active_to_be_owner"); break; - case USER_CANNOT_BE_MANAGER_OF_COMPANY_MANAGED_GROUP: + } + case USER_CANNOT_BE_MANAGER_OF_COMPANY_MANAGED_GROUP: { g.writeStartObject(); - g.writeStringField(".tag", "user_cannot_be_manager_of_company_managed_group"); - g.writeObjectField("user_cannot_be_manager_of_company_managed_group", value.userCannotBeManagerOfCompanyManagedGroupValue); + writeTag("user_cannot_be_manager_of_company_managed_group", g); + g.writeFieldName("user_cannot_be_manager_of_company_managed_group"); + StoneSerializers.list(StoneSerializers.string()).serialize(value.userCannotBeManagerOfCompanyManagedGroupValue, g); g.writeEndObject(); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupMembersAddError.class, getTagMapping(), null); - } - - @Override - public GroupMembersAddError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case GROUP_NOT_FOUND: { - return GroupMembersAddError.GROUP_NOT_FOUND; - } - case OTHER: { - return GroupMembersAddError.OTHER; - } - case DUPLICATE_USER: { - return GroupMembersAddError.DUPLICATE_USER; - } - case GROUP_NOT_IN_TEAM: { - return GroupMembersAddError.GROUP_NOT_IN_TEAM; - } - case MEMBERS_NOT_IN_TEAM: { - List value = null; - expectField(_p, "members_not_in_team"); - expectArrayStart(_p); - value = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - String _x = null; - _x = getStringValue(_p); - _p.nextToken(); - value.add(_x); - } - expectArrayEnd(_p); - _p.nextToken(); - return GroupMembersAddError.membersNotInTeam(value); - } - case USERS_NOT_FOUND: { - List value = null; - expectField(_p, "users_not_found"); - expectArrayStart(_p); - value = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - String _x = null; - _x = getStringValue(_p); - _p.nextToken(); - value.add(_x); - } - expectArrayEnd(_p); - _p.nextToken(); - return GroupMembersAddError.usersNotFound(value); } - case USER_MUST_BE_ACTIVE_TO_BE_OWNER: { - return GroupMembersAddError.USER_MUST_BE_ACTIVE_TO_BE_OWNER; - } - case USER_CANNOT_BE_MANAGER_OF_COMPANY_MANAGED_GROUP: { - List value = null; - expectField(_p, "user_cannot_be_manager_of_company_managed_group"); - expectArrayStart(_p); - value = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - String _x = null; - _x = getStringValue(_p); - _p.nextToken(); - value.add(_x); - } - expectArrayEnd(_p); - _p.nextToken(); - return GroupMembersAddError.userCannotBeManagerOfCompanyManagedGroup(value); + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("duplicate_user", GroupMembersAddError.Tag.DUPLICATE_USER); - values.put("group_not_in_team", GroupMembersAddError.Tag.GROUP_NOT_IN_TEAM); - values.put("members_not_in_team", GroupMembersAddError.Tag.MEMBERS_NOT_IN_TEAM); - values.put("users_not_found", GroupMembersAddError.Tag.USERS_NOT_FOUND); - values.put("user_must_be_active_to_be_owner", GroupMembersAddError.Tag.USER_MUST_BE_ACTIVE_TO_BE_OWNER); - values.put("user_cannot_be_manager_of_company_managed_group", GroupMembersAddError.Tag.USER_CANNOT_BE_MANAGER_OF_COMPANY_MANAGED_GROUP); - return Collections.unmodifiableMap(values); + @Override + public GroupMembersAddError deserialize(JsonParser p) throws IOException, JsonParseException { + GroupMembersAddError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("group_not_found".equals(tag)) { + value = GroupMembersAddError.GROUP_NOT_FOUND; + } + else if ("other".equals(tag)) { + value = GroupMembersAddError.OTHER; + } + else if ("duplicate_user".equals(tag)) { + value = GroupMembersAddError.DUPLICATE_USER; + } + else if ("group_not_in_team".equals(tag)) { + value = GroupMembersAddError.GROUP_NOT_IN_TEAM; + } + else if ("members_not_in_team".equals(tag)) { + List fieldValue = null; + expectField("members_not_in_team", p); + fieldValue = StoneSerializers.list(StoneSerializers.string()).deserialize(p); + value = GroupMembersAddError.membersNotInTeam(fieldValue); + } + else if ("users_not_found".equals(tag)) { + List fieldValue = null; + expectField("users_not_found", p); + fieldValue = StoneSerializers.list(StoneSerializers.string()).deserialize(p); + value = GroupMembersAddError.usersNotFound(fieldValue); + } + else if ("user_must_be_active_to_be_owner".equals(tag)) { + value = GroupMembersAddError.USER_MUST_BE_ACTIVE_TO_BE_OWNER; + } + else if ("user_cannot_be_manager_of_company_managed_group".equals(tag)) { + List fieldValue = null; + expectField("user_cannot_be_manager_of_company_managed_group", p); + fieldValue = StoneSerializers.list(StoneSerializers.string()).deserialize(p); + value = GroupMembersAddError.userCannotBeManagerOfCompanyManagedGroup(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupMembersAddErrorException.java b/src/main/java/com/dropbox/core/v2/team/GroupMembersAddErrorException.java index f283a2166..c5190a2c9 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupMembersAddErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupMembersAddErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/GroupMembersChangeResult.java b/src/main/java/com/dropbox/core/v2/team/GroupMembersChangeResult.java index aba8acde9..a1125725d 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupMembersChangeResult.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupMembersChangeResult.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; @@ -31,15 +20,9 @@ * {@link * DbxTeamTeamRequests#groupsMembersRemove(GroupSelector,java.util.List)}. */ -@JsonSerialize(using=GroupMembersChangeResult.Serializer.class) -@JsonDeserialize(using=GroupMembersChangeResult.Deserializer.class) public class GroupMembersChangeResult { // struct GroupMembersChangeResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final GroupFullInfo groupInfo; protected final String asyncJobId; @@ -119,7 +102,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -131,87 +114,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupMembersChangeResult.class); - } - - public Serializer(boolean unwrapping) { - super(GroupMembersChangeResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GroupMembersChangeResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("group_info", value.groupInfo); - g.writeObjectField("async_job_id", value.asyncJobId); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupMembersChangeResult.class); - } - - public Deserializer(boolean unwrapping) { - super(GroupMembersChangeResult.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GroupMembersChangeResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("group_info"); + GroupFullInfo.Serializer.INSTANCE.serialize(value.groupInfo, g); + g.writeFieldName("async_job_id"); + StoneSerializers.string().serialize(value.asyncJobId, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GroupMembersChangeResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - GroupFullInfo groupInfo = null; - String asyncJobId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("group_info".equals(_field)) { - groupInfo = _p.readValueAs(GroupFullInfo.class); - _p.nextToken(); + public GroupMembersChangeResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GroupMembersChangeResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + GroupFullInfo f_groupInfo = null; + String f_asyncJobId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("group_info".equals(field)) { + f_groupInfo = GroupFullInfo.Serializer.INSTANCE.deserialize(p); + } + else if ("async_job_id".equals(field)) { + f_asyncJobId = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else if ("async_job_id".equals(_field)) { - asyncJobId = getStringValue(_p); - _p.nextToken(); + if (f_groupInfo == null) { + throw new JsonParseException(p, "Required field \"group_info\" missing."); } - else { - skipValue(_p); + if (f_asyncJobId == null) { + throw new JsonParseException(p, "Required field \"async_job_id\" missing."); } + value = new GroupMembersChangeResult(f_groupInfo, f_asyncJobId); } - - if (groupInfo == null) { - throw new JsonParseException(_p, "Required field \"group_info\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (asyncJobId == null) { - throw new JsonParseException(_p, "Required field \"async_job_id\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new GroupMembersChangeResult(groupInfo, asyncJobId); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupMembersRemoveArg.java b/src/main/java/com/dropbox/core/v2/team/GroupMembersRemoveArg.java index 11100078b..0508b1e3f 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupMembersRemoveArg.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupMembersRemoveArg.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=GroupMembersRemoveArg.Serializer.class) -@JsonDeserialize(using=GroupMembersRemoveArg.Deserializer.class) class GroupMembersRemoveArg extends IncludeMembersArg { // struct GroupMembersRemoveArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final GroupSelector group; protected final List users; @@ -131,7 +114,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -143,101 +126,74 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupMembersRemoveArg.class); - } - - public Serializer(boolean unwrapping) { - super(GroupMembersRemoveArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GroupMembersRemoveArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("group", value.group); - g.writeObjectField("users", value.users); - g.writeObjectField("return_members", value.returnMembers); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupMembersRemoveArg.class); - } - - public Deserializer(boolean unwrapping) { - super(GroupMembersRemoveArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GroupMembersRemoveArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("group"); + GroupSelector.Serializer.INSTANCE.serialize(value.group, g); + g.writeFieldName("users"); + StoneSerializers.list(UserSelectorArg.Serializer.INSTANCE).serialize(value.users, g); + g.writeFieldName("return_members"); + StoneSerializers.boolean_().serialize(value.returnMembers, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GroupMembersRemoveArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - GroupSelector group = null; - List users = null; - boolean returnMembers = true; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("group".equals(_field)) { - group = _p.readValueAs(GroupSelector.class); - _p.nextToken(); - } - else if ("users".equals(_field)) { - expectArrayStart(_p); - users = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - UserSelectorArg _x = null; - _x = _p.readValueAs(UserSelectorArg.class); - _p.nextToken(); - users.add(_x); + public GroupMembersRemoveArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GroupMembersRemoveArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + GroupSelector f_group = null; + List f_users = null; + Boolean f_returnMembers = true; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("group".equals(field)) { + f_group = GroupSelector.Serializer.INSTANCE.deserialize(p); + } + else if ("users".equals(field)) { + f_users = StoneSerializers.list(UserSelectorArg.Serializer.INSTANCE).deserialize(p); + } + else if ("return_members".equals(field)) { + f_returnMembers = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else if ("return_members".equals(_field)) { - returnMembers = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_group == null) { + throw new JsonParseException(p, "Required field \"group\" missing."); } - else { - skipValue(_p); + if (f_users == null) { + throw new JsonParseException(p, "Required field \"users\" missing."); } + value = new GroupMembersRemoveArg(f_group, f_users, f_returnMembers); } - - if (group == null) { - throw new JsonParseException(_p, "Required field \"group\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (users == null) { - throw new JsonParseException(_p, "Required field \"users\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new GroupMembersRemoveArg(group, users, returnMembers); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupMembersRemoveError.java b/src/main/java/com/dropbox/core/v2/team/GroupMembersRemoveError.java index 7ad1424ec..c631a6788 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupMembersRemoveError.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupMembersRemoveError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=GroupMembersRemoveError.Serializer.class) -@JsonDeserialize(using=GroupMembersRemoveError.Deserializer.class) public enum GroupMembersRemoveError { // union GroupMembersRemoveError /** @@ -45,52 +31,74 @@ public enum GroupMembersRemoveError { */ GROUP_NOT_IN_TEAM; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupMembersRemoveError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GroupMembersRemoveError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(GroupMembersRemoveError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case GROUP_NOT_FOUND: + case GROUP_NOT_FOUND: { g.writeString("group_not_found"); break; - case OTHER: + } + case OTHER: { g.writeString("other"); break; - case MEMBER_NOT_IN_GROUP: + } + case MEMBER_NOT_IN_GROUP: { g.writeString("member_not_in_group"); break; - case GROUP_NOT_IN_TEAM: + } + case GROUP_NOT_IN_TEAM: { g.writeString("group_not_in_team"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupMembersRemoveError.class, getTagMapping(), null); - } @Override - public GroupMembersRemoveError deserialize(GroupMembersRemoveError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("group_not_in_team", GroupMembersRemoveError.GROUP_NOT_IN_TEAM); - return Collections.unmodifiableMap(values); + public GroupMembersRemoveError deserialize(JsonParser p) throws IOException, JsonParseException { + GroupMembersRemoveError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("group_not_found".equals(tag)) { + value = GroupMembersRemoveError.GROUP_NOT_FOUND; + } + else if ("other".equals(tag)) { + value = GroupMembersRemoveError.OTHER; + } + else if ("member_not_in_group".equals(tag)) { + value = GroupMembersRemoveError.MEMBER_NOT_IN_GROUP; + } + else if ("group_not_in_team".equals(tag)) { + value = GroupMembersRemoveError.GROUP_NOT_IN_TEAM; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupMembersRemoveErrorException.java b/src/main/java/com/dropbox/core/v2/team/GroupMembersRemoveErrorException.java index 0f573fe2f..fe75157d9 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupMembersRemoveErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupMembersRemoveErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/GroupMembersSelector.java b/src/main/java/com/dropbox/core/v2/team/GroupMembersSelector.java index d7b3aa429..f3fa34188 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupMembersSelector.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupMembersSelector.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Argument for selecting a group and a list of users. */ -@JsonSerialize(using=GroupMembersSelector.Serializer.class) -@JsonDeserialize(using=GroupMembersSelector.Deserializer.class) public class GroupMembersSelector { // struct GroupMembersSelector - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final GroupSelector group; protected final UsersSelectorArg users; @@ -108,7 +91,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -120,87 +103,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupMembersSelector.class); - } - - public Serializer(boolean unwrapping) { - super(GroupMembersSelector.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GroupMembersSelector value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("group", value.group); - g.writeObjectField("users", value.users); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupMembersSelector.class); - } - - public Deserializer(boolean unwrapping) { - super(GroupMembersSelector.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GroupMembersSelector value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("group"); + GroupSelector.Serializer.INSTANCE.serialize(value.group, g); + g.writeFieldName("users"); + UsersSelectorArg.Serializer.INSTANCE.serialize(value.users, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GroupMembersSelector deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - GroupSelector group = null; - UsersSelectorArg users = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("group".equals(_field)) { - group = _p.readValueAs(GroupSelector.class); - _p.nextToken(); + public GroupMembersSelector deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GroupMembersSelector value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + GroupSelector f_group = null; + UsersSelectorArg f_users = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("group".equals(field)) { + f_group = GroupSelector.Serializer.INSTANCE.deserialize(p); + } + else if ("users".equals(field)) { + f_users = UsersSelectorArg.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else if ("users".equals(_field)) { - users = _p.readValueAs(UsersSelectorArg.class); - _p.nextToken(); + if (f_group == null) { + throw new JsonParseException(p, "Required field \"group\" missing."); } - else { - skipValue(_p); + if (f_users == null) { + throw new JsonParseException(p, "Required field \"users\" missing."); } + value = new GroupMembersSelector(f_group, f_users); } - - if (group == null) { - throw new JsonParseException(_p, "Required field \"group\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (users == null) { - throw new JsonParseException(_p, "Required field \"users\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new GroupMembersSelector(group, users); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupMembersSelectorError.java b/src/main/java/com/dropbox/core/v2/team/GroupMembersSelectorError.java index 047996a8f..cfeebaab8 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupMembersSelectorError.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupMembersSelectorError.java @@ -1,37 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Error that can be raised when {@link GroupMembersSelector} is used, and the * users are required to be members of the specified group. */ -@JsonSerialize(using=GroupMembersSelectorError.Serializer.class) -@JsonDeserialize(using=GroupMembersSelectorError.Deserializer.class) public enum GroupMembersSelectorError { // union GroupMembersSelectorError /** @@ -44,49 +30,67 @@ public enum GroupMembersSelectorError { */ MEMBER_NOT_IN_GROUP; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupMembersSelectorError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GroupMembersSelectorError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(GroupMembersSelectorError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case GROUP_NOT_FOUND: + case GROUP_NOT_FOUND: { g.writeString("group_not_found"); break; - case OTHER: + } + case OTHER: { g.writeString("other"); break; - case MEMBER_NOT_IN_GROUP: + } + case MEMBER_NOT_IN_GROUP: { g.writeString("member_not_in_group"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupMembersSelectorError.class, getTagMapping(), null); - } @Override - public GroupMembersSelectorError deserialize(GroupMembersSelectorError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("member_not_in_group", GroupMembersSelectorError.MEMBER_NOT_IN_GROUP); - return Collections.unmodifiableMap(values); + public GroupMembersSelectorError deserialize(JsonParser p) throws IOException, JsonParseException { + GroupMembersSelectorError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("group_not_found".equals(tag)) { + value = GroupMembersSelectorError.GROUP_NOT_FOUND; + } + else if ("other".equals(tag)) { + value = GroupMembersSelectorError.OTHER; + } + else if ("member_not_in_group".equals(tag)) { + value = GroupMembersSelectorError.MEMBER_NOT_IN_GROUP; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupMembersSetAccessTypeArg.java b/src/main/java/com/dropbox/core/v2/team/GroupMembersSetAccessTypeArg.java index 799cf548a..9d3225961 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupMembersSetAccessTypeArg.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupMembersSetAccessTypeArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=GroupMembersSetAccessTypeArg.Serializer.class) -@JsonDeserialize(using=GroupMembersSetAccessTypeArg.Deserializer.class) class GroupMembersSetAccessTypeArg extends GroupMemberSelector { // struct GroupMembersSetAccessTypeArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final GroupAccessType accessType; protected final boolean returnMembers; @@ -128,7 +111,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -140,102 +123,83 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupMembersSetAccessTypeArg.class); - } - - public Serializer(boolean unwrapping) { - super(GroupMembersSetAccessTypeArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GroupMembersSetAccessTypeArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("group", value.group); - g.writeObjectField("user", value.user); - g.writeObjectField("access_type", value.accessType); - g.writeObjectField("return_members", value.returnMembers); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupMembersSetAccessTypeArg.class); - } - - public Deserializer(boolean unwrapping) { - super(GroupMembersSetAccessTypeArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GroupMembersSetAccessTypeArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("group"); + GroupSelector.Serializer.INSTANCE.serialize(value.group, g); + g.writeFieldName("user"); + UserSelectorArg.Serializer.INSTANCE.serialize(value.user, g); + g.writeFieldName("access_type"); + GroupAccessType.Serializer.INSTANCE.serialize(value.accessType, g); + g.writeFieldName("return_members"); + StoneSerializers.boolean_().serialize(value.returnMembers, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GroupMembersSetAccessTypeArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - GroupSelector group = null; - UserSelectorArg user = null; - GroupAccessType accessType = null; - boolean returnMembers = true; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("group".equals(_field)) { - group = _p.readValueAs(GroupSelector.class); - _p.nextToken(); - } - else if ("user".equals(_field)) { - user = _p.readValueAs(UserSelectorArg.class); - _p.nextToken(); + public GroupMembersSetAccessTypeArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GroupMembersSetAccessTypeArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + GroupSelector f_group = null; + UserSelectorArg f_user = null; + GroupAccessType f_accessType = null; + Boolean f_returnMembers = true; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("group".equals(field)) { + f_group = GroupSelector.Serializer.INSTANCE.deserialize(p); + } + else if ("user".equals(field)) { + f_user = UserSelectorArg.Serializer.INSTANCE.deserialize(p); + } + else if ("access_type".equals(field)) { + f_accessType = GroupAccessType.Serializer.INSTANCE.deserialize(p); + } + else if ("return_members".equals(field)) { + f_returnMembers = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } } - else if ("access_type".equals(_field)) { - accessType = _p.readValueAs(GroupAccessType.class); - _p.nextToken(); + if (f_group == null) { + throw new JsonParseException(p, "Required field \"group\" missing."); } - else if ("return_members".equals(_field)) { - returnMembers = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_user == null) { + throw new JsonParseException(p, "Required field \"user\" missing."); } - else { - skipValue(_p); + if (f_accessType == null) { + throw new JsonParseException(p, "Required field \"access_type\" missing."); } + value = new GroupMembersSetAccessTypeArg(f_group, f_user, f_accessType, f_returnMembers); } - - if (group == null) { - throw new JsonParseException(_p, "Required field \"group\" is missing."); - } - if (user == null) { - throw new JsonParseException(_p, "Required field \"user\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (accessType == null) { - throw new JsonParseException(_p, "Required field \"access_type\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new GroupMembersSetAccessTypeArg(group, user, accessType, returnMembers); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupSelector.java b/src/main/java/com/dropbox/core/v2/team/GroupSelector.java index d1f7ffe47..e03667734 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupSelector.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupSelector.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Argument for selecting a single group, either by group_id or by external @@ -35,15 +23,9 @@ * methods will return {@code true}. You can use {@link #tag()} to determine the * tag associated with this instance.

*/ -@JsonSerialize(using=GroupSelector.Serializer.class) -@JsonDeserialize(using=GroupSelector.Deserializer.class) public final class GroupSelector { // union GroupSelector - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link GroupSelector}. */ @@ -222,7 +204,7 @@ else if (obj instanceof GroupSelector) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -234,78 +216,77 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupSelector.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GroupSelector value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case GROUP_ID: + public void serialize(GroupSelector value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case GROUP_ID: { g.writeStartObject(); - g.writeStringField(".tag", "group_id"); - g.writeObjectField("group_id", value.groupIdValue); + writeTag("group_id", g); + g.writeFieldName("group_id"); + StoneSerializers.string().serialize(value.groupIdValue, g); g.writeEndObject(); break; - case GROUP_EXTERNAL_ID: + } + case GROUP_EXTERNAL_ID: { g.writeStartObject(); - g.writeStringField(".tag", "group_external_id"); - g.writeObjectField("group_external_id", value.groupExternalIdValue); + writeTag("group_external_id", g); + g.writeFieldName("group_external_id"); + StoneSerializers.string().serialize(value.groupExternalIdValue, g); g.writeEndObject(); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupSelector.class, getTagMapping(), null); - } - - @Override - public GroupSelector deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case GROUP_ID: { - String value = null; - expectField(_p, "group_id"); - value = getStringValue(_p); - _p.nextToken(); - return GroupSelector.groupId(value); } - case GROUP_EXTERNAL_ID: { - String value = null; - expectField(_p, "group_external_id"); - value = getStringValue(_p); - _p.nextToken(); - return GroupSelector.groupExternalId(value); + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("group_id", GroupSelector.Tag.GROUP_ID); - values.put("group_external_id", GroupSelector.Tag.GROUP_EXTERNAL_ID); - return Collections.unmodifiableMap(values); + @Override + public GroupSelector deserialize(JsonParser p) throws IOException, JsonParseException { + GroupSelector value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("group_id".equals(tag)) { + String fieldValue = null; + expectField("group_id", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = GroupSelector.groupId(fieldValue); + } + else if ("group_external_id".equals(tag)) { + String fieldValue = null; + expectField("group_external_id", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = GroupSelector.groupExternalId(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupSelectorError.java b/src/main/java/com/dropbox/core/v2/team/GroupSelectorError.java index 519297255..88d895797 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupSelectorError.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupSelectorError.java @@ -1,36 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Error that can be raised when {@link GroupSelector}is used. */ -@JsonSerialize(using=GroupSelectorError.Serializer.class) -@JsonDeserialize(using=GroupSelectorError.Deserializer.class) public enum GroupSelectorError { // union GroupSelectorError /** @@ -46,47 +32,54 @@ public enum GroupSelectorError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupSelectorError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GroupSelectorError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(GroupSelectorError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case GROUP_NOT_FOUND: + case GROUP_NOT_FOUND: { g.writeString("group_not_found"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupSelectorError.class, getTagMapping(), GroupSelectorError.OTHER); - } @Override - public GroupSelectorError deserialize(GroupSelectorError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("group_not_found", GroupSelectorError.GROUP_NOT_FOUND); - values.put("other", GroupSelectorError.OTHER); - return Collections.unmodifiableMap(values); + public GroupSelectorError deserialize(JsonParser p) throws IOException, JsonParseException { + GroupSelectorError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("group_not_found".equals(tag)) { + value = GroupSelectorError.GROUP_NOT_FOUND; + } + else { + value = GroupSelectorError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupSelectorErrorException.java b/src/main/java/com/dropbox/core/v2/team/GroupSelectorErrorException.java new file mode 100644 index 000000000..2de4eec6d --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/team/GroupSelectorErrorException.java @@ -0,0 +1,29 @@ +/* DO NOT EDIT */ +/* This file was generated from team_groups.stone */ + +package com.dropbox.core.v2.team; + +import com.dropbox.core.DbxApiException; +import com.dropbox.core.LocalizedText; + +/** + * Exception thrown when the server responds with a {@link GroupSelectorError} + * error. + */ +public class GroupSelectorErrorException extends DbxApiException { + private static final long serialVersionUID = 0L; + + /** + * The error reported by {@link + * DbxTeamTeamRequests#groupsMembersList(GroupSelector)}. + */ + public final GroupSelectorError errorValue; + + public GroupSelectorErrorException(String requestId, LocalizedText userMessage, GroupSelectorError errorValue) { + super(requestId, userMessage, buildMessage("groups/members/list", userMessage, errorValue)); + if (errorValue == null) { + throw new NullPointerException("errorValue"); + } + this.errorValue = errorValue; + } +} diff --git a/src/main/java/com/dropbox/core/v2/team/GroupType.java b/src/main/java/com/dropbox/core/v2/team/GroupType.java deleted file mode 100644 index f5f62ec15..000000000 --- a/src/main/java/com/dropbox/core/v2/team/GroupType.java +++ /dev/null @@ -1,101 +0,0 @@ -/* DO NOT EDIT */ -/* This file was generated from team_common.babel */ - -package com.dropbox.core.v2.team; - -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; - -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -/** - * The group type determines how a group is created and managed. - */ -@JsonSerialize(using=GroupType.Serializer.class) -@JsonDeserialize(using=GroupType.Deserializer.class) -public enum GroupType { - // union GroupType - /** - * A group to which team members are automatically added. Applicable to team folders only. - */ - TEAM, - /** - * A group is created and managed by a user. - */ - USER_MANAGED, - /** - * Catch-all used for unknown tag values returned by the Dropbox servers. - * - *

Receiving a catch-all value typically indicates this SDK version is - * not up to date. Consider updating your SDK version to handle the new - * tags.

- */ - OTHER; // *catch_all - - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupType.class); - } - - @Override - public void serialize(GroupType value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value) { - case TEAM: - g.writeString("team"); - break; - case USER_MANAGED: - g.writeString("user_managed"); - break; - case OTHER: - g.writeString("other"); - break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupType.class, getTagMapping(), GroupType.OTHER); - } - - @Override - public GroupType deserialize(GroupType _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("team", GroupType.TEAM); - values.put("user_managed", GroupType.USER_MANAGED); - values.put("other", GroupType.OTHER); - return Collections.unmodifiableMap(values); - } - } -} diff --git a/src/main/java/com/dropbox/core/v2/team/GroupUpdateArgs.java b/src/main/java/com/dropbox/core/v2/team/GroupUpdateArgs.java index e0d2144ae..ff2d91ac8 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupUpdateArgs.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupUpdateArgs.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=GroupUpdateArgs.Serializer.class) -@JsonDeserialize(using=GroupUpdateArgs.Deserializer.class) -class GroupUpdateArgs extends IncludeMembersArg { +public class GroupUpdateArgs extends IncludeMembersArg { // struct GroupUpdateArgs - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final GroupSelector group; protected final String newGroupName; protected final String newGroupExternalId; @@ -236,7 +219,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -248,100 +231,81 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupUpdateArgs.class); - } - - public Serializer(boolean unwrapping) { - super(GroupUpdateArgs.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(GroupUpdateArgs value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("group", value.group); - g.writeObjectField("return_members", value.returnMembers); + public void serialize(GroupUpdateArgs value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("group"); + GroupSelector.Serializer.INSTANCE.serialize(value.group, g); + g.writeFieldName("return_members"); + StoneSerializers.boolean_().serialize(value.returnMembers, g); if (value.newGroupName != null) { - g.writeObjectField("new_group_name", value.newGroupName); + g.writeFieldName("new_group_name"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.newGroupName, g); } if (value.newGroupExternalId != null) { - g.writeObjectField("new_group_external_id", value.newGroupExternalId); + g.writeFieldName("new_group_external_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.newGroupExternalId, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupUpdateArgs.class); - } - - public Deserializer(boolean unwrapping) { - super(GroupUpdateArgs.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public GroupUpdateArgs deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - GroupSelector group = null; - boolean returnMembers = true; - String newGroupName = null; - String newGroupExternalId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("group".equals(_field)) { - group = _p.readValueAs(GroupSelector.class); - _p.nextToken(); - } - else if ("return_members".equals(_field)) { - returnMembers = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("new_group_name".equals(_field)) { - newGroupName = getStringValue(_p); - _p.nextToken(); - } - else if ("new_group_external_id".equals(_field)) { - newGroupExternalId = getStringValue(_p); - _p.nextToken(); + public GroupUpdateArgs deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GroupUpdateArgs value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + GroupSelector f_group = null; + Boolean f_returnMembers = true; + String f_newGroupName = null; + String f_newGroupExternalId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("group".equals(field)) { + f_group = GroupSelector.Serializer.INSTANCE.deserialize(p); + } + else if ("return_members".equals(field)) { + f_returnMembers = StoneSerializers.boolean_().deserialize(p); + } + else if ("new_group_name".equals(field)) { + f_newGroupName = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("new_group_external_id".equals(field)) { + f_newGroupExternalId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_group == null) { + throw new JsonParseException(p, "Required field \"group\" missing."); } + value = new GroupUpdateArgs(f_group, f_returnMembers, f_newGroupName, f_newGroupExternalId); } - - if (group == null) { - throw new JsonParseException(_p, "Required field \"group\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new GroupUpdateArgs(group, returnMembers, newGroupName, newGroupExternalId); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupUpdateError.java b/src/main/java/com/dropbox/core/v2/team/GroupUpdateError.java index 12f3f7854..666723699 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupUpdateError.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupUpdateError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=GroupUpdateError.Serializer.class) -@JsonDeserialize(using=GroupUpdateError.Deserializer.class) public enum GroupUpdateError { // union GroupUpdateError /** @@ -40,49 +26,67 @@ public enum GroupUpdateError { */ EXTERNAL_ID_ALREADY_IN_USE; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupUpdateError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GroupUpdateError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(GroupUpdateError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case GROUP_NOT_FOUND: + case GROUP_NOT_FOUND: { g.writeString("group_not_found"); break; - case OTHER: + } + case OTHER: { g.writeString("other"); break; - case EXTERNAL_ID_ALREADY_IN_USE: + } + case EXTERNAL_ID_ALREADY_IN_USE: { g.writeString("external_id_already_in_use"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupUpdateError.class, getTagMapping(), null); - } @Override - public GroupUpdateError deserialize(GroupUpdateError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("external_id_already_in_use", GroupUpdateError.EXTERNAL_ID_ALREADY_IN_USE); - return Collections.unmodifiableMap(values); + public GroupUpdateError deserialize(JsonParser p) throws IOException, JsonParseException { + GroupUpdateError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("group_not_found".equals(tag)) { + value = GroupUpdateError.GROUP_NOT_FOUND; + } + else if ("other".equals(tag)) { + value = GroupUpdateError.OTHER; + } + else if ("external_id_already_in_use".equals(tag)) { + value = GroupUpdateError.EXTERNAL_ID_ALREADY_IN_USE; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupUpdateErrorException.java b/src/main/java/com/dropbox/core/v2/team/GroupUpdateErrorException.java index a3fc4d9e9..a30da5dc4 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupUpdateErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupUpdateErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/GroupsGetInfoError.java b/src/main/java/com/dropbox/core/v2/team/GroupsGetInfoError.java index 48fc46abc..d4f56bd74 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupsGetInfoError.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupsGetInfoError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=GroupsGetInfoError.Serializer.class) -@JsonDeserialize(using=GroupsGetInfoError.Deserializer.class) public enum GroupsGetInfoError { // union GroupsGetInfoError /** @@ -43,47 +29,54 @@ public enum GroupsGetInfoError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupsGetInfoError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GroupsGetInfoError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(GroupsGetInfoError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case GROUP_NOT_ON_TEAM: + case GROUP_NOT_ON_TEAM: { g.writeString("group_not_on_team"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupsGetInfoError.class, getTagMapping(), GroupsGetInfoError.OTHER); - } @Override - public GroupsGetInfoError deserialize(GroupsGetInfoError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("group_not_on_team", GroupsGetInfoError.GROUP_NOT_ON_TEAM); - values.put("other", GroupsGetInfoError.OTHER); - return Collections.unmodifiableMap(values); + public GroupsGetInfoError deserialize(JsonParser p) throws IOException, JsonParseException { + GroupsGetInfoError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("group_not_on_team".equals(tag)) { + value = GroupsGetInfoError.GROUP_NOT_ON_TEAM; + } + else { + value = GroupsGetInfoError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupsGetInfoErrorException.java b/src/main/java/com/dropbox/core/v2/team/GroupsGetInfoErrorException.java index f5f0554e5..3c34e3939 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupsGetInfoErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupsGetInfoErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/GroupsGetInfoItem.java b/src/main/java/com/dropbox/core/v2/team/GroupsGetInfoItem.java index 6947e4951..25aeb653e 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupsGetInfoItem.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupsGetInfoItem.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is a tagged union. Tagged unions instances are always associated @@ -32,15 +20,9 @@ * return {@code true}. You can use {@link #tag()} to determine the tag * associated with this instance. */ -@JsonSerialize(using=GroupsGetInfoItem.Serializer.class) -@JsonDeserialize(using=GroupsGetInfoItem.Deserializer.class) public final class GroupsGetInfoItem { // union GroupsGetInfoItem - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link GroupsGetInfoItem}. */ @@ -225,7 +207,7 @@ else if (obj instanceof GroupsGetInfoItem) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -237,76 +219,75 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupsGetInfoItem.class, GroupFullInfo.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GroupsGetInfoItem value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case ID_NOT_FOUND: + public void serialize(GroupsGetInfoItem value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case ID_NOT_FOUND: { g.writeStartObject(); - g.writeStringField(".tag", "id_not_found"); - g.writeObjectField("id_not_found", value.idNotFoundValue); + writeTag("id_not_found", g); + g.writeFieldName("id_not_found"); + StoneSerializers.string().serialize(value.idNotFoundValue, g); g.writeEndObject(); break; - case GROUP_INFO: + } + case GROUP_INFO: { g.writeStartObject(); - g.writeStringField(".tag", "group_info"); - getUnwrappingSerializer(GroupFullInfo.class).serialize(value.groupInfoValue, g, provider); + writeTag("group_info", g); + GroupFullInfo.Serializer.INSTANCE.serialize(value.groupInfoValue, g, true); g.writeEndObject(); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupsGetInfoItem.class, getTagMapping(), null, GroupFullInfo.class); - } - - @Override - public GroupsGetInfoItem deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case ID_NOT_FOUND: { - String value = null; - expectField(_p, "id_not_found"); - value = getStringValue(_p); - _p.nextToken(); - return GroupsGetInfoItem.idNotFound(value); } - case GROUP_INFO: { - GroupFullInfo value = null; - value = readCollapsedStructValue(GroupFullInfo.class, _p, _ctx); - return GroupsGetInfoItem.groupInfo(value); + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("id_not_found", GroupsGetInfoItem.Tag.ID_NOT_FOUND); - values.put("group_info", GroupsGetInfoItem.Tag.GROUP_INFO); - return Collections.unmodifiableMap(values); + @Override + public GroupsGetInfoItem deserialize(JsonParser p) throws IOException, JsonParseException { + GroupsGetInfoItem value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("id_not_found".equals(tag)) { + String fieldValue = null; + expectField("id_not_found", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = GroupsGetInfoItem.idNotFound(fieldValue); + } + else if ("group_info".equals(tag)) { + GroupFullInfo fieldValue = null; + fieldValue = GroupFullInfo.Serializer.INSTANCE.deserialize(p, true); + value = GroupsGetInfoItem.groupInfo(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupsListArg.java b/src/main/java/com/dropbox/core/v2/team/GroupsListArg.java index 0a1314c5a..9f3de78ba 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupsListArg.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupsListArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=GroupsListArg.Serializer.class) -@JsonDeserialize(using=GroupsListArg.Deserializer.class) class GroupsListArg { // struct GroupsListArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final long limit; /** @@ -96,7 +79,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -108,79 +91,56 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupsListArg.class); - } - - public Serializer(boolean unwrapping) { - super(GroupsListArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GroupsListArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("limit", value.limit); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupsListArg.class); - } - - public Deserializer(boolean unwrapping) { - super(GroupsListArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GroupsListArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("limit"); + StoneSerializers.uInt32().serialize(value.limit, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GroupsListArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - long limit = 1000L; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("limit".equals(_field)) { - limit = _p.getLongValue(); - assertUnsigned(_p, limit); - if (limit > Integer.MAX_VALUE) { - throw new JsonParseException(_p, "expecting a 32-bit unsigned integer, got: " + limit); + public GroupsListArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GroupsListArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Long f_limit = 1000L; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("limit".equals(field)) { + f_limit = StoneSerializers.uInt32().deserialize(p); + } + else { + skipValue(p); } - _p.nextToken(); - } - else { - skipValue(_p); } + value = new GroupsListArg(f_limit); } - - - return new GroupsListArg(limit); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupsListContinueArg.java b/src/main/java/com/dropbox/core/v2/team/GroupsListContinueArg.java index b64aa40cf..ddd1e2025 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupsListContinueArg.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupsListContinueArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=GroupsListContinueArg.Serializer.class) -@JsonDeserialize(using=GroupsListContinueArg.Deserializer.class) class GroupsListContinueArg { // struct GroupsListContinueArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String cursor; /** @@ -85,7 +68,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -97,78 +80,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupsListContinueArg.class); - } - - public Serializer(boolean unwrapping) { - super(GroupsListContinueArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GroupsListContinueArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("cursor", value.cursor); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupsListContinueArg.class); - } - - public Deserializer(boolean unwrapping) { - super(GroupsListContinueArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GroupsListContinueArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("cursor"); + StoneSerializers.string().serialize(value.cursor, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GroupsListContinueArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String cursor = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); + public GroupsListContinueArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GroupsListContinueArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_cursor = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("cursor".equals(field)) { + f_cursor = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_cursor == null) { + throw new JsonParseException(p, "Required field \"cursor\" missing."); } + value = new GroupsListContinueArg(f_cursor); } - - if (cursor == null) { - throw new JsonParseException(_p, "Required field \"cursor\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new GroupsListContinueArg(cursor); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupsListContinueError.java b/src/main/java/com/dropbox/core/v2/team/GroupsListContinueError.java index 9994ec3d8..f85b1388e 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupsListContinueError.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupsListContinueError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=GroupsListContinueError.Serializer.class) -@JsonDeserialize(using=GroupsListContinueError.Deserializer.class) public enum GroupsListContinueError { // union GroupsListContinueError /** @@ -39,47 +25,54 @@ public enum GroupsListContinueError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupsListContinueError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GroupsListContinueError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(GroupsListContinueError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case INVALID_CURSOR: + case INVALID_CURSOR: { g.writeString("invalid_cursor"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupsListContinueError.class, getTagMapping(), GroupsListContinueError.OTHER); - } @Override - public GroupsListContinueError deserialize(GroupsListContinueError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("invalid_cursor", GroupsListContinueError.INVALID_CURSOR); - values.put("other", GroupsListContinueError.OTHER); - return Collections.unmodifiableMap(values); + public GroupsListContinueError deserialize(JsonParser p) throws IOException, JsonParseException { + GroupsListContinueError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("invalid_cursor".equals(tag)) { + value = GroupsListContinueError.INVALID_CURSOR; + } + else { + value = GroupsListContinueError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupsListContinueErrorException.java b/src/main/java/com/dropbox/core/v2/team/GroupsListContinueErrorException.java index 3bca02fa2..20ca37fe9 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupsListContinueErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupsListContinueErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/GroupsListResult.java b/src/main/java/com/dropbox/core/v2/team/GroupsListResult.java index 140f07ea9..8f387260e 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupsListResult.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupsListResult.java @@ -1,40 +1,24 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; +import com.dropbox.core.v2.teamcommon.GroupSummary; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=GroupsListResult.Serializer.class) -@JsonDeserialize(using=GroupsListResult.Deserializer.class) public class GroupsListResult { // struct GroupsListResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List groups; protected final String cursor; protected final boolean hasMore; @@ -130,7 +114,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -142,104 +126,77 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupsListResult.class); - } - - public Serializer(boolean unwrapping) { - super(GroupsListResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GroupsListResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("groups", value.groups); - g.writeObjectField("cursor", value.cursor); - g.writeObjectField("has_more", value.hasMore); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupsListResult.class); - } - - public Deserializer(boolean unwrapping) { - super(GroupsListResult.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GroupsListResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("groups"); + StoneSerializers.list(GroupSummary.Serializer.INSTANCE).serialize(value.groups, g); + g.writeFieldName("cursor"); + StoneSerializers.string().serialize(value.cursor, g); + g.writeFieldName("has_more"); + StoneSerializers.boolean_().serialize(value.hasMore, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GroupsListResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List groups = null; - String cursor = null; - Boolean hasMore = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("groups".equals(_field)) { - expectArrayStart(_p); - groups = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - GroupSummary _x = null; - _x = _p.readValueAs(GroupSummary.class); - _p.nextToken(); - groups.add(_x); + public GroupsListResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GroupsListResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_groups = null; + String f_cursor = null; + Boolean f_hasMore = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("groups".equals(field)) { + f_groups = StoneSerializers.list(GroupSummary.Serializer.INSTANCE).deserialize(p); + } + else if ("cursor".equals(field)) { + f_cursor = StoneSerializers.string().deserialize(p); + } + else if ("has_more".equals(field)) { + f_hasMore = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); + if (f_groups == null) { + throw new JsonParseException(p, "Required field \"groups\" missing."); } - else if ("has_more".equals(_field)) { - hasMore = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_cursor == null) { + throw new JsonParseException(p, "Required field \"cursor\" missing."); } - else { - skipValue(_p); + if (f_hasMore == null) { + throw new JsonParseException(p, "Required field \"has_more\" missing."); } + value = new GroupsListResult(f_groups, f_cursor, f_hasMore); } - - if (groups == null) { - throw new JsonParseException(_p, "Required field \"groups\" is missing."); - } - if (cursor == null) { - throw new JsonParseException(_p, "Required field \"cursor\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (hasMore == null) { - throw new JsonParseException(_p, "Required field \"has_more\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new GroupsListResult(groups, cursor, hasMore); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupsMembersListArg.java b/src/main/java/com/dropbox/core/v2/team/GroupsMembersListArg.java new file mode 100644 index 000000000..8f382a9ed --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/team/GroupsMembersListArg.java @@ -0,0 +1,180 @@ +/* DO NOT EDIT */ +/* This file was generated from team_groups.stone */ + +package com.dropbox.core.v2.team; + +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + +import java.io.IOException; + +class GroupsMembersListArg { + // struct GroupsMembersListArg + + protected final GroupSelector group; + protected final long limit; + + /** + * + * @param group The group whose members are to be listed. Must not be + * {@code null}. + * @param limit Number of results to return per call. Must be greater than + * or equal to 1 and be less than or equal to 1000. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public GroupsMembersListArg(GroupSelector group, long limit) { + if (group == null) { + throw new IllegalArgumentException("Required value for 'group' is null"); + } + this.group = group; + if (limit < 1L) { + throw new IllegalArgumentException("Number 'limit' is smaller than 1L"); + } + if (limit > 1000L) { + throw new IllegalArgumentException("Number 'limit' is larger than 1000L"); + } + this.limit = limit; + } + + /** + * The default values for unset fields will be used. + * + * @param group The group whose members are to be listed. Must not be + * {@code null}. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public GroupsMembersListArg(GroupSelector group) { + this(group, 1000L); + } + + /** + * The group whose members are to be listed. + * + * @return value for this field, never {@code null}. + */ + public GroupSelector getGroup() { + return group; + } + + /** + * Number of results to return per call. + * + * @return value for this field, or {@code null} if not present. Defaults to + * 1000L. + */ + public long getLimit() { + return limit; + } + + @Override + public int hashCode() { + int hash = java.util.Arrays.hashCode(new Object [] { + group, + limit + }); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + // be careful with inheritance + else if (obj.getClass().equals(this.getClass())) { + GroupsMembersListArg other = (GroupsMembersListArg) obj; + return ((this.group == other.group) || (this.group.equals(other.group))) + && (this.limit == other.limit) + ; + } + else { + return false; + } + } + + @Override + public String toString() { + return Serializer.INSTANCE.serialize(this, false); + } + + /** + * Returns a String representation of this object formatted for easier + * readability. + * + *

The returned String may contain newlines.

+ * + * @return Formatted, multiline String representation of this object + */ + public String toStringMultiline() { + return Serializer.INSTANCE.serialize(this, true); + } + + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); + + @Override + public void serialize(GroupsMembersListArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("group"); + GroupSelector.Serializer.INSTANCE.serialize(value.group, g); + g.writeFieldName("limit"); + StoneSerializers.uInt32().serialize(value.limit, g); + if (!collapse) { + g.writeEndObject(); + } + } + + @Override + public GroupsMembersListArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GroupsMembersListArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + GroupSelector f_group = null; + Long f_limit = 1000L; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("group".equals(field)) { + f_group = GroupSelector.Serializer.INSTANCE.deserialize(p); + } + else if ("limit".equals(field)) { + f_limit = StoneSerializers.uInt32().deserialize(p); + } + else { + skipValue(p); + } + } + if (f_group == null) { + throw new JsonParseException(p, "Required field \"group\" missing."); + } + value = new GroupsMembersListArg(f_group, f_limit); + } + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; + } + } +} diff --git a/src/main/java/com/dropbox/core/v2/team/GroupsMembersListContinueArg.java b/src/main/java/com/dropbox/core/v2/team/GroupsMembersListContinueArg.java new file mode 100644 index 000000000..6658cdc25 --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/team/GroupsMembersListContinueArg.java @@ -0,0 +1,138 @@ +/* DO NOT EDIT */ +/* This file was generated from team_groups.stone */ + +package com.dropbox.core.v2.team; + +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + +import java.io.IOException; + +class GroupsMembersListContinueArg { + // struct GroupsMembersListContinueArg + + protected final String cursor; + + /** + * + * @param cursor Indicates from what point to get the next set of groups. + * Must not be {@code null}. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public GroupsMembersListContinueArg(String cursor) { + if (cursor == null) { + throw new IllegalArgumentException("Required value for 'cursor' is null"); + } + this.cursor = cursor; + } + + /** + * Indicates from what point to get the next set of groups. + * + * @return value for this field, never {@code null}. + */ + public String getCursor() { + return cursor; + } + + @Override + public int hashCode() { + int hash = java.util.Arrays.hashCode(new Object [] { + cursor + }); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + // be careful with inheritance + else if (obj.getClass().equals(this.getClass())) { + GroupsMembersListContinueArg other = (GroupsMembersListContinueArg) obj; + return (this.cursor == other.cursor) || (this.cursor.equals(other.cursor)); + } + else { + return false; + } + } + + @Override + public String toString() { + return Serializer.INSTANCE.serialize(this, false); + } + + /** + * Returns a String representation of this object formatted for easier + * readability. + * + *

The returned String may contain newlines.

+ * + * @return Formatted, multiline String representation of this object + */ + public String toStringMultiline() { + return Serializer.INSTANCE.serialize(this, true); + } + + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); + + @Override + public void serialize(GroupsMembersListContinueArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("cursor"); + StoneSerializers.string().serialize(value.cursor, g); + if (!collapse) { + g.writeEndObject(); + } + } + + @Override + public GroupsMembersListContinueArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GroupsMembersListContinueArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_cursor = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("cursor".equals(field)) { + f_cursor = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } + } + if (f_cursor == null) { + throw new JsonParseException(p, "Required field \"cursor\" missing."); + } + value = new GroupsMembersListContinueArg(f_cursor); + } + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; + } + } +} diff --git a/src/main/java/com/dropbox/core/v2/team/GroupsMembersListContinueError.java b/src/main/java/com/dropbox/core/v2/team/GroupsMembersListContinueError.java new file mode 100644 index 000000000..7a499e135 --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/team/GroupsMembersListContinueError.java @@ -0,0 +1,78 @@ +/* DO NOT EDIT */ +/* This file was generated from team_groups.stone */ + +package com.dropbox.core.v2.team; + +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + +import java.io.IOException; + +public enum GroupsMembersListContinueError { + // union GroupsMembersListContinueError + /** + * The cursor is invalid. + */ + INVALID_CURSOR, + /** + * An unspecified error. + */ + OTHER; // *catch_all + + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); + + @Override + public void serialize(GroupsMembersListContinueError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value) { + case INVALID_CURSOR: { + g.writeString("invalid_cursor"); + break; + } + default: { + g.writeString("other"); + } + } + } + + @Override + public GroupsMembersListContinueError deserialize(JsonParser p) throws IOException, JsonParseException { + GroupsMembersListContinueError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("invalid_cursor".equals(tag)) { + value = GroupsMembersListContinueError.INVALID_CURSOR; + } + else { + value = GroupsMembersListContinueError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; + } + } +} diff --git a/src/main/java/com/dropbox/core/v2/team/GroupsMembersListContinueErrorException.java b/src/main/java/com/dropbox/core/v2/team/GroupsMembersListContinueErrorException.java new file mode 100644 index 000000000..0626ce35b --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/team/GroupsMembersListContinueErrorException.java @@ -0,0 +1,29 @@ +/* DO NOT EDIT */ +/* This file was generated from team_groups.stone */ + +package com.dropbox.core.v2.team; + +import com.dropbox.core.DbxApiException; +import com.dropbox.core.LocalizedText; + +/** + * Exception thrown when the server responds with a {@link + * GroupsMembersListContinueError} error. + */ +public class GroupsMembersListContinueErrorException extends DbxApiException { + private static final long serialVersionUID = 0L; + + /** + * The error reported by {@link + * DbxTeamTeamRequests#groupsMembersListContinue(String)}. + */ + public final GroupsMembersListContinueError errorValue; + + public GroupsMembersListContinueErrorException(String requestId, LocalizedText userMessage, GroupsMembersListContinueError errorValue) { + super(requestId, userMessage, buildMessage("groups/members/list/continue", userMessage, errorValue)); + if (errorValue == null) { + throw new NullPointerException("errorValue"); + } + this.errorValue = errorValue; + } +} diff --git a/src/main/java/com/dropbox/core/v2/team/GroupsMembersListResult.java b/src/main/java/com/dropbox/core/v2/team/GroupsMembersListResult.java new file mode 100644 index 000000000..5c8eb0d95 --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/team/GroupsMembersListResult.java @@ -0,0 +1,202 @@ +/* DO NOT EDIT */ +/* This file was generated from team_groups.stone */ + +package com.dropbox.core.v2.team; + +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + +import java.io.IOException; +import java.util.List; + +public class GroupsMembersListResult { + // struct GroupsMembersListResult + + protected final List members; + protected final String cursor; + protected final boolean hasMore; + + /** + * + * @param members Must not contain a {@code null} item and not be {@code + * null}. + * @param cursor Pass the cursor into {@link + * DbxTeamTeamRequests#groupsMembersListContinue(String)} to obtain + * additional group members. Must not be {@code null}. + * @param hasMore Is true if there are additional group members that have + * not been returned yet. An additional call to {@link + * DbxTeamTeamRequests#groupsMembersListContinue(String)} can retrieve + * them. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public GroupsMembersListResult(List members, String cursor, boolean hasMore) { + if (members == null) { + throw new IllegalArgumentException("Required value for 'members' is null"); + } + for (GroupMemberInfo x : members) { + if (x == null) { + throw new IllegalArgumentException("An item in list 'members' is null"); + } + } + this.members = members; + if (cursor == null) { + throw new IllegalArgumentException("Required value for 'cursor' is null"); + } + this.cursor = cursor; + this.hasMore = hasMore; + } + + /** + * + * @return value for this field, never {@code null}. + */ + public List getMembers() { + return members; + } + + /** + * Pass the cursor into {@link + * DbxTeamTeamRequests#groupsMembersListContinue(String)} to obtain + * additional group members. + * + * @return value for this field, never {@code null}. + */ + public String getCursor() { + return cursor; + } + + /** + * Is true if there are additional group members that have not been returned + * yet. An additional call to {@link + * DbxTeamTeamRequests#groupsMembersListContinue(String)} can retrieve them. + * + * @return value for this field. + */ + public boolean getHasMore() { + return hasMore; + } + + @Override + public int hashCode() { + int hash = java.util.Arrays.hashCode(new Object [] { + members, + cursor, + hasMore + }); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + // be careful with inheritance + else if (obj.getClass().equals(this.getClass())) { + GroupsMembersListResult other = (GroupsMembersListResult) obj; + return ((this.members == other.members) || (this.members.equals(other.members))) + && ((this.cursor == other.cursor) || (this.cursor.equals(other.cursor))) + && (this.hasMore == other.hasMore) + ; + } + else { + return false; + } + } + + @Override + public String toString() { + return Serializer.INSTANCE.serialize(this, false); + } + + /** + * Returns a String representation of this object formatted for easier + * readability. + * + *

The returned String may contain newlines.

+ * + * @return Formatted, multiline String representation of this object + */ + public String toStringMultiline() { + return Serializer.INSTANCE.serialize(this, true); + } + + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); + + @Override + public void serialize(GroupsMembersListResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("members"); + StoneSerializers.list(GroupMemberInfo.Serializer.INSTANCE).serialize(value.members, g); + g.writeFieldName("cursor"); + StoneSerializers.string().serialize(value.cursor, g); + g.writeFieldName("has_more"); + StoneSerializers.boolean_().serialize(value.hasMore, g); + if (!collapse) { + g.writeEndObject(); + } + } + + @Override + public GroupsMembersListResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GroupsMembersListResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_members = null; + String f_cursor = null; + Boolean f_hasMore = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("members".equals(field)) { + f_members = StoneSerializers.list(GroupMemberInfo.Serializer.INSTANCE).deserialize(p); + } + else if ("cursor".equals(field)) { + f_cursor = StoneSerializers.string().deserialize(p); + } + else if ("has_more".equals(field)) { + f_hasMore = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } + } + if (f_members == null) { + throw new JsonParseException(p, "Required field \"members\" missing."); + } + if (f_cursor == null) { + throw new JsonParseException(p, "Required field \"cursor\" missing."); + } + if (f_hasMore == null) { + throw new JsonParseException(p, "Required field \"has_more\" missing."); + } + value = new GroupsMembersListResult(f_members, f_cursor, f_hasMore); + } + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; + } + } +} diff --git a/src/main/java/com/dropbox/core/v2/team/GroupsPollError.java b/src/main/java/com/dropbox/core/v2/team/GroupsPollError.java index e9443be37..b0c7e3629 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupsPollError.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupsPollError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=GroupsPollError.Serializer.class) -@JsonDeserialize(using=GroupsPollError.Deserializer.class) public enum GroupsPollError { // union GroupsPollError /** @@ -49,52 +35,74 @@ public enum GroupsPollError { */ ACCESS_DENIED; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupsPollError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GroupsPollError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(GroupsPollError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case INVALID_ASYNC_JOB_ID: + case INVALID_ASYNC_JOB_ID: { g.writeString("invalid_async_job_id"); break; - case INTERNAL_ERROR: + } + case INTERNAL_ERROR: { g.writeString("internal_error"); break; - case OTHER: + } + case OTHER: { g.writeString("other"); break; - case ACCESS_DENIED: + } + case ACCESS_DENIED: { g.writeString("access_denied"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupsPollError.class, getTagMapping(), null); - } @Override - public GroupsPollError deserialize(GroupsPollError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("access_denied", GroupsPollError.ACCESS_DENIED); - return Collections.unmodifiableMap(values); + public GroupsPollError deserialize(JsonParser p) throws IOException, JsonParseException { + GroupsPollError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("invalid_async_job_id".equals(tag)) { + value = GroupsPollError.INVALID_ASYNC_JOB_ID; + } + else if ("internal_error".equals(tag)) { + value = GroupsPollError.INTERNAL_ERROR; + } + else if ("other".equals(tag)) { + value = GroupsPollError.OTHER; + } + else if ("access_denied".equals(tag)) { + value = GroupsPollError.ACCESS_DENIED; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupsPollErrorException.java b/src/main/java/com/dropbox/core/v2/team/GroupsPollErrorException.java index a5a7ac109..7b1d3d12e 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupsPollErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupsPollErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/GroupsSelector.java b/src/main/java/com/dropbox/core/v2/team/GroupsSelector.java index b915b5956..3c5fcf5d6 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupsSelector.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupsSelector.java @@ -1,31 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * Argument for selecting a list of groups, either by group_ids, or external @@ -36,15 +24,9 @@ * methods will return {@code true}. You can use {@link #tag()} to determine the * tag associated with this instance.

*/ -@JsonSerialize(using=GroupsSelector.Serializer.class) -@JsonDeserialize(using=GroupsSelector.Deserializer.class) public final class GroupsSelector { // union GroupsSelector - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link GroupsSelector}. */ @@ -235,7 +217,7 @@ else if (obj instanceof GroupsSelector) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -247,94 +229,77 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupsSelector.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GroupsSelector value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case GROUP_IDS: + public void serialize(GroupsSelector value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case GROUP_IDS: { g.writeStartObject(); - g.writeStringField(".tag", "group_ids"); - g.writeObjectField("group_ids", value.groupIdsValue); + writeTag("group_ids", g); + g.writeFieldName("group_ids"); + StoneSerializers.list(StoneSerializers.string()).serialize(value.groupIdsValue, g); g.writeEndObject(); break; - case GROUP_EXTERNAL_IDS: + } + case GROUP_EXTERNAL_IDS: { g.writeStartObject(); - g.writeStringField(".tag", "group_external_ids"); - g.writeObjectField("group_external_ids", value.groupExternalIdsValue); + writeTag("group_external_ids", g); + g.writeFieldName("group_external_ids"); + StoneSerializers.list(StoneSerializers.string()).serialize(value.groupExternalIdsValue, g); g.writeEndObject(); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupsSelector.class, getTagMapping(), null); - } - - @Override - public GroupsSelector deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case GROUP_IDS: { - List value = null; - expectField(_p, "group_ids"); - expectArrayStart(_p); - value = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - String _x = null; - _x = getStringValue(_p); - _p.nextToken(); - value.add(_x); - } - expectArrayEnd(_p); - _p.nextToken(); - return GroupsSelector.groupIds(value); } - case GROUP_EXTERNAL_IDS: { - List value = null; - expectField(_p, "group_external_ids"); - expectArrayStart(_p); - value = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - String _x = null; - _x = getStringValue(_p); - _p.nextToken(); - value.add(_x); - } - expectArrayEnd(_p); - _p.nextToken(); - return GroupsSelector.groupExternalIds(value); + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("group_ids", GroupsSelector.Tag.GROUP_IDS); - values.put("group_external_ids", GroupsSelector.Tag.GROUP_EXTERNAL_IDS); - return Collections.unmodifiableMap(values); + @Override + public GroupsSelector deserialize(JsonParser p) throws IOException, JsonParseException { + GroupsSelector value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("group_ids".equals(tag)) { + List fieldValue = null; + expectField("group_ids", p); + fieldValue = StoneSerializers.list(StoneSerializers.string()).deserialize(p); + value = GroupsSelector.groupIds(fieldValue); + } + else if ("group_external_ids".equals(tag)) { + List fieldValue = null; + expectField("group_external_ids", p); + fieldValue = StoneSerializers.list(StoneSerializers.string()).deserialize(p); + value = GroupsSelector.groupExternalIds(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/GroupsUpdateBuilder.java b/src/main/java/com/dropbox/core/v2/team/GroupsUpdateBuilder.java index 97ef0131c..51b2c8d8d 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupsUpdateBuilder.java +++ b/src/main/java/com/dropbox/core/v2/team/GroupsUpdateBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; @@ -13,26 +13,26 @@ * request.

*/ public class GroupsUpdateBuilder { - private final DbxTeamTeamRequests team; + private final DbxTeamTeamRequests team_; private final GroupUpdateArgs.Builder groupUpdateArgsBuilder; /** * Creates a new instance of this builder. * - * @param team Dropbox namespace-specific client used to issue team + * @param team_ Dropbox namespace-specific client used to issue team * requests. * @param groupUpdateArgsBuilder Request argument builder. * * @return instsance of this builder */ - GroupsUpdateBuilder(DbxTeamTeamRequests team, GroupUpdateArgs.Builder groupUpdateArgsBuilder) { - if (team == null) { - throw new NullPointerException("team"); + GroupsUpdateBuilder(DbxTeamTeamRequests team_, GroupUpdateArgs.Builder groupUpdateArgsBuilder) { + if (team_ == null) { + throw new NullPointerException("team_"); } + this.team_ = team_; if (groupUpdateArgsBuilder == null) { throw new NullPointerException("groupUpdateArgsBuilder"); } - this.team = team; this.groupUpdateArgsBuilder = groupUpdateArgsBuilder; } @@ -85,7 +85,7 @@ public GroupsUpdateBuilder withNewGroupExternalId(String newGroupExternalId) { * Issues the request. */ public GroupFullInfo start() throws GroupUpdateErrorException, DbxException { - GroupUpdateArgs arg = this.groupUpdateArgsBuilder.build(); - return team.groupsUpdate(arg); + GroupUpdateArgs arg_ = this.groupUpdateArgsBuilder.build(); + return team_.groupsUpdate(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/team/IncludeMembersArg.java b/src/main/java/com/dropbox/core/v2/team/IncludeMembersArg.java index 5596138f8..daa5aa572 100644 --- a/src/main/java/com/dropbox/core/v2/team/IncludeMembersArg.java +++ b/src/main/java/com/dropbox/core/v2/team/IncludeMembersArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=IncludeMembersArg.Serializer.class) -@JsonDeserialize(using=IncludeMembersArg.Deserializer.class) public class IncludeMembersArg { // struct IncludeMembersArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final boolean returnMembers; /** @@ -90,7 +73,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -102,75 +85,56 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(IncludeMembersArg.class); - } - - public Serializer(boolean unwrapping) { - super(IncludeMembersArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(IncludeMembersArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("return_members", value.returnMembers); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(IncludeMembersArg.class); - } - - public Deserializer(boolean unwrapping) { - super(IncludeMembersArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(IncludeMembersArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("return_members"); + StoneSerializers.boolean_().serialize(value.returnMembers, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public IncludeMembersArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - boolean returnMembers = true; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("return_members".equals(_field)) { - returnMembers = _p.getValueAsBoolean(); - _p.nextToken(); - } - else { - skipValue(_p); + public IncludeMembersArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + IncludeMembersArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Boolean f_returnMembers = true; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("return_members".equals(field)) { + f_returnMembers = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } } + value = new IncludeMembersArg(f_returnMembers); } - - - return new IncludeMembersArg(returnMembers); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/ListMemberAppsArg.java b/src/main/java/com/dropbox/core/v2/team/ListMemberAppsArg.java index 76f9e0bdf..ebd7c9fc9 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListMemberAppsArg.java +++ b/src/main/java/com/dropbox/core/v2/team/ListMemberAppsArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=ListMemberAppsArg.Serializer.class) -@JsonDeserialize(using=ListMemberAppsArg.Deserializer.class) class ListMemberAppsArg { // struct ListMemberAppsArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String teamMemberId; /** @@ -84,7 +67,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -96,78 +79,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListMemberAppsArg.class); - } - - public Serializer(boolean unwrapping) { - super(ListMemberAppsArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(ListMemberAppsArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("team_member_id", value.teamMemberId); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListMemberAppsArg.class); - } - - public Deserializer(boolean unwrapping) { - super(ListMemberAppsArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(ListMemberAppsArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("team_member_id"); + StoneSerializers.string().serialize(value.teamMemberId, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public ListMemberAppsArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String teamMemberId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("team_member_id".equals(_field)) { - teamMemberId = getStringValue(_p); - _p.nextToken(); + public ListMemberAppsArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListMemberAppsArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_teamMemberId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("team_member_id".equals(field)) { + f_teamMemberId = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_teamMemberId == null) { + throw new JsonParseException(p, "Required field \"team_member_id\" missing."); } + value = new ListMemberAppsArg(f_teamMemberId); } - - if (teamMemberId == null) { - throw new JsonParseException(_p, "Required field \"team_member_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new ListMemberAppsArg(teamMemberId); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/ListMemberAppsError.java b/src/main/java/com/dropbox/core/v2/team/ListMemberAppsError.java index 836702bdb..b132a1b41 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListMemberAppsError.java +++ b/src/main/java/com/dropbox/core/v2/team/ListMemberAppsError.java @@ -1,37 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Error returned by {@link * DbxTeamTeamRequests#linkedAppsListMemberLinkedApps(String)}. */ -@JsonSerialize(using=ListMemberAppsError.Serializer.class) -@JsonDeserialize(using=ListMemberAppsError.Deserializer.class) public enum ListMemberAppsError { // union ListMemberAppsError /** @@ -43,47 +29,54 @@ public enum ListMemberAppsError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListMemberAppsError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ListMemberAppsError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(ListMemberAppsError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case MEMBER_NOT_FOUND: + case MEMBER_NOT_FOUND: { g.writeString("member_not_found"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListMemberAppsError.class, getTagMapping(), ListMemberAppsError.OTHER); - } @Override - public ListMemberAppsError deserialize(ListMemberAppsError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("member_not_found", ListMemberAppsError.MEMBER_NOT_FOUND); - values.put("other", ListMemberAppsError.OTHER); - return Collections.unmodifiableMap(values); + public ListMemberAppsError deserialize(JsonParser p) throws IOException, JsonParseException { + ListMemberAppsError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("member_not_found".equals(tag)) { + value = ListMemberAppsError.MEMBER_NOT_FOUND; + } + else { + value = ListMemberAppsError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/ListMemberAppsErrorException.java b/src/main/java/com/dropbox/core/v2/team/ListMemberAppsErrorException.java index 781670e84..e3c6a6cf6 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListMemberAppsErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/ListMemberAppsErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/ListMemberAppsResult.java b/src/main/java/com/dropbox/core/v2/team/ListMemberAppsResult.java index 076f607b6..e6ffb9778 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListMemberAppsResult.java +++ b/src/main/java/com/dropbox/core/v2/team/ListMemberAppsResult.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=ListMemberAppsResult.Serializer.class) -@JsonDeserialize(using=ListMemberAppsResult.Deserializer.class) public class ListMemberAppsResult { // struct ListMemberAppsResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List linkedApiApps; /** @@ -92,7 +75,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -104,86 +87,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListMemberAppsResult.class); - } - - public Serializer(boolean unwrapping) { - super(ListMemberAppsResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(ListMemberAppsResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("linked_api_apps", value.linkedApiApps); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListMemberAppsResult.class); - } - - public Deserializer(boolean unwrapping) { - super(ListMemberAppsResult.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(ListMemberAppsResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("linked_api_apps"); + StoneSerializers.list(ApiApp.Serializer.INSTANCE).serialize(value.linkedApiApps, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public ListMemberAppsResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List linkedApiApps = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("linked_api_apps".equals(_field)) { - expectArrayStart(_p); - linkedApiApps = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - ApiApp _x = null; - _x = _p.readValueAs(ApiApp.class); - _p.nextToken(); - linkedApiApps.add(_x); + public ListMemberAppsResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListMemberAppsResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_linkedApiApps = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("linked_api_apps".equals(field)) { + f_linkedApiApps = StoneSerializers.list(ApiApp.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else { - skipValue(_p); + if (f_linkedApiApps == null) { + throw new JsonParseException(p, "Required field \"linked_api_apps\" missing."); } + value = new ListMemberAppsResult(f_linkedApiApps); } - - if (linkedApiApps == null) { - throw new JsonParseException(_p, "Required field \"linked_api_apps\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new ListMemberAppsResult(linkedApiApps); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/ListMemberDevicesArg.java b/src/main/java/com/dropbox/core/v2/team/ListMemberDevicesArg.java index b0f4be991..150186e9b 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListMemberDevicesArg.java +++ b/src/main/java/com/dropbox/core/v2/team/ListMemberDevicesArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=ListMemberDevicesArg.Serializer.class) -@JsonDeserialize(using=ListMemberDevicesArg.Deserializer.class) class ListMemberDevicesArg { // struct ListMemberDevicesArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String teamMemberId; protected final boolean includeWebSessions; protected final boolean includeDesktopClients; @@ -257,7 +240,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -269,96 +252,77 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListMemberDevicesArg.class); - } - - public Serializer(boolean unwrapping) { - super(ListMemberDevicesArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(ListMemberDevicesArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("team_member_id", value.teamMemberId); - g.writeObjectField("include_web_sessions", value.includeWebSessions); - g.writeObjectField("include_desktop_clients", value.includeDesktopClients); - g.writeObjectField("include_mobile_clients", value.includeMobileClients); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListMemberDevicesArg.class); - } - - public Deserializer(boolean unwrapping) { - super(ListMemberDevicesArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(ListMemberDevicesArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("team_member_id"); + StoneSerializers.string().serialize(value.teamMemberId, g); + g.writeFieldName("include_web_sessions"); + StoneSerializers.boolean_().serialize(value.includeWebSessions, g); + g.writeFieldName("include_desktop_clients"); + StoneSerializers.boolean_().serialize(value.includeDesktopClients, g); + g.writeFieldName("include_mobile_clients"); + StoneSerializers.boolean_().serialize(value.includeMobileClients, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public ListMemberDevicesArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String teamMemberId = null; - boolean includeWebSessions = true; - boolean includeDesktopClients = true; - boolean includeMobileClients = true; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("team_member_id".equals(_field)) { - teamMemberId = getStringValue(_p); - _p.nextToken(); - } - else if ("include_web_sessions".equals(_field)) { - includeWebSessions = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("include_desktop_clients".equals(_field)) { - includeDesktopClients = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("include_mobile_clients".equals(_field)) { - includeMobileClients = _p.getValueAsBoolean(); - _p.nextToken(); + public ListMemberDevicesArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListMemberDevicesArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_teamMemberId = null; + Boolean f_includeWebSessions = true; + Boolean f_includeDesktopClients = true; + Boolean f_includeMobileClients = true; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("team_member_id".equals(field)) { + f_teamMemberId = StoneSerializers.string().deserialize(p); + } + else if ("include_web_sessions".equals(field)) { + f_includeWebSessions = StoneSerializers.boolean_().deserialize(p); + } + else if ("include_desktop_clients".equals(field)) { + f_includeDesktopClients = StoneSerializers.boolean_().deserialize(p); + } + else if ("include_mobile_clients".equals(field)) { + f_includeMobileClients = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_teamMemberId == null) { + throw new JsonParseException(p, "Required field \"team_member_id\" missing."); } + value = new ListMemberDevicesArg(f_teamMemberId, f_includeWebSessions, f_includeDesktopClients, f_includeMobileClients); } - - if (teamMemberId == null) { - throw new JsonParseException(_p, "Required field \"team_member_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new ListMemberDevicesArg(teamMemberId, includeWebSessions, includeDesktopClients, includeMobileClients); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/ListMemberDevicesError.java b/src/main/java/com/dropbox/core/v2/team/ListMemberDevicesError.java index 11f756e39..f26dbdf2d 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListMemberDevicesError.java +++ b/src/main/java/com/dropbox/core/v2/team/ListMemberDevicesError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=ListMemberDevicesError.Serializer.class) -@JsonDeserialize(using=ListMemberDevicesError.Deserializer.class) public enum ListMemberDevicesError { // union ListMemberDevicesError /** @@ -39,47 +25,54 @@ public enum ListMemberDevicesError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListMemberDevicesError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ListMemberDevicesError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(ListMemberDevicesError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case MEMBER_NOT_FOUND: + case MEMBER_NOT_FOUND: { g.writeString("member_not_found"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListMemberDevicesError.class, getTagMapping(), ListMemberDevicesError.OTHER); - } @Override - public ListMemberDevicesError deserialize(ListMemberDevicesError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("member_not_found", ListMemberDevicesError.MEMBER_NOT_FOUND); - values.put("other", ListMemberDevicesError.OTHER); - return Collections.unmodifiableMap(values); + public ListMemberDevicesError deserialize(JsonParser p) throws IOException, JsonParseException { + ListMemberDevicesError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("member_not_found".equals(tag)) { + value = ListMemberDevicesError.MEMBER_NOT_FOUND; + } + else { + value = ListMemberDevicesError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/ListMemberDevicesErrorException.java b/src/main/java/com/dropbox/core/v2/team/ListMemberDevicesErrorException.java index 9dbdb1d17..d9f679935 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListMemberDevicesErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/ListMemberDevicesErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/ListMemberDevicesResult.java b/src/main/java/com/dropbox/core/v2/team/ListMemberDevicesResult.java index e70892873..5fd463f43 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListMemberDevicesResult.java +++ b/src/main/java/com/dropbox/core/v2/team/ListMemberDevicesResult.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=ListMemberDevicesResult.Serializer.class) -@JsonDeserialize(using=ListMemberDevicesResult.Deserializer.class) public class ListMemberDevicesResult { // struct ListMemberDevicesResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List activeWebSessions; protected final List desktopClientSessions; protected final List mobileClientSessions; @@ -248,7 +231,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -260,117 +243,74 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListMemberDevicesResult.class); - } - - public Serializer(boolean unwrapping) { - super(ListMemberDevicesResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(ListMemberDevicesResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(ListMemberDevicesResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } if (value.activeWebSessions != null) { - g.writeObjectField("active_web_sessions", value.activeWebSessions); + g.writeFieldName("active_web_sessions"); + StoneSerializers.nullable(StoneSerializers.list(ActiveWebSession.Serializer.INSTANCE)).serialize(value.activeWebSessions, g); } if (value.desktopClientSessions != null) { - g.writeObjectField("desktop_client_sessions", value.desktopClientSessions); + g.writeFieldName("desktop_client_sessions"); + StoneSerializers.nullable(StoneSerializers.list(DesktopClientSession.Serializer.INSTANCE)).serialize(value.desktopClientSessions, g); } if (value.mobileClientSessions != null) { - g.writeObjectField("mobile_client_sessions", value.mobileClientSessions); + g.writeFieldName("mobile_client_sessions"); + StoneSerializers.nullable(StoneSerializers.list(MobileClientSession.Serializer.INSTANCE)).serialize(value.mobileClientSessions, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListMemberDevicesResult.class); - } - - public Deserializer(boolean unwrapping) { - super(ListMemberDevicesResult.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public ListMemberDevicesResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List activeWebSessions = null; - List desktopClientSessions = null; - List mobileClientSessions = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("active_web_sessions".equals(_field)) { - expectArrayStart(_p); - activeWebSessions = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - ActiveWebSession _x = null; - _x = _p.readValueAs(ActiveWebSession.class); - _p.nextToken(); - activeWebSessions.add(_x); + public ListMemberDevicesResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListMemberDevicesResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_activeWebSessions = null; + List f_desktopClientSessions = null; + List f_mobileClientSessions = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("active_web_sessions".equals(field)) { + f_activeWebSessions = StoneSerializers.nullable(StoneSerializers.list(ActiveWebSession.Serializer.INSTANCE)).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("desktop_client_sessions".equals(_field)) { - expectArrayStart(_p); - desktopClientSessions = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - DesktopClientSession _x = null; - _x = _p.readValueAs(DesktopClientSession.class); - _p.nextToken(); - desktopClientSessions.add(_x); + else if ("desktop_client_sessions".equals(field)) { + f_desktopClientSessions = StoneSerializers.nullable(StoneSerializers.list(DesktopClientSession.Serializer.INSTANCE)).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("mobile_client_sessions".equals(_field)) { - expectArrayStart(_p); - mobileClientSessions = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - MobileClientSession _x = null; - _x = _p.readValueAs(MobileClientSession.class); - _p.nextToken(); - mobileClientSessions.add(_x); + else if ("mobile_client_sessions".equals(field)) { + f_mobileClientSessions = StoneSerializers.nullable(StoneSerializers.list(MobileClientSession.Serializer.INSTANCE)).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else { - skipValue(_p); } + value = new ListMemberDevicesResult(f_activeWebSessions, f_desktopClientSessions, f_mobileClientSessions); } - - - return new ListMemberDevicesResult(activeWebSessions, desktopClientSessions, mobileClientSessions); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/ListMembersAppsArg.java b/src/main/java/com/dropbox/core/v2/team/ListMembersAppsArg.java index cff8a3642..4ee1fcb28 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListMembersAppsArg.java +++ b/src/main/java/com/dropbox/core/v2/team/ListMembersAppsArg.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Arguments for {@link DbxTeamTeamRequests#linkedAppsListMembersLinkedApps()}. */ -@JsonSerialize(using=ListMembersAppsArg.Serializer.class) -@JsonDeserialize(using=ListMembersAppsArg.Deserializer.class) class ListMembersAppsArg { // struct ListMembersAppsArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String cursor; /** @@ -101,7 +84,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -113,77 +96,58 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListMembersAppsArg.class); - } - - public Serializer(boolean unwrapping) { - super(ListMembersAppsArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(ListMembersAppsArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(ListMembersAppsArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } if (value.cursor != null) { - g.writeObjectField("cursor", value.cursor); + g.writeFieldName("cursor"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.cursor, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListMembersAppsArg.class); - } - - public Deserializer(boolean unwrapping) { - super(ListMembersAppsArg.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public ListMembersAppsArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String cursor = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); - } - else { - skipValue(_p); + public ListMembersAppsArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListMembersAppsArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_cursor = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("cursor".equals(field)) { + f_cursor = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } + value = new ListMembersAppsArg(f_cursor); } - - - return new ListMembersAppsArg(cursor); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/ListMembersAppsError.java b/src/main/java/com/dropbox/core/v2/team/ListMembersAppsError.java index 123bd466c..689a2bd6d 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListMembersAppsError.java +++ b/src/main/java/com/dropbox/core/v2/team/ListMembersAppsError.java @@ -1,37 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Error returned by {@link * DbxTeamTeamRequests#linkedAppsListMembersLinkedApps()} */ -@JsonSerialize(using=ListMembersAppsError.Serializer.class) -@JsonDeserialize(using=ListMembersAppsError.Deserializer.class) public enum ListMembersAppsError { // union ListMembersAppsError /** @@ -45,47 +31,54 @@ public enum ListMembersAppsError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListMembersAppsError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ListMembersAppsError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(ListMembersAppsError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case RESET: + case RESET: { g.writeString("reset"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListMembersAppsError.class, getTagMapping(), ListMembersAppsError.OTHER); - } @Override - public ListMembersAppsError deserialize(ListMembersAppsError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("reset", ListMembersAppsError.RESET); - values.put("other", ListMembersAppsError.OTHER); - return Collections.unmodifiableMap(values); + public ListMembersAppsError deserialize(JsonParser p) throws IOException, JsonParseException { + ListMembersAppsError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("reset".equals(tag)) { + value = ListMembersAppsError.RESET; + } + else { + value = ListMembersAppsError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/ListMembersAppsErrorException.java b/src/main/java/com/dropbox/core/v2/team/ListMembersAppsErrorException.java index 5be0798cb..8db4d71d4 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListMembersAppsErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/ListMembersAppsErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/ListMembersAppsResult.java b/src/main/java/com/dropbox/core/v2/team/ListMembersAppsResult.java index 0915a07e9..1e163d7c4 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListMembersAppsResult.java +++ b/src/main/java/com/dropbox/core/v2/team/ListMembersAppsResult.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; @@ -30,15 +19,9 @@ * Information returned by {@link * DbxTeamTeamRequests#linkedAppsListMembersLinkedApps()}. */ -@JsonSerialize(using=ListMembersAppsResult.Serializer.class) -@JsonDeserialize(using=ListMembersAppsResult.Deserializer.class) public class ListMembersAppsResult { // struct ListMembersAppsResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List apps; protected final boolean hasMore; protected final String cursor; @@ -155,7 +138,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -167,103 +150,76 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListMembersAppsResult.class); - } - - public Serializer(boolean unwrapping) { - super(ListMembersAppsResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(ListMembersAppsResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("apps", value.apps); - g.writeObjectField("has_more", value.hasMore); + public void serialize(ListMembersAppsResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("apps"); + StoneSerializers.list(MemberLinkedApps.Serializer.INSTANCE).serialize(value.apps, g); + g.writeFieldName("has_more"); + StoneSerializers.boolean_().serialize(value.hasMore, g); if (value.cursor != null) { - g.writeObjectField("cursor", value.cursor); + g.writeFieldName("cursor"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.cursor, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListMembersAppsResult.class); - } - - public Deserializer(boolean unwrapping) { - super(ListMembersAppsResult.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public ListMembersAppsResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List apps = null; - Boolean hasMore = null; - String cursor = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("apps".equals(_field)) { - expectArrayStart(_p); - apps = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - MemberLinkedApps _x = null; - _x = _p.readValueAs(MemberLinkedApps.class); - _p.nextToken(); - apps.add(_x); + public ListMembersAppsResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListMembersAppsResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_apps = null; + Boolean f_hasMore = null; + String f_cursor = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("apps".equals(field)) { + f_apps = StoneSerializers.list(MemberLinkedApps.Serializer.INSTANCE).deserialize(p); + } + else if ("has_more".equals(field)) { + f_hasMore = StoneSerializers.boolean_().deserialize(p); + } + else if ("cursor".equals(field)) { + f_cursor = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("has_more".equals(_field)) { - hasMore = _p.getValueAsBoolean(); - _p.nextToken(); } - else if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); + if (f_apps == null) { + throw new JsonParseException(p, "Required field \"apps\" missing."); } - else { - skipValue(_p); + if (f_hasMore == null) { + throw new JsonParseException(p, "Required field \"has_more\" missing."); } + value = new ListMembersAppsResult(f_apps, f_hasMore, f_cursor); } - - if (apps == null) { - throw new JsonParseException(_p, "Required field \"apps\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (hasMore == null) { - throw new JsonParseException(_p, "Required field \"has_more\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new ListMembersAppsResult(apps, hasMore, cursor); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/ListMembersDevicesArg.java b/src/main/java/com/dropbox/core/v2/team/ListMembersDevicesArg.java index ee11fb423..7f86db2da 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListMembersDevicesArg.java +++ b/src/main/java/com/dropbox/core/v2/team/ListMembersDevicesArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=ListMembersDevicesArg.Serializer.class) -@JsonDeserialize(using=ListMembersDevicesArg.Deserializer.class) class ListMembersDevicesArg { // struct ListMembersDevicesArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String cursor; protected final boolean includeWebSessions; protected final boolean includeDesktopClients; @@ -260,7 +243,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -272,95 +255,76 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListMembersDevicesArg.class); - } - - public Serializer(boolean unwrapping) { - super(ListMembersDevicesArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(ListMembersDevicesArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(ListMembersDevicesArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } if (value.cursor != null) { - g.writeObjectField("cursor", value.cursor); + g.writeFieldName("cursor"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.cursor, g); + } + g.writeFieldName("include_web_sessions"); + StoneSerializers.boolean_().serialize(value.includeWebSessions, g); + g.writeFieldName("include_desktop_clients"); + StoneSerializers.boolean_().serialize(value.includeDesktopClients, g); + g.writeFieldName("include_mobile_clients"); + StoneSerializers.boolean_().serialize(value.includeMobileClients, g); + if (!collapse) { + g.writeEndObject(); } - g.writeObjectField("include_web_sessions", value.includeWebSessions); - g.writeObjectField("include_desktop_clients", value.includeDesktopClients); - g.writeObjectField("include_mobile_clients", value.includeMobileClients); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListMembersDevicesArg.class); - } - - public Deserializer(boolean unwrapping) { - super(ListMembersDevicesArg.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public ListMembersDevicesArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String cursor = null; - boolean includeWebSessions = true; - boolean includeDesktopClients = true; - boolean includeMobileClients = true; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); - } - else if ("include_web_sessions".equals(_field)) { - includeWebSessions = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("include_desktop_clients".equals(_field)) { - includeDesktopClients = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("include_mobile_clients".equals(_field)) { - includeMobileClients = _p.getValueAsBoolean(); - _p.nextToken(); - } - else { - skipValue(_p); + public ListMembersDevicesArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListMembersDevicesArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_cursor = null; + Boolean f_includeWebSessions = true; + Boolean f_includeDesktopClients = true; + Boolean f_includeMobileClients = true; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("cursor".equals(field)) { + f_cursor = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("include_web_sessions".equals(field)) { + f_includeWebSessions = StoneSerializers.boolean_().deserialize(p); + } + else if ("include_desktop_clients".equals(field)) { + f_includeDesktopClients = StoneSerializers.boolean_().deserialize(p); + } + else if ("include_mobile_clients".equals(field)) { + f_includeMobileClients = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } } + value = new ListMembersDevicesArg(f_cursor, f_includeWebSessions, f_includeDesktopClients, f_includeMobileClients); } - - - return new ListMembersDevicesArg(cursor, includeWebSessions, includeDesktopClients, includeMobileClients); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/ListMembersDevicesError.java b/src/main/java/com/dropbox/core/v2/team/ListMembersDevicesError.java index c7ad8b597..7fd32373c 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListMembersDevicesError.java +++ b/src/main/java/com/dropbox/core/v2/team/ListMembersDevicesError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=ListMembersDevicesError.Serializer.class) -@JsonDeserialize(using=ListMembersDevicesError.Deserializer.class) public enum ListMembersDevicesError { // union ListMembersDevicesError /** @@ -41,47 +27,54 @@ public enum ListMembersDevicesError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListMembersDevicesError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ListMembersDevicesError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(ListMembersDevicesError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case RESET: + case RESET: { g.writeString("reset"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListMembersDevicesError.class, getTagMapping(), ListMembersDevicesError.OTHER); - } @Override - public ListMembersDevicesError deserialize(ListMembersDevicesError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("reset", ListMembersDevicesError.RESET); - values.put("other", ListMembersDevicesError.OTHER); - return Collections.unmodifiableMap(values); + public ListMembersDevicesError deserialize(JsonParser p) throws IOException, JsonParseException { + ListMembersDevicesError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("reset".equals(tag)) { + value = ListMembersDevicesError.RESET; + } + else { + value = ListMembersDevicesError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/ListMembersDevicesErrorException.java b/src/main/java/com/dropbox/core/v2/team/ListMembersDevicesErrorException.java index c3a389704..b5c8cc328 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListMembersDevicesErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/ListMembersDevicesErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/ListMembersDevicesResult.java b/src/main/java/com/dropbox/core/v2/team/ListMembersDevicesResult.java index 55eea0c77..bf5b5c625 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListMembersDevicesResult.java +++ b/src/main/java/com/dropbox/core/v2/team/ListMembersDevicesResult.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=ListMembersDevicesResult.Serializer.class) -@JsonDeserialize(using=ListMembersDevicesResult.Deserializer.class) public class ListMembersDevicesResult { // struct ListMembersDevicesResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List devices; protected final boolean hasMore; protected final String cursor; @@ -143,7 +126,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -155,103 +138,76 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListMembersDevicesResult.class); - } - - public Serializer(boolean unwrapping) { - super(ListMembersDevicesResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(ListMembersDevicesResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("devices", value.devices); - g.writeObjectField("has_more", value.hasMore); + public void serialize(ListMembersDevicesResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("devices"); + StoneSerializers.list(MemberDevices.Serializer.INSTANCE).serialize(value.devices, g); + g.writeFieldName("has_more"); + StoneSerializers.boolean_().serialize(value.hasMore, g); if (value.cursor != null) { - g.writeObjectField("cursor", value.cursor); + g.writeFieldName("cursor"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.cursor, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListMembersDevicesResult.class); - } - - public Deserializer(boolean unwrapping) { - super(ListMembersDevicesResult.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public ListMembersDevicesResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List devices = null; - Boolean hasMore = null; - String cursor = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("devices".equals(_field)) { - expectArrayStart(_p); - devices = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - MemberDevices _x = null; - _x = _p.readValueAs(MemberDevices.class); - _p.nextToken(); - devices.add(_x); + public ListMembersDevicesResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListMembersDevicesResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_devices = null; + Boolean f_hasMore = null; + String f_cursor = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("devices".equals(field)) { + f_devices = StoneSerializers.list(MemberDevices.Serializer.INSTANCE).deserialize(p); + } + else if ("has_more".equals(field)) { + f_hasMore = StoneSerializers.boolean_().deserialize(p); + } + else if ("cursor".equals(field)) { + f_cursor = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("has_more".equals(_field)) { - hasMore = _p.getValueAsBoolean(); - _p.nextToken(); } - else if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); + if (f_devices == null) { + throw new JsonParseException(p, "Required field \"devices\" missing."); } - else { - skipValue(_p); + if (f_hasMore == null) { + throw new JsonParseException(p, "Required field \"has_more\" missing."); } + value = new ListMembersDevicesResult(f_devices, f_hasMore, f_cursor); } - - if (devices == null) { - throw new JsonParseException(_p, "Required field \"devices\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (hasMore == null) { - throw new JsonParseException(_p, "Required field \"has_more\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new ListMembersDevicesResult(devices, hasMore, cursor); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/ListTeamAppsArg.java b/src/main/java/com/dropbox/core/v2/team/ListTeamAppsArg.java index 15c0b1d50..01c9afa78 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListTeamAppsArg.java +++ b/src/main/java/com/dropbox/core/v2/team/ListTeamAppsArg.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Arguments for {@link DbxTeamTeamRequests#linkedAppsListTeamLinkedApps()}. */ -@JsonSerialize(using=ListTeamAppsArg.Serializer.class) -@JsonDeserialize(using=ListTeamAppsArg.Deserializer.class) class ListTeamAppsArg { // struct ListTeamAppsArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String cursor; /** @@ -99,7 +82,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -111,77 +94,58 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListTeamAppsArg.class); - } - - public Serializer(boolean unwrapping) { - super(ListTeamAppsArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(ListTeamAppsArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(ListTeamAppsArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } if (value.cursor != null) { - g.writeObjectField("cursor", value.cursor); + g.writeFieldName("cursor"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.cursor, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListTeamAppsArg.class); - } - - public Deserializer(boolean unwrapping) { - super(ListTeamAppsArg.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public ListTeamAppsArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String cursor = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); - } - else { - skipValue(_p); + public ListTeamAppsArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListTeamAppsArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_cursor = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("cursor".equals(field)) { + f_cursor = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } + value = new ListTeamAppsArg(f_cursor); } - - - return new ListTeamAppsArg(cursor); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/ListTeamAppsError.java b/src/main/java/com/dropbox/core/v2/team/ListTeamAppsError.java index 8e86936f5..50aa32e43 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListTeamAppsError.java +++ b/src/main/java/com/dropbox/core/v2/team/ListTeamAppsError.java @@ -1,36 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Error returned by {@link DbxTeamTeamRequests#linkedAppsListTeamLinkedApps()} */ -@JsonSerialize(using=ListTeamAppsError.Serializer.class) -@JsonDeserialize(using=ListTeamAppsError.Deserializer.class) public enum ListTeamAppsError { // union ListTeamAppsError /** @@ -44,47 +30,54 @@ public enum ListTeamAppsError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListTeamAppsError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ListTeamAppsError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(ListTeamAppsError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case RESET: + case RESET: { g.writeString("reset"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListTeamAppsError.class, getTagMapping(), ListTeamAppsError.OTHER); - } @Override - public ListTeamAppsError deserialize(ListTeamAppsError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("reset", ListTeamAppsError.RESET); - values.put("other", ListTeamAppsError.OTHER); - return Collections.unmodifiableMap(values); + public ListTeamAppsError deserialize(JsonParser p) throws IOException, JsonParseException { + ListTeamAppsError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("reset".equals(tag)) { + value = ListTeamAppsError.RESET; + } + else { + value = ListTeamAppsError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/ListTeamAppsErrorException.java b/src/main/java/com/dropbox/core/v2/team/ListTeamAppsErrorException.java index 921776e9f..928133cc4 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListTeamAppsErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/ListTeamAppsErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/ListTeamAppsResult.java b/src/main/java/com/dropbox/core/v2/team/ListTeamAppsResult.java index fa735ceed..e74efa0ac 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListTeamAppsResult.java +++ b/src/main/java/com/dropbox/core/v2/team/ListTeamAppsResult.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; @@ -30,15 +19,9 @@ * Information returned by {@link * DbxTeamTeamRequests#linkedAppsListTeamLinkedApps()}. */ -@JsonSerialize(using=ListTeamAppsResult.Serializer.class) -@JsonDeserialize(using=ListTeamAppsResult.Deserializer.class) public class ListTeamAppsResult { // struct ListTeamAppsResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List apps; protected final boolean hasMore; protected final String cursor; @@ -152,7 +135,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -164,103 +147,76 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListTeamAppsResult.class); - } - - public Serializer(boolean unwrapping) { - super(ListTeamAppsResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(ListTeamAppsResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("apps", value.apps); - g.writeObjectField("has_more", value.hasMore); + public void serialize(ListTeamAppsResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("apps"); + StoneSerializers.list(MemberLinkedApps.Serializer.INSTANCE).serialize(value.apps, g); + g.writeFieldName("has_more"); + StoneSerializers.boolean_().serialize(value.hasMore, g); if (value.cursor != null) { - g.writeObjectField("cursor", value.cursor); + g.writeFieldName("cursor"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.cursor, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListTeamAppsResult.class); - } - - public Deserializer(boolean unwrapping) { - super(ListTeamAppsResult.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public ListTeamAppsResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List apps = null; - Boolean hasMore = null; - String cursor = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("apps".equals(_field)) { - expectArrayStart(_p); - apps = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - MemberLinkedApps _x = null; - _x = _p.readValueAs(MemberLinkedApps.class); - _p.nextToken(); - apps.add(_x); + public ListTeamAppsResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListTeamAppsResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_apps = null; + Boolean f_hasMore = null; + String f_cursor = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("apps".equals(field)) { + f_apps = StoneSerializers.list(MemberLinkedApps.Serializer.INSTANCE).deserialize(p); + } + else if ("has_more".equals(field)) { + f_hasMore = StoneSerializers.boolean_().deserialize(p); + } + else if ("cursor".equals(field)) { + f_cursor = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("has_more".equals(_field)) { - hasMore = _p.getValueAsBoolean(); - _p.nextToken(); } - else if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); + if (f_apps == null) { + throw new JsonParseException(p, "Required field \"apps\" missing."); } - else { - skipValue(_p); + if (f_hasMore == null) { + throw new JsonParseException(p, "Required field \"has_more\" missing."); } + value = new ListTeamAppsResult(f_apps, f_hasMore, f_cursor); } - - if (apps == null) { - throw new JsonParseException(_p, "Required field \"apps\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (hasMore == null) { - throw new JsonParseException(_p, "Required field \"has_more\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new ListTeamAppsResult(apps, hasMore, cursor); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/ListTeamDevicesArg.java b/src/main/java/com/dropbox/core/v2/team/ListTeamDevicesArg.java index 82496be19..0cecb4e84 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListTeamDevicesArg.java +++ b/src/main/java/com/dropbox/core/v2/team/ListTeamDevicesArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=ListTeamDevicesArg.Serializer.class) -@JsonDeserialize(using=ListTeamDevicesArg.Deserializer.class) class ListTeamDevicesArg { // struct ListTeamDevicesArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String cursor; protected final boolean includeWebSessions; protected final boolean includeDesktopClients; @@ -260,7 +243,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -272,95 +255,76 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListTeamDevicesArg.class); - } - - public Serializer(boolean unwrapping) { - super(ListTeamDevicesArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(ListTeamDevicesArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(ListTeamDevicesArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } if (value.cursor != null) { - g.writeObjectField("cursor", value.cursor); + g.writeFieldName("cursor"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.cursor, g); + } + g.writeFieldName("include_web_sessions"); + StoneSerializers.boolean_().serialize(value.includeWebSessions, g); + g.writeFieldName("include_desktop_clients"); + StoneSerializers.boolean_().serialize(value.includeDesktopClients, g); + g.writeFieldName("include_mobile_clients"); + StoneSerializers.boolean_().serialize(value.includeMobileClients, g); + if (!collapse) { + g.writeEndObject(); } - g.writeObjectField("include_web_sessions", value.includeWebSessions); - g.writeObjectField("include_desktop_clients", value.includeDesktopClients); - g.writeObjectField("include_mobile_clients", value.includeMobileClients); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListTeamDevicesArg.class); - } - - public Deserializer(boolean unwrapping) { - super(ListTeamDevicesArg.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public ListTeamDevicesArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String cursor = null; - boolean includeWebSessions = true; - boolean includeDesktopClients = true; - boolean includeMobileClients = true; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); - } - else if ("include_web_sessions".equals(_field)) { - includeWebSessions = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("include_desktop_clients".equals(_field)) { - includeDesktopClients = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("include_mobile_clients".equals(_field)) { - includeMobileClients = _p.getValueAsBoolean(); - _p.nextToken(); - } - else { - skipValue(_p); + public ListTeamDevicesArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListTeamDevicesArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_cursor = null; + Boolean f_includeWebSessions = true; + Boolean f_includeDesktopClients = true; + Boolean f_includeMobileClients = true; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("cursor".equals(field)) { + f_cursor = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("include_web_sessions".equals(field)) { + f_includeWebSessions = StoneSerializers.boolean_().deserialize(p); + } + else if ("include_desktop_clients".equals(field)) { + f_includeDesktopClients = StoneSerializers.boolean_().deserialize(p); + } + else if ("include_mobile_clients".equals(field)) { + f_includeMobileClients = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } } + value = new ListTeamDevicesArg(f_cursor, f_includeWebSessions, f_includeDesktopClients, f_includeMobileClients); } - - - return new ListTeamDevicesArg(cursor, includeWebSessions, includeDesktopClients, includeMobileClients); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/ListTeamDevicesError.java b/src/main/java/com/dropbox/core/v2/team/ListTeamDevicesError.java index 43a5b6f4f..592a93ccc 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListTeamDevicesError.java +++ b/src/main/java/com/dropbox/core/v2/team/ListTeamDevicesError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=ListTeamDevicesError.Serializer.class) -@JsonDeserialize(using=ListTeamDevicesError.Deserializer.class) public enum ListTeamDevicesError { // union ListTeamDevicesError /** @@ -41,47 +27,54 @@ public enum ListTeamDevicesError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListTeamDevicesError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(ListTeamDevicesError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(ListTeamDevicesError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case RESET: + case RESET: { g.writeString("reset"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListTeamDevicesError.class, getTagMapping(), ListTeamDevicesError.OTHER); - } @Override - public ListTeamDevicesError deserialize(ListTeamDevicesError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("reset", ListTeamDevicesError.RESET); - values.put("other", ListTeamDevicesError.OTHER); - return Collections.unmodifiableMap(values); + public ListTeamDevicesError deserialize(JsonParser p) throws IOException, JsonParseException { + ListTeamDevicesError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("reset".equals(tag)) { + value = ListTeamDevicesError.RESET; + } + else { + value = ListTeamDevicesError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/ListTeamDevicesErrorException.java b/src/main/java/com/dropbox/core/v2/team/ListTeamDevicesErrorException.java index 573e6efca..381ac788c 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListTeamDevicesErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/ListTeamDevicesErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/ListTeamDevicesResult.java b/src/main/java/com/dropbox/core/v2/team/ListTeamDevicesResult.java index 24d34fda1..7037acc75 100644 --- a/src/main/java/com/dropbox/core/v2/team/ListTeamDevicesResult.java +++ b/src/main/java/com/dropbox/core/v2/team/ListTeamDevicesResult.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=ListTeamDevicesResult.Serializer.class) -@JsonDeserialize(using=ListTeamDevicesResult.Deserializer.class) public class ListTeamDevicesResult { // struct ListTeamDevicesResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List devices; protected final boolean hasMore; protected final String cursor; @@ -142,7 +125,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -154,103 +137,76 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(ListTeamDevicesResult.class); - } - - public Serializer(boolean unwrapping) { - super(ListTeamDevicesResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(ListTeamDevicesResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("devices", value.devices); - g.writeObjectField("has_more", value.hasMore); + public void serialize(ListTeamDevicesResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("devices"); + StoneSerializers.list(MemberDevices.Serializer.INSTANCE).serialize(value.devices, g); + g.writeFieldName("has_more"); + StoneSerializers.boolean_().serialize(value.hasMore, g); if (value.cursor != null) { - g.writeObjectField("cursor", value.cursor); + g.writeFieldName("cursor"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.cursor, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(ListTeamDevicesResult.class); - } - - public Deserializer(boolean unwrapping) { - super(ListTeamDevicesResult.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public ListTeamDevicesResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List devices = null; - Boolean hasMore = null; - String cursor = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("devices".equals(_field)) { - expectArrayStart(_p); - devices = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - MemberDevices _x = null; - _x = _p.readValueAs(MemberDevices.class); - _p.nextToken(); - devices.add(_x); + public ListTeamDevicesResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + ListTeamDevicesResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_devices = null; + Boolean f_hasMore = null; + String f_cursor = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("devices".equals(field)) { + f_devices = StoneSerializers.list(MemberDevices.Serializer.INSTANCE).deserialize(p); + } + else if ("has_more".equals(field)) { + f_hasMore = StoneSerializers.boolean_().deserialize(p); + } + else if ("cursor".equals(field)) { + f_cursor = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("has_more".equals(_field)) { - hasMore = _p.getValueAsBoolean(); - _p.nextToken(); } - else if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); + if (f_devices == null) { + throw new JsonParseException(p, "Required field \"devices\" missing."); } - else { - skipValue(_p); + if (f_hasMore == null) { + throw new JsonParseException(p, "Required field \"has_more\" missing."); } + value = new ListTeamDevicesResult(f_devices, f_hasMore, f_cursor); } - - if (devices == null) { - throw new JsonParseException(_p, "Required field \"devices\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (hasMore == null) { - throw new JsonParseException(_p, "Required field \"has_more\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new ListTeamDevicesResult(devices, hasMore, cursor); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MemberAccess.java b/src/main/java/com/dropbox/core/v2/team/MemberAccess.java index c1fba6beb..98c50f766 100644 --- a/src/main/java/com/dropbox/core/v2/team/MemberAccess.java +++ b/src/main/java/com/dropbox/core/v2/team/MemberAccess.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from team_groups.babel */ +/* This file was generated from team_groups.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Specify access type a member should have when joined to a group. */ -@JsonSerialize(using=MemberAccess.Serializer.class) -@JsonDeserialize(using=MemberAccess.Deserializer.class) public class MemberAccess { // struct MemberAccess - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final UserSelectorArg user; protected final GroupAccessType accessType; @@ -106,7 +89,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -118,87 +101,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MemberAccess.class); - } - - public Serializer(boolean unwrapping) { - super(MemberAccess.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(MemberAccess value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("user", value.user); - g.writeObjectField("access_type", value.accessType); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MemberAccess.class); - } - - public Deserializer(boolean unwrapping) { - super(MemberAccess.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(MemberAccess value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("user"); + UserSelectorArg.Serializer.INSTANCE.serialize(value.user, g); + g.writeFieldName("access_type"); + GroupAccessType.Serializer.INSTANCE.serialize(value.accessType, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public MemberAccess deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - UserSelectorArg user = null; - GroupAccessType accessType = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("user".equals(_field)) { - user = _p.readValueAs(UserSelectorArg.class); - _p.nextToken(); + public MemberAccess deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MemberAccess value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + UserSelectorArg f_user = null; + GroupAccessType f_accessType = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("user".equals(field)) { + f_user = UserSelectorArg.Serializer.INSTANCE.deserialize(p); + } + else if ("access_type".equals(field)) { + f_accessType = GroupAccessType.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else if ("access_type".equals(_field)) { - accessType = _p.readValueAs(GroupAccessType.class); - _p.nextToken(); + if (f_user == null) { + throw new JsonParseException(p, "Required field \"user\" missing."); } - else { - skipValue(_p); + if (f_accessType == null) { + throw new JsonParseException(p, "Required field \"access_type\" missing."); } + value = new MemberAccess(f_user, f_accessType); } - - if (user == null) { - throw new JsonParseException(_p, "Required field \"user\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (accessType == null) { - throw new JsonParseException(_p, "Required field \"access_type\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new MemberAccess(user, accessType); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MemberAddArg.java b/src/main/java/com/dropbox/core/v2/team/MemberAddArg.java index 13969b25b..66b17528f 100644 --- a/src/main/java/com/dropbox/core/v2/team/MemberAddArg.java +++ b/src/main/java/com/dropbox/core/v2/team/MemberAddArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=MemberAddArg.Serializer.class) -@JsonDeserialize(using=MemberAddArg.Deserializer.class) public class MemberAddArg { // struct MemberAddArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String memberEmail; protected final String memberGivenName; protected final String memberSurname; @@ -384,7 +367,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -396,116 +379,97 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MemberAddArg.class); - } - - public Serializer(boolean unwrapping) { - super(MemberAddArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(MemberAddArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("member_email", value.memberEmail); - g.writeObjectField("member_given_name", value.memberGivenName); - g.writeObjectField("member_surname", value.memberSurname); + public void serialize(MemberAddArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("member_email"); + StoneSerializers.string().serialize(value.memberEmail, g); + g.writeFieldName("member_given_name"); + StoneSerializers.string().serialize(value.memberGivenName, g); + g.writeFieldName("member_surname"); + StoneSerializers.string().serialize(value.memberSurname, g); if (value.memberExternalId != null) { - g.writeObjectField("member_external_id", value.memberExternalId); + g.writeFieldName("member_external_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.memberExternalId, g); + } + g.writeFieldName("send_welcome_email"); + StoneSerializers.boolean_().serialize(value.sendWelcomeEmail, g); + g.writeFieldName("role"); + AdminTier.Serializer.INSTANCE.serialize(value.role, g); + if (!collapse) { + g.writeEndObject(); } - g.writeObjectField("send_welcome_email", value.sendWelcomeEmail); - g.writeObjectField("role", value.role); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MemberAddArg.class); - } - - public Deserializer(boolean unwrapping) { - super(MemberAddArg.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public MemberAddArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String memberEmail = null; - String memberGivenName = null; - String memberSurname = null; - String memberExternalId = null; - boolean sendWelcomeEmail = true; - AdminTier role = AdminTier.MEMBER_ONLY; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("member_email".equals(_field)) { - memberEmail = getStringValue(_p); - _p.nextToken(); - } - else if ("member_given_name".equals(_field)) { - memberGivenName = getStringValue(_p); - _p.nextToken(); - } - else if ("member_surname".equals(_field)) { - memberSurname = getStringValue(_p); - _p.nextToken(); - } - else if ("member_external_id".equals(_field)) { - memberExternalId = getStringValue(_p); - _p.nextToken(); + public MemberAddArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MemberAddArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_memberEmail = null; + String f_memberGivenName = null; + String f_memberSurname = null; + String f_memberExternalId = null; + Boolean f_sendWelcomeEmail = true; + AdminTier f_role = AdminTier.MEMBER_ONLY; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("member_email".equals(field)) { + f_memberEmail = StoneSerializers.string().deserialize(p); + } + else if ("member_given_name".equals(field)) { + f_memberGivenName = StoneSerializers.string().deserialize(p); + } + else if ("member_surname".equals(field)) { + f_memberSurname = StoneSerializers.string().deserialize(p); + } + else if ("member_external_id".equals(field)) { + f_memberExternalId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("send_welcome_email".equals(field)) { + f_sendWelcomeEmail = StoneSerializers.boolean_().deserialize(p); + } + else if ("role".equals(field)) { + f_role = AdminTier.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else if ("send_welcome_email".equals(_field)) { - sendWelcomeEmail = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_memberEmail == null) { + throw new JsonParseException(p, "Required field \"member_email\" missing."); } - else if ("role".equals(_field)) { - role = _p.readValueAs(AdminTier.class); - _p.nextToken(); + if (f_memberGivenName == null) { + throw new JsonParseException(p, "Required field \"member_given_name\" missing."); } - else { - skipValue(_p); + if (f_memberSurname == null) { + throw new JsonParseException(p, "Required field \"member_surname\" missing."); } + value = new MemberAddArg(f_memberEmail, f_memberGivenName, f_memberSurname, f_memberExternalId, f_sendWelcomeEmail, f_role); } - - if (memberEmail == null) { - throw new JsonParseException(_p, "Required field \"member_email\" is missing."); - } - if (memberGivenName == null) { - throw new JsonParseException(_p, "Required field \"member_given_name\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (memberSurname == null) { - throw new JsonParseException(_p, "Required field \"member_surname\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new MemberAddArg(memberEmail, memberGivenName, memberSurname, memberExternalId, sendWelcomeEmail, role); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MemberAddResult.java b/src/main/java/com/dropbox/core/v2/team/MemberAddResult.java index 73ce79c09..cc74e5d2b 100644 --- a/src/main/java/com/dropbox/core/v2/team/MemberAddResult.java +++ b/src/main/java/com/dropbox/core/v2/team/MemberAddResult.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Describes the result of attempting to add a single user to the team. @@ -37,15 +25,9 @@ * methods will return {@code true}. You can use {@link #tag()} to determine the * tag associated with this instance.

*/ -@JsonSerialize(using=MemberAddResult.Serializer.class) -@JsonDeserialize(using=MemberAddResult.Deserializer.class) public final class MemberAddResult { // union MemberAddResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link MemberAddResult}. */ @@ -725,7 +707,7 @@ else if (obj instanceof MemberAddResult) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -737,174 +719,173 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MemberAddResult.class, TeamMemberInfo.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MemberAddResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case SUCCESS: + public void serialize(MemberAddResult value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case SUCCESS: { g.writeStartObject(); - g.writeStringField(".tag", "success"); - getUnwrappingSerializer(TeamMemberInfo.class).serialize(value.successValue, g, provider); + writeTag("success", g); + TeamMemberInfo.Serializer.INSTANCE.serialize(value.successValue, g, true); g.writeEndObject(); break; - case TEAM_LICENSE_LIMIT: + } + case TEAM_LICENSE_LIMIT: { g.writeStartObject(); - g.writeStringField(".tag", "team_license_limit"); - g.writeObjectField("team_license_limit", value.teamLicenseLimitValue); + writeTag("team_license_limit", g); + g.writeFieldName("team_license_limit"); + StoneSerializers.string().serialize(value.teamLicenseLimitValue, g); g.writeEndObject(); break; - case FREE_TEAM_MEMBER_LIMIT_REACHED: + } + case FREE_TEAM_MEMBER_LIMIT_REACHED: { g.writeStartObject(); - g.writeStringField(".tag", "free_team_member_limit_reached"); - g.writeObjectField("free_team_member_limit_reached", value.freeTeamMemberLimitReachedValue); + writeTag("free_team_member_limit_reached", g); + g.writeFieldName("free_team_member_limit_reached"); + StoneSerializers.string().serialize(value.freeTeamMemberLimitReachedValue, g); g.writeEndObject(); break; - case USER_ALREADY_ON_TEAM: + } + case USER_ALREADY_ON_TEAM: { g.writeStartObject(); - g.writeStringField(".tag", "user_already_on_team"); - g.writeObjectField("user_already_on_team", value.userAlreadyOnTeamValue); + writeTag("user_already_on_team", g); + g.writeFieldName("user_already_on_team"); + StoneSerializers.string().serialize(value.userAlreadyOnTeamValue, g); g.writeEndObject(); break; - case USER_ON_ANOTHER_TEAM: + } + case USER_ON_ANOTHER_TEAM: { g.writeStartObject(); - g.writeStringField(".tag", "user_on_another_team"); - g.writeObjectField("user_on_another_team", value.userOnAnotherTeamValue); + writeTag("user_on_another_team", g); + g.writeFieldName("user_on_another_team"); + StoneSerializers.string().serialize(value.userOnAnotherTeamValue, g); g.writeEndObject(); break; - case USER_ALREADY_PAIRED: + } + case USER_ALREADY_PAIRED: { g.writeStartObject(); - g.writeStringField(".tag", "user_already_paired"); - g.writeObjectField("user_already_paired", value.userAlreadyPairedValue); + writeTag("user_already_paired", g); + g.writeFieldName("user_already_paired"); + StoneSerializers.string().serialize(value.userAlreadyPairedValue, g); g.writeEndObject(); break; - case USER_MIGRATION_FAILED: + } + case USER_MIGRATION_FAILED: { g.writeStartObject(); - g.writeStringField(".tag", "user_migration_failed"); - g.writeObjectField("user_migration_failed", value.userMigrationFailedValue); + writeTag("user_migration_failed", g); + g.writeFieldName("user_migration_failed"); + StoneSerializers.string().serialize(value.userMigrationFailedValue, g); g.writeEndObject(); break; - case DUPLICATE_EXTERNAL_MEMBER_ID: + } + case DUPLICATE_EXTERNAL_MEMBER_ID: { g.writeStartObject(); - g.writeStringField(".tag", "duplicate_external_member_id"); - g.writeObjectField("duplicate_external_member_id", value.duplicateExternalMemberIdValue); + writeTag("duplicate_external_member_id", g); + g.writeFieldName("duplicate_external_member_id"); + StoneSerializers.string().serialize(value.duplicateExternalMemberIdValue, g); g.writeEndObject(); break; - case USER_CREATION_FAILED: + } + case USER_CREATION_FAILED: { g.writeStartObject(); - g.writeStringField(".tag", "user_creation_failed"); - g.writeObjectField("user_creation_failed", value.userCreationFailedValue); + writeTag("user_creation_failed", g); + g.writeFieldName("user_creation_failed"); + StoneSerializers.string().serialize(value.userCreationFailedValue, g); g.writeEndObject(); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MemberAddResult.class, getTagMapping(), null, TeamMemberInfo.class); - } @Override - public MemberAddResult deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case SUCCESS: { - TeamMemberInfo value = null; - value = readCollapsedStructValue(TeamMemberInfo.class, _p, _ctx); - return MemberAddResult.success(value); - } - case TEAM_LICENSE_LIMIT: { - String value = null; - expectField(_p, "team_license_limit"); - value = getStringValue(_p); - _p.nextToken(); - return MemberAddResult.teamLicenseLimit(value); - } - case FREE_TEAM_MEMBER_LIMIT_REACHED: { - String value = null; - expectField(_p, "free_team_member_limit_reached"); - value = getStringValue(_p); - _p.nextToken(); - return MemberAddResult.freeTeamMemberLimitReached(value); - } - case USER_ALREADY_ON_TEAM: { - String value = null; - expectField(_p, "user_already_on_team"); - value = getStringValue(_p); - _p.nextToken(); - return MemberAddResult.userAlreadyOnTeam(value); - } - case USER_ON_ANOTHER_TEAM: { - String value = null; - expectField(_p, "user_on_another_team"); - value = getStringValue(_p); - _p.nextToken(); - return MemberAddResult.userOnAnotherTeam(value); - } - case USER_ALREADY_PAIRED: { - String value = null; - expectField(_p, "user_already_paired"); - value = getStringValue(_p); - _p.nextToken(); - return MemberAddResult.userAlreadyPaired(value); - } - case USER_MIGRATION_FAILED: { - String value = null; - expectField(_p, "user_migration_failed"); - value = getStringValue(_p); - _p.nextToken(); - return MemberAddResult.userMigrationFailed(value); - } - case DUPLICATE_EXTERNAL_MEMBER_ID: { - String value = null; - expectField(_p, "duplicate_external_member_id"); - value = getStringValue(_p); - _p.nextToken(); - return MemberAddResult.duplicateExternalMemberId(value); - } - case USER_CREATION_FAILED: { - String value = null; - expectField(_p, "user_creation_failed"); - value = getStringValue(_p); - _p.nextToken(); - return MemberAddResult.userCreationFailed(value); - } + public MemberAddResult deserialize(JsonParser p) throws IOException, JsonParseException { + MemberAddResult value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("success".equals(tag)) { + TeamMemberInfo fieldValue = null; + fieldValue = TeamMemberInfo.Serializer.INSTANCE.deserialize(p, true); + value = MemberAddResult.success(fieldValue); + } + else if ("team_license_limit".equals(tag)) { + String fieldValue = null; + expectField("team_license_limit", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = MemberAddResult.teamLicenseLimit(fieldValue); + } + else if ("free_team_member_limit_reached".equals(tag)) { + String fieldValue = null; + expectField("free_team_member_limit_reached", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = MemberAddResult.freeTeamMemberLimitReached(fieldValue); + } + else if ("user_already_on_team".equals(tag)) { + String fieldValue = null; + expectField("user_already_on_team", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = MemberAddResult.userAlreadyOnTeam(fieldValue); + } + else if ("user_on_another_team".equals(tag)) { + String fieldValue = null; + expectField("user_on_another_team", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = MemberAddResult.userOnAnotherTeam(fieldValue); + } + else if ("user_already_paired".equals(tag)) { + String fieldValue = null; + expectField("user_already_paired", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = MemberAddResult.userAlreadyPaired(fieldValue); + } + else if ("user_migration_failed".equals(tag)) { + String fieldValue = null; + expectField("user_migration_failed", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = MemberAddResult.userMigrationFailed(fieldValue); + } + else if ("duplicate_external_member_id".equals(tag)) { + String fieldValue = null; + expectField("duplicate_external_member_id", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = MemberAddResult.duplicateExternalMemberId(fieldValue); + } + else if ("user_creation_failed".equals(tag)) { + String fieldValue = null; + expectField("user_creation_failed", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = MemberAddResult.userCreationFailed(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("success", MemberAddResult.Tag.SUCCESS); - values.put("team_license_limit", MemberAddResult.Tag.TEAM_LICENSE_LIMIT); - values.put("free_team_member_limit_reached", MemberAddResult.Tag.FREE_TEAM_MEMBER_LIMIT_REACHED); - values.put("user_already_on_team", MemberAddResult.Tag.USER_ALREADY_ON_TEAM); - values.put("user_on_another_team", MemberAddResult.Tag.USER_ON_ANOTHER_TEAM); - values.put("user_already_paired", MemberAddResult.Tag.USER_ALREADY_PAIRED); - values.put("user_migration_failed", MemberAddResult.Tag.USER_MIGRATION_FAILED); - values.put("duplicate_external_member_id", MemberAddResult.Tag.DUPLICATE_EXTERNAL_MEMBER_ID); - values.put("user_creation_failed", MemberAddResult.Tag.USER_CREATION_FAILED); - return Collections.unmodifiableMap(values); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MemberDevices.java b/src/main/java/com/dropbox/core/v2/team/MemberDevices.java index 9bb86a09c..1d3f5d383 100644 --- a/src/main/java/com/dropbox/core/v2/team/MemberDevices.java +++ b/src/main/java/com/dropbox/core/v2/team/MemberDevices.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; @@ -29,15 +18,9 @@ /** * Information on devices of a team's member. */ -@JsonSerialize(using=MemberDevices.Serializer.class) -@JsonDeserialize(using=MemberDevices.Deserializer.class) public class MemberDevices { // struct MemberDevices - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String teamMemberId; protected final List webSessions; protected final List desktopClients; @@ -287,7 +270,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -299,126 +282,83 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MemberDevices.class); - } - - public Serializer(boolean unwrapping) { - super(MemberDevices.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(MemberDevices value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("team_member_id", value.teamMemberId); + public void serialize(MemberDevices value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("team_member_id"); + StoneSerializers.string().serialize(value.teamMemberId, g); if (value.webSessions != null) { - g.writeObjectField("web_sessions", value.webSessions); + g.writeFieldName("web_sessions"); + StoneSerializers.nullable(StoneSerializers.list(ActiveWebSession.Serializer.INSTANCE)).serialize(value.webSessions, g); } if (value.desktopClients != null) { - g.writeObjectField("desktop_clients", value.desktopClients); + g.writeFieldName("desktop_clients"); + StoneSerializers.nullable(StoneSerializers.list(DesktopClientSession.Serializer.INSTANCE)).serialize(value.desktopClients, g); } if (value.mobileClients != null) { - g.writeObjectField("mobile_clients", value.mobileClients); + g.writeFieldName("mobile_clients"); + StoneSerializers.nullable(StoneSerializers.list(MobileClientSession.Serializer.INSTANCE)).serialize(value.mobileClients, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MemberDevices.class); - } - - public Deserializer(boolean unwrapping) { - super(MemberDevices.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public MemberDevices deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String teamMemberId = null; - List webSessions = null; - List desktopClients = null; - List mobileClients = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("team_member_id".equals(_field)) { - teamMemberId = getStringValue(_p); - _p.nextToken(); - } - else if ("web_sessions".equals(_field)) { - expectArrayStart(_p); - webSessions = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - ActiveWebSession _x = null; - _x = _p.readValueAs(ActiveWebSession.class); - _p.nextToken(); - webSessions.add(_x); + public MemberDevices deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MemberDevices value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_teamMemberId = null; + List f_webSessions = null; + List f_desktopClients = null; + List f_mobileClients = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("team_member_id".equals(field)) { + f_teamMemberId = StoneSerializers.string().deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("desktop_clients".equals(_field)) { - expectArrayStart(_p); - desktopClients = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - DesktopClientSession _x = null; - _x = _p.readValueAs(DesktopClientSession.class); - _p.nextToken(); - desktopClients.add(_x); + else if ("web_sessions".equals(field)) { + f_webSessions = StoneSerializers.nullable(StoneSerializers.list(ActiveWebSession.Serializer.INSTANCE)).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("mobile_clients".equals(_field)) { - expectArrayStart(_p); - mobileClients = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - MobileClientSession _x = null; - _x = _p.readValueAs(MobileClientSession.class); - _p.nextToken(); - mobileClients.add(_x); + else if ("desktop_clients".equals(field)) { + f_desktopClients = StoneSerializers.nullable(StoneSerializers.list(DesktopClientSession.Serializer.INSTANCE)).deserialize(p); + } + else if ("mobile_clients".equals(field)) { + f_mobileClients = StoneSerializers.nullable(StoneSerializers.list(MobileClientSession.Serializer.INSTANCE)).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else { - skipValue(_p); + if (f_teamMemberId == null) { + throw new JsonParseException(p, "Required field \"team_member_id\" missing."); } + value = new MemberDevices(f_teamMemberId, f_webSessions, f_desktopClients, f_mobileClients); } - - if (teamMemberId == null) { - throw new JsonParseException(_p, "Required field \"team_member_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new MemberDevices(teamMemberId, webSessions, desktopClients, mobileClients); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MemberLinkedApps.java b/src/main/java/com/dropbox/core/v2/team/MemberLinkedApps.java index 6bf807488..91e8f0787 100644 --- a/src/main/java/com/dropbox/core/v2/team/MemberLinkedApps.java +++ b/src/main/java/com/dropbox/core/v2/team/MemberLinkedApps.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; @@ -29,15 +18,9 @@ /** * Information on linked applications of a team member. */ -@JsonSerialize(using=MemberLinkedApps.Serializer.class) -@JsonDeserialize(using=MemberLinkedApps.Deserializer.class) public class MemberLinkedApps { // struct MemberLinkedApps - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String teamMemberId; protected final List linkedApiApps; @@ -114,7 +97,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -126,95 +109,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MemberLinkedApps.class); - } - - public Serializer(boolean unwrapping) { - super(MemberLinkedApps.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(MemberLinkedApps value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("team_member_id", value.teamMemberId); - g.writeObjectField("linked_api_apps", value.linkedApiApps); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MemberLinkedApps.class); - } - - public Deserializer(boolean unwrapping) { - super(MemberLinkedApps.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(MemberLinkedApps value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("team_member_id"); + StoneSerializers.string().serialize(value.teamMemberId, g); + g.writeFieldName("linked_api_apps"); + StoneSerializers.list(ApiApp.Serializer.INSTANCE).serialize(value.linkedApiApps, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public MemberLinkedApps deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String teamMemberId = null; - List linkedApiApps = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("team_member_id".equals(_field)) { - teamMemberId = getStringValue(_p); - _p.nextToken(); - } - else if ("linked_api_apps".equals(_field)) { - expectArrayStart(_p); - linkedApiApps = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - ApiApp _x = null; - _x = _p.readValueAs(ApiApp.class); - _p.nextToken(); - linkedApiApps.add(_x); + public MemberLinkedApps deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MemberLinkedApps value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_teamMemberId = null; + List f_linkedApiApps = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("team_member_id".equals(field)) { + f_teamMemberId = StoneSerializers.string().deserialize(p); + } + else if ("linked_api_apps".equals(field)) { + f_linkedApiApps = StoneSerializers.list(ApiApp.Serializer.INSTANCE).deserialize(p); } - expectArrayEnd(_p); - _p.nextToken(); + else { + skipValue(p); + } + } + if (f_teamMemberId == null) { + throw new JsonParseException(p, "Required field \"team_member_id\" missing."); } - else { - skipValue(_p); + if (f_linkedApiApps == null) { + throw new JsonParseException(p, "Required field \"linked_api_apps\" missing."); } + value = new MemberLinkedApps(f_teamMemberId, f_linkedApiApps); } - - if (teamMemberId == null) { - throw new JsonParseException(_p, "Required field \"team_member_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (linkedApiApps == null) { - throw new JsonParseException(_p, "Required field \"linked_api_apps\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new MemberLinkedApps(teamMemberId, linkedApiApps); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MemberProfile.java b/src/main/java/com/dropbox/core/v2/team/MemberProfile.java index 6e5004a40..708e5cecc 100644 --- a/src/main/java/com/dropbox/core/v2/team/MemberProfile.java +++ b/src/main/java/com/dropbox/core/v2/team/MemberProfile.java @@ -1,49 +1,33 @@ /* DO NOT EDIT */ -/* This file was generated from team.babel */ +/* This file was generated from team.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.dropbox.core.v2.users.Name; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Basic member profile. */ -@JsonSerialize(using=MemberProfile.Serializer.class) -@JsonDeserialize(using=MemberProfile.Deserializer.class) public class MemberProfile { // struct MemberProfile - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String teamMemberId; protected final String externalId; protected final String email; protected final boolean emailVerified; protected final TeamMemberStatus status; protected final Name name; + protected final TeamMembershipType membershipType; /** * Basic member profile. @@ -57,6 +41,9 @@ public class MemberProfile { * be {@code null}. * @param name Representations for a person's name. Must not be {@code * null}. + * @param membershipType The user's membership type: full (normal team + * member) vs limited (does not use a license; no access to the team's + * shared quota). Must not be {@code null}. * @param externalId External ID that a team can attach to the user. An * application using the API may find it easier to use their own IDs * instead of Dropbox IDs like account_id or team_member_id. @@ -64,7 +51,7 @@ public class MemberProfile { * @throws IllegalArgumentException If any argument does not meet its * preconditions. */ - public MemberProfile(String teamMemberId, String email, boolean emailVerified, TeamMemberStatus status, Name name, String externalId) { + public MemberProfile(String teamMemberId, String email, boolean emailVerified, TeamMemberStatus status, Name name, TeamMembershipType membershipType, String externalId) { if (teamMemberId == null) { throw new IllegalArgumentException("Required value for 'teamMemberId' is null"); } @@ -83,6 +70,10 @@ public MemberProfile(String teamMemberId, String email, boolean emailVerified, T throw new IllegalArgumentException("Required value for 'name' is null"); } this.name = name; + if (membershipType == null) { + throw new IllegalArgumentException("Required value for 'membershipType' is null"); + } + this.membershipType = membershipType; } /** @@ -99,12 +90,15 @@ public MemberProfile(String teamMemberId, String email, boolean emailVerified, T * be {@code null}. * @param name Representations for a person's name. Must not be {@code * null}. + * @param membershipType The user's membership type: full (normal team + * member) vs limited (does not use a license; no access to the team's + * shared quota). Must not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. */ - public MemberProfile(String teamMemberId, String email, boolean emailVerified, TeamMemberStatus status, Name name) { - this(teamMemberId, email, emailVerified, status, name, null); + public MemberProfile(String teamMemberId, String email, boolean emailVerified, TeamMemberStatus status, Name name, TeamMembershipType membershipType) { + this(teamMemberId, email, emailVerified, status, name, membershipType, null); } /** @@ -163,6 +157,16 @@ public Name getName() { return name; } + /** + * The user's membership type: full (normal team member) vs limited (does + * not use a license; no access to the team's shared quota). + * + * @return value for this field, never {@code null}. + */ + public TeamMembershipType getMembershipType() { + return membershipType; + } + @Override public int hashCode() { int hash = java.util.Arrays.hashCode(new Object [] { @@ -171,7 +175,8 @@ public int hashCode() { email, emailVerified, status, - name + name, + membershipType }); return hash; } @@ -189,6 +194,7 @@ else if (obj.getClass().equals(this.getClass())) { && (this.emailVerified == other.emailVerified) && ((this.status == other.status) || (this.status.equals(other.status))) && ((this.name == other.name) || (this.name.equals(other.name))) + && ((this.membershipType == other.membershipType) || (this.membershipType.equals(other.membershipType))) && ((this.externalId == other.externalId) || (this.externalId != null && this.externalId.equals(other.externalId))) ; } @@ -199,7 +205,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -211,122 +217,112 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MemberProfile.class); - } - - public Serializer(boolean unwrapping) { - super(MemberProfile.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(MemberProfile value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("team_member_id", value.teamMemberId); - g.writeObjectField("email", value.email); - g.writeObjectField("email_verified", value.emailVerified); - g.writeObjectField("status", value.status); - g.writeObjectField("name", value.name); + public void serialize(MemberProfile value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("team_member_id"); + StoneSerializers.string().serialize(value.teamMemberId, g); + g.writeFieldName("email"); + StoneSerializers.string().serialize(value.email, g); + g.writeFieldName("email_verified"); + StoneSerializers.boolean_().serialize(value.emailVerified, g); + g.writeFieldName("status"); + TeamMemberStatus.Serializer.INSTANCE.serialize(value.status, g); + g.writeFieldName("name"); + Name.Serializer.INSTANCE.serialize(value.name, g); + g.writeFieldName("membership_type"); + TeamMembershipType.Serializer.INSTANCE.serialize(value.membershipType, g); if (value.externalId != null) { - g.writeObjectField("external_id", value.externalId); + g.writeFieldName("external_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.externalId, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MemberProfile.class); - } - - public Deserializer(boolean unwrapping) { - super(MemberProfile.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public MemberProfile deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String teamMemberId = null; - String email = null; - Boolean emailVerified = null; - TeamMemberStatus status = null; - Name name = null; - String externalId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("team_member_id".equals(_field)) { - teamMemberId = getStringValue(_p); - _p.nextToken(); + public MemberProfile deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MemberProfile value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_teamMemberId = null; + String f_email = null; + Boolean f_emailVerified = null; + TeamMemberStatus f_status = null; + Name f_name = null; + TeamMembershipType f_membershipType = null; + String f_externalId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("team_member_id".equals(field)) { + f_teamMemberId = StoneSerializers.string().deserialize(p); + } + else if ("email".equals(field)) { + f_email = StoneSerializers.string().deserialize(p); + } + else if ("email_verified".equals(field)) { + f_emailVerified = StoneSerializers.boolean_().deserialize(p); + } + else if ("status".equals(field)) { + f_status = TeamMemberStatus.Serializer.INSTANCE.deserialize(p); + } + else if ("name".equals(field)) { + f_name = Name.Serializer.INSTANCE.deserialize(p); + } + else if ("membership_type".equals(field)) { + f_membershipType = TeamMembershipType.Serializer.INSTANCE.deserialize(p); + } + else if ("external_id".equals(field)) { + f_externalId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } - else if ("email".equals(_field)) { - email = getStringValue(_p); - _p.nextToken(); + if (f_teamMemberId == null) { + throw new JsonParseException(p, "Required field \"team_member_id\" missing."); } - else if ("email_verified".equals(_field)) { - emailVerified = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_email == null) { + throw new JsonParseException(p, "Required field \"email\" missing."); } - else if ("status".equals(_field)) { - status = _p.readValueAs(TeamMemberStatus.class); - _p.nextToken(); + if (f_emailVerified == null) { + throw new JsonParseException(p, "Required field \"email_verified\" missing."); } - else if ("name".equals(_field)) { - name = _p.readValueAs(Name.class); - _p.nextToken(); + if (f_status == null) { + throw new JsonParseException(p, "Required field \"status\" missing."); } - else if ("external_id".equals(_field)) { - externalId = getStringValue(_p); - _p.nextToken(); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } - else { - skipValue(_p); + if (f_membershipType == null) { + throw new JsonParseException(p, "Required field \"membership_type\" missing."); } + value = new MemberProfile(f_teamMemberId, f_email, f_emailVerified, f_status, f_name, f_membershipType, f_externalId); } - - if (teamMemberId == null) { - throw new JsonParseException(_p, "Required field \"team_member_id\" is missing."); - } - if (email == null) { - throw new JsonParseException(_p, "Required field \"email\" is missing."); - } - if (emailVerified == null) { - throw new JsonParseException(_p, "Required field \"email_verified\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (status == null) { - throw new JsonParseException(_p, "Required field \"status\" is missing."); + if (!collapsed) { + expectEndObject(p); } - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); - } - - return new MemberProfile(teamMemberId, email, emailVerified, status, name, externalId); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MemberSelectorError.java b/src/main/java/com/dropbox/core/v2/team/MemberSelectorError.java index 9a137e33c..17f986940 100644 --- a/src/main/java/com/dropbox/core/v2/team/MemberSelectorError.java +++ b/src/main/java/com/dropbox/core/v2/team/MemberSelectorError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=MemberSelectorError.Serializer.class) -@JsonDeserialize(using=MemberSelectorError.Deserializer.class) public enum MemberSelectorError { // union MemberSelectorError /** @@ -40,46 +26,60 @@ public enum MemberSelectorError { */ USER_NOT_IN_TEAM; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MemberSelectorError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MemberSelectorError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(MemberSelectorError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case USER_NOT_FOUND: + case USER_NOT_FOUND: { g.writeString("user_not_found"); break; - case USER_NOT_IN_TEAM: + } + case USER_NOT_IN_TEAM: { g.writeString("user_not_in_team"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MemberSelectorError.class, getTagMapping(), null); - } @Override - public MemberSelectorError deserialize(MemberSelectorError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("user_not_in_team", MemberSelectorError.USER_NOT_IN_TEAM); - return Collections.unmodifiableMap(values); + public MemberSelectorError deserialize(JsonParser p) throws IOException, JsonParseException { + MemberSelectorError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("user_not_found".equals(tag)) { + value = MemberSelectorError.USER_NOT_FOUND; + } + else if ("user_not_in_team".equals(tag)) { + value = MemberSelectorError.USER_NOT_IN_TEAM; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersAddArg.java b/src/main/java/com/dropbox/core/v2/team/MembersAddArg.java index 18c356f2d..a32cad03b 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersAddArg.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersAddArg.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=MembersAddArg.Serializer.class) -@JsonDeserialize(using=MembersAddArg.Deserializer.class) class MembersAddArg { // struct MembersAddArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List newMembers; protected final boolean forceAsync; @@ -120,7 +103,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -132,92 +115,65 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersAddArg.class); - } - - public Serializer(boolean unwrapping) { - super(MembersAddArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(MembersAddArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("new_members", value.newMembers); - g.writeObjectField("force_async", value.forceAsync); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersAddArg.class); - } - - public Deserializer(boolean unwrapping) { - super(MembersAddArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(MembersAddArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("new_members"); + StoneSerializers.list(MemberAddArg.Serializer.INSTANCE).serialize(value.newMembers, g); + g.writeFieldName("force_async"); + StoneSerializers.boolean_().serialize(value.forceAsync, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public MembersAddArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List newMembers = null; - boolean forceAsync = false; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("new_members".equals(_field)) { - expectArrayStart(_p); - newMembers = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - MemberAddArg _x = null; - _x = _p.readValueAs(MemberAddArg.class); - _p.nextToken(); - newMembers.add(_x); + public MembersAddArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MembersAddArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_newMembers = null; + Boolean f_forceAsync = false; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("new_members".equals(field)) { + f_newMembers = StoneSerializers.list(MemberAddArg.Serializer.INSTANCE).deserialize(p); + } + else if ("force_async".equals(field)) { + f_forceAsync = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); - } - else if ("force_async".equals(_field)) { - forceAsync = _p.getValueAsBoolean(); - _p.nextToken(); } - else { - skipValue(_p); + if (f_newMembers == null) { + throw new JsonParseException(p, "Required field \"new_members\" missing."); } + value = new MembersAddArg(f_newMembers, f_forceAsync); } - - if (newMembers == null) { - throw new JsonParseException(_p, "Required field \"new_members\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new MembersAddArg(newMembers, forceAsync); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersAddJobStatus.java b/src/main/java/com/dropbox/core/v2/team/MembersAddJobStatus.java index cb0924fce..36930a387 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersAddJobStatus.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersAddJobStatus.java @@ -1,31 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * This class is a tagged union. Tagged unions instances are always associated @@ -33,15 +21,9 @@ * return {@code true}. You can use {@link #tag()} to determine the tag * associated with this instance. */ -@JsonSerialize(using=MembersAddJobStatus.Serializer.class) -@JsonDeserialize(using=MembersAddJobStatus.Deserializer.class) public final class MembersAddJobStatus { // union MembersAddJobStatus - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link MembersAddJobStatus}. */ @@ -258,7 +240,7 @@ else if (obj instanceof MembersAddJobStatus) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -270,92 +252,84 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersAddJobStatus.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MembersAddJobStatus value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case IN_PROGRESS: + public void serialize(MembersAddJobStatus value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case IN_PROGRESS: { g.writeString("in_progress"); break; - case COMPLETE: + } + case COMPLETE: { g.writeStartObject(); - g.writeStringField(".tag", "complete"); - g.writeObjectField("complete", value.completeValue); + writeTag("complete", g); + g.writeFieldName("complete"); + StoneSerializers.list(MemberAddResult.Serializer.INSTANCE).serialize(value.completeValue, g); g.writeEndObject(); break; - case FAILED: + } + case FAILED: { g.writeStartObject(); - g.writeStringField(".tag", "failed"); - g.writeObjectField("failed", value.failedValue); + writeTag("failed", g); + g.writeFieldName("failed"); + StoneSerializers.string().serialize(value.failedValue, g); g.writeEndObject(); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersAddJobStatus.class, getTagMapping(), null); - } - - @Override - public MembersAddJobStatus deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case IN_PROGRESS: { - return MembersAddJobStatus.IN_PROGRESS; } - case COMPLETE: { - List value = null; - expectField(_p, "complete"); - expectArrayStart(_p); - value = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - MemberAddResult _x = null; - _x = _p.readValueAs(MemberAddResult.class); - _p.nextToken(); - value.add(_x); - } - expectArrayEnd(_p); - _p.nextToken(); - return MembersAddJobStatus.complete(value); - } - case FAILED: { - String value = null; - expectField(_p, "failed"); - value = getStringValue(_p); - _p.nextToken(); - return MembersAddJobStatus.failed(value); + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("complete", MembersAddJobStatus.Tag.COMPLETE); - values.put("failed", MembersAddJobStatus.Tag.FAILED); - return Collections.unmodifiableMap(values); + @Override + public MembersAddJobStatus deserialize(JsonParser p) throws IOException, JsonParseException { + MembersAddJobStatus value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("in_progress".equals(tag)) { + value = MembersAddJobStatus.IN_PROGRESS; + } + else if ("complete".equals(tag)) { + List fieldValue = null; + expectField("complete", p); + fieldValue = StoneSerializers.list(MemberAddResult.Serializer.INSTANCE).deserialize(p); + value = MembersAddJobStatus.complete(fieldValue); + } + else if ("failed".equals(tag)) { + String fieldValue = null; + expectField("failed", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = MembersAddJobStatus.failed(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersAddLaunch.java b/src/main/java/com/dropbox/core/v2/team/MembersAddLaunch.java index 7f12fbe8b..e4555fa19 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersAddLaunch.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersAddLaunch.java @@ -1,31 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * This class is a tagged union. Tagged unions instances are always associated @@ -33,15 +21,9 @@ * return {@code true}. You can use {@link #tag()} to determine the tag * associated with this instance. */ -@JsonSerialize(using=MembersAddLaunch.Serializer.class) -@JsonDeserialize(using=MembersAddLaunch.Deserializer.class) public final class MembersAddLaunch { // union MembersAddLaunch - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link MembersAddLaunch}. */ @@ -226,7 +208,7 @@ else if (obj instanceof MembersAddLaunch) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -238,85 +220,77 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersAddLaunch.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MembersAddLaunch value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case ASYNC_JOB_ID: + public void serialize(MembersAddLaunch value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case ASYNC_JOB_ID: { g.writeStartObject(); - g.writeStringField(".tag", "async_job_id"); - g.writeObjectField("async_job_id", value.asyncJobIdValue); + writeTag("async_job_id", g); + g.writeFieldName("async_job_id"); + StoneSerializers.string().serialize(value.asyncJobIdValue, g); g.writeEndObject(); break; - case COMPLETE: + } + case COMPLETE: { g.writeStartObject(); - g.writeStringField(".tag", "complete"); - g.writeObjectField("complete", value.completeValue); + writeTag("complete", g); + g.writeFieldName("complete"); + StoneSerializers.list(MemberAddResult.Serializer.INSTANCE).serialize(value.completeValue, g); g.writeEndObject(); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersAddLaunch.class, getTagMapping(), null); - } - - @Override - public MembersAddLaunch deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case ASYNC_JOB_ID: { - String value = null; - expectField(_p, "async_job_id"); - value = getStringValue(_p); - _p.nextToken(); - return MembersAddLaunch.asyncJobId(value); } - case COMPLETE: { - List value = null; - expectField(_p, "complete"); - expectArrayStart(_p); - value = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - MemberAddResult _x = null; - _x = _p.readValueAs(MemberAddResult.class); - _p.nextToken(); - value.add(_x); - } - expectArrayEnd(_p); - _p.nextToken(); - return MembersAddLaunch.complete(value); + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("complete", MembersAddLaunch.Tag.COMPLETE); - return Collections.unmodifiableMap(values); + @Override + public MembersAddLaunch deserialize(JsonParser p) throws IOException, JsonParseException { + MembersAddLaunch value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("async_job_id".equals(tag)) { + String fieldValue = null; + expectField("async_job_id", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = MembersAddLaunch.asyncJobId(fieldValue); + } + else if ("complete".equals(tag)) { + List fieldValue = null; + expectField("complete", p); + fieldValue = StoneSerializers.list(MemberAddResult.Serializer.INSTANCE).deserialize(p); + value = MembersAddLaunch.complete(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersDeactivateArg.java b/src/main/java/com/dropbox/core/v2/team/MembersDeactivateArg.java index ca37ad035..5ca8cfaf6 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersDeactivateArg.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersDeactivateArg.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; @@ -29,15 +18,9 @@ * Exactly one of team_member_id, email, or external_id must be provided to * identify the user account. */ -@JsonSerialize(using=MembersDeactivateArg.Serializer.class) -@JsonDeserialize(using=MembersDeactivateArg.Deserializer.class) public class MembersDeactivateArg { // struct MembersDeactivateArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final UserSelectorArg user; protected final boolean wipeData; @@ -125,7 +108,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -137,84 +120,65 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersDeactivateArg.class); - } - - public Serializer(boolean unwrapping) { - super(MembersDeactivateArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(MembersDeactivateArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("user", value.user); - g.writeObjectField("wipe_data", value.wipeData); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersDeactivateArg.class); - } - - public Deserializer(boolean unwrapping) { - super(MembersDeactivateArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(MembersDeactivateArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("user"); + UserSelectorArg.Serializer.INSTANCE.serialize(value.user, g); + g.writeFieldName("wipe_data"); + StoneSerializers.boolean_().serialize(value.wipeData, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public MembersDeactivateArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - UserSelectorArg user = null; - boolean wipeData = true; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("user".equals(_field)) { - user = _p.readValueAs(UserSelectorArg.class); - _p.nextToken(); - } - else if ("wipe_data".equals(_field)) { - wipeData = _p.getValueAsBoolean(); - _p.nextToken(); + public MembersDeactivateArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MembersDeactivateArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + UserSelectorArg f_user = null; + Boolean f_wipeData = true; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("user".equals(field)) { + f_user = UserSelectorArg.Serializer.INSTANCE.deserialize(p); + } + else if ("wipe_data".equals(field)) { + f_wipeData = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_user == null) { + throw new JsonParseException(p, "Required field \"user\" missing."); } + value = new MembersDeactivateArg(f_user, f_wipeData); } - - if (user == null) { - throw new JsonParseException(_p, "Required field \"user\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new MembersDeactivateArg(user, wipeData); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersDeactivateError.java b/src/main/java/com/dropbox/core/v2/team/MembersDeactivateError.java index 34861b63a..d6ef0387c 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersDeactivateError.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersDeactivateError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=MembersDeactivateError.Serializer.class) -@JsonDeserialize(using=MembersDeactivateError.Deserializer.class) public enum MembersDeactivateError { // union MembersDeactivateError /** @@ -44,50 +30,61 @@ public enum MembersDeactivateError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersDeactivateError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MembersDeactivateError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(MembersDeactivateError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case USER_NOT_FOUND: + case USER_NOT_FOUND: { g.writeString("user_not_found"); break; - case USER_NOT_IN_TEAM: + } + case USER_NOT_IN_TEAM: { g.writeString("user_not_in_team"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersDeactivateError.class, getTagMapping(), MembersDeactivateError.OTHER); - } @Override - public MembersDeactivateError deserialize(MembersDeactivateError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("user_not_in_team", MembersDeactivateError.USER_NOT_IN_TEAM); - values.put("other", MembersDeactivateError.OTHER); - return Collections.unmodifiableMap(values); + public MembersDeactivateError deserialize(JsonParser p) throws IOException, JsonParseException { + MembersDeactivateError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("user_not_found".equals(tag)) { + value = MembersDeactivateError.USER_NOT_FOUND; + } + else if ("user_not_in_team".equals(tag)) { + value = MembersDeactivateError.USER_NOT_IN_TEAM; + } + else { + value = MembersDeactivateError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersGetInfoArgs.java b/src/main/java/com/dropbox/core/v2/team/MembersGetInfoArgs.java index da65cb240..355442834 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersGetInfoArgs.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersGetInfoArgs.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=MembersGetInfoArgs.Serializer.class) -@JsonDeserialize(using=MembersGetInfoArgs.Deserializer.class) class MembersGetInfoArgs { // struct MembersGetInfoArgs - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List members; /** @@ -91,7 +74,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -103,86 +86,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersGetInfoArgs.class); - } - - public Serializer(boolean unwrapping) { - super(MembersGetInfoArgs.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(MembersGetInfoArgs value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("members", value.members); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersGetInfoArgs.class); - } - - public Deserializer(boolean unwrapping) { - super(MembersGetInfoArgs.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(MembersGetInfoArgs value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("members"); + StoneSerializers.list(UserSelectorArg.Serializer.INSTANCE).serialize(value.members, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public MembersGetInfoArgs deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List members = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("members".equals(_field)) { - expectArrayStart(_p); - members = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - UserSelectorArg _x = null; - _x = _p.readValueAs(UserSelectorArg.class); - _p.nextToken(); - members.add(_x); + public MembersGetInfoArgs deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MembersGetInfoArgs value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_members = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("members".equals(field)) { + f_members = StoneSerializers.list(UserSelectorArg.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else { - skipValue(_p); + if (f_members == null) { + throw new JsonParseException(p, "Required field \"members\" missing."); } + value = new MembersGetInfoArgs(f_members); } - - if (members == null) { - throw new JsonParseException(_p, "Required field \"members\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new MembersGetInfoArgs(members); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersGetInfoError.java b/src/main/java/com/dropbox/core/v2/team/MembersGetInfoError.java index 62d872620..dc8b288d3 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersGetInfoError.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersGetInfoError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=MembersGetInfoError.Serializer.class) -@JsonDeserialize(using=MembersGetInfoError.Deserializer.class) public enum MembersGetInfoError { // union MembersGetInfoError /** @@ -35,43 +21,47 @@ public enum MembersGetInfoError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersGetInfoError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MembersGetInfoError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(MembersGetInfoError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case OTHER: + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersGetInfoError.class, getTagMapping(), MembersGetInfoError.OTHER); - } @Override - public MembersGetInfoError deserialize(MembersGetInfoError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("other", MembersGetInfoError.OTHER); - return Collections.unmodifiableMap(values); + public MembersGetInfoError deserialize(JsonParser p) throws IOException, JsonParseException { + MembersGetInfoError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else { + value = MembersGetInfoError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersGetInfoErrorException.java b/src/main/java/com/dropbox/core/v2/team/MembersGetInfoErrorException.java index 1dd0ddd64..f50b54728 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersGetInfoErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersGetInfoErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/MembersGetInfoItem.java b/src/main/java/com/dropbox/core/v2/team/MembersGetInfoItem.java index 6b4093108..1d967458f 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersGetInfoItem.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersGetInfoItem.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Describes a result obtained for a single user whose id was specified in the @@ -35,15 +23,9 @@ * methods will return {@code true}. You can use {@link #tag()} to determine the * tag associated with this instance.

*/ -@JsonSerialize(using=MembersGetInfoItem.Serializer.class) -@JsonDeserialize(using=MembersGetInfoItem.Deserializer.class) public final class MembersGetInfoItem { // union MembersGetInfoItem - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link MembersGetInfoItem}. */ @@ -231,7 +213,7 @@ else if (obj instanceof MembersGetInfoItem) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -243,76 +225,75 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersGetInfoItem.class, TeamMemberInfo.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MembersGetInfoItem value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case ID_NOT_FOUND: + public void serialize(MembersGetInfoItem value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case ID_NOT_FOUND: { g.writeStartObject(); - g.writeStringField(".tag", "id_not_found"); - g.writeObjectField("id_not_found", value.idNotFoundValue); + writeTag("id_not_found", g); + g.writeFieldName("id_not_found"); + StoneSerializers.string().serialize(value.idNotFoundValue, g); g.writeEndObject(); break; - case MEMBER_INFO: + } + case MEMBER_INFO: { g.writeStartObject(); - g.writeStringField(".tag", "member_info"); - getUnwrappingSerializer(TeamMemberInfo.class).serialize(value.memberInfoValue, g, provider); + writeTag("member_info", g); + TeamMemberInfo.Serializer.INSTANCE.serialize(value.memberInfoValue, g, true); g.writeEndObject(); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersGetInfoItem.class, getTagMapping(), null, TeamMemberInfo.class); - } - - @Override - public MembersGetInfoItem deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case ID_NOT_FOUND: { - String value = null; - expectField(_p, "id_not_found"); - value = getStringValue(_p); - _p.nextToken(); - return MembersGetInfoItem.idNotFound(value); } - case MEMBER_INFO: { - TeamMemberInfo value = null; - value = readCollapsedStructValue(TeamMemberInfo.class, _p, _ctx); - return MembersGetInfoItem.memberInfo(value); + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("id_not_found", MembersGetInfoItem.Tag.ID_NOT_FOUND); - values.put("member_info", MembersGetInfoItem.Tag.MEMBER_INFO); - return Collections.unmodifiableMap(values); + @Override + public MembersGetInfoItem deserialize(JsonParser p) throws IOException, JsonParseException { + MembersGetInfoItem value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("id_not_found".equals(tag)) { + String fieldValue = null; + expectField("id_not_found", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = MembersGetInfoItem.idNotFound(fieldValue); + } + else if ("member_info".equals(tag)) { + TeamMemberInfo fieldValue = null; + fieldValue = TeamMemberInfo.Serializer.INSTANCE.deserialize(p, true); + value = MembersGetInfoItem.memberInfo(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersListArg.java b/src/main/java/com/dropbox/core/v2/team/MembersListArg.java index ef38464e9..8ed186ab1 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersListArg.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersListArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=MembersListArg.Serializer.class) -@JsonDeserialize(using=MembersListArg.Deserializer.class) class MembersListArg { // struct MembersListArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final long limit; /** @@ -96,7 +79,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -108,79 +91,56 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersListArg.class); - } - - public Serializer(boolean unwrapping) { - super(MembersListArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(MembersListArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("limit", value.limit); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersListArg.class); - } - - public Deserializer(boolean unwrapping) { - super(MembersListArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(MembersListArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("limit"); + StoneSerializers.uInt32().serialize(value.limit, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public MembersListArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - long limit = 1000L; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("limit".equals(_field)) { - limit = _p.getLongValue(); - assertUnsigned(_p, limit); - if (limit > Integer.MAX_VALUE) { - throw new JsonParseException(_p, "expecting a 32-bit unsigned integer, got: " + limit); + public MembersListArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MembersListArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Long f_limit = 1000L; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("limit".equals(field)) { + f_limit = StoneSerializers.uInt32().deserialize(p); + } + else { + skipValue(p); } - _p.nextToken(); - } - else { - skipValue(_p); } + value = new MembersListArg(f_limit); } - - - return new MembersListArg(limit); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersListContinueArg.java b/src/main/java/com/dropbox/core/v2/team/MembersListContinueArg.java index 81f2b6020..9d308f0b7 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersListContinueArg.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersListContinueArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=MembersListContinueArg.Serializer.class) -@JsonDeserialize(using=MembersListContinueArg.Deserializer.class) class MembersListContinueArg { // struct MembersListContinueArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String cursor; /** @@ -85,7 +68,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -97,78 +80,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersListContinueArg.class); - } - - public Serializer(boolean unwrapping) { - super(MembersListContinueArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(MembersListContinueArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("cursor", value.cursor); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersListContinueArg.class); - } - - public Deserializer(boolean unwrapping) { - super(MembersListContinueArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(MembersListContinueArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("cursor"); + StoneSerializers.string().serialize(value.cursor, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public MembersListContinueArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String cursor = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); + public MembersListContinueArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MembersListContinueArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_cursor = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("cursor".equals(field)) { + f_cursor = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_cursor == null) { + throw new JsonParseException(p, "Required field \"cursor\" missing."); } + value = new MembersListContinueArg(f_cursor); } - - if (cursor == null) { - throw new JsonParseException(_p, "Required field \"cursor\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new MembersListContinueArg(cursor); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersListContinueError.java b/src/main/java/com/dropbox/core/v2/team/MembersListContinueError.java index 8c33a8f50..0b2677b36 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersListContinueError.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersListContinueError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=MembersListContinueError.Serializer.class) -@JsonDeserialize(using=MembersListContinueError.Deserializer.class) public enum MembersListContinueError { // union MembersListContinueError /** @@ -39,47 +25,54 @@ public enum MembersListContinueError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersListContinueError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MembersListContinueError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(MembersListContinueError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case INVALID_CURSOR: + case INVALID_CURSOR: { g.writeString("invalid_cursor"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersListContinueError.class, getTagMapping(), MembersListContinueError.OTHER); - } @Override - public MembersListContinueError deserialize(MembersListContinueError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("invalid_cursor", MembersListContinueError.INVALID_CURSOR); - values.put("other", MembersListContinueError.OTHER); - return Collections.unmodifiableMap(values); + public MembersListContinueError deserialize(JsonParser p) throws IOException, JsonParseException { + MembersListContinueError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("invalid_cursor".equals(tag)) { + value = MembersListContinueError.INVALID_CURSOR; + } + else { + value = MembersListContinueError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersListContinueErrorException.java b/src/main/java/com/dropbox/core/v2/team/MembersListContinueErrorException.java index d03d0f3a8..5b332e407 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersListContinueErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersListContinueErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/MembersListError.java b/src/main/java/com/dropbox/core/v2/team/MembersListError.java index 3d2fd972c..660ff82d1 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersListError.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersListError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=MembersListError.Serializer.class) -@JsonDeserialize(using=MembersListError.Deserializer.class) public enum MembersListError { // union MembersListError /** @@ -35,43 +21,47 @@ public enum MembersListError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersListError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MembersListError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(MembersListError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case OTHER: + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersListError.class, getTagMapping(), MembersListError.OTHER); - } @Override - public MembersListError deserialize(MembersListError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("other", MembersListError.OTHER); - return Collections.unmodifiableMap(values); + public MembersListError deserialize(JsonParser p) throws IOException, JsonParseException { + MembersListError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else { + value = MembersListError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersListErrorException.java b/src/main/java/com/dropbox/core/v2/team/MembersListErrorException.java index 9d6176434..4a770add9 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersListErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersListErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/MembersListResult.java b/src/main/java/com/dropbox/core/v2/team/MembersListResult.java index f95b05b26..33a984b20 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersListResult.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersListResult.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=MembersListResult.Serializer.class) -@JsonDeserialize(using=MembersListResult.Deserializer.class) public class MembersListResult { // struct MembersListResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List members; protected final String cursor; protected final boolean hasMore; @@ -131,7 +114,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -143,104 +126,77 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersListResult.class); - } - - public Serializer(boolean unwrapping) { - super(MembersListResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(MembersListResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("members", value.members); - g.writeObjectField("cursor", value.cursor); - g.writeObjectField("has_more", value.hasMore); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersListResult.class); - } - - public Deserializer(boolean unwrapping) { - super(MembersListResult.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(MembersListResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("members"); + StoneSerializers.list(TeamMemberInfo.Serializer.INSTANCE).serialize(value.members, g); + g.writeFieldName("cursor"); + StoneSerializers.string().serialize(value.cursor, g); + g.writeFieldName("has_more"); + StoneSerializers.boolean_().serialize(value.hasMore, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public MembersListResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List members = null; - String cursor = null; - Boolean hasMore = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("members".equals(_field)) { - expectArrayStart(_p); - members = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - TeamMemberInfo _x = null; - _x = _p.readValueAs(TeamMemberInfo.class); - _p.nextToken(); - members.add(_x); + public MembersListResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MembersListResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_members = null; + String f_cursor = null; + Boolean f_hasMore = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("members".equals(field)) { + f_members = StoneSerializers.list(TeamMemberInfo.Serializer.INSTANCE).deserialize(p); + } + else if ("cursor".equals(field)) { + f_cursor = StoneSerializers.string().deserialize(p); + } + else if ("has_more".equals(field)) { + f_hasMore = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else if ("cursor".equals(_field)) { - cursor = getStringValue(_p); - _p.nextToken(); + if (f_members == null) { + throw new JsonParseException(p, "Required field \"members\" missing."); } - else if ("has_more".equals(_field)) { - hasMore = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_cursor == null) { + throw new JsonParseException(p, "Required field \"cursor\" missing."); } - else { - skipValue(_p); + if (f_hasMore == null) { + throw new JsonParseException(p, "Required field \"has_more\" missing."); } + value = new MembersListResult(f_members, f_cursor, f_hasMore); } - - if (members == null) { - throw new JsonParseException(_p, "Required field \"members\" is missing."); - } - if (cursor == null) { - throw new JsonParseException(_p, "Required field \"cursor\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (hasMore == null) { - throw new JsonParseException(_p, "Required field \"has_more\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new MembersListResult(members, cursor, hasMore); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersRemoveArg.java b/src/main/java/com/dropbox/core/v2/team/MembersRemoveArg.java index 72b4d3b93..cd7cfdd39 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersRemoveArg.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersRemoveArg.java @@ -1,41 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=MembersRemoveArg.Serializer.class) -@JsonDeserialize(using=MembersRemoveArg.Deserializer.class) class MembersRemoveArg extends MembersDeactivateArg { // struct MembersRemoveArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final UserSelectorArg transferDestId; protected final UserSelectorArg transferAdminId; + protected final boolean keepAccount; /** * Use {@link newBuilder} to create instances of this class without @@ -50,14 +34,18 @@ class MembersRemoveArg extends MembersDeactivateArg { * @param transferAdminId If provided, errors during the transfer process * will be sent via email to this user. If the transfer_dest_id argument * was provided, then this argument must be provided as well. + * @param keepAccount Downgrade the member to a Basic account. The user + * will retain the email address associated with their Dropbox account + * and data in their account that is not restricted to team members. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. */ - public MembersRemoveArg(UserSelectorArg user, boolean wipeData, UserSelectorArg transferDestId, UserSelectorArg transferAdminId) { + public MembersRemoveArg(UserSelectorArg user, boolean wipeData, UserSelectorArg transferDestId, UserSelectorArg transferAdminId, boolean keepAccount) { super(user, wipeData); this.transferDestId = transferDestId; this.transferAdminId = transferAdminId; + this.keepAccount = keepAccount; } /** @@ -70,7 +58,7 @@ public MembersRemoveArg(UserSelectorArg user, boolean wipeData, UserSelectorArg * preconditions. */ public MembersRemoveArg(UserSelectorArg user) { - this(user, true, null, null); + this(user, true, null, null, false); } /** @@ -94,6 +82,18 @@ public UserSelectorArg getTransferAdminId() { return transferAdminId; } + /** + * Downgrade the member to a Basic account. The user will retain the email + * address associated with their Dropbox account and data in their account + * that is not restricted to team members. + * + * @return value for this field, or {@code null} if not present. Defaults to + * false. + */ + public boolean getKeepAccount() { + return keepAccount; + } + /** * Returns a new builder for creating an instance of this class. * @@ -118,6 +118,7 @@ public static class Builder { protected boolean wipeData; protected UserSelectorArg transferDestId; protected UserSelectorArg transferAdminId; + protected boolean keepAccount; protected Builder(UserSelectorArg user) { if (user == null) { @@ -127,6 +128,7 @@ protected Builder(UserSelectorArg user) { this.wipeData = true; this.transferDestId = null; this.transferAdminId = null; + this.keepAccount = false; } /** @@ -179,6 +181,29 @@ public Builder withTransferAdminId(UserSelectorArg transferAdminId) { return this; } + /** + * Set value for optional field. + * + *

If left unset or set to {@code null}, defaults to {@code false}. + *

+ * + * @param keepAccount Downgrade the member to a Basic account. The user + * will retain the email address associated with their Dropbox + * account and data in their account that is not restricted to team + * members. Defaults to {@code false} when set to {@code null}. + * + * @return this builder + */ + public Builder withKeepAccount(Boolean keepAccount) { + if (keepAccount != null) { + this.keepAccount = keepAccount; + } + else { + this.keepAccount = false; + } + return this; + } + /** * Builds an instance of {@link MembersRemoveArg} configured with this * builder's values @@ -186,7 +211,7 @@ public Builder withTransferAdminId(UserSelectorArg transferAdminId) { * @return new instance of {@link MembersRemoveArg} */ public MembersRemoveArg build() { - return new MembersRemoveArg(user, wipeData, transferDestId, transferAdminId); + return new MembersRemoveArg(user, wipeData, transferDestId, transferAdminId, keepAccount); } } @@ -194,7 +219,8 @@ public MembersRemoveArg build() { public int hashCode() { int hash = java.util.Arrays.hashCode(new Object [] { transferDestId, - transferAdminId + transferAdminId, + keepAccount }); hash = (31 * super.hashCode()) + hash; return hash; @@ -212,6 +238,7 @@ else if (obj.getClass().equals(this.getClass())) { && (this.wipeData == other.wipeData) && ((this.transferDestId == other.transferDestId) || (this.transferDestId != null && this.transferDestId.equals(other.transferDestId))) && ((this.transferAdminId == other.transferAdminId) || (this.transferAdminId != null && this.transferAdminId.equals(other.transferAdminId))) + && (this.keepAccount == other.keepAccount) ; } else { @@ -221,7 +248,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -233,100 +260,87 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersRemoveArg.class); - } - - public Serializer(boolean unwrapping) { - super(MembersRemoveArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(MembersRemoveArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("user", value.user); - g.writeObjectField("wipe_data", value.wipeData); + public void serialize(MembersRemoveArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("user"); + UserSelectorArg.Serializer.INSTANCE.serialize(value.user, g); + g.writeFieldName("wipe_data"); + StoneSerializers.boolean_().serialize(value.wipeData, g); if (value.transferDestId != null) { - g.writeObjectField("transfer_dest_id", value.transferDestId); + g.writeFieldName("transfer_dest_id"); + StoneSerializers.nullable(UserSelectorArg.Serializer.INSTANCE).serialize(value.transferDestId, g); } if (value.transferAdminId != null) { - g.writeObjectField("transfer_admin_id", value.transferAdminId); + g.writeFieldName("transfer_admin_id"); + StoneSerializers.nullable(UserSelectorArg.Serializer.INSTANCE).serialize(value.transferAdminId, g); + } + g.writeFieldName("keep_account"); + StoneSerializers.boolean_().serialize(value.keepAccount, g); + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersRemoveArg.class); - } - - public Deserializer(boolean unwrapping) { - super(MembersRemoveArg.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public MembersRemoveArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - UserSelectorArg user = null; - boolean wipeData = true; - UserSelectorArg transferDestId = null; - UserSelectorArg transferAdminId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("user".equals(_field)) { - user = _p.readValueAs(UserSelectorArg.class); - _p.nextToken(); - } - else if ("wipe_data".equals(_field)) { - wipeData = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("transfer_dest_id".equals(_field)) { - transferDestId = _p.readValueAs(UserSelectorArg.class); - _p.nextToken(); - } - else if ("transfer_admin_id".equals(_field)) { - transferAdminId = _p.readValueAs(UserSelectorArg.class); - _p.nextToken(); + public MembersRemoveArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MembersRemoveArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + UserSelectorArg f_user = null; + Boolean f_wipeData = true; + UserSelectorArg f_transferDestId = null; + UserSelectorArg f_transferAdminId = null; + Boolean f_keepAccount = false; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("user".equals(field)) { + f_user = UserSelectorArg.Serializer.INSTANCE.deserialize(p); + } + else if ("wipe_data".equals(field)) { + f_wipeData = StoneSerializers.boolean_().deserialize(p); + } + else if ("transfer_dest_id".equals(field)) { + f_transferDestId = StoneSerializers.nullable(UserSelectorArg.Serializer.INSTANCE).deserialize(p); + } + else if ("transfer_admin_id".equals(field)) { + f_transferAdminId = StoneSerializers.nullable(UserSelectorArg.Serializer.INSTANCE).deserialize(p); + } + else if ("keep_account".equals(field)) { + f_keepAccount = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_user == null) { + throw new JsonParseException(p, "Required field \"user\" missing."); } + value = new MembersRemoveArg(f_user, f_wipeData, f_transferDestId, f_transferAdminId, f_keepAccount); } - - if (user == null) { - throw new JsonParseException(_p, "Required field \"user\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new MembersRemoveArg(user, wipeData, transferDestId, transferAdminId); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersRemoveBuilder.java b/src/main/java/com/dropbox/core/v2/team/MembersRemoveBuilder.java index 20f384444..da15e64e1 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersRemoveBuilder.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersRemoveBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; @@ -13,26 +13,26 @@ * request.

*/ public class MembersRemoveBuilder { - private final DbxTeamTeamRequests team; + private final DbxTeamTeamRequests team_; private final MembersRemoveArg.Builder membersRemoveArgBuilder; /** * Creates a new instance of this builder. * - * @param team Dropbox namespace-specific client used to issue team + * @param team_ Dropbox namespace-specific client used to issue team * requests. * @param membersRemoveArgBuilder Request argument builder. * * @return instsance of this builder */ - MembersRemoveBuilder(DbxTeamTeamRequests team, MembersRemoveArg.Builder membersRemoveArgBuilder) { - if (team == null) { - throw new NullPointerException("team"); + MembersRemoveBuilder(DbxTeamTeamRequests team_, MembersRemoveArg.Builder membersRemoveArgBuilder) { + if (team_ == null) { + throw new NullPointerException("team_"); } + this.team_ = team_; if (membersRemoveArgBuilder == null) { throw new NullPointerException("membersRemoveArgBuilder"); } - this.team = team; this.membersRemoveArgBuilder = membersRemoveArgBuilder; } @@ -79,11 +79,28 @@ public MembersRemoveBuilder withTransferAdminId(UserSelectorArg transferAdminId) return this; } + /** + * Set value for optional field. + * + *

If left unset or set to {@code null}, defaults to {@code false}.

+ * + * @param keepAccount Downgrade the member to a Basic account. The user + * will retain the email address associated with their Dropbox account + * and data in their account that is not restricted to team members. + * Defaults to {@code false} when set to {@code null}. + * + * @return this builder + */ + public MembersRemoveBuilder withKeepAccount(Boolean keepAccount) { + this.membersRemoveArgBuilder.withKeepAccount(keepAccount); + return this; + } + /** * Issues the request. */ public com.dropbox.core.v2.async.LaunchEmptyResult start() throws MembersRemoveErrorException, DbxException { - MembersRemoveArg arg = this.membersRemoveArgBuilder.build(); - return team.membersRemove(arg); + MembersRemoveArg arg_ = this.membersRemoveArgBuilder.build(); + return team_.membersRemove(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersRemoveError.java b/src/main/java/com/dropbox/core/v2/team/MembersRemoveError.java index da5d254a1..303bc1463 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersRemoveError.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersRemoveError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=MembersRemoveError.Serializer.class) -@JsonDeserialize(using=MembersRemoveError.Deserializer.class) public enum MembersRemoveError { // union MembersRemoveError /** @@ -79,86 +65,155 @@ public enum MembersRemoveError { /** * Specified transfer_admin user is not a team admin. */ - TRANSFER_ADMIN_IS_NOT_ADMIN; - - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; + TRANSFER_ADMIN_IS_NOT_ADMIN, + /** + * Cannot keep account and transfer the data to another user at the same + * time. + */ + CANNOT_KEEP_ACCOUNT_AND_TRANSFER, + /** + * Cannot keep account and delete the data at the same time. + */ + CANNOT_KEEP_ACCOUNT_AND_DELETE_DATA; - public Serializer() { - super(MembersRemoveError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MembersRemoveError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(MembersRemoveError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case USER_NOT_FOUND: + case USER_NOT_FOUND: { g.writeString("user_not_found"); break; - case USER_NOT_IN_TEAM: + } + case USER_NOT_IN_TEAM: { g.writeString("user_not_in_team"); break; - case OTHER: + } + case OTHER: { g.writeString("other"); break; - case REMOVE_LAST_ADMIN: + } + case REMOVE_LAST_ADMIN: { g.writeString("remove_last_admin"); break; - case REMOVED_AND_TRANSFER_DEST_SHOULD_DIFFER: + } + case REMOVED_AND_TRANSFER_DEST_SHOULD_DIFFER: { g.writeString("removed_and_transfer_dest_should_differ"); break; - case REMOVED_AND_TRANSFER_ADMIN_SHOULD_DIFFER: + } + case REMOVED_AND_TRANSFER_ADMIN_SHOULD_DIFFER: { g.writeString("removed_and_transfer_admin_should_differ"); break; - case TRANSFER_DEST_USER_NOT_FOUND: + } + case TRANSFER_DEST_USER_NOT_FOUND: { g.writeString("transfer_dest_user_not_found"); break; - case TRANSFER_DEST_USER_NOT_IN_TEAM: + } + case TRANSFER_DEST_USER_NOT_IN_TEAM: { g.writeString("transfer_dest_user_not_in_team"); break; - case TRANSFER_ADMIN_USER_NOT_FOUND: + } + case TRANSFER_ADMIN_USER_NOT_FOUND: { g.writeString("transfer_admin_user_not_found"); break; - case TRANSFER_ADMIN_USER_NOT_IN_TEAM: + } + case TRANSFER_ADMIN_USER_NOT_IN_TEAM: { g.writeString("transfer_admin_user_not_in_team"); break; - case UNSPECIFIED_TRANSFER_ADMIN_ID: + } + case UNSPECIFIED_TRANSFER_ADMIN_ID: { g.writeString("unspecified_transfer_admin_id"); break; - case TRANSFER_ADMIN_IS_NOT_ADMIN: + } + case TRANSFER_ADMIN_IS_NOT_ADMIN: { g.writeString("transfer_admin_is_not_admin"); break; + } + case CANNOT_KEEP_ACCOUNT_AND_TRANSFER: { + g.writeString("cannot_keep_account_and_transfer"); + break; + } + case CANNOT_KEEP_ACCOUNT_AND_DELETE_DATA: { + g.writeString("cannot_keep_account_and_delete_data"); + break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersRemoveError.class, getTagMapping(), null); - } @Override - public MembersRemoveError deserialize(MembersRemoveError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("remove_last_admin", MembersRemoveError.REMOVE_LAST_ADMIN); - values.put("removed_and_transfer_dest_should_differ", MembersRemoveError.REMOVED_AND_TRANSFER_DEST_SHOULD_DIFFER); - values.put("removed_and_transfer_admin_should_differ", MembersRemoveError.REMOVED_AND_TRANSFER_ADMIN_SHOULD_DIFFER); - values.put("transfer_dest_user_not_found", MembersRemoveError.TRANSFER_DEST_USER_NOT_FOUND); - values.put("transfer_dest_user_not_in_team", MembersRemoveError.TRANSFER_DEST_USER_NOT_IN_TEAM); - values.put("transfer_admin_user_not_found", MembersRemoveError.TRANSFER_ADMIN_USER_NOT_FOUND); - values.put("transfer_admin_user_not_in_team", MembersRemoveError.TRANSFER_ADMIN_USER_NOT_IN_TEAM); - values.put("unspecified_transfer_admin_id", MembersRemoveError.UNSPECIFIED_TRANSFER_ADMIN_ID); - values.put("transfer_admin_is_not_admin", MembersRemoveError.TRANSFER_ADMIN_IS_NOT_ADMIN); - return Collections.unmodifiableMap(values); + public MembersRemoveError deserialize(JsonParser p) throws IOException, JsonParseException { + MembersRemoveError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("user_not_found".equals(tag)) { + value = MembersRemoveError.USER_NOT_FOUND; + } + else if ("user_not_in_team".equals(tag)) { + value = MembersRemoveError.USER_NOT_IN_TEAM; + } + else if ("other".equals(tag)) { + value = MembersRemoveError.OTHER; + } + else if ("remove_last_admin".equals(tag)) { + value = MembersRemoveError.REMOVE_LAST_ADMIN; + } + else if ("removed_and_transfer_dest_should_differ".equals(tag)) { + value = MembersRemoveError.REMOVED_AND_TRANSFER_DEST_SHOULD_DIFFER; + } + else if ("removed_and_transfer_admin_should_differ".equals(tag)) { + value = MembersRemoveError.REMOVED_AND_TRANSFER_ADMIN_SHOULD_DIFFER; + } + else if ("transfer_dest_user_not_found".equals(tag)) { + value = MembersRemoveError.TRANSFER_DEST_USER_NOT_FOUND; + } + else if ("transfer_dest_user_not_in_team".equals(tag)) { + value = MembersRemoveError.TRANSFER_DEST_USER_NOT_IN_TEAM; + } + else if ("transfer_admin_user_not_found".equals(tag)) { + value = MembersRemoveError.TRANSFER_ADMIN_USER_NOT_FOUND; + } + else if ("transfer_admin_user_not_in_team".equals(tag)) { + value = MembersRemoveError.TRANSFER_ADMIN_USER_NOT_IN_TEAM; + } + else if ("unspecified_transfer_admin_id".equals(tag)) { + value = MembersRemoveError.UNSPECIFIED_TRANSFER_ADMIN_ID; + } + else if ("transfer_admin_is_not_admin".equals(tag)) { + value = MembersRemoveError.TRANSFER_ADMIN_IS_NOT_ADMIN; + } + else if ("cannot_keep_account_and_transfer".equals(tag)) { + value = MembersRemoveError.CANNOT_KEEP_ACCOUNT_AND_TRANSFER; + } + else if ("cannot_keep_account_and_delete_data".equals(tag)) { + value = MembersRemoveError.CANNOT_KEEP_ACCOUNT_AND_DELETE_DATA; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersRemoveErrorException.java b/src/main/java/com/dropbox/core/v2/team/MembersRemoveErrorException.java index 51a0885d2..d1c907373 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersRemoveErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersRemoveErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/MembersSendWelcomeError.java b/src/main/java/com/dropbox/core/v2/team/MembersSendWelcomeError.java index a8e049b19..8205462ea 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersSendWelcomeError.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersSendWelcomeError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=MembersSendWelcomeError.Serializer.class) -@JsonDeserialize(using=MembersSendWelcomeError.Deserializer.class) public enum MembersSendWelcomeError { // union MembersSendWelcomeError /** @@ -44,49 +30,61 @@ public enum MembersSendWelcomeError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersSendWelcomeError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MembersSendWelcomeError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(MembersSendWelcomeError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case USER_NOT_FOUND: + case USER_NOT_FOUND: { g.writeString("user_not_found"); break; - case USER_NOT_IN_TEAM: + } + case USER_NOT_IN_TEAM: { g.writeString("user_not_in_team"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersSendWelcomeError.class, getTagMapping(), MembersSendWelcomeError.OTHER); - } @Override - public MembersSendWelcomeError deserialize(MembersSendWelcomeError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("other", MembersSendWelcomeError.OTHER); - return Collections.unmodifiableMap(values); + public MembersSendWelcomeError deserialize(JsonParser p) throws IOException, JsonParseException { + MembersSendWelcomeError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("user_not_found".equals(tag)) { + value = MembersSendWelcomeError.USER_NOT_FOUND; + } + else if ("user_not_in_team".equals(tag)) { + value = MembersSendWelcomeError.USER_NOT_IN_TEAM; + } + else { + value = MembersSendWelcomeError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersSendWelcomeErrorException.java b/src/main/java/com/dropbox/core/v2/team/MembersSendWelcomeErrorException.java index 225ecbb8a..7d10710ad 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersSendWelcomeErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersSendWelcomeErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/MembersSetPermissionsArg.java b/src/main/java/com/dropbox/core/v2/team/MembersSetPermissionsArg.java index c8eec8477..0d9772de2 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersSetPermissionsArg.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersSetPermissionsArg.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; @@ -29,15 +18,9 @@ * Exactly one of team_member_id, email, or external_id must be provided to * identify the user account. */ -@JsonSerialize(using=MembersSetPermissionsArg.Serializer.class) -@JsonDeserialize(using=MembersSetPermissionsArg.Deserializer.class) class MembersSetPermissionsArg { // struct MembersSetPermissionsArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final UserSelectorArg user; protected final AdminTier newRole; @@ -109,7 +92,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -121,87 +104,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersSetPermissionsArg.class); - } - - public Serializer(boolean unwrapping) { - super(MembersSetPermissionsArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(MembersSetPermissionsArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("user", value.user); - g.writeObjectField("new_role", value.newRole); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersSetPermissionsArg.class); - } - - public Deserializer(boolean unwrapping) { - super(MembersSetPermissionsArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(MembersSetPermissionsArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("user"); + UserSelectorArg.Serializer.INSTANCE.serialize(value.user, g); + g.writeFieldName("new_role"); + AdminTier.Serializer.INSTANCE.serialize(value.newRole, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public MembersSetPermissionsArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - UserSelectorArg user = null; - AdminTier newRole = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("user".equals(_field)) { - user = _p.readValueAs(UserSelectorArg.class); - _p.nextToken(); + public MembersSetPermissionsArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MembersSetPermissionsArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + UserSelectorArg f_user = null; + AdminTier f_newRole = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("user".equals(field)) { + f_user = UserSelectorArg.Serializer.INSTANCE.deserialize(p); + } + else if ("new_role".equals(field)) { + f_newRole = AdminTier.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else if ("new_role".equals(_field)) { - newRole = _p.readValueAs(AdminTier.class); - _p.nextToken(); + if (f_user == null) { + throw new JsonParseException(p, "Required field \"user\" missing."); } - else { - skipValue(_p); + if (f_newRole == null) { + throw new JsonParseException(p, "Required field \"new_role\" missing."); } + value = new MembersSetPermissionsArg(f_user, f_newRole); } - - if (user == null) { - throw new JsonParseException(_p, "Required field \"user\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (newRole == null) { - throw new JsonParseException(_p, "Required field \"new_role\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new MembersSetPermissionsArg(user, newRole); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersSetPermissionsError.java b/src/main/java/com/dropbox/core/v2/team/MembersSetPermissionsError.java index 31ce69bef..31a05e398 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersSetPermissionsError.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersSetPermissionsError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=MembersSetPermissionsError.Serializer.class) -@JsonDeserialize(using=MembersSetPermissionsError.Deserializer.class) public enum MembersSetPermissionsError { // union MembersSetPermissionsError /** @@ -56,62 +42,82 @@ public enum MembersSetPermissionsError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersSetPermissionsError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MembersSetPermissionsError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(MembersSetPermissionsError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case USER_NOT_FOUND: + case USER_NOT_FOUND: { g.writeString("user_not_found"); break; - case LAST_ADMIN: + } + case LAST_ADMIN: { g.writeString("last_admin"); break; - case USER_NOT_IN_TEAM: + } + case USER_NOT_IN_TEAM: { g.writeString("user_not_in_team"); break; - case CANNOT_SET_PERMISSIONS: + } + case CANNOT_SET_PERMISSIONS: { g.writeString("cannot_set_permissions"); break; - case TEAM_LICENSE_LIMIT: + } + case TEAM_LICENSE_LIMIT: { g.writeString("team_license_limit"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersSetPermissionsError.class, getTagMapping(), MembersSetPermissionsError.OTHER); - } @Override - public MembersSetPermissionsError deserialize(MembersSetPermissionsError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("last_admin", MembersSetPermissionsError.LAST_ADMIN); - values.put("user_not_in_team", MembersSetPermissionsError.USER_NOT_IN_TEAM); - values.put("cannot_set_permissions", MembersSetPermissionsError.CANNOT_SET_PERMISSIONS); - values.put("team_license_limit", MembersSetPermissionsError.TEAM_LICENSE_LIMIT); - values.put("other", MembersSetPermissionsError.OTHER); - return Collections.unmodifiableMap(values); + public MembersSetPermissionsError deserialize(JsonParser p) throws IOException, JsonParseException { + MembersSetPermissionsError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("user_not_found".equals(tag)) { + value = MembersSetPermissionsError.USER_NOT_FOUND; + } + else if ("last_admin".equals(tag)) { + value = MembersSetPermissionsError.LAST_ADMIN; + } + else if ("user_not_in_team".equals(tag)) { + value = MembersSetPermissionsError.USER_NOT_IN_TEAM; + } + else if ("cannot_set_permissions".equals(tag)) { + value = MembersSetPermissionsError.CANNOT_SET_PERMISSIONS; + } + else if ("team_license_limit".equals(tag)) { + value = MembersSetPermissionsError.TEAM_LICENSE_LIMIT; + } + else { + value = MembersSetPermissionsError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersSetPermissionsErrorException.java b/src/main/java/com/dropbox/core/v2/team/MembersSetPermissionsErrorException.java index 80de30ae4..cdd9ec6d2 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersSetPermissionsErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersSetPermissionsErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/MembersSetPermissionsResult.java b/src/main/java/com/dropbox/core/v2/team/MembersSetPermissionsResult.java index 3e991ed88..46d647543 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersSetPermissionsResult.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersSetPermissionsResult.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=MembersSetPermissionsResult.Serializer.class) -@JsonDeserialize(using=MembersSetPermissionsResult.Deserializer.class) public class MembersSetPermissionsResult { // struct MembersSetPermissionsResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String teamMemberId; protected final AdminTier role; @@ -103,7 +86,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -115,87 +98,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersSetPermissionsResult.class); - } - - public Serializer(boolean unwrapping) { - super(MembersSetPermissionsResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(MembersSetPermissionsResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("team_member_id", value.teamMemberId); - g.writeObjectField("role", value.role); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersSetPermissionsResult.class); - } - - public Deserializer(boolean unwrapping) { - super(MembersSetPermissionsResult.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(MembersSetPermissionsResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("team_member_id"); + StoneSerializers.string().serialize(value.teamMemberId, g); + g.writeFieldName("role"); + AdminTier.Serializer.INSTANCE.serialize(value.role, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public MembersSetPermissionsResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String teamMemberId = null; - AdminTier role = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("team_member_id".equals(_field)) { - teamMemberId = getStringValue(_p); - _p.nextToken(); + public MembersSetPermissionsResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MembersSetPermissionsResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_teamMemberId = null; + AdminTier f_role = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("team_member_id".equals(field)) { + f_teamMemberId = StoneSerializers.string().deserialize(p); + } + else if ("role".equals(field)) { + f_role = AdminTier.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else if ("role".equals(_field)) { - role = _p.readValueAs(AdminTier.class); - _p.nextToken(); + if (f_teamMemberId == null) { + throw new JsonParseException(p, "Required field \"team_member_id\" missing."); } - else { - skipValue(_p); + if (f_role == null) { + throw new JsonParseException(p, "Required field \"role\" missing."); } + value = new MembersSetPermissionsResult(f_teamMemberId, f_role); } - - if (teamMemberId == null) { - throw new JsonParseException(_p, "Required field \"team_member_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (role == null) { - throw new JsonParseException(_p, "Required field \"role\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new MembersSetPermissionsResult(teamMemberId, role); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersSetProfileArg.java b/src/main/java/com/dropbox/core/v2/team/MembersSetProfileArg.java index 7b0acebc2..1cfd6675f 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersSetProfileArg.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersSetProfileArg.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; @@ -30,15 +19,9 @@ * identify the user account. At least one of new_email, new_external_id, * new_given_name, and/or new_surname must be provided. */ -@JsonSerialize(using=MembersSetProfileArg.Serializer.class) -@JsonDeserialize(using=MembersSetProfileArg.Deserializer.class) class MembersSetProfileArg { // struct MembersSetProfileArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final UserSelectorArg user; protected final String newEmail; protected final String newExternalId; @@ -362,7 +345,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -374,110 +357,91 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersSetProfileArg.class); - } - - public Serializer(boolean unwrapping) { - super(MembersSetProfileArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(MembersSetProfileArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("user", value.user); + public void serialize(MembersSetProfileArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("user"); + UserSelectorArg.Serializer.INSTANCE.serialize(value.user, g); if (value.newEmail != null) { - g.writeObjectField("new_email", value.newEmail); + g.writeFieldName("new_email"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.newEmail, g); } if (value.newExternalId != null) { - g.writeObjectField("new_external_id", value.newExternalId); + g.writeFieldName("new_external_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.newExternalId, g); } if (value.newGivenName != null) { - g.writeObjectField("new_given_name", value.newGivenName); + g.writeFieldName("new_given_name"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.newGivenName, g); } if (value.newSurname != null) { - g.writeObjectField("new_surname", value.newSurname); + g.writeFieldName("new_surname"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.newSurname, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersSetProfileArg.class); - } - - public Deserializer(boolean unwrapping) { - super(MembersSetProfileArg.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public MembersSetProfileArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - UserSelectorArg user = null; - String newEmail = null; - String newExternalId = null; - String newGivenName = null; - String newSurname = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("user".equals(_field)) { - user = _p.readValueAs(UserSelectorArg.class); - _p.nextToken(); - } - else if ("new_email".equals(_field)) { - newEmail = getStringValue(_p); - _p.nextToken(); - } - else if ("new_external_id".equals(_field)) { - newExternalId = getStringValue(_p); - _p.nextToken(); - } - else if ("new_given_name".equals(_field)) { - newGivenName = getStringValue(_p); - _p.nextToken(); - } - else if ("new_surname".equals(_field)) { - newSurname = getStringValue(_p); - _p.nextToken(); + public MembersSetProfileArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MembersSetProfileArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + UserSelectorArg f_user = null; + String f_newEmail = null; + String f_newExternalId = null; + String f_newGivenName = null; + String f_newSurname = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("user".equals(field)) { + f_user = UserSelectorArg.Serializer.INSTANCE.deserialize(p); + } + else if ("new_email".equals(field)) { + f_newEmail = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("new_external_id".equals(field)) { + f_newExternalId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("new_given_name".equals(field)) { + f_newGivenName = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("new_surname".equals(field)) { + f_newSurname = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_user == null) { + throw new JsonParseException(p, "Required field \"user\" missing."); } + value = new MembersSetProfileArg(f_user, f_newEmail, f_newExternalId, f_newGivenName, f_newSurname); } - - if (user == null) { - throw new JsonParseException(_p, "Required field \"user\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new MembersSetProfileArg(user, newEmail, newExternalId, newGivenName, newSurname); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersSetProfileBuilder.java b/src/main/java/com/dropbox/core/v2/team/MembersSetProfileBuilder.java index 1726d2bef..668610ed1 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersSetProfileBuilder.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersSetProfileBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; @@ -13,26 +13,26 @@ * request.

*/ public class MembersSetProfileBuilder { - private final DbxTeamTeamRequests team; + private final DbxTeamTeamRequests team_; private final MembersSetProfileArg.Builder membersSetProfileArgBuilder; /** * Creates a new instance of this builder. * - * @param team Dropbox namespace-specific client used to issue team + * @param team_ Dropbox namespace-specific client used to issue team * requests. * @param membersSetProfileArgBuilder Request argument builder. * * @return instsance of this builder */ - MembersSetProfileBuilder(DbxTeamTeamRequests team, MembersSetProfileArg.Builder membersSetProfileArgBuilder) { - if (team == null) { - throw new NullPointerException("team"); + MembersSetProfileBuilder(DbxTeamTeamRequests team_, MembersSetProfileArg.Builder membersSetProfileArgBuilder) { + if (team_ == null) { + throw new NullPointerException("team_"); } + this.team_ = team_; if (membersSetProfileArgBuilder == null) { throw new NullPointerException("membersSetProfileArgBuilder"); } - this.team = team; this.membersSetProfileArgBuilder = membersSetProfileArgBuilder; } @@ -107,7 +107,7 @@ public MembersSetProfileBuilder withNewSurname(String newSurname) { * Issues the request. */ public TeamMemberInfo start() throws MembersSetProfileErrorException, DbxException { - MembersSetProfileArg arg = this.membersSetProfileArgBuilder.build(); - return team.membersSetProfile(arg); + MembersSetProfileArg arg_ = this.membersSetProfileArgBuilder.build(); + return team_.membersSetProfile(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersSetProfileError.java b/src/main/java/com/dropbox/core/v2/team/MembersSetProfileError.java index 786d7544a..73669f1cf 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersSetProfileError.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersSetProfileError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=MembersSetProfileError.Serializer.class) -@JsonDeserialize(using=MembersSetProfileError.Deserializer.class) public enum MembersSetProfileError { // union MembersSetProfileError /** @@ -69,73 +55,103 @@ public enum MembersSetProfileError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersSetProfileError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MembersSetProfileError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(MembersSetProfileError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case USER_NOT_FOUND: + case USER_NOT_FOUND: { g.writeString("user_not_found"); break; - case USER_NOT_IN_TEAM: + } + case USER_NOT_IN_TEAM: { g.writeString("user_not_in_team"); break; - case EXTERNAL_ID_AND_NEW_EXTERNAL_ID_UNSAFE: + } + case EXTERNAL_ID_AND_NEW_EXTERNAL_ID_UNSAFE: { g.writeString("external_id_and_new_external_id_unsafe"); break; - case NO_NEW_DATA_SPECIFIED: + } + case NO_NEW_DATA_SPECIFIED: { g.writeString("no_new_data_specified"); break; - case EMAIL_RESERVED_FOR_OTHER_USER: + } + case EMAIL_RESERVED_FOR_OTHER_USER: { g.writeString("email_reserved_for_other_user"); break; - case EXTERNAL_ID_USED_BY_OTHER_USER: + } + case EXTERNAL_ID_USED_BY_OTHER_USER: { g.writeString("external_id_used_by_other_user"); break; - case SET_PROFILE_DISALLOWED: + } + case SET_PROFILE_DISALLOWED: { g.writeString("set_profile_disallowed"); break; - case PARAM_CANNOT_BE_EMPTY: + } + case PARAM_CANNOT_BE_EMPTY: { g.writeString("param_cannot_be_empty"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersSetProfileError.class, getTagMapping(), MembersSetProfileError.OTHER); - } @Override - public MembersSetProfileError deserialize(MembersSetProfileError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("external_id_and_new_external_id_unsafe", MembersSetProfileError.EXTERNAL_ID_AND_NEW_EXTERNAL_ID_UNSAFE); - values.put("no_new_data_specified", MembersSetProfileError.NO_NEW_DATA_SPECIFIED); - values.put("email_reserved_for_other_user", MembersSetProfileError.EMAIL_RESERVED_FOR_OTHER_USER); - values.put("external_id_used_by_other_user", MembersSetProfileError.EXTERNAL_ID_USED_BY_OTHER_USER); - values.put("set_profile_disallowed", MembersSetProfileError.SET_PROFILE_DISALLOWED); - values.put("param_cannot_be_empty", MembersSetProfileError.PARAM_CANNOT_BE_EMPTY); - values.put("other", MembersSetProfileError.OTHER); - return Collections.unmodifiableMap(values); + public MembersSetProfileError deserialize(JsonParser p) throws IOException, JsonParseException { + MembersSetProfileError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("user_not_found".equals(tag)) { + value = MembersSetProfileError.USER_NOT_FOUND; + } + else if ("user_not_in_team".equals(tag)) { + value = MembersSetProfileError.USER_NOT_IN_TEAM; + } + else if ("external_id_and_new_external_id_unsafe".equals(tag)) { + value = MembersSetProfileError.EXTERNAL_ID_AND_NEW_EXTERNAL_ID_UNSAFE; + } + else if ("no_new_data_specified".equals(tag)) { + value = MembersSetProfileError.NO_NEW_DATA_SPECIFIED; + } + else if ("email_reserved_for_other_user".equals(tag)) { + value = MembersSetProfileError.EMAIL_RESERVED_FOR_OTHER_USER; + } + else if ("external_id_used_by_other_user".equals(tag)) { + value = MembersSetProfileError.EXTERNAL_ID_USED_BY_OTHER_USER; + } + else if ("set_profile_disallowed".equals(tag)) { + value = MembersSetProfileError.SET_PROFILE_DISALLOWED; + } + else if ("param_cannot_be_empty".equals(tag)) { + value = MembersSetProfileError.PARAM_CANNOT_BE_EMPTY; + } + else { + value = MembersSetProfileError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersSetProfileErrorException.java b/src/main/java/com/dropbox/core/v2/team/MembersSetProfileErrorException.java index c33226c29..7f0aa67f4 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersSetProfileErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersSetProfileErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/MembersSuspendError.java b/src/main/java/com/dropbox/core/v2/team/MembersSuspendError.java index 210a53c23..0f8f13625 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersSuspendError.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersSuspendError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=MembersSuspendError.Serializer.class) -@JsonDeserialize(using=MembersSuspendError.Deserializer.class) public enum MembersSuspendError { // union MembersSuspendError /** @@ -56,60 +42,88 @@ public enum MembersSuspendError { */ TEAM_LICENSE_LIMIT; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersSuspendError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MembersSuspendError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(MembersSuspendError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case USER_NOT_FOUND: + case USER_NOT_FOUND: { g.writeString("user_not_found"); break; - case USER_NOT_IN_TEAM: + } + case USER_NOT_IN_TEAM: { g.writeString("user_not_in_team"); break; - case OTHER: + } + case OTHER: { g.writeString("other"); break; - case SUSPEND_INACTIVE_USER: + } + case SUSPEND_INACTIVE_USER: { g.writeString("suspend_inactive_user"); break; - case SUSPEND_LAST_ADMIN: + } + case SUSPEND_LAST_ADMIN: { g.writeString("suspend_last_admin"); break; - case TEAM_LICENSE_LIMIT: + } + case TEAM_LICENSE_LIMIT: { g.writeString("team_license_limit"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersSuspendError.class, getTagMapping(), null); - } @Override - public MembersSuspendError deserialize(MembersSuspendError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("suspend_inactive_user", MembersSuspendError.SUSPEND_INACTIVE_USER); - values.put("suspend_last_admin", MembersSuspendError.SUSPEND_LAST_ADMIN); - values.put("team_license_limit", MembersSuspendError.TEAM_LICENSE_LIMIT); - return Collections.unmodifiableMap(values); + public MembersSuspendError deserialize(JsonParser p) throws IOException, JsonParseException { + MembersSuspendError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("user_not_found".equals(tag)) { + value = MembersSuspendError.USER_NOT_FOUND; + } + else if ("user_not_in_team".equals(tag)) { + value = MembersSuspendError.USER_NOT_IN_TEAM; + } + else if ("other".equals(tag)) { + value = MembersSuspendError.OTHER; + } + else if ("suspend_inactive_user".equals(tag)) { + value = MembersSuspendError.SUSPEND_INACTIVE_USER; + } + else if ("suspend_last_admin".equals(tag)) { + value = MembersSuspendError.SUSPEND_LAST_ADMIN; + } + else if ("team_license_limit".equals(tag)) { + value = MembersSuspendError.TEAM_LICENSE_LIMIT; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersSuspendErrorException.java b/src/main/java/com/dropbox/core/v2/team/MembersSuspendErrorException.java index d5aa0483a..dd1fa115d 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersSuspendErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersSuspendErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/MembersUnsuspendArg.java b/src/main/java/com/dropbox/core/v2/team/MembersUnsuspendArg.java index 212a05304..6608b053c 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersUnsuspendArg.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersUnsuspendArg.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; @@ -29,15 +18,9 @@ * Exactly one of team_member_id, email, or external_id must be provided to * identify the user account. */ -@JsonSerialize(using=MembersUnsuspendArg.Serializer.class) -@JsonDeserialize(using=MembersUnsuspendArg.Deserializer.class) class MembersUnsuspendArg { // struct MembersUnsuspendArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final UserSelectorArg user; /** @@ -90,7 +73,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -102,78 +85,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersUnsuspendArg.class); - } - - public Serializer(boolean unwrapping) { - super(MembersUnsuspendArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(MembersUnsuspendArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("user", value.user); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersUnsuspendArg.class); - } - - public Deserializer(boolean unwrapping) { - super(MembersUnsuspendArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(MembersUnsuspendArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("user"); + UserSelectorArg.Serializer.INSTANCE.serialize(value.user, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public MembersUnsuspendArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - UserSelectorArg user = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("user".equals(_field)) { - user = _p.readValueAs(UserSelectorArg.class); - _p.nextToken(); + public MembersUnsuspendArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MembersUnsuspendArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + UserSelectorArg f_user = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("user".equals(field)) { + f_user = UserSelectorArg.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_user == null) { + throw new JsonParseException(p, "Required field \"user\" missing."); } + value = new MembersUnsuspendArg(f_user); } - - if (user == null) { - throw new JsonParseException(_p, "Required field \"user\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new MembersUnsuspendArg(user); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersUnsuspendError.java b/src/main/java/com/dropbox/core/v2/team/MembersUnsuspendError.java index 3af44bf54..f32895434 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersUnsuspendError.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersUnsuspendError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=MembersUnsuspendError.Serializer.class) -@JsonDeserialize(using=MembersUnsuspendError.Deserializer.class) public enum MembersUnsuspendError { // union MembersUnsuspendError /** @@ -52,56 +38,81 @@ public enum MembersUnsuspendError { */ TEAM_LICENSE_LIMIT; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MembersUnsuspendError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MembersUnsuspendError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(MembersUnsuspendError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case USER_NOT_FOUND: + case USER_NOT_FOUND: { g.writeString("user_not_found"); break; - case USER_NOT_IN_TEAM: + } + case USER_NOT_IN_TEAM: { g.writeString("user_not_in_team"); break; - case OTHER: + } + case OTHER: { g.writeString("other"); break; - case UNSUSPEND_NON_SUSPENDED_MEMBER: + } + case UNSUSPEND_NON_SUSPENDED_MEMBER: { g.writeString("unsuspend_non_suspended_member"); break; - case TEAM_LICENSE_LIMIT: + } + case TEAM_LICENSE_LIMIT: { g.writeString("team_license_limit"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MembersUnsuspendError.class, getTagMapping(), null); - } @Override - public MembersUnsuspendError deserialize(MembersUnsuspendError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("unsuspend_non_suspended_member", MembersUnsuspendError.UNSUSPEND_NON_SUSPENDED_MEMBER); - values.put("team_license_limit", MembersUnsuspendError.TEAM_LICENSE_LIMIT); - return Collections.unmodifiableMap(values); + public MembersUnsuspendError deserialize(JsonParser p) throws IOException, JsonParseException { + MembersUnsuspendError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("user_not_found".equals(tag)) { + value = MembersUnsuspendError.USER_NOT_FOUND; + } + else if ("user_not_in_team".equals(tag)) { + value = MembersUnsuspendError.USER_NOT_IN_TEAM; + } + else if ("other".equals(tag)) { + value = MembersUnsuspendError.OTHER; + } + else if ("unsuspend_non_suspended_member".equals(tag)) { + value = MembersUnsuspendError.UNSUSPEND_NON_SUSPENDED_MEMBER; + } + else if ("team_license_limit".equals(tag)) { + value = MembersUnsuspendError.TEAM_LICENSE_LIMIT; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MembersUnsuspendErrorException.java b/src/main/java/com/dropbox/core/v2/team/MembersUnsuspendErrorException.java index d00b3cad6..5317bf878 100644 --- a/src/main/java/com/dropbox/core/v2/team/MembersUnsuspendErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/MembersUnsuspendErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/MobileClientPlatform.java b/src/main/java/com/dropbox/core/v2/team/MobileClientPlatform.java index 50d41fa9a..746021df4 100644 --- a/src/main/java/com/dropbox/core/v2/team/MobileClientPlatform.java +++ b/src/main/java/com/dropbox/core/v2/team/MobileClientPlatform.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=MobileClientPlatform.Serializer.class) -@JsonDeserialize(using=MobileClientPlatform.Deserializer.class) public enum MobileClientPlatform { // union MobileClientPlatform /** @@ -55,63 +41,82 @@ public enum MobileClientPlatform { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MobileClientPlatform.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(MobileClientPlatform value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(MobileClientPlatform value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case IPHONE: + case IPHONE: { g.writeString("iphone"); break; - case IPAD: + } + case IPAD: { g.writeString("ipad"); break; - case ANDROID: + } + case ANDROID: { g.writeString("android"); break; - case WINDOWS_PHONE: + } + case WINDOWS_PHONE: { g.writeString("windows_phone"); break; - case BLACKBERRY: + } + case BLACKBERRY: { g.writeString("blackberry"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MobileClientPlatform.class, getTagMapping(), MobileClientPlatform.OTHER); - } @Override - public MobileClientPlatform deserialize(MobileClientPlatform _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("iphone", MobileClientPlatform.IPHONE); - values.put("ipad", MobileClientPlatform.IPAD); - values.put("android", MobileClientPlatform.ANDROID); - values.put("windows_phone", MobileClientPlatform.WINDOWS_PHONE); - values.put("blackberry", MobileClientPlatform.BLACKBERRY); - values.put("other", MobileClientPlatform.OTHER); - return Collections.unmodifiableMap(values); + public MobileClientPlatform deserialize(JsonParser p) throws IOException, JsonParseException { + MobileClientPlatform value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("iphone".equals(tag)) { + value = MobileClientPlatform.IPHONE; + } + else if ("ipad".equals(tag)) { + value = MobileClientPlatform.IPAD; + } + else if ("android".equals(tag)) { + value = MobileClientPlatform.ANDROID; + } + else if ("windows_phone".equals(tag)) { + value = MobileClientPlatform.WINDOWS_PHONE; + } + else if ("blackberry".equals(tag)) { + value = MobileClientPlatform.BLACKBERRY; + } + else { + value = MobileClientPlatform.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/MobileClientSession.java b/src/main/java/com/dropbox/core/v2/team/MobileClientSession.java index 576ec6dab..792a92c47 100644 --- a/src/main/java/com/dropbox/core/v2/team/MobileClientSession.java +++ b/src/main/java/com/dropbox/core/v2/team/MobileClientSession.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.Date; @@ -29,15 +18,9 @@ /** * Information about linked Dropbox mobile client sessions */ -@JsonSerialize(using=MobileClientSession.Serializer.class) -@JsonDeserialize(using=MobileClientSession.Deserializer.class) public class MobileClientSession extends DeviceSession { // struct MobileClientSession - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String deviceName; protected final MobileClientPlatform clientType; protected final String clientVersion; @@ -270,7 +253,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -282,152 +265,133 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(MobileClientSession.class); - } - - public Serializer(boolean unwrapping) { - super(MobileClientSession.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(MobileClientSession value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("session_id", value.sessionId); - g.writeObjectField("device_name", value.deviceName); - g.writeObjectField("client_type", value.clientType); + public void serialize(MobileClientSession value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("session_id"); + StoneSerializers.string().serialize(value.sessionId, g); + g.writeFieldName("device_name"); + StoneSerializers.string().serialize(value.deviceName, g); + g.writeFieldName("client_type"); + MobileClientPlatform.Serializer.INSTANCE.serialize(value.clientType, g); if (value.ipAddress != null) { - g.writeObjectField("ip_address", value.ipAddress); + g.writeFieldName("ip_address"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.ipAddress, g); } if (value.country != null) { - g.writeObjectField("country", value.country); + g.writeFieldName("country"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.country, g); } if (value.created != null) { - g.writeObjectField("created", value.created); + g.writeFieldName("created"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.created, g); } if (value.updated != null) { - g.writeObjectField("updated", value.updated); + g.writeFieldName("updated"); + StoneSerializers.nullable(StoneSerializers.timestamp()).serialize(value.updated, g); } if (value.clientVersion != null) { - g.writeObjectField("client_version", value.clientVersion); + g.writeFieldName("client_version"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.clientVersion, g); } if (value.osVersion != null) { - g.writeObjectField("os_version", value.osVersion); + g.writeFieldName("os_version"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.osVersion, g); } if (value.lastCarrier != null) { - g.writeObjectField("last_carrier", value.lastCarrier); + g.writeFieldName("last_carrier"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.lastCarrier, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(MobileClientSession.class); - } - - public Deserializer(boolean unwrapping) { - super(MobileClientSession.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public MobileClientSession deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String sessionId = null; - String deviceName = null; - MobileClientPlatform clientType = null; - String ipAddress = null; - String country = null; - Date created = null; - Date updated = null; - String clientVersion = null; - String osVersion = null; - String lastCarrier = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("session_id".equals(_field)) { - sessionId = getStringValue(_p); - _p.nextToken(); - } - else if ("device_name".equals(_field)) { - deviceName = getStringValue(_p); - _p.nextToken(); - } - else if ("client_type".equals(_field)) { - clientType = _p.readValueAs(MobileClientPlatform.class); - _p.nextToken(); - } - else if ("ip_address".equals(_field)) { - ipAddress = getStringValue(_p); - _p.nextToken(); - } - else if ("country".equals(_field)) { - country = getStringValue(_p); - _p.nextToken(); - } - else if ("created".equals(_field)) { - created = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); - } - else if ("updated".equals(_field)) { - updated = _ctx.parseDate(getStringValue(_p)); - _p.nextToken(); - } - else if ("client_version".equals(_field)) { - clientVersion = getStringValue(_p); - _p.nextToken(); + public MobileClientSession deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + MobileClientSession value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_sessionId = null; + String f_deviceName = null; + MobileClientPlatform f_clientType = null; + String f_ipAddress = null; + String f_country = null; + Date f_created = null; + Date f_updated = null; + String f_clientVersion = null; + String f_osVersion = null; + String f_lastCarrier = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("session_id".equals(field)) { + f_sessionId = StoneSerializers.string().deserialize(p); + } + else if ("device_name".equals(field)) { + f_deviceName = StoneSerializers.string().deserialize(p); + } + else if ("client_type".equals(field)) { + f_clientType = MobileClientPlatform.Serializer.INSTANCE.deserialize(p); + } + else if ("ip_address".equals(field)) { + f_ipAddress = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("country".equals(field)) { + f_country = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("created".equals(field)) { + f_created = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else if ("updated".equals(field)) { + f_updated = StoneSerializers.nullable(StoneSerializers.timestamp()).deserialize(p); + } + else if ("client_version".equals(field)) { + f_clientVersion = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("os_version".equals(field)) { + f_osVersion = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("last_carrier".equals(field)) { + f_lastCarrier = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } - else if ("os_version".equals(_field)) { - osVersion = getStringValue(_p); - _p.nextToken(); + if (f_sessionId == null) { + throw new JsonParseException(p, "Required field \"session_id\" missing."); } - else if ("last_carrier".equals(_field)) { - lastCarrier = getStringValue(_p); - _p.nextToken(); + if (f_deviceName == null) { + throw new JsonParseException(p, "Required field \"device_name\" missing."); } - else { - skipValue(_p); + if (f_clientType == null) { + throw new JsonParseException(p, "Required field \"client_type\" missing."); } + value = new MobileClientSession(f_sessionId, f_deviceName, f_clientType, f_ipAddress, f_country, f_created, f_updated, f_clientVersion, f_osVersion, f_lastCarrier); } - - if (sessionId == null) { - throw new JsonParseException(_p, "Required field \"session_id\" is missing."); - } - if (deviceName == null) { - throw new JsonParseException(_p, "Required field \"device_name\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (clientType == null) { - throw new JsonParseException(_p, "Required field \"client_type\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new MobileClientSession(sessionId, deviceName, clientType, ipAddress, country, created, updated, clientVersion, osVersion, lastCarrier); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/PropertiesTemplateUpdateBuilder.java b/src/main/java/com/dropbox/core/v2/team/PropertiesTemplateUpdateBuilder.java deleted file mode 100644 index 697fbd6c1..000000000 --- a/src/main/java/com/dropbox/core/v2/team/PropertiesTemplateUpdateBuilder.java +++ /dev/null @@ -1,93 +0,0 @@ -/* DO NOT EDIT */ -/* This file was generated from team_property_templates.babel */ - -package com.dropbox.core.v2.team; - -import com.dropbox.core.DbxException; -import com.dropbox.core.v2.properties.ModifyPropertyTemplateErrorException; -import com.dropbox.core.v2.properties.PropertyFieldTemplate; - -import java.util.List; - -/** - * The request builder returned by {@link - * DbxTeamTeamRequests#propertiesTemplateUpdateBuilder(String)}. - * - *

Use this class to set optional request parameters and complete the - * request.

- */ -public class PropertiesTemplateUpdateBuilder { - private final DbxTeamTeamRequests team; - private final UpdatePropertyTemplateArg.Builder updatePropertyTemplateArgBuilder; - - /** - * Creates a new instance of this builder. - * - * @param team Dropbox namespace-specific client used to issue team - * requests. - * @param updatePropertyTemplateArgBuilder Request argument builder. - * - * @return instsance of this builder - */ - PropertiesTemplateUpdateBuilder(DbxTeamTeamRequests team, UpdatePropertyTemplateArg.Builder updatePropertyTemplateArgBuilder) { - if (team == null) { - throw new NullPointerException("team"); - } - if (updatePropertyTemplateArgBuilder == null) { - throw new NullPointerException("updatePropertyTemplateArgBuilder"); - } - this.team = team; - this.updatePropertyTemplateArgBuilder = updatePropertyTemplateArgBuilder; - } - - /** - * Set value for optional field. - * - * @param name A display name for the property template. Property template - * names can be up to 256 bytes. - * - * @return this builder - */ - public PropertiesTemplateUpdateBuilder withName(String name) { - this.updatePropertyTemplateArgBuilder.withName(name); - return this; - } - - /** - * Set value for optional field. - * - * @param description Description for new property template. Property - * template descriptions can be up to 1024 bytes. - * - * @return this builder - */ - public PropertiesTemplateUpdateBuilder withDescription(String description) { - this.updatePropertyTemplateArgBuilder.withDescription(description); - return this; - } - - /** - * Set value for optional field. - * - * @param addFields This is a list of custom properties to add to the - * property template. There can be up to 64 properties in a single - * property template. Must not contain a {@code null} item. - * - * @return this builder - * - * @throws IllegalArgumentException If any argument does not meet its - * preconditions. - */ - public PropertiesTemplateUpdateBuilder withAddFields(List addFields) { - this.updatePropertyTemplateArgBuilder.withAddFields(addFields); - return this; - } - - /** - * Issues the request. - */ - public UpdatePropertyTemplateResult start() throws ModifyPropertyTemplateErrorException, DbxException { - UpdatePropertyTemplateArg arg = this.updatePropertyTemplateArgBuilder.build(); - return team.propertiesTemplateUpdate(arg); - } -} diff --git a/src/main/java/com/dropbox/core/v2/team/ReportsGetActivityBuilder.java b/src/main/java/com/dropbox/core/v2/team/ReportsGetActivityBuilder.java index 6e90f046b..1324b47d7 100644 --- a/src/main/java/com/dropbox/core/v2/team/ReportsGetActivityBuilder.java +++ b/src/main/java/com/dropbox/core/v2/team/ReportsGetActivityBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_reports.babel */ +/* This file was generated from team_reports.stone */ package com.dropbox.core.v2.team; @@ -15,26 +15,26 @@ * request.

*/ public class ReportsGetActivityBuilder { - private final DbxTeamTeamRequests team; + private final DbxTeamTeamRequests team_; private final DateRange.Builder dateRangeBuilder; /** * Creates a new instance of this builder. * - * @param team Dropbox namespace-specific client used to issue team + * @param team_ Dropbox namespace-specific client used to issue team * requests. * @param dateRangeBuilder Request argument builder. * * @return instsance of this builder */ - ReportsGetActivityBuilder(DbxTeamTeamRequests team, DateRange.Builder dateRangeBuilder) { - if (team == null) { - throw new NullPointerException("team"); + ReportsGetActivityBuilder(DbxTeamTeamRequests team_, DateRange.Builder dateRangeBuilder) { + if (team_ == null) { + throw new NullPointerException("team_"); } + this.team_ = team_; if (dateRangeBuilder == null) { throw new NullPointerException("dateRangeBuilder"); } - this.team = team; this.dateRangeBuilder = dateRangeBuilder; } @@ -66,7 +66,7 @@ public ReportsGetActivityBuilder withEndDate(Date endDate) { * Issues the request. */ public GetActivityReport start() throws DateRangeErrorException, DbxException { - DateRange arg = this.dateRangeBuilder.build(); - return team.reportsGetActivity(arg); + DateRange arg_ = this.dateRangeBuilder.build(); + return team_.reportsGetActivity(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/team/ReportsGetDevicesBuilder.java b/src/main/java/com/dropbox/core/v2/team/ReportsGetDevicesBuilder.java index ca0f1a10c..68e200a83 100644 --- a/src/main/java/com/dropbox/core/v2/team/ReportsGetDevicesBuilder.java +++ b/src/main/java/com/dropbox/core/v2/team/ReportsGetDevicesBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_reports.babel */ +/* This file was generated from team_reports.stone */ package com.dropbox.core.v2.team; @@ -15,26 +15,26 @@ * request.

*/ public class ReportsGetDevicesBuilder { - private final DbxTeamTeamRequests team; + private final DbxTeamTeamRequests team_; private final DateRange.Builder dateRangeBuilder; /** * Creates a new instance of this builder. * - * @param team Dropbox namespace-specific client used to issue team + * @param team_ Dropbox namespace-specific client used to issue team * requests. * @param dateRangeBuilder Request argument builder. * * @return instsance of this builder */ - ReportsGetDevicesBuilder(DbxTeamTeamRequests team, DateRange.Builder dateRangeBuilder) { - if (team == null) { - throw new NullPointerException("team"); + ReportsGetDevicesBuilder(DbxTeamTeamRequests team_, DateRange.Builder dateRangeBuilder) { + if (team_ == null) { + throw new NullPointerException("team_"); } + this.team_ = team_; if (dateRangeBuilder == null) { throw new NullPointerException("dateRangeBuilder"); } - this.team = team; this.dateRangeBuilder = dateRangeBuilder; } @@ -66,7 +66,7 @@ public ReportsGetDevicesBuilder withEndDate(Date endDate) { * Issues the request. */ public GetDevicesReport start() throws DateRangeErrorException, DbxException { - DateRange arg = this.dateRangeBuilder.build(); - return team.reportsGetDevices(arg); + DateRange arg_ = this.dateRangeBuilder.build(); + return team_.reportsGetDevices(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/team/ReportsGetMembershipBuilder.java b/src/main/java/com/dropbox/core/v2/team/ReportsGetMembershipBuilder.java index 80f32adb2..247b12028 100644 --- a/src/main/java/com/dropbox/core/v2/team/ReportsGetMembershipBuilder.java +++ b/src/main/java/com/dropbox/core/v2/team/ReportsGetMembershipBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_reports.babel */ +/* This file was generated from team_reports.stone */ package com.dropbox.core.v2.team; @@ -15,26 +15,26 @@ * request.

*/ public class ReportsGetMembershipBuilder { - private final DbxTeamTeamRequests team; + private final DbxTeamTeamRequests team_; private final DateRange.Builder dateRangeBuilder; /** * Creates a new instance of this builder. * - * @param team Dropbox namespace-specific client used to issue team + * @param team_ Dropbox namespace-specific client used to issue team * requests. * @param dateRangeBuilder Request argument builder. * * @return instsance of this builder */ - ReportsGetMembershipBuilder(DbxTeamTeamRequests team, DateRange.Builder dateRangeBuilder) { - if (team == null) { - throw new NullPointerException("team"); + ReportsGetMembershipBuilder(DbxTeamTeamRequests team_, DateRange.Builder dateRangeBuilder) { + if (team_ == null) { + throw new NullPointerException("team_"); } + this.team_ = team_; if (dateRangeBuilder == null) { throw new NullPointerException("dateRangeBuilder"); } - this.team = team; this.dateRangeBuilder = dateRangeBuilder; } @@ -66,7 +66,7 @@ public ReportsGetMembershipBuilder withEndDate(Date endDate) { * Issues the request. */ public GetMembershipReport start() throws DateRangeErrorException, DbxException { - DateRange arg = this.dateRangeBuilder.build(); - return team.reportsGetMembership(arg); + DateRange arg_ = this.dateRangeBuilder.build(); + return team_.reportsGetMembership(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/team/ReportsGetStorageBuilder.java b/src/main/java/com/dropbox/core/v2/team/ReportsGetStorageBuilder.java index b05106ffa..263380135 100644 --- a/src/main/java/com/dropbox/core/v2/team/ReportsGetStorageBuilder.java +++ b/src/main/java/com/dropbox/core/v2/team/ReportsGetStorageBuilder.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_reports.babel */ +/* This file was generated from team_reports.stone */ package com.dropbox.core.v2.team; @@ -15,26 +15,26 @@ * request.

*/ public class ReportsGetStorageBuilder { - private final DbxTeamTeamRequests team; + private final DbxTeamTeamRequests team_; private final DateRange.Builder dateRangeBuilder; /** * Creates a new instance of this builder. * - * @param team Dropbox namespace-specific client used to issue team + * @param team_ Dropbox namespace-specific client used to issue team * requests. * @param dateRangeBuilder Request argument builder. * * @return instsance of this builder */ - ReportsGetStorageBuilder(DbxTeamTeamRequests team, DateRange.Builder dateRangeBuilder) { - if (team == null) { - throw new NullPointerException("team"); + ReportsGetStorageBuilder(DbxTeamTeamRequests team_, DateRange.Builder dateRangeBuilder) { + if (team_ == null) { + throw new NullPointerException("team_"); } + this.team_ = team_; if (dateRangeBuilder == null) { throw new NullPointerException("dateRangeBuilder"); } - this.team = team; this.dateRangeBuilder = dateRangeBuilder; } @@ -66,7 +66,7 @@ public ReportsGetStorageBuilder withEndDate(Date endDate) { * Issues the request. */ public GetStorageReport start() throws DateRangeErrorException, DbxException { - DateRange arg = this.dateRangeBuilder.build(); - return team.reportsGetStorage(arg); + DateRange arg_ = this.dateRangeBuilder.build(); + return team_.reportsGetStorage(arg_); } } diff --git a/src/main/java/com/dropbox/core/v2/team/RevokeDesktopClientArg.java b/src/main/java/com/dropbox/core/v2/team/RevokeDesktopClientArg.java index e40388e3a..a975f76b7 100644 --- a/src/main/java/com/dropbox/core/v2/team/RevokeDesktopClientArg.java +++ b/src/main/java/com/dropbox/core/v2/team/RevokeDesktopClientArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=RevokeDesktopClientArg.Serializer.class) -@JsonDeserialize(using=RevokeDesktopClientArg.Deserializer.class) public class RevokeDesktopClientArg extends DeviceSessionArg { // struct RevokeDesktopClientArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final boolean deleteOnUnlink; /** @@ -108,7 +91,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -120,93 +103,74 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RevokeDesktopClientArg.class); - } - - public Serializer(boolean unwrapping) { - super(RevokeDesktopClientArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(RevokeDesktopClientArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("session_id", value.sessionId); - g.writeObjectField("team_member_id", value.teamMemberId); - g.writeObjectField("delete_on_unlink", value.deleteOnUnlink); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RevokeDesktopClientArg.class); - } - - public Deserializer(boolean unwrapping) { - super(RevokeDesktopClientArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(RevokeDesktopClientArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("session_id"); + StoneSerializers.string().serialize(value.sessionId, g); + g.writeFieldName("team_member_id"); + StoneSerializers.string().serialize(value.teamMemberId, g); + g.writeFieldName("delete_on_unlink"); + StoneSerializers.boolean_().serialize(value.deleteOnUnlink, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public RevokeDesktopClientArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String sessionId = null; - String teamMemberId = null; - boolean deleteOnUnlink = false; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("session_id".equals(_field)) { - sessionId = getStringValue(_p); - _p.nextToken(); - } - else if ("team_member_id".equals(_field)) { - teamMemberId = getStringValue(_p); - _p.nextToken(); + public RevokeDesktopClientArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + RevokeDesktopClientArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_sessionId = null; + String f_teamMemberId = null; + Boolean f_deleteOnUnlink = false; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("session_id".equals(field)) { + f_sessionId = StoneSerializers.string().deserialize(p); + } + else if ("team_member_id".equals(field)) { + f_teamMemberId = StoneSerializers.string().deserialize(p); + } + else if ("delete_on_unlink".equals(field)) { + f_deleteOnUnlink = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } } - else if ("delete_on_unlink".equals(_field)) { - deleteOnUnlink = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_sessionId == null) { + throw new JsonParseException(p, "Required field \"session_id\" missing."); } - else { - skipValue(_p); + if (f_teamMemberId == null) { + throw new JsonParseException(p, "Required field \"team_member_id\" missing."); } + value = new RevokeDesktopClientArg(f_sessionId, f_teamMemberId, f_deleteOnUnlink); } - - if (sessionId == null) { - throw new JsonParseException(_p, "Required field \"session_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (teamMemberId == null) { - throw new JsonParseException(_p, "Required field \"team_member_id\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new RevokeDesktopClientArg(sessionId, teamMemberId, deleteOnUnlink); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionArg.java b/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionArg.java index 3b757fe80..8f2f7890b 100644 --- a/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionArg.java +++ b/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionArg.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is a tagged union. Tagged unions instances are always associated @@ -32,15 +20,9 @@ * return {@code true}. You can use {@link #tag()} to determine the tag * associated with this instance. */ -@JsonSerialize(using=RevokeDeviceSessionArg.Serializer.class) -@JsonDeserialize(using=RevokeDeviceSessionArg.Deserializer.class) public final class RevokeDeviceSessionArg { // union RevokeDeviceSessionArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link RevokeDeviceSessionArg}. */ @@ -275,7 +257,7 @@ else if (obj instanceof RevokeDeviceSessionArg) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -287,86 +269,85 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RevokeDeviceSessionArg.class, DeviceSessionArg.class, RevokeDesktopClientArg.class, DeviceSessionArg.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(RevokeDeviceSessionArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case WEB_SESSION: + public void serialize(RevokeDeviceSessionArg value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case WEB_SESSION: { g.writeStartObject(); - g.writeStringField(".tag", "web_session"); - getUnwrappingSerializer(DeviceSessionArg.class).serialize(value.webSessionValue, g, provider); + writeTag("web_session", g); + DeviceSessionArg.Serializer.INSTANCE.serialize(value.webSessionValue, g, true); g.writeEndObject(); break; - case DESKTOP_CLIENT: + } + case DESKTOP_CLIENT: { g.writeStartObject(); - g.writeStringField(".tag", "desktop_client"); - getUnwrappingSerializer(RevokeDesktopClientArg.class).serialize(value.desktopClientValue, g, provider); + writeTag("desktop_client", g); + RevokeDesktopClientArg.Serializer.INSTANCE.serialize(value.desktopClientValue, g, true); g.writeEndObject(); break; - case MOBILE_CLIENT: + } + case MOBILE_CLIENT: { g.writeStartObject(); - g.writeStringField(".tag", "mobile_client"); - getUnwrappingSerializer(DeviceSessionArg.class).serialize(value.mobileClientValue, g, provider); + writeTag("mobile_client", g); + DeviceSessionArg.Serializer.INSTANCE.serialize(value.mobileClientValue, g, true); g.writeEndObject(); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RevokeDeviceSessionArg.class, getTagMapping(), null, DeviceSessionArg.class, RevokeDesktopClientArg.class, DeviceSessionArg.class); - } - - @Override - public RevokeDeviceSessionArg deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case WEB_SESSION: { - DeviceSessionArg value = null; - value = readCollapsedStructValue(DeviceSessionArg.class, _p, _ctx); - return RevokeDeviceSessionArg.webSession(value); } - case DESKTOP_CLIENT: { - RevokeDesktopClientArg value = null; - value = readCollapsedStructValue(RevokeDesktopClientArg.class, _p, _ctx); - return RevokeDeviceSessionArg.desktopClient(value); - } - case MOBILE_CLIENT: { - DeviceSessionArg value = null; - value = readCollapsedStructValue(DeviceSessionArg.class, _p, _ctx); - return RevokeDeviceSessionArg.mobileClient(value); + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("web_session", RevokeDeviceSessionArg.Tag.WEB_SESSION); - values.put("desktop_client", RevokeDeviceSessionArg.Tag.DESKTOP_CLIENT); - values.put("mobile_client", RevokeDeviceSessionArg.Tag.MOBILE_CLIENT); - return Collections.unmodifiableMap(values); + @Override + public RevokeDeviceSessionArg deserialize(JsonParser p) throws IOException, JsonParseException { + RevokeDeviceSessionArg value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("web_session".equals(tag)) { + DeviceSessionArg fieldValue = null; + fieldValue = DeviceSessionArg.Serializer.INSTANCE.deserialize(p, true); + value = RevokeDeviceSessionArg.webSession(fieldValue); + } + else if ("desktop_client".equals(tag)) { + RevokeDesktopClientArg fieldValue = null; + fieldValue = RevokeDesktopClientArg.Serializer.INSTANCE.deserialize(p, true); + value = RevokeDeviceSessionArg.desktopClient(fieldValue); + } + else if ("mobile_client".equals(tag)) { + DeviceSessionArg fieldValue = null; + fieldValue = DeviceSessionArg.Serializer.INSTANCE.deserialize(p, true); + value = RevokeDeviceSessionArg.mobileClient(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionBatchArg.java b/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionBatchArg.java index 8e6589631..0cf5d9be2 100644 --- a/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionBatchArg.java +++ b/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionBatchArg.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=RevokeDeviceSessionBatchArg.Serializer.class) -@JsonDeserialize(using=RevokeDeviceSessionBatchArg.Deserializer.class) class RevokeDeviceSessionBatchArg { // struct RevokeDeviceSessionBatchArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List revokeDevices; /** @@ -90,7 +73,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -102,86 +85,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RevokeDeviceSessionBatchArg.class); - } - - public Serializer(boolean unwrapping) { - super(RevokeDeviceSessionBatchArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(RevokeDeviceSessionBatchArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("revoke_devices", value.revokeDevices); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RevokeDeviceSessionBatchArg.class); - } - - public Deserializer(boolean unwrapping) { - super(RevokeDeviceSessionBatchArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(RevokeDeviceSessionBatchArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("revoke_devices"); + StoneSerializers.list(RevokeDeviceSessionArg.Serializer.INSTANCE).serialize(value.revokeDevices, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public RevokeDeviceSessionBatchArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List revokeDevices = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("revoke_devices".equals(_field)) { - expectArrayStart(_p); - revokeDevices = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - RevokeDeviceSessionArg _x = null; - _x = _p.readValueAs(RevokeDeviceSessionArg.class); - _p.nextToken(); - revokeDevices.add(_x); + public RevokeDeviceSessionBatchArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + RevokeDeviceSessionBatchArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_revokeDevices = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("revoke_devices".equals(field)) { + f_revokeDevices = StoneSerializers.list(RevokeDeviceSessionArg.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else { - skipValue(_p); + if (f_revokeDevices == null) { + throw new JsonParseException(p, "Required field \"revoke_devices\" missing."); } + value = new RevokeDeviceSessionBatchArg(f_revokeDevices); } - - if (revokeDevices == null) { - throw new JsonParseException(_p, "Required field \"revoke_devices\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new RevokeDeviceSessionBatchArg(revokeDevices); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionBatchError.java b/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionBatchError.java index 41c7c5447..e892d888b 100644 --- a/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionBatchError.java +++ b/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionBatchError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=RevokeDeviceSessionBatchError.Serializer.class) -@JsonDeserialize(using=RevokeDeviceSessionBatchError.Deserializer.class) public enum RevokeDeviceSessionBatchError { // union RevokeDeviceSessionBatchError /** @@ -35,43 +21,47 @@ public enum RevokeDeviceSessionBatchError { */ UNSPECIFIED; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RevokeDeviceSessionBatchError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(RevokeDeviceSessionBatchError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(RevokeDeviceSessionBatchError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case UNSPECIFIED: + default: { g.writeString("unspecified"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RevokeDeviceSessionBatchError.class, getTagMapping(), RevokeDeviceSessionBatchError.UNSPECIFIED); - } @Override - public RevokeDeviceSessionBatchError deserialize(RevokeDeviceSessionBatchError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("unspecified", RevokeDeviceSessionBatchError.UNSPECIFIED); - return Collections.unmodifiableMap(values); + public RevokeDeviceSessionBatchError deserialize(JsonParser p) throws IOException, JsonParseException { + RevokeDeviceSessionBatchError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else { + value = RevokeDeviceSessionBatchError.UNSPECIFIED; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionBatchErrorException.java b/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionBatchErrorException.java index 950f8c271..c119507be 100644 --- a/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionBatchErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionBatchErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionBatchResult.java b/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionBatchResult.java index 0c6e45fa2..7856a7703 100644 --- a/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionBatchResult.java +++ b/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionBatchResult.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=RevokeDeviceSessionBatchResult.Serializer.class) -@JsonDeserialize(using=RevokeDeviceSessionBatchResult.Deserializer.class) public class RevokeDeviceSessionBatchResult { // struct RevokeDeviceSessionBatchResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List revokeDevicesStatus; /** @@ -90,7 +73,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -102,86 +85,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RevokeDeviceSessionBatchResult.class); - } - - public Serializer(boolean unwrapping) { - super(RevokeDeviceSessionBatchResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(RevokeDeviceSessionBatchResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("revoke_devices_status", value.revokeDevicesStatus); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RevokeDeviceSessionBatchResult.class); - } - - public Deserializer(boolean unwrapping) { - super(RevokeDeviceSessionBatchResult.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(RevokeDeviceSessionBatchResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("revoke_devices_status"); + StoneSerializers.list(RevokeDeviceSessionStatus.Serializer.INSTANCE).serialize(value.revokeDevicesStatus, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public RevokeDeviceSessionBatchResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List revokeDevicesStatus = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("revoke_devices_status".equals(_field)) { - expectArrayStart(_p); - revokeDevicesStatus = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - RevokeDeviceSessionStatus _x = null; - _x = _p.readValueAs(RevokeDeviceSessionStatus.class); - _p.nextToken(); - revokeDevicesStatus.add(_x); + public RevokeDeviceSessionBatchResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + RevokeDeviceSessionBatchResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_revokeDevicesStatus = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("revoke_devices_status".equals(field)) { + f_revokeDevicesStatus = StoneSerializers.list(RevokeDeviceSessionStatus.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else { - skipValue(_p); + if (f_revokeDevicesStatus == null) { + throw new JsonParseException(p, "Required field \"revoke_devices_status\" missing."); } + value = new RevokeDeviceSessionBatchResult(f_revokeDevicesStatus); } - - if (revokeDevicesStatus == null) { - throw new JsonParseException(_p, "Required field \"revoke_devices_status\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new RevokeDeviceSessionBatchResult(revokeDevicesStatus); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionError.java b/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionError.java index 864154ced..64be1a7e7 100644 --- a/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionError.java +++ b/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=RevokeDeviceSessionError.Serializer.class) -@JsonDeserialize(using=RevokeDeviceSessionError.Deserializer.class) public enum RevokeDeviceSessionError { // union RevokeDeviceSessionError /** @@ -43,51 +29,61 @@ public enum RevokeDeviceSessionError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RevokeDeviceSessionError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(RevokeDeviceSessionError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(RevokeDeviceSessionError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case DEVICE_SESSION_NOT_FOUND: + case DEVICE_SESSION_NOT_FOUND: { g.writeString("device_session_not_found"); break; - case MEMBER_NOT_FOUND: + } + case MEMBER_NOT_FOUND: { g.writeString("member_not_found"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RevokeDeviceSessionError.class, getTagMapping(), RevokeDeviceSessionError.OTHER); - } @Override - public RevokeDeviceSessionError deserialize(RevokeDeviceSessionError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("device_session_not_found", RevokeDeviceSessionError.DEVICE_SESSION_NOT_FOUND); - values.put("member_not_found", RevokeDeviceSessionError.MEMBER_NOT_FOUND); - values.put("other", RevokeDeviceSessionError.OTHER); - return Collections.unmodifiableMap(values); + public RevokeDeviceSessionError deserialize(JsonParser p) throws IOException, JsonParseException { + RevokeDeviceSessionError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("device_session_not_found".equals(tag)) { + value = RevokeDeviceSessionError.DEVICE_SESSION_NOT_FOUND; + } + else if ("member_not_found".equals(tag)) { + value = RevokeDeviceSessionError.MEMBER_NOT_FOUND; + } + else { + value = RevokeDeviceSessionError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionErrorException.java b/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionErrorException.java index d206c727e..8fe876dbd 100644 --- a/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionStatus.java b/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionStatus.java index e98727495..e5ee0b4ab 100644 --- a/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionStatus.java +++ b/src/main/java/com/dropbox/core/v2/team/RevokeDeviceSessionStatus.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel */ +/* This file was generated from team_devices.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=RevokeDeviceSessionStatus.Serializer.class) -@JsonDeserialize(using=RevokeDeviceSessionStatus.Deserializer.class) public class RevokeDeviceSessionStatus { // struct RevokeDeviceSessionStatus - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final boolean success; protected final RevokeDeviceSessionError errorType; @@ -102,7 +85,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -114,86 +97,67 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RevokeDeviceSessionStatus.class); - } - - public Serializer(boolean unwrapping) { - super(RevokeDeviceSessionStatus.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(RevokeDeviceSessionStatus value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("success", value.success); + public void serialize(RevokeDeviceSessionStatus value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("success"); + StoneSerializers.boolean_().serialize(value.success, g); if (value.errorType != null) { - g.writeObjectField("error_type", value.errorType); + g.writeFieldName("error_type"); + StoneSerializers.nullable(RevokeDeviceSessionError.Serializer.INSTANCE).serialize(value.errorType, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RevokeDeviceSessionStatus.class); - } - - public Deserializer(boolean unwrapping) { - super(RevokeDeviceSessionStatus.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public RevokeDeviceSessionStatus deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - Boolean success = null; - RevokeDeviceSessionError errorType = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("success".equals(_field)) { - success = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("error_type".equals(_field)) { - errorType = _p.readValueAs(RevokeDeviceSessionError.class); - _p.nextToken(); + public RevokeDeviceSessionStatus deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + RevokeDeviceSessionStatus value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Boolean f_success = null; + RevokeDeviceSessionError f_errorType = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("success".equals(field)) { + f_success = StoneSerializers.boolean_().deserialize(p); + } + else if ("error_type".equals(field)) { + f_errorType = StoneSerializers.nullable(RevokeDeviceSessionError.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_success == null) { + throw new JsonParseException(p, "Required field \"success\" missing."); } + value = new RevokeDeviceSessionStatus(f_success, f_errorType); } - - if (success == null) { - throw new JsonParseException(_p, "Required field \"success\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new RevokeDeviceSessionStatus(success, errorType); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/RevokeLinkedApiAppArg.java b/src/main/java/com/dropbox/core/v2/team/RevokeLinkedApiAppArg.java index d46a4227c..a000d9c3f 100644 --- a/src/main/java/com/dropbox/core/v2/team/RevokeLinkedApiAppArg.java +++ b/src/main/java/com/dropbox/core/v2/team/RevokeLinkedApiAppArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=RevokeLinkedApiAppArg.Serializer.class) -@JsonDeserialize(using=RevokeLinkedApiAppArg.Deserializer.class) public class RevokeLinkedApiAppArg { // struct RevokeLinkedApiAppArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String appId; protected final String teamMemberId; protected final boolean keepAppFolder; @@ -134,7 +117,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -146,93 +129,74 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RevokeLinkedApiAppArg.class); - } - - public Serializer(boolean unwrapping) { - super(RevokeLinkedApiAppArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(RevokeLinkedApiAppArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("app_id", value.appId); - g.writeObjectField("team_member_id", value.teamMemberId); - g.writeObjectField("keep_app_folder", value.keepAppFolder); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RevokeLinkedApiAppArg.class); - } - - public Deserializer(boolean unwrapping) { - super(RevokeLinkedApiAppArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(RevokeLinkedApiAppArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("app_id"); + StoneSerializers.string().serialize(value.appId, g); + g.writeFieldName("team_member_id"); + StoneSerializers.string().serialize(value.teamMemberId, g); + g.writeFieldName("keep_app_folder"); + StoneSerializers.boolean_().serialize(value.keepAppFolder, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public RevokeLinkedApiAppArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String appId = null; - String teamMemberId = null; - boolean keepAppFolder = true; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("app_id".equals(_field)) { - appId = getStringValue(_p); - _p.nextToken(); - } - else if ("team_member_id".equals(_field)) { - teamMemberId = getStringValue(_p); - _p.nextToken(); + public RevokeLinkedApiAppArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + RevokeLinkedApiAppArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_appId = null; + String f_teamMemberId = null; + Boolean f_keepAppFolder = true; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("app_id".equals(field)) { + f_appId = StoneSerializers.string().deserialize(p); + } + else if ("team_member_id".equals(field)) { + f_teamMemberId = StoneSerializers.string().deserialize(p); + } + else if ("keep_app_folder".equals(field)) { + f_keepAppFolder = StoneSerializers.boolean_().deserialize(p); + } + else { + skipValue(p); + } } - else if ("keep_app_folder".equals(_field)) { - keepAppFolder = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_appId == null) { + throw new JsonParseException(p, "Required field \"app_id\" missing."); } - else { - skipValue(_p); + if (f_teamMemberId == null) { + throw new JsonParseException(p, "Required field \"team_member_id\" missing."); } + value = new RevokeLinkedApiAppArg(f_appId, f_teamMemberId, f_keepAppFolder); } - - if (appId == null) { - throw new JsonParseException(_p, "Required field \"app_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (teamMemberId == null) { - throw new JsonParseException(_p, "Required field \"team_member_id\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new RevokeLinkedApiAppArg(appId, teamMemberId, keepAppFolder); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/RevokeLinkedApiAppBatchArg.java b/src/main/java/com/dropbox/core/v2/team/RevokeLinkedApiAppBatchArg.java index f8b17150b..0bb7cac01 100644 --- a/src/main/java/com/dropbox/core/v2/team/RevokeLinkedApiAppBatchArg.java +++ b/src/main/java/com/dropbox/core/v2/team/RevokeLinkedApiAppBatchArg.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=RevokeLinkedApiAppBatchArg.Serializer.class) -@JsonDeserialize(using=RevokeLinkedApiAppBatchArg.Deserializer.class) class RevokeLinkedApiAppBatchArg { // struct RevokeLinkedApiAppBatchArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List revokeLinkedApp; /** @@ -90,7 +73,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -102,86 +85,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RevokeLinkedApiAppBatchArg.class); - } - - public Serializer(boolean unwrapping) { - super(RevokeLinkedApiAppBatchArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(RevokeLinkedApiAppBatchArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("revoke_linked_app", value.revokeLinkedApp); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RevokeLinkedApiAppBatchArg.class); - } - - public Deserializer(boolean unwrapping) { - super(RevokeLinkedApiAppBatchArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(RevokeLinkedApiAppBatchArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("revoke_linked_app"); + StoneSerializers.list(RevokeLinkedApiAppArg.Serializer.INSTANCE).serialize(value.revokeLinkedApp, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public RevokeLinkedApiAppBatchArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List revokeLinkedApp = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("revoke_linked_app".equals(_field)) { - expectArrayStart(_p); - revokeLinkedApp = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - RevokeLinkedApiAppArg _x = null; - _x = _p.readValueAs(RevokeLinkedApiAppArg.class); - _p.nextToken(); - revokeLinkedApp.add(_x); + public RevokeLinkedApiAppBatchArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + RevokeLinkedApiAppBatchArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_revokeLinkedApp = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("revoke_linked_app".equals(field)) { + f_revokeLinkedApp = StoneSerializers.list(RevokeLinkedApiAppArg.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else { - skipValue(_p); + if (f_revokeLinkedApp == null) { + throw new JsonParseException(p, "Required field \"revoke_linked_app\" missing."); } + value = new RevokeLinkedApiAppBatchArg(f_revokeLinkedApp); } - - if (revokeLinkedApp == null) { - throw new JsonParseException(_p, "Required field \"revoke_linked_app\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new RevokeLinkedApiAppBatchArg(revokeLinkedApp); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppBatchError.java b/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppBatchError.java index ed2bbf9c4..7b0f669b5 100644 --- a/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppBatchError.java +++ b/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppBatchError.java @@ -1,37 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Error returned by {@link * DbxTeamTeamRequests#linkedAppsRevokeLinkedAppBatch(java.util.List)}. */ -@JsonSerialize(using=RevokeLinkedAppBatchError.Serializer.class) -@JsonDeserialize(using=RevokeLinkedAppBatchError.Deserializer.class) public enum RevokeLinkedAppBatchError { // union RevokeLinkedAppBatchError /** @@ -39,43 +25,47 @@ public enum RevokeLinkedAppBatchError { */ UNSPECIFIED; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RevokeLinkedAppBatchError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(RevokeLinkedAppBatchError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(RevokeLinkedAppBatchError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case UNSPECIFIED: + default: { g.writeString("unspecified"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RevokeLinkedAppBatchError.class, getTagMapping(), RevokeLinkedAppBatchError.UNSPECIFIED); - } @Override - public RevokeLinkedAppBatchError deserialize(RevokeLinkedAppBatchError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("unspecified", RevokeLinkedAppBatchError.UNSPECIFIED); - return Collections.unmodifiableMap(values); + public RevokeLinkedAppBatchError deserialize(JsonParser p) throws IOException, JsonParseException { + RevokeLinkedAppBatchError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else { + value = RevokeLinkedAppBatchError.UNSPECIFIED; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppBatchErrorException.java b/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppBatchErrorException.java index 949c47f26..eb2ba1724 100644 --- a/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppBatchErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppBatchErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppBatchResult.java b/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppBatchResult.java index a1cfd2c87..18b1c425a 100644 --- a/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppBatchResult.java +++ b/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppBatchResult.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=RevokeLinkedAppBatchResult.Serializer.class) -@JsonDeserialize(using=RevokeLinkedAppBatchResult.Deserializer.class) public class RevokeLinkedAppBatchResult { // struct RevokeLinkedAppBatchResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List revokeLinkedAppStatus; /** @@ -90,7 +73,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -102,86 +85,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RevokeLinkedAppBatchResult.class); - } - - public Serializer(boolean unwrapping) { - super(RevokeLinkedAppBatchResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(RevokeLinkedAppBatchResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("revoke_linked_app_status", value.revokeLinkedAppStatus); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RevokeLinkedAppBatchResult.class); - } - - public Deserializer(boolean unwrapping) { - super(RevokeLinkedAppBatchResult.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(RevokeLinkedAppBatchResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("revoke_linked_app_status"); + StoneSerializers.list(RevokeLinkedAppStatus.Serializer.INSTANCE).serialize(value.revokeLinkedAppStatus, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public RevokeLinkedAppBatchResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List revokeLinkedAppStatus = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("revoke_linked_app_status".equals(_field)) { - expectArrayStart(_p); - revokeLinkedAppStatus = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - RevokeLinkedAppStatus _x = null; - _x = _p.readValueAs(RevokeLinkedAppStatus.class); - _p.nextToken(); - revokeLinkedAppStatus.add(_x); + public RevokeLinkedAppBatchResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + RevokeLinkedAppBatchResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_revokeLinkedAppStatus = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("revoke_linked_app_status".equals(field)) { + f_revokeLinkedAppStatus = StoneSerializers.list(RevokeLinkedAppStatus.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else { - skipValue(_p); + if (f_revokeLinkedAppStatus == null) { + throw new JsonParseException(p, "Required field \"revoke_linked_app_status\" missing."); } + value = new RevokeLinkedAppBatchResult(f_revokeLinkedAppStatus); } - - if (revokeLinkedAppStatus == null) { - throw new JsonParseException(_p, "Required field \"revoke_linked_app_status\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new RevokeLinkedAppBatchResult(revokeLinkedAppStatus); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppError.java b/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppError.java index 67c127bb4..cc158950a 100644 --- a/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppError.java +++ b/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppError.java @@ -1,37 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Error returned by {@link * DbxTeamTeamRequests#linkedAppsRevokeLinkedApp(String,String)}. */ -@JsonSerialize(using=RevokeLinkedAppError.Serializer.class) -@JsonDeserialize(using=RevokeLinkedAppError.Deserializer.class) public enum RevokeLinkedAppError { // union RevokeLinkedAppError /** @@ -47,51 +33,61 @@ public enum RevokeLinkedAppError { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RevokeLinkedAppError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(RevokeLinkedAppError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(RevokeLinkedAppError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case APP_NOT_FOUND: + case APP_NOT_FOUND: { g.writeString("app_not_found"); break; - case MEMBER_NOT_FOUND: + } + case MEMBER_NOT_FOUND: { g.writeString("member_not_found"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RevokeLinkedAppError.class, getTagMapping(), RevokeLinkedAppError.OTHER); - } @Override - public RevokeLinkedAppError deserialize(RevokeLinkedAppError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("app_not_found", RevokeLinkedAppError.APP_NOT_FOUND); - values.put("member_not_found", RevokeLinkedAppError.MEMBER_NOT_FOUND); - values.put("other", RevokeLinkedAppError.OTHER); - return Collections.unmodifiableMap(values); + public RevokeLinkedAppError deserialize(JsonParser p) throws IOException, JsonParseException { + RevokeLinkedAppError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("app_not_found".equals(tag)) { + value = RevokeLinkedAppError.APP_NOT_FOUND; + } + else if ("member_not_found".equals(tag)) { + value = RevokeLinkedAppError.MEMBER_NOT_FOUND; + } + else { + value = RevokeLinkedAppError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppErrorException.java b/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppErrorException.java index 08e07820e..bd83aaba1 100644 --- a/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppErrorException.java +++ b/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; diff --git a/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppStatus.java b/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppStatus.java index aebc6f6cd..2d123f322 100644 --- a/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppStatus.java +++ b/src/main/java/com/dropbox/core/v2/team/RevokeLinkedAppStatus.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_linked_apps.babel */ +/* This file was generated from team_linked_apps.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=RevokeLinkedAppStatus.Serializer.class) -@JsonDeserialize(using=RevokeLinkedAppStatus.Deserializer.class) public class RevokeLinkedAppStatus { // struct RevokeLinkedAppStatus - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final boolean success; protected final RevokeLinkedAppError errorType; @@ -102,7 +85,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -114,86 +97,67 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(RevokeLinkedAppStatus.class); - } - - public Serializer(boolean unwrapping) { - super(RevokeLinkedAppStatus.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(RevokeLinkedAppStatus value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("success", value.success); + public void serialize(RevokeLinkedAppStatus value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("success"); + StoneSerializers.boolean_().serialize(value.success, g); if (value.errorType != null) { - g.writeObjectField("error_type", value.errorType); + g.writeFieldName("error_type"); + StoneSerializers.nullable(RevokeLinkedAppError.Serializer.INSTANCE).serialize(value.errorType, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(RevokeLinkedAppStatus.class); - } - - public Deserializer(boolean unwrapping) { - super(RevokeLinkedAppStatus.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public RevokeLinkedAppStatus deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - Boolean success = null; - RevokeLinkedAppError errorType = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("success".equals(_field)) { - success = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("error_type".equals(_field)) { - errorType = _p.readValueAs(RevokeLinkedAppError.class); - _p.nextToken(); + public RevokeLinkedAppStatus deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + RevokeLinkedAppStatus value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Boolean f_success = null; + RevokeLinkedAppError f_errorType = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("success".equals(field)) { + f_success = StoneSerializers.boolean_().deserialize(p); + } + else if ("error_type".equals(field)) { + f_errorType = StoneSerializers.nullable(RevokeLinkedAppError.Serializer.INSTANCE).deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_success == null) { + throw new JsonParseException(p, "Required field \"success\" missing."); } + value = new RevokeLinkedAppStatus(f_success, f_errorType); } - - if (success == null) { - throw new JsonParseException(_p, "Required field \"success\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new RevokeLinkedAppStatus(success, errorType); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/StorageBucket.java b/src/main/java/com/dropbox/core/v2/team/StorageBucket.java index dcf7c039b..152cf8680 100644 --- a/src/main/java/com/dropbox/core/v2/team/StorageBucket.java +++ b/src/main/java/com/dropbox/core/v2/team/StorageBucket.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from team_reports.babel */ +/* This file was generated from team_reports.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Describes the number of users in a specific storage bucket. */ -@JsonSerialize(using=StorageBucket.Serializer.class) -@JsonDeserialize(using=StorageBucket.Deserializer.class) public class StorageBucket { // struct StorageBucket - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String bucket; protected final long users; @@ -108,7 +91,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -120,88 +103,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(StorageBucket.class); - } - - public Serializer(boolean unwrapping) { - super(StorageBucket.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(StorageBucket value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("bucket", value.bucket); - g.writeObjectField("users", value.users); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(StorageBucket.class); - } - - public Deserializer(boolean unwrapping) { - super(StorageBucket.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(StorageBucket value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("bucket"); + StoneSerializers.string().serialize(value.bucket, g); + g.writeFieldName("users"); + StoneSerializers.uInt64().serialize(value.users, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public StorageBucket deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String bucket = null; - Long users = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("bucket".equals(_field)) { - bucket = getStringValue(_p); - _p.nextToken(); + public StorageBucket deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + StorageBucket value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_bucket = null; + Long f_users = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("bucket".equals(field)) { + f_bucket = StoneSerializers.string().deserialize(p); + } + else if ("users".equals(field)) { + f_users = StoneSerializers.uInt64().deserialize(p); + } + else { + skipValue(p); + } } - else if ("users".equals(_field)) { - users = _p.getLongValue(); - assertUnsigned(_p, users); - _p.nextToken(); + if (f_bucket == null) { + throw new JsonParseException(p, "Required field \"bucket\" missing."); } - else { - skipValue(_p); + if (f_users == null) { + throw new JsonParseException(p, "Required field \"users\" missing."); } + value = new StorageBucket(f_bucket, f_users); } - - if (bucket == null) { - throw new JsonParseException(_p, "Required field \"bucket\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (users == null) { - throw new JsonParseException(_p, "Required field \"users\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new StorageBucket(bucket, users); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/TeamGetInfoResult.java b/src/main/java/com/dropbox/core/v2/team/TeamGetInfoResult.java index f93a288cc..dd51a478a 100644 --- a/src/main/java/com/dropbox/core/v2/team/TeamGetInfoResult.java +++ b/src/main/java/com/dropbox/core/v2/team/TeamGetInfoResult.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team.babel */ +/* This file was generated from team.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.dropbox.core.v2.teampolicies.TeamPolicies; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=TeamGetInfoResult.Serializer.class) -@JsonDeserialize(using=TeamGetInfoResult.Deserializer.class) public class TeamGetInfoResult { // struct TeamGetInfoResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String name; protected final String teamId; protected final long numLicensedUsers; @@ -149,7 +132,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -161,122 +144,95 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(TeamGetInfoResult.class); - } - - public Serializer(boolean unwrapping) { - super(TeamGetInfoResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(TeamGetInfoResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("name", value.name); - g.writeObjectField("team_id", value.teamId); - g.writeObjectField("num_licensed_users", value.numLicensedUsers); - g.writeObjectField("num_provisioned_users", value.numProvisionedUsers); - g.writeObjectField("policies", value.policies); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(TeamGetInfoResult.class); - } - - public Deserializer(boolean unwrapping) { - super(TeamGetInfoResult.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(TeamGetInfoResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("name"); + StoneSerializers.string().serialize(value.name, g); + g.writeFieldName("team_id"); + StoneSerializers.string().serialize(value.teamId, g); + g.writeFieldName("num_licensed_users"); + StoneSerializers.uInt32().serialize(value.numLicensedUsers, g); + g.writeFieldName("num_provisioned_users"); + StoneSerializers.uInt32().serialize(value.numProvisionedUsers, g); + g.writeFieldName("policies"); + TeamPolicies.Serializer.INSTANCE.serialize(value.policies, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public TeamGetInfoResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String name = null; - String teamId = null; - Long numLicensedUsers = null; - Long numProvisionedUsers = null; - TeamPolicies policies = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("name".equals(_field)) { - name = getStringValue(_p); - _p.nextToken(); + public TeamGetInfoResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + TeamGetInfoResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_name = null; + String f_teamId = null; + Long f_numLicensedUsers = null; + Long f_numProvisionedUsers = null; + TeamPolicies f_policies = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("name".equals(field)) { + f_name = StoneSerializers.string().deserialize(p); + } + else if ("team_id".equals(field)) { + f_teamId = StoneSerializers.string().deserialize(p); + } + else if ("num_licensed_users".equals(field)) { + f_numLicensedUsers = StoneSerializers.uInt32().deserialize(p); + } + else if ("num_provisioned_users".equals(field)) { + f_numProvisionedUsers = StoneSerializers.uInt32().deserialize(p); + } + else if ("policies".equals(field)) { + f_policies = TeamPolicies.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else if ("team_id".equals(_field)) { - teamId = getStringValue(_p); - _p.nextToken(); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } - else if ("num_licensed_users".equals(_field)) { - numLicensedUsers = _p.getLongValue(); - assertUnsigned(_p, numLicensedUsers); - if (numLicensedUsers > Integer.MAX_VALUE) { - throw new JsonParseException(_p, "expecting a 32-bit unsigned integer, got: " + numLicensedUsers); - } - _p.nextToken(); + if (f_teamId == null) { + throw new JsonParseException(p, "Required field \"team_id\" missing."); } - else if ("num_provisioned_users".equals(_field)) { - numProvisionedUsers = _p.getLongValue(); - assertUnsigned(_p, numProvisionedUsers); - if (numProvisionedUsers > Integer.MAX_VALUE) { - throw new JsonParseException(_p, "expecting a 32-bit unsigned integer, got: " + numProvisionedUsers); - } - _p.nextToken(); + if (f_numLicensedUsers == null) { + throw new JsonParseException(p, "Required field \"num_licensed_users\" missing."); } - else if ("policies".equals(_field)) { - policies = _p.readValueAs(TeamPolicies.class); - _p.nextToken(); + if (f_numProvisionedUsers == null) { + throw new JsonParseException(p, "Required field \"num_provisioned_users\" missing."); } - else { - skipValue(_p); + if (f_policies == null) { + throw new JsonParseException(p, "Required field \"policies\" missing."); } + value = new TeamGetInfoResult(f_name, f_teamId, f_numLicensedUsers, f_numProvisionedUsers, f_policies); } - - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); - } - if (teamId == null) { - throw new JsonParseException(_p, "Required field \"team_id\" is missing."); - } - if (numLicensedUsers == null) { - throw new JsonParseException(_p, "Required field \"num_licensed_users\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (numProvisionedUsers == null) { - throw new JsonParseException(_p, "Required field \"num_provisioned_users\" is missing."); + if (!collapsed) { + expectEndObject(p); } - if (policies == null) { - throw new JsonParseException(_p, "Required field \"policies\" is missing."); - } - - return new TeamGetInfoResult(name, teamId, numLicensedUsers, numProvisionedUsers, policies); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/TeamMemberInfo.java b/src/main/java/com/dropbox/core/v2/team/TeamMemberInfo.java index ad72a174c..5a23f9298 100644 --- a/src/main/java/com/dropbox/core/v2/team/TeamMemberInfo.java +++ b/src/main/java/com/dropbox/core/v2/team/TeamMemberInfo.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Information about a team member. */ -@JsonSerialize(using=TeamMemberInfo.Serializer.class) -@JsonDeserialize(using=TeamMemberInfo.Deserializer.class) public class TeamMemberInfo { // struct TeamMemberInfo - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final TeamMemberProfile profile; protected final AdminTier role; @@ -107,7 +90,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -119,87 +102,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(TeamMemberInfo.class); - } - - public Serializer(boolean unwrapping) { - super(TeamMemberInfo.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(TeamMemberInfo value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("profile", value.profile); - g.writeObjectField("role", value.role); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(TeamMemberInfo.class); - } - - public Deserializer(boolean unwrapping) { - super(TeamMemberInfo.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(TeamMemberInfo value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("profile"); + TeamMemberProfile.Serializer.INSTANCE.serialize(value.profile, g); + g.writeFieldName("role"); + AdminTier.Serializer.INSTANCE.serialize(value.role, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public TeamMemberInfo deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - TeamMemberProfile profile = null; - AdminTier role = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("profile".equals(_field)) { - profile = _p.readValueAs(TeamMemberProfile.class); - _p.nextToken(); + public TeamMemberInfo deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + TeamMemberInfo value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + TeamMemberProfile f_profile = null; + AdminTier f_role = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("profile".equals(field)) { + f_profile = TeamMemberProfile.Serializer.INSTANCE.deserialize(p); + } + else if ("role".equals(field)) { + f_role = AdminTier.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else if ("role".equals(_field)) { - role = _p.readValueAs(AdminTier.class); - _p.nextToken(); + if (f_profile == null) { + throw new JsonParseException(p, "Required field \"profile\" missing."); } - else { - skipValue(_p); + if (f_role == null) { + throw new JsonParseException(p, "Required field \"role\" missing."); } + value = new TeamMemberInfo(f_profile, f_role); } - - if (profile == null) { - throw new JsonParseException(_p, "Required field \"profile\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (role == null) { - throw new JsonParseException(_p, "Required field \"role\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new TeamMemberInfo(profile, role); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/TeamMemberProfile.java b/src/main/java/com/dropbox/core/v2/team/TeamMemberProfile.java index c1023b7af..5e0ade0ec 100644 --- a/src/main/java/com/dropbox/core/v2/team/TeamMemberProfile.java +++ b/src/main/java/com/dropbox/core/v2/team/TeamMemberProfile.java @@ -1,28 +1,17 @@ /* DO NOT EDIT */ -/* This file was generated from team_members.babel */ +/* This file was generated from team_members.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.dropbox.core.v2.users.Name; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; @@ -30,15 +19,9 @@ /** * Profile of a user as a member of a team. */ -@JsonSerialize(using=TeamMemberProfile.Serializer.class) -@JsonDeserialize(using=TeamMemberProfile.Deserializer.class) public class TeamMemberProfile extends MemberProfile { // struct TeamMemberProfile - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List groups; /** @@ -53,6 +36,9 @@ public class TeamMemberProfile extends MemberProfile { * be {@code null}. * @param name Representations for a person's name. Must not be {@code * null}. + * @param membershipType The user's membership type: full (normal team + * member) vs limited (does not use a license; no access to the team's + * shared quota). Must not be {@code null}. * @param groups List of group IDs of groups that the user belongs to. Must * not contain a {@code null} item and not be {@code null}. * @param externalId External ID that a team can attach to the user. An @@ -62,8 +48,8 @@ public class TeamMemberProfile extends MemberProfile { * @throws IllegalArgumentException If any argument does not meet its * preconditions. */ - public TeamMemberProfile(String teamMemberId, String email, boolean emailVerified, TeamMemberStatus status, Name name, List groups, String externalId) { - super(teamMemberId, email, emailVerified, status, name, externalId); + public TeamMemberProfile(String teamMemberId, String email, boolean emailVerified, TeamMemberStatus status, Name name, TeamMembershipType membershipType, List groups, String externalId) { + super(teamMemberId, email, emailVerified, status, name, membershipType, externalId); if (groups == null) { throw new IllegalArgumentException("Required value for 'groups' is null"); } @@ -89,14 +75,17 @@ public TeamMemberProfile(String teamMemberId, String email, boolean emailVerifie * be {@code null}. * @param name Representations for a person's name. Must not be {@code * null}. + * @param membershipType The user's membership type: full (normal team + * member) vs limited (does not use a license; no access to the team's + * shared quota). Must not be {@code null}. * @param groups List of group IDs of groups that the user belongs to. Must * not contain a {@code null} item and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. */ - public TeamMemberProfile(String teamMemberId, String email, boolean emailVerified, TeamMemberStatus status, Name name, List groups) { - this(teamMemberId, email, emailVerified, status, name, groups, null); + public TeamMemberProfile(String teamMemberId, String email, boolean emailVerified, TeamMemberStatus status, Name name, TeamMembershipType membershipType, List groups) { + this(teamMemberId, email, emailVerified, status, name, membershipType, groups, null); } /** @@ -130,6 +119,7 @@ else if (obj.getClass().equals(this.getClass())) { && (this.emailVerified == other.emailVerified) && ((this.status == other.status) || (this.status.equals(other.status))) && ((this.name == other.name) || (this.name.equals(other.name))) + && ((this.membershipType == other.membershipType) || (this.membershipType.equals(other.membershipType))) && ((this.groups == other.groups) || (this.groups.equals(other.groups))) && ((this.externalId == other.externalId) || (this.externalId != null && this.externalId.equals(other.externalId))) ; @@ -141,7 +131,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -153,139 +143,121 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(TeamMemberProfile.class); - } - - public Serializer(boolean unwrapping) { - super(TeamMemberProfile.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(TeamMemberProfile value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("team_member_id", value.teamMemberId); - g.writeObjectField("email", value.email); - g.writeObjectField("email_verified", value.emailVerified); - g.writeObjectField("status", value.status); - g.writeObjectField("name", value.name); - g.writeObjectField("groups", value.groups); + public void serialize(TeamMemberProfile value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("team_member_id"); + StoneSerializers.string().serialize(value.teamMemberId, g); + g.writeFieldName("email"); + StoneSerializers.string().serialize(value.email, g); + g.writeFieldName("email_verified"); + StoneSerializers.boolean_().serialize(value.emailVerified, g); + g.writeFieldName("status"); + TeamMemberStatus.Serializer.INSTANCE.serialize(value.status, g); + g.writeFieldName("name"); + Name.Serializer.INSTANCE.serialize(value.name, g); + g.writeFieldName("membership_type"); + TeamMembershipType.Serializer.INSTANCE.serialize(value.membershipType, g); + g.writeFieldName("groups"); + StoneSerializers.list(StoneSerializers.string()).serialize(value.groups, g); if (value.externalId != null) { - g.writeObjectField("external_id", value.externalId); + g.writeFieldName("external_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.externalId, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(TeamMemberProfile.class); - } - - public Deserializer(boolean unwrapping) { - super(TeamMemberProfile.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public TeamMemberProfile deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String teamMemberId = null; - String email = null; - Boolean emailVerified = null; - TeamMemberStatus status = null; - Name name = null; - List groups = null; - String externalId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("team_member_id".equals(_field)) { - teamMemberId = getStringValue(_p); - _p.nextToken(); + public TeamMemberProfile deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + TeamMemberProfile value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_teamMemberId = null; + String f_email = null; + Boolean f_emailVerified = null; + TeamMemberStatus f_status = null; + Name f_name = null; + TeamMembershipType f_membershipType = null; + List f_groups = null; + String f_externalId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("team_member_id".equals(field)) { + f_teamMemberId = StoneSerializers.string().deserialize(p); + } + else if ("email".equals(field)) { + f_email = StoneSerializers.string().deserialize(p); + } + else if ("email_verified".equals(field)) { + f_emailVerified = StoneSerializers.boolean_().deserialize(p); + } + else if ("status".equals(field)) { + f_status = TeamMemberStatus.Serializer.INSTANCE.deserialize(p); + } + else if ("name".equals(field)) { + f_name = Name.Serializer.INSTANCE.deserialize(p); + } + else if ("membership_type".equals(field)) { + f_membershipType = TeamMembershipType.Serializer.INSTANCE.deserialize(p); + } + else if ("groups".equals(field)) { + f_groups = StoneSerializers.list(StoneSerializers.string()).deserialize(p); + } + else if ("external_id".equals(field)) { + f_externalId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } - else if ("email".equals(_field)) { - email = getStringValue(_p); - _p.nextToken(); + if (f_teamMemberId == null) { + throw new JsonParseException(p, "Required field \"team_member_id\" missing."); } - else if ("email_verified".equals(_field)) { - emailVerified = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_email == null) { + throw new JsonParseException(p, "Required field \"email\" missing."); } - else if ("status".equals(_field)) { - status = _p.readValueAs(TeamMemberStatus.class); - _p.nextToken(); + if (f_emailVerified == null) { + throw new JsonParseException(p, "Required field \"email_verified\" missing."); } - else if ("name".equals(_field)) { - name = _p.readValueAs(Name.class); - _p.nextToken(); + if (f_status == null) { + throw new JsonParseException(p, "Required field \"status\" missing."); } - else if ("groups".equals(_field)) { - expectArrayStart(_p); - groups = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - String _x = null; - _x = getStringValue(_p); - _p.nextToken(); - groups.add(_x); - } - expectArrayEnd(_p); - _p.nextToken(); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } - else if ("external_id".equals(_field)) { - externalId = getStringValue(_p); - _p.nextToken(); + if (f_membershipType == null) { + throw new JsonParseException(p, "Required field \"membership_type\" missing."); } - else { - skipValue(_p); + if (f_groups == null) { + throw new JsonParseException(p, "Required field \"groups\" missing."); } + value = new TeamMemberProfile(f_teamMemberId, f_email, f_emailVerified, f_status, f_name, f_membershipType, f_groups, f_externalId); } - - if (teamMemberId == null) { - throw new JsonParseException(_p, "Required field \"team_member_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (email == null) { - throw new JsonParseException(_p, "Required field \"email\" is missing."); + if (!collapsed) { + expectEndObject(p); } - if (emailVerified == null) { - throw new JsonParseException(_p, "Required field \"email_verified\" is missing."); - } - if (status == null) { - throw new JsonParseException(_p, "Required field \"status\" is missing."); - } - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); - } - if (groups == null) { - throw new JsonParseException(_p, "Required field \"groups\" is missing."); - } - - return new TeamMemberProfile(teamMemberId, email, emailVerified, status, name, groups, externalId); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/TeamMemberStatus.java b/src/main/java/com/dropbox/core/v2/team/TeamMemberStatus.java index 7e9f8492a..93996cb4d 100644 --- a/src/main/java/com/dropbox/core/v2/team/TeamMemberStatus.java +++ b/src/main/java/com/dropbox/core/v2/team/TeamMemberStatus.java @@ -1,36 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team.babel */ +/* This file was generated from team.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * The user's status as a member of a specific team. */ -@JsonSerialize(using=TeamMemberStatus.Serializer.class) -@JsonDeserialize(using=TeamMemberStatus.Deserializer.class) public enum TeamMemberStatus { // union TeamMemberStatus /** @@ -47,51 +33,67 @@ public enum TeamMemberStatus { */ SUSPENDED; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(TeamMemberStatus.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(TeamMemberStatus value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(TeamMemberStatus value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case ACTIVE: + case ACTIVE: { g.writeString("active"); break; - case INVITED: + } + case INVITED: { g.writeString("invited"); break; - case SUSPENDED: + } + case SUSPENDED: { g.writeString("suspended"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(TeamMemberStatus.class, getTagMapping(), null); - } @Override - public TeamMemberStatus deserialize(TeamMemberStatus _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("active", TeamMemberStatus.ACTIVE); - values.put("invited", TeamMemberStatus.INVITED); - values.put("suspended", TeamMemberStatus.SUSPENDED); - return Collections.unmodifiableMap(values); + public TeamMemberStatus deserialize(JsonParser p) throws IOException, JsonParseException { + TeamMemberStatus value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("active".equals(tag)) { + value = TeamMemberStatus.ACTIVE; + } + else if ("invited".equals(tag)) { + value = TeamMemberStatus.INVITED; + } + else if ("suspended".equals(tag)) { + value = TeamMemberStatus.SUSPENDED; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/TeamMembershipType.java b/src/main/java/com/dropbox/core/v2/team/TeamMembershipType.java new file mode 100644 index 000000000..2652952f2 --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/team/TeamMembershipType.java @@ -0,0 +1,86 @@ +/* DO NOT EDIT */ +/* This file was generated from team.stone */ + +package com.dropbox.core.v2.team; + +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + +import java.io.IOException; + +public enum TeamMembershipType { + // union TeamMembershipType + /** + * User uses a license and has full access to team resources like the shared + * quota. + */ + FULL, + /** + * User does not have access to the shared quota and team admins have + * restricted administrative control. + */ + LIMITED; + + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); + + @Override + public void serialize(TeamMembershipType value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value) { + case FULL: { + g.writeString("full"); + break; + } + case LIMITED: { + g.writeString("limited"); + break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } + } + } + + @Override + public TeamMembershipType deserialize(JsonParser p) throws IOException, JsonParseException { + TeamMembershipType value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("full".equals(tag)) { + value = TeamMembershipType.FULL; + } + else if ("limited".equals(tag)) { + value = TeamMembershipType.LIMITED; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; + } + } +} diff --git a/src/main/java/com/dropbox/core/v2/team/UpdatePropertyTemplateArg.java b/src/main/java/com/dropbox/core/v2/team/UpdatePropertyTemplateArg.java index 5f7a4b318..2561e340b 100644 --- a/src/main/java/com/dropbox/core/v2/team/UpdatePropertyTemplateArg.java +++ b/src/main/java/com/dropbox/core/v2/team/UpdatePropertyTemplateArg.java @@ -1,41 +1,24 @@ /* DO NOT EDIT */ -/* This file was generated from team_property_templates.babel */ +/* This file was generated from team_property_templates.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.dropbox.core.v2.properties.PropertyFieldTemplate; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=UpdatePropertyTemplateArg.Serializer.class) -@JsonDeserialize(using=UpdatePropertyTemplateArg.Deserializer.class) -class UpdatePropertyTemplateArg { +public class UpdatePropertyTemplateArg { // struct UpdatePropertyTemplateArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String templateId; protected final String name; protected final String description; @@ -45,10 +28,9 @@ class UpdatePropertyTemplateArg { * Use {@link newBuilder} to create instances of this class without * specifying values for all optional fields. * - * @param templateId An identifier for property template added by {@link - * DbxTeamTeamRequests#propertiesTemplateAdd(String,String,List)}. Must - * have length of at least 1, match pattern "{@code (/|ptid:).*}", and - * not be {@code null}. + * @param templateId An identifier for property template added by {@code + * propertiesTemplateAdd}. Must have length of at least 1, match pattern + * "{@code (/|ptid:).*}", and not be {@code null}. * @param name A display name for the property template. Property template * names can be up to 256 bytes. * @param description Description for new property template. Property @@ -86,10 +68,9 @@ public UpdatePropertyTemplateArg(String templateId, String name, String descript /** * The default values for unset fields will be used. * - * @param templateId An identifier for property template added by {@link - * DbxTeamTeamRequests#propertiesTemplateAdd(String,String,List)}. Must - * have length of at least 1, match pattern "{@code (/|ptid:).*}", and - * not be {@code null}. + * @param templateId An identifier for property template added by {@code + * propertiesTemplateAdd}. Must have length of at least 1, match pattern + * "{@code (/|ptid:).*}", and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -99,8 +80,8 @@ public UpdatePropertyTemplateArg(String templateId) { } /** - * An identifier for property template added by {@link - * DbxTeamTeamRequests#propertiesTemplateAdd(String,String,List)}. + * An identifier for property template added by {@code + * propertiesTemplateAdd}. * * @return value for this field, never {@code null}. */ @@ -141,10 +122,9 @@ public List getAddFields() { /** * Returns a new builder for creating an instance of this class. * - * @param templateId An identifier for property template added by {@link - * DbxTeamTeamRequests#propertiesTemplateAdd(String,String,List)}. Must - * have length of at least 1, match pattern "{@code (/|ptid:).*}", and - * not be {@code null}. + * @param templateId An identifier for property template added by {@code + * propertiesTemplateAdd}. Must have length of at least 1, match pattern + * "{@code (/|ptid:).*}", and not be {@code null}. * * @return builder for this class. * @@ -274,7 +254,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -286,110 +266,83 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UpdatePropertyTemplateArg.class); - } - - public Serializer(boolean unwrapping) { - super(UpdatePropertyTemplateArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(UpdatePropertyTemplateArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("template_id", value.templateId); + public void serialize(UpdatePropertyTemplateArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("template_id"); + StoneSerializers.string().serialize(value.templateId, g); if (value.name != null) { - g.writeObjectField("name", value.name); + g.writeFieldName("name"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.name, g); } if (value.description != null) { - g.writeObjectField("description", value.description); + g.writeFieldName("description"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.description, g); } if (value.addFields != null) { - g.writeObjectField("add_fields", value.addFields); + g.writeFieldName("add_fields"); + StoneSerializers.nullable(StoneSerializers.list(PropertyFieldTemplate.Serializer.INSTANCE)).serialize(value.addFields, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UpdatePropertyTemplateArg.class); - } - - public Deserializer(boolean unwrapping) { - super(UpdatePropertyTemplateArg.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public UpdatePropertyTemplateArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String templateId = null; - String name = null; - String description = null; - List addFields = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("template_id".equals(_field)) { - templateId = getStringValue(_p); - _p.nextToken(); - } - else if ("name".equals(_field)) { - name = getStringValue(_p); - _p.nextToken(); - } - else if ("description".equals(_field)) { - description = getStringValue(_p); - _p.nextToken(); - } - else if ("add_fields".equals(_field)) { - expectArrayStart(_p); - addFields = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - PropertyFieldTemplate _x = null; - _x = _p.readValueAs(PropertyFieldTemplate.class); - _p.nextToken(); - addFields.add(_x); + public UpdatePropertyTemplateArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + UpdatePropertyTemplateArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_templateId = null; + String f_name = null; + String f_description = null; + List f_addFields = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("template_id".equals(field)) { + f_templateId = StoneSerializers.string().deserialize(p); + } + else if ("name".equals(field)) { + f_name = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("description".equals(field)) { + f_description = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("add_fields".equals(field)) { + f_addFields = StoneSerializers.nullable(StoneSerializers.list(PropertyFieldTemplate.Serializer.INSTANCE)).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else { - skipValue(_p); + if (f_templateId == null) { + throw new JsonParseException(p, "Required field \"template_id\" missing."); } + value = new UpdatePropertyTemplateArg(f_templateId, f_name, f_description, f_addFields); } - - if (templateId == null) { - throw new JsonParseException(_p, "Required field \"template_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new UpdatePropertyTemplateArg(templateId, name, description, addFields); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/UpdatePropertyTemplateResult.java b/src/main/java/com/dropbox/core/v2/team/UpdatePropertyTemplateResult.java index ac35d16b7..7f07b9d52 100644 --- a/src/main/java/com/dropbox/core/v2/team/UpdatePropertyTemplateResult.java +++ b/src/main/java/com/dropbox/core/v2/team/UpdatePropertyTemplateResult.java @@ -1,47 +1,29 @@ /* DO NOT EDIT */ -/* This file was generated from team_property_templates.babel */ +/* This file was generated from team_property_templates.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=UpdatePropertyTemplateResult.Serializer.class) -@JsonDeserialize(using=UpdatePropertyTemplateResult.Deserializer.class) public class UpdatePropertyTemplateResult { // struct UpdatePropertyTemplateResult - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String templateId; /** * - * @param templateId An identifier for property template added by {@link - * DbxTeamTeamRequests#propertiesTemplateAdd(String,String,java.util.List)}. - * Must have length of at least 1, match pattern "{@code (/|ptid:).*}", - * and not be {@code null}. + * @param templateId An identifier for property template added by {@code + * propertiesTemplateAdd}. Must have length of at least 1, match pattern + * "{@code (/|ptid:).*}", and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. @@ -60,8 +42,8 @@ public UpdatePropertyTemplateResult(String templateId) { } /** - * An identifier for property template added by {@link - * DbxTeamTeamRequests#propertiesTemplateAdd(String,String,java.util.List)}. + * An identifier for property template added by {@code + * propertiesTemplateAdd}. * * @return value for this field, never {@code null}. */ @@ -94,7 +76,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -106,78 +88,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UpdatePropertyTemplateResult.class); - } - - public Serializer(boolean unwrapping) { - super(UpdatePropertyTemplateResult.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(UpdatePropertyTemplateResult value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("template_id", value.templateId); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UpdatePropertyTemplateResult.class); - } - - public Deserializer(boolean unwrapping) { - super(UpdatePropertyTemplateResult.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(UpdatePropertyTemplateResult value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("template_id"); + StoneSerializers.string().serialize(value.templateId, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public UpdatePropertyTemplateResult deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String templateId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("template_id".equals(_field)) { - templateId = getStringValue(_p); - _p.nextToken(); + public UpdatePropertyTemplateResult deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + UpdatePropertyTemplateResult value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_templateId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("template_id".equals(field)) { + f_templateId = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_templateId == null) { + throw new JsonParseException(p, "Required field \"template_id\" missing."); } + value = new UpdatePropertyTemplateResult(f_templateId); } - - if (templateId == null) { - throw new JsonParseException(_p, "Required field \"template_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new UpdatePropertyTemplateResult(templateId); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/UserSelectorArg.java b/src/main/java/com/dropbox/core/v2/team/UserSelectorArg.java index 0a681151d..f04817206 100644 --- a/src/main/java/com/dropbox/core/v2/team/UserSelectorArg.java +++ b/src/main/java/com/dropbox/core/v2/team/UserSelectorArg.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from team.babel */ +/* This file was generated from team.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Argument for selecting a single user, either by team_member_id, external_id @@ -35,15 +23,9 @@ * methods will return {@code true}. You can use {@link #tag()} to determine the * tag associated with this instance.

*/ -@JsonSerialize(using=UserSelectorArg.Serializer.class) -@JsonDeserialize(using=UserSelectorArg.Deserializer.class) public final class UserSelectorArg { // union UserSelectorArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link UserSelectorArg}. */ @@ -271,7 +253,7 @@ else if (obj instanceof UserSelectorArg) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -283,92 +265,91 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UserSelectorArg.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(UserSelectorArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case TEAM_MEMBER_ID: + public void serialize(UserSelectorArg value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case TEAM_MEMBER_ID: { g.writeStartObject(); - g.writeStringField(".tag", "team_member_id"); - g.writeObjectField("team_member_id", value.teamMemberIdValue); + writeTag("team_member_id", g); + g.writeFieldName("team_member_id"); + StoneSerializers.string().serialize(value.teamMemberIdValue, g); g.writeEndObject(); break; - case EXTERNAL_ID: + } + case EXTERNAL_ID: { g.writeStartObject(); - g.writeStringField(".tag", "external_id"); - g.writeObjectField("external_id", value.externalIdValue); + writeTag("external_id", g); + g.writeFieldName("external_id"); + StoneSerializers.string().serialize(value.externalIdValue, g); g.writeEndObject(); break; - case EMAIL: + } + case EMAIL: { g.writeStartObject(); - g.writeStringField(".tag", "email"); - g.writeObjectField("email", value.emailValue); + writeTag("email", g); + g.writeFieldName("email"); + StoneSerializers.string().serialize(value.emailValue, g); g.writeEndObject(); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UserSelectorArg.class, getTagMapping(), null); - } - - @Override - public UserSelectorArg deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case TEAM_MEMBER_ID: { - String value = null; - expectField(_p, "team_member_id"); - value = getStringValue(_p); - _p.nextToken(); - return UserSelectorArg.teamMemberId(value); } - case EXTERNAL_ID: { - String value = null; - expectField(_p, "external_id"); - value = getStringValue(_p); - _p.nextToken(); - return UserSelectorArg.externalId(value); - } - case EMAIL: { - String value = null; - expectField(_p, "email"); - value = getStringValue(_p); - _p.nextToken(); - return UserSelectorArg.email(value); + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("team_member_id", UserSelectorArg.Tag.TEAM_MEMBER_ID); - values.put("external_id", UserSelectorArg.Tag.EXTERNAL_ID); - values.put("email", UserSelectorArg.Tag.EMAIL); - return Collections.unmodifiableMap(values); + @Override + public UserSelectorArg deserialize(JsonParser p) throws IOException, JsonParseException { + UserSelectorArg value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("team_member_id".equals(tag)) { + String fieldValue = null; + expectField("team_member_id", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = UserSelectorArg.teamMemberId(fieldValue); + } + else if ("external_id".equals(tag)) { + String fieldValue = null; + expectField("external_id", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = UserSelectorArg.externalId(fieldValue); + } + else if ("email".equals(tag)) { + String fieldValue = null; + expectField("email", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = UserSelectorArg.email(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/UserSelectorError.java b/src/main/java/com/dropbox/core/v2/team/UserSelectorError.java index a8b586ea4..0bdfd54a6 100644 --- a/src/main/java/com/dropbox/core/v2/team/UserSelectorError.java +++ b/src/main/java/com/dropbox/core/v2/team/UserSelectorError.java @@ -1,37 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from team.babel */ +/* This file was generated from team.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Error that can be returned whenever a struct derived from {@link * UserSelectorArg} is used. */ -@JsonSerialize(using=UserSelectorError.Serializer.class) -@JsonDeserialize(using=UserSelectorError.Deserializer.class) public enum UserSelectorError { // union UserSelectorError /** @@ -40,43 +26,53 @@ public enum UserSelectorError { */ USER_NOT_FOUND; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UserSelectorError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(UserSelectorError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(UserSelectorError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case USER_NOT_FOUND: + case USER_NOT_FOUND: { g.writeString("user_not_found"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UserSelectorError.class, getTagMapping(), null); - } @Override - public UserSelectorError deserialize(UserSelectorError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("user_not_found", UserSelectorError.USER_NOT_FOUND); - return Collections.unmodifiableMap(values); + public UserSelectorError deserialize(JsonParser p) throws IOException, JsonParseException { + UserSelectorError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("user_not_found".equals(tag)) { + value = UserSelectorError.USER_NOT_FOUND; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/UsersSelectorArg.java b/src/main/java/com/dropbox/core/v2/team/UsersSelectorArg.java index abc03a354..0fced3d5d 100644 --- a/src/main/java/com/dropbox/core/v2/team/UsersSelectorArg.java +++ b/src/main/java/com/dropbox/core/v2/team/UsersSelectorArg.java @@ -1,31 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team.babel */ +/* This file was generated from team.stone */ package com.dropbox.core.v2.team; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * Argument for selecting a list of users, either by team_member_ids, @@ -36,15 +24,9 @@ * methods will return {@code true}. You can use {@link #tag()} to determine the * tag associated with this instance.

*/ -@JsonSerialize(using=UsersSelectorArg.Serializer.class) -@JsonDeserialize(using=UsersSelectorArg.Deserializer.class) public final class UsersSelectorArg { // union UsersSelectorArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link UsersSelectorArg}. */ @@ -308,7 +290,7 @@ else if (obj instanceof UsersSelectorArg) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -320,116 +302,91 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(UsersSelectorArg.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(UsersSelectorArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case TEAM_MEMBER_IDS: + public void serialize(UsersSelectorArg value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case TEAM_MEMBER_IDS: { g.writeStartObject(); - g.writeStringField(".tag", "team_member_ids"); - g.writeObjectField("team_member_ids", value.teamMemberIdsValue); + writeTag("team_member_ids", g); + g.writeFieldName("team_member_ids"); + StoneSerializers.list(StoneSerializers.string()).serialize(value.teamMemberIdsValue, g); g.writeEndObject(); break; - case EXTERNAL_IDS: + } + case EXTERNAL_IDS: { g.writeStartObject(); - g.writeStringField(".tag", "external_ids"); - g.writeObjectField("external_ids", value.externalIdsValue); + writeTag("external_ids", g); + g.writeFieldName("external_ids"); + StoneSerializers.list(StoneSerializers.string()).serialize(value.externalIdsValue, g); g.writeEndObject(); break; - case EMAILS: + } + case EMAILS: { g.writeStartObject(); - g.writeStringField(".tag", "emails"); - g.writeObjectField("emails", value.emailsValue); + writeTag("emails", g); + g.writeFieldName("emails"); + StoneSerializers.list(StoneSerializers.string()).serialize(value.emailsValue, g); g.writeEndObject(); break; - } - } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(UsersSelectorArg.class, getTagMapping(), null); - } - - @Override - public UsersSelectorArg deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case TEAM_MEMBER_IDS: { - List value = null; - expectField(_p, "team_member_ids"); - expectArrayStart(_p); - value = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - String _x = null; - _x = getStringValue(_p); - _p.nextToken(); - value.add(_x); - } - expectArrayEnd(_p); - _p.nextToken(); - return UsersSelectorArg.teamMemberIds(value); } - case EXTERNAL_IDS: { - List value = null; - expectField(_p, "external_ids"); - expectArrayStart(_p); - value = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - String _x = null; - _x = getStringValue(_p); - _p.nextToken(); - value.add(_x); - } - expectArrayEnd(_p); - _p.nextToken(); - return UsersSelectorArg.externalIds(value); - } - case EMAILS: { - List value = null; - expectField(_p, "emails"); - expectArrayStart(_p); - value = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - String _x = null; - _x = getStringValue(_p); - _p.nextToken(); - value.add(_x); - } - expectArrayEnd(_p); - _p.nextToken(); - return UsersSelectorArg.emails(value); + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value.tag()); } } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); } - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("team_member_ids", UsersSelectorArg.Tag.TEAM_MEMBER_IDS); - values.put("external_ids", UsersSelectorArg.Tag.EXTERNAL_IDS); - values.put("emails", UsersSelectorArg.Tag.EMAILS); - return Collections.unmodifiableMap(values); + @Override + public UsersSelectorArg deserialize(JsonParser p) throws IOException, JsonParseException { + UsersSelectorArg value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("team_member_ids".equals(tag)) { + List fieldValue = null; + expectField("team_member_ids", p); + fieldValue = StoneSerializers.list(StoneSerializers.string()).deserialize(p); + value = UsersSelectorArg.teamMemberIds(fieldValue); + } + else if ("external_ids".equals(tag)) { + List fieldValue = null; + expectField("external_ids", p); + fieldValue = StoneSerializers.list(StoneSerializers.string()).deserialize(p); + value = UsersSelectorArg.externalIds(fieldValue); + } + else if ("emails".equals(tag)) { + List fieldValue = null; + expectField("emails", p); + fieldValue = StoneSerializers.list(StoneSerializers.string()).deserialize(p); + value = UsersSelectorArg.emails(fieldValue); + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/team/package-info.java b/src/main/java/com/dropbox/core/v2/team/package-info.java index f1360b570..cc1901cd0 100644 --- a/src/main/java/com/dropbox/core/v2/team/package-info.java +++ b/src/main/java/com/dropbox/core/v2/team/package-info.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_devices.babel, team_property_templates.babel, team_members.babel, team_linked_apps.babel, team_reports.babel, team_groups.babel, team_common.babel, team.babel */ +/* This file was generated from team_devices.stone, team_property_templates.stone, team_members.stone, team_groups.stone, team_linked_apps.stone, team_reports.stone, team.stone */ /** * See {@link com.dropbox.core.v2.team.DbxTeamTeamRequests} for a list of diff --git a/src/main/java/com/dropbox/core/v2/teamcommon/AlphaGroupSummary.java b/src/main/java/com/dropbox/core/v2/teamcommon/AlphaGroupSummary.java new file mode 100644 index 000000000..980bcc208 --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/teamcommon/AlphaGroupSummary.java @@ -0,0 +1,250 @@ +/* DO NOT EDIT */ +/* This file was generated from team_common.stone */ + +package com.dropbox.core.v2.teamcommon; + +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + +import java.io.IOException; + +/** + * Information about a group. + */ +public class AlphaGroupSummary extends GroupSummary { + // struct AlphaGroupSummary + + protected final GroupManagementType groupManagementType; + + /** + * Information about a group. + * + *

Use {@link newBuilder} to create instances of this class without + * specifying values for all optional fields.

+ * + * @param groupName Must not be {@code null}. + * @param groupId Must not be {@code null}. + * @param groupManagementType Who is allowed to manage the group. Must not + * be {@code null}. + * @param groupExternalId External ID of group. This is an arbitrary ID + * that an admin can attach to a group. + * @param memberCount The number of members in the group. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public AlphaGroupSummary(String groupName, String groupId, GroupManagementType groupManagementType, String groupExternalId, Long memberCount) { + super(groupName, groupId, groupExternalId, memberCount); + if (groupManagementType == null) { + throw new IllegalArgumentException("Required value for 'groupManagementType' is null"); + } + this.groupManagementType = groupManagementType; + } + + /** + * Information about a group. + * + *

The default values for unset fields will be used.

+ * + * @param groupName Must not be {@code null}. + * @param groupId Must not be {@code null}. + * @param groupManagementType Who is allowed to manage the group. Must not + * be {@code null}. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public AlphaGroupSummary(String groupName, String groupId, GroupManagementType groupManagementType) { + this(groupName, groupId, groupManagementType, null, null); + } + + /** + * Who is allowed to manage the group. + * + * @return value for this field, never {@code null}. + */ + public GroupManagementType getGroupManagementType() { + return groupManagementType; + } + + /** + * Returns a new builder for creating an instance of this class. + * + * @param groupName Must not be {@code null}. + * @param groupId Must not be {@code null}. + * @param groupManagementType Who is allowed to manage the group. Must not + * be {@code null}. + * + * @return builder for this class. + * + * @throws IllegalArgumentException If any argument does not meet its + * preconditions. + */ + public static Builder newBuilder(String groupName, String groupId, GroupManagementType groupManagementType) { + return new Builder(groupName, groupId, groupManagementType); + } + + /** + * Builder for {@link AlphaGroupSummary}. + */ + public static class Builder extends GroupSummary.Builder { + protected final GroupManagementType groupManagementType; + + protected Builder(String groupName, String groupId, GroupManagementType groupManagementType) { + super(groupName, groupId); + if (groupManagementType == null) { + throw new IllegalArgumentException("Required value for 'groupManagementType' is null"); + } + this.groupManagementType = groupManagementType; + } + + /** + * Builds an instance of {@link AlphaGroupSummary} configured with this + * builder's values + * + * @return new instance of {@link AlphaGroupSummary} + */ + public AlphaGroupSummary build() { + return new AlphaGroupSummary(groupName, groupId, groupManagementType, groupExternalId, memberCount); + } + } + + @Override + public int hashCode() { + int hash = java.util.Arrays.hashCode(new Object [] { + groupManagementType + }); + hash = (31 * super.hashCode()) + hash; + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + // be careful with inheritance + else if (obj.getClass().equals(this.getClass())) { + AlphaGroupSummary other = (AlphaGroupSummary) obj; + return ((this.groupName == other.groupName) || (this.groupName.equals(other.groupName))) + && ((this.groupId == other.groupId) || (this.groupId.equals(other.groupId))) + && ((this.groupManagementType == other.groupManagementType) || (this.groupManagementType.equals(other.groupManagementType))) + && ((this.groupExternalId == other.groupExternalId) || (this.groupExternalId != null && this.groupExternalId.equals(other.groupExternalId))) + && ((this.memberCount == other.memberCount) || (this.memberCount != null && this.memberCount.equals(other.memberCount))) + ; + } + else { + return false; + } + } + + @Override + public String toString() { + return Serializer.INSTANCE.serialize(this, false); + } + + /** + * Returns a String representation of this object formatted for easier + * readability. + * + *

The returned String may contain newlines.

+ * + * @return Formatted, multiline String representation of this object + */ + public String toStringMultiline() { + return Serializer.INSTANCE.serialize(this, true); + } + + /** + * For internal use only. + */ + public static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); + + @Override + public void serialize(AlphaGroupSummary value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("group_name"); + StoneSerializers.string().serialize(value.groupName, g); + g.writeFieldName("group_id"); + StoneSerializers.string().serialize(value.groupId, g); + g.writeFieldName("group_management_type"); + GroupManagementType.Serializer.INSTANCE.serialize(value.groupManagementType, g); + if (value.groupExternalId != null) { + g.writeFieldName("group_external_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.groupExternalId, g); + } + if (value.memberCount != null) { + g.writeFieldName("member_count"); + StoneSerializers.nullable(StoneSerializers.uInt32()).serialize(value.memberCount, g); + } + if (!collapse) { + g.writeEndObject(); + } + } + + @Override + public AlphaGroupSummary deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + AlphaGroupSummary value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_groupName = null; + String f_groupId = null; + GroupManagementType f_groupManagementType = null; + String f_groupExternalId = null; + Long f_memberCount = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("group_name".equals(field)) { + f_groupName = StoneSerializers.string().deserialize(p); + } + else if ("group_id".equals(field)) { + f_groupId = StoneSerializers.string().deserialize(p); + } + else if ("group_management_type".equals(field)) { + f_groupManagementType = GroupManagementType.Serializer.INSTANCE.deserialize(p); + } + else if ("group_external_id".equals(field)) { + f_groupExternalId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("member_count".equals(field)) { + f_memberCount = StoneSerializers.nullable(StoneSerializers.uInt32()).deserialize(p); + } + else { + skipValue(p); + } + } + if (f_groupName == null) { + throw new JsonParseException(p, "Required field \"group_name\" missing."); + } + if (f_groupId == null) { + throw new JsonParseException(p, "Required field \"group_id\" missing."); + } + if (f_groupManagementType == null) { + throw new JsonParseException(p, "Required field \"group_management_type\" missing."); + } + value = new AlphaGroupSummary(f_groupName, f_groupId, f_groupManagementType, f_groupExternalId, f_memberCount); + } + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); + } + if (!collapsed) { + expectEndObject(p); + } + return value; + } + } +} diff --git a/src/main/java/com/dropbox/core/v2/teamcommon/GroupManagementType.java b/src/main/java/com/dropbox/core/v2/teamcommon/GroupManagementType.java new file mode 100644 index 000000000..918948510 --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/teamcommon/GroupManagementType.java @@ -0,0 +1,96 @@ +/* DO NOT EDIT */ +/* This file was generated from team_common.stone */ + +package com.dropbox.core.v2.teamcommon; + +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + +import java.io.IOException; + +/** + * The group type determines how a group is managed. + */ +public enum GroupManagementType { + // union GroupManagementType + /** + * A group which is managed by team admins only. + */ + COMPANY_MANAGED, + /** + * A group which is managed by selected users. + */ + USER_MANAGED, + /** + * Catch-all used for unknown tag values returned by the Dropbox servers. + * + *

Receiving a catch-all value typically indicates this SDK version is + * not up to date. Consider updating your SDK version to handle the new + * tags.

+ */ + OTHER; // *catch_all + + /** + * For internal use only. + */ + public static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); + + @Override + public void serialize(GroupManagementType value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value) { + case COMPANY_MANAGED: { + g.writeString("company_managed"); + break; + } + case USER_MANAGED: { + g.writeString("user_managed"); + break; + } + default: { + g.writeString("other"); + } + } + } + + @Override + public GroupManagementType deserialize(JsonParser p) throws IOException, JsonParseException { + GroupManagementType value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("company_managed".equals(tag)) { + value = GroupManagementType.COMPANY_MANAGED; + } + else if ("user_managed".equals(tag)) { + value = GroupManagementType.USER_MANAGED; + } + else { + value = GroupManagementType.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; + } + } +} diff --git a/src/main/java/com/dropbox/core/v2/team/GroupSummary.java b/src/main/java/com/dropbox/core/v2/teamcommon/GroupSummary.java similarity index 60% rename from src/main/java/com/dropbox/core/v2/team/GroupSummary.java rename to src/main/java/com/dropbox/core/v2/teamcommon/GroupSummary.java index 11d7b059c..ec3bce9ce 100644 --- a/src/main/java/com/dropbox/core/v2/team/GroupSummary.java +++ b/src/main/java/com/dropbox/core/v2/teamcommon/GroupSummary.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from team_common.babel */ +/* This file was generated from team_common.stone */ -package com.dropbox.core.v2.team; +package com.dropbox.core.v2.teamcommon; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Information about a group. */ -@JsonSerialize(using=GroupSummary.Serializer.class) -@JsonDeserialize(using=GroupSummary.Deserializer.class) public class GroupSummary { // struct GroupSummary - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String groupName; protected final String groupId; protected final String groupExternalId; @@ -226,7 +209,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -238,107 +221,84 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GroupSummary.class); - } - - public Serializer(boolean unwrapping) { - super(GroupSummary.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + public static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(GroupSummary value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("group_name", value.groupName); - g.writeObjectField("group_id", value.groupId); + public void serialize(GroupSummary value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("group_name"); + StoneSerializers.string().serialize(value.groupName, g); + g.writeFieldName("group_id"); + StoneSerializers.string().serialize(value.groupId, g); if (value.groupExternalId != null) { - g.writeObjectField("group_external_id", value.groupExternalId); + g.writeFieldName("group_external_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.groupExternalId, g); } if (value.memberCount != null) { - g.writeObjectField("member_count", value.memberCount); + g.writeFieldName("member_count"); + StoneSerializers.nullable(StoneSerializers.uInt32()).serialize(value.memberCount, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GroupSummary.class); - } - - public Deserializer(boolean unwrapping) { - super(GroupSummary.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public GroupSummary deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String groupName = null; - String groupId = null; - String groupExternalId = null; - Long memberCount = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("group_name".equals(_field)) { - groupName = getStringValue(_p); - _p.nextToken(); - } - else if ("group_id".equals(_field)) { - groupId = getStringValue(_p); - _p.nextToken(); - } - else if ("group_external_id".equals(_field)) { - groupExternalId = getStringValue(_p); - _p.nextToken(); - } - else if ("member_count".equals(_field)) { - memberCount = _p.getLongValue(); - assertUnsigned(_p, memberCount); - if (memberCount > Integer.MAX_VALUE) { - throw new JsonParseException(_p, "expecting a 32-bit unsigned integer, got: " + memberCount); + public GroupSummary deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GroupSummary value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_groupName = null; + String f_groupId = null; + String f_groupExternalId = null; + Long f_memberCount = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("group_name".equals(field)) { + f_groupName = StoneSerializers.string().deserialize(p); } - _p.nextToken(); + else if ("group_id".equals(field)) { + f_groupId = StoneSerializers.string().deserialize(p); + } + else if ("group_external_id".equals(field)) { + f_groupExternalId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("member_count".equals(field)) { + f_memberCount = StoneSerializers.nullable(StoneSerializers.uInt32()).deserialize(p); + } + else { + skipValue(p); + } + } + if (f_groupName == null) { + throw new JsonParseException(p, "Required field \"group_name\" missing."); } - else { - skipValue(_p); + if (f_groupId == null) { + throw new JsonParseException(p, "Required field \"group_id\" missing."); } + value = new GroupSummary(f_groupName, f_groupId, f_groupExternalId, f_memberCount); } - - if (groupName == null) { - throw new JsonParseException(_p, "Required field \"group_name\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (groupId == null) { - throw new JsonParseException(_p, "Required field \"group_id\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new GroupSummary(groupName, groupId, groupExternalId, memberCount); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/teamcommon/GroupType.java b/src/main/java/com/dropbox/core/v2/teamcommon/GroupType.java new file mode 100644 index 000000000..053e591de --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/teamcommon/GroupType.java @@ -0,0 +1,97 @@ +/* DO NOT EDIT */ +/* This file was generated from team_common.stone */ + +package com.dropbox.core.v2.teamcommon; + +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + +import java.io.IOException; + +/** + * The group type determines how a group is created and managed. + */ +public enum GroupType { + // union GroupType + /** + * A group to which team members are automatically added. Applicable to team folders only. + */ + TEAM, + /** + * A group is created and managed by a user. + */ + USER_MANAGED, + /** + * Catch-all used for unknown tag values returned by the Dropbox servers. + * + *

Receiving a catch-all value typically indicates this SDK version is + * not up to date. Consider updating your SDK version to handle the new + * tags.

+ */ + OTHER; // *catch_all + + /** + * For internal use only. + */ + public static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); + + @Override + public void serialize(GroupType value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value) { + case TEAM: { + g.writeString("team"); + break; + } + case USER_MANAGED: { + g.writeString("user_managed"); + break; + } + default: { + g.writeString("other"); + } + } + } + + @Override + public GroupType deserialize(JsonParser p) throws IOException, JsonParseException { + GroupType value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("team".equals(tag)) { + value = GroupType.TEAM; + } + else if ("user_managed".equals(tag)) { + value = GroupType.USER_MANAGED; + } + else { + value = GroupType.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; + } + } +} diff --git a/src/main/java/com/dropbox/core/v2/teamcommon/package-info.java b/src/main/java/com/dropbox/core/v2/teamcommon/package-info.java new file mode 100644 index 000000000..fcfbd404d --- /dev/null +++ b/src/main/java/com/dropbox/core/v2/teamcommon/package-info.java @@ -0,0 +1,7 @@ +/* DO NOT EDIT */ +/* This file was generated from team_common.stone */ + +/** + * See None for a list of possible requests for this namespace. + */ +package com.dropbox.core.v2.teamcommon; diff --git a/src/main/java/com/dropbox/core/v2/teampolicies/EmmState.java b/src/main/java/com/dropbox/core/v2/teampolicies/EmmState.java index a8c136626..75634364d 100644 --- a/src/main/java/com/dropbox/core/v2/teampolicies/EmmState.java +++ b/src/main/java/com/dropbox/core/v2/teampolicies/EmmState.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from team_policies.babel */ +/* This file was generated from team_policies.stone */ package com.dropbox.core.v2.teampolicies; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=EmmState.Serializer.class) -@JsonDeserialize(using=EmmState.Deserializer.class) public enum EmmState { // union EmmState /** @@ -51,55 +37,68 @@ public enum EmmState { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(EmmState.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(EmmState value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(EmmState value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case DISABLED: + case DISABLED: { g.writeString("disabled"); break; - case OPTIONAL: + } + case OPTIONAL: { g.writeString("optional"); break; - case REQUIRED: + } + case REQUIRED: { g.writeString("required"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(EmmState.class, getTagMapping(), EmmState.OTHER); - } @Override - public EmmState deserialize(EmmState _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("disabled", EmmState.DISABLED); - values.put("optional", EmmState.OPTIONAL); - values.put("required", EmmState.REQUIRED); - values.put("other", EmmState.OTHER); - return Collections.unmodifiableMap(values); + public EmmState deserialize(JsonParser p) throws IOException, JsonParseException { + EmmState value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("disabled".equals(tag)) { + value = EmmState.DISABLED; + } + else if ("optional".equals(tag)) { + value = EmmState.OPTIONAL; + } + else if ("required".equals(tag)) { + value = EmmState.REQUIRED; + } + else { + value = EmmState.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/teampolicies/SharedFolderJoinPolicy.java b/src/main/java/com/dropbox/core/v2/teampolicies/SharedFolderJoinPolicy.java index c02de20f9..019be64a6 100644 --- a/src/main/java/com/dropbox/core/v2/teampolicies/SharedFolderJoinPolicy.java +++ b/src/main/java/com/dropbox/core/v2/teampolicies/SharedFolderJoinPolicy.java @@ -1,36 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_policies.babel */ +/* This file was generated from team_policies.stone */ package com.dropbox.core.v2.teampolicies; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Policy governing which shared folders a team member can join. */ -@JsonSerialize(using=SharedFolderJoinPolicy.Serializer.class) -@JsonDeserialize(using=SharedFolderJoinPolicy.Deserializer.class) public enum SharedFolderJoinPolicy { // union SharedFolderJoinPolicy /** @@ -51,51 +37,61 @@ public enum SharedFolderJoinPolicy { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SharedFolderJoinPolicy.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(SharedFolderJoinPolicy value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(SharedFolderJoinPolicy value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case FROM_TEAM_ONLY: + case FROM_TEAM_ONLY: { g.writeString("from_team_only"); break; - case FROM_ANYONE: + } + case FROM_ANYONE: { g.writeString("from_anyone"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SharedFolderJoinPolicy.class, getTagMapping(), SharedFolderJoinPolicy.OTHER); - } @Override - public SharedFolderJoinPolicy deserialize(SharedFolderJoinPolicy _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("from_team_only", SharedFolderJoinPolicy.FROM_TEAM_ONLY); - values.put("from_anyone", SharedFolderJoinPolicy.FROM_ANYONE); - values.put("other", SharedFolderJoinPolicy.OTHER); - return Collections.unmodifiableMap(values); + public SharedFolderJoinPolicy deserialize(JsonParser p) throws IOException, JsonParseException { + SharedFolderJoinPolicy value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("from_team_only".equals(tag)) { + value = SharedFolderJoinPolicy.FROM_TEAM_ONLY; + } + else if ("from_anyone".equals(tag)) { + value = SharedFolderJoinPolicy.FROM_ANYONE; + } + else { + value = SharedFolderJoinPolicy.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/teampolicies/SharedFolderMemberPolicy.java b/src/main/java/com/dropbox/core/v2/teampolicies/SharedFolderMemberPolicy.java index 09c0ab33d..0f026fb6b 100644 --- a/src/main/java/com/dropbox/core/v2/teampolicies/SharedFolderMemberPolicy.java +++ b/src/main/java/com/dropbox/core/v2/teampolicies/SharedFolderMemberPolicy.java @@ -1,36 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_policies.babel */ +/* This file was generated from team_policies.stone */ package com.dropbox.core.v2.teampolicies; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Policy governing who can be a member of a folder shared by a team member. */ -@JsonSerialize(using=SharedFolderMemberPolicy.Serializer.class) -@JsonDeserialize(using=SharedFolderMemberPolicy.Deserializer.class) public enum SharedFolderMemberPolicy { // union SharedFolderMemberPolicy /** @@ -50,51 +36,61 @@ public enum SharedFolderMemberPolicy { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SharedFolderMemberPolicy.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(SharedFolderMemberPolicy value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(SharedFolderMemberPolicy value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case TEAM: + case TEAM: { g.writeString("team"); break; - case ANYONE: + } + case ANYONE: { g.writeString("anyone"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SharedFolderMemberPolicy.class, getTagMapping(), SharedFolderMemberPolicy.OTHER); - } @Override - public SharedFolderMemberPolicy deserialize(SharedFolderMemberPolicy _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("team", SharedFolderMemberPolicy.TEAM); - values.put("anyone", SharedFolderMemberPolicy.ANYONE); - values.put("other", SharedFolderMemberPolicy.OTHER); - return Collections.unmodifiableMap(values); + public SharedFolderMemberPolicy deserialize(JsonParser p) throws IOException, JsonParseException { + SharedFolderMemberPolicy value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("team".equals(tag)) { + value = SharedFolderMemberPolicy.TEAM; + } + else if ("anyone".equals(tag)) { + value = SharedFolderMemberPolicy.ANYONE; + } + else { + value = SharedFolderMemberPolicy.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/teampolicies/SharedLinkCreatePolicy.java b/src/main/java/com/dropbox/core/v2/teampolicies/SharedLinkCreatePolicy.java index 633085119..36085968b 100644 --- a/src/main/java/com/dropbox/core/v2/teampolicies/SharedLinkCreatePolicy.java +++ b/src/main/java/com/dropbox/core/v2/teampolicies/SharedLinkCreatePolicy.java @@ -1,36 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from team_policies.babel */ +/* This file was generated from team_policies.stone */ package com.dropbox.core.v2.teampolicies; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Policy governing the visibility of newly created shared links. */ -@JsonSerialize(using=SharedLinkCreatePolicy.Serializer.class) -@JsonDeserialize(using=SharedLinkCreatePolicy.Deserializer.class) public enum SharedLinkCreatePolicy { // union SharedLinkCreatePolicy /** @@ -58,55 +44,68 @@ public enum SharedLinkCreatePolicy { */ OTHER; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SharedLinkCreatePolicy.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(SharedLinkCreatePolicy value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(SharedLinkCreatePolicy value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case DEFAULT_PUBLIC: + case DEFAULT_PUBLIC: { g.writeString("default_public"); break; - case DEFAULT_TEAM_ONLY: + } + case DEFAULT_TEAM_ONLY: { g.writeString("default_team_only"); break; - case TEAM_ONLY: + } + case TEAM_ONLY: { g.writeString("team_only"); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SharedLinkCreatePolicy.class, getTagMapping(), SharedLinkCreatePolicy.OTHER); - } @Override - public SharedLinkCreatePolicy deserialize(SharedLinkCreatePolicy _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("default_public", SharedLinkCreatePolicy.DEFAULT_PUBLIC); - values.put("default_team_only", SharedLinkCreatePolicy.DEFAULT_TEAM_ONLY); - values.put("team_only", SharedLinkCreatePolicy.TEAM_ONLY); - values.put("other", SharedLinkCreatePolicy.OTHER); - return Collections.unmodifiableMap(values); + public SharedLinkCreatePolicy deserialize(JsonParser p) throws IOException, JsonParseException { + SharedLinkCreatePolicy value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("default_public".equals(tag)) { + value = SharedLinkCreatePolicy.DEFAULT_PUBLIC; + } + else if ("default_team_only".equals(tag)) { + value = SharedLinkCreatePolicy.DEFAULT_TEAM_ONLY; + } + else if ("team_only".equals(tag)) { + value = SharedLinkCreatePolicy.TEAM_ONLY; + } + else { + value = SharedLinkCreatePolicy.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/teampolicies/TeamPolicies.java b/src/main/java/com/dropbox/core/v2/teampolicies/TeamPolicies.java index 347f61efd..4a1529813 100644 --- a/src/main/java/com/dropbox/core/v2/teampolicies/TeamPolicies.java +++ b/src/main/java/com/dropbox/core/v2/teampolicies/TeamPolicies.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from team_policies.babel */ +/* This file was generated from team_policies.stone */ package com.dropbox.core.v2.teampolicies; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Policies governing team members. */ -@JsonSerialize(using=TeamPolicies.Serializer.class) -@JsonDeserialize(using=TeamPolicies.Deserializer.class) public class TeamPolicies { // struct TeamPolicies - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final TeamSharingPolicies sharing; protected final EmmState emmState; @@ -116,7 +99,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -128,87 +111,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(TeamPolicies.class); - } - - public Serializer(boolean unwrapping) { - super(TeamPolicies.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(TeamPolicies value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("sharing", value.sharing); - g.writeObjectField("emm_state", value.emmState); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(TeamPolicies.class); - } - - public Deserializer(boolean unwrapping) { - super(TeamPolicies.class, unwrapping); - } + /** + * For internal use only. + */ + public static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(TeamPolicies value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("sharing"); + TeamSharingPolicies.Serializer.INSTANCE.serialize(value.sharing, g); + g.writeFieldName("emm_state"); + EmmState.Serializer.INSTANCE.serialize(value.emmState, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public TeamPolicies deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - TeamSharingPolicies sharing = null; - EmmState emmState = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("sharing".equals(_field)) { - sharing = _p.readValueAs(TeamSharingPolicies.class); - _p.nextToken(); + public TeamPolicies deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + TeamPolicies value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + TeamSharingPolicies f_sharing = null; + EmmState f_emmState = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("sharing".equals(field)) { + f_sharing = TeamSharingPolicies.Serializer.INSTANCE.deserialize(p); + } + else if ("emm_state".equals(field)) { + f_emmState = EmmState.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else if ("emm_state".equals(_field)) { - emmState = _p.readValueAs(EmmState.class); - _p.nextToken(); + if (f_sharing == null) { + throw new JsonParseException(p, "Required field \"sharing\" missing."); } - else { - skipValue(_p); + if (f_emmState == null) { + throw new JsonParseException(p, "Required field \"emm_state\" missing."); } + value = new TeamPolicies(f_sharing, f_emmState); } - - if (sharing == null) { - throw new JsonParseException(_p, "Required field \"sharing\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (emmState == null) { - throw new JsonParseException(_p, "Required field \"emm_state\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new TeamPolicies(sharing, emmState); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/teampolicies/TeamSharingPolicies.java b/src/main/java/com/dropbox/core/v2/teampolicies/TeamSharingPolicies.java index 23f195094..16e1e1335 100644 --- a/src/main/java/com/dropbox/core/v2/teampolicies/TeamSharingPolicies.java +++ b/src/main/java/com/dropbox/core/v2/teampolicies/TeamSharingPolicies.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from team_policies.babel */ +/* This file was generated from team_policies.stone */ package com.dropbox.core.v2.teampolicies; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Policies governing sharing within and outside of the team. */ -@JsonSerialize(using=TeamSharingPolicies.Serializer.class) -@JsonDeserialize(using=TeamSharingPolicies.Deserializer.class) public class TeamSharingPolicies { // struct TeamSharingPolicies - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final SharedFolderMemberPolicy sharedFolderMemberPolicy; protected final SharedFolderJoinPolicy sharedFolderJoinPolicy; protected final SharedLinkCreatePolicy sharedLinkCreatePolicy; @@ -126,7 +109,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -138,96 +121,77 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(TeamSharingPolicies.class); - } - - public Serializer(boolean unwrapping) { - super(TeamSharingPolicies.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(TeamSharingPolicies value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("shared_folder_member_policy", value.sharedFolderMemberPolicy); - g.writeObjectField("shared_folder_join_policy", value.sharedFolderJoinPolicy); - g.writeObjectField("shared_link_create_policy", value.sharedLinkCreatePolicy); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(TeamSharingPolicies.class); - } - - public Deserializer(boolean unwrapping) { - super(TeamSharingPolicies.class, unwrapping); - } + /** + * For internal use only. + */ + public static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(TeamSharingPolicies value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("shared_folder_member_policy"); + SharedFolderMemberPolicy.Serializer.INSTANCE.serialize(value.sharedFolderMemberPolicy, g); + g.writeFieldName("shared_folder_join_policy"); + SharedFolderJoinPolicy.Serializer.INSTANCE.serialize(value.sharedFolderJoinPolicy, g); + g.writeFieldName("shared_link_create_policy"); + SharedLinkCreatePolicy.Serializer.INSTANCE.serialize(value.sharedLinkCreatePolicy, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public TeamSharingPolicies deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - SharedFolderMemberPolicy sharedFolderMemberPolicy = null; - SharedFolderJoinPolicy sharedFolderJoinPolicy = null; - SharedLinkCreatePolicy sharedLinkCreatePolicy = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("shared_folder_member_policy".equals(_field)) { - sharedFolderMemberPolicy = _p.readValueAs(SharedFolderMemberPolicy.class); - _p.nextToken(); + public TeamSharingPolicies deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + TeamSharingPolicies value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + SharedFolderMemberPolicy f_sharedFolderMemberPolicy = null; + SharedFolderJoinPolicy f_sharedFolderJoinPolicy = null; + SharedLinkCreatePolicy f_sharedLinkCreatePolicy = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("shared_folder_member_policy".equals(field)) { + f_sharedFolderMemberPolicy = SharedFolderMemberPolicy.Serializer.INSTANCE.deserialize(p); + } + else if ("shared_folder_join_policy".equals(field)) { + f_sharedFolderJoinPolicy = SharedFolderJoinPolicy.Serializer.INSTANCE.deserialize(p); + } + else if ("shared_link_create_policy".equals(field)) { + f_sharedLinkCreatePolicy = SharedLinkCreatePolicy.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else if ("shared_folder_join_policy".equals(_field)) { - sharedFolderJoinPolicy = _p.readValueAs(SharedFolderJoinPolicy.class); - _p.nextToken(); + if (f_sharedFolderMemberPolicy == null) { + throw new JsonParseException(p, "Required field \"shared_folder_member_policy\" missing."); } - else if ("shared_link_create_policy".equals(_field)) { - sharedLinkCreatePolicy = _p.readValueAs(SharedLinkCreatePolicy.class); - _p.nextToken(); + if (f_sharedFolderJoinPolicy == null) { + throw new JsonParseException(p, "Required field \"shared_folder_join_policy\" missing."); } - else { - skipValue(_p); + if (f_sharedLinkCreatePolicy == null) { + throw new JsonParseException(p, "Required field \"shared_link_create_policy\" missing."); } + value = new TeamSharingPolicies(f_sharedFolderMemberPolicy, f_sharedFolderJoinPolicy, f_sharedLinkCreatePolicy); } - - if (sharedFolderMemberPolicy == null) { - throw new JsonParseException(_p, "Required field \"shared_folder_member_policy\" is missing."); - } - if (sharedFolderJoinPolicy == null) { - throw new JsonParseException(_p, "Required field \"shared_folder_join_policy\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (sharedLinkCreatePolicy == null) { - throw new JsonParseException(_p, "Required field \"shared_link_create_policy\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new TeamSharingPolicies(sharedFolderMemberPolicy, sharedFolderJoinPolicy, sharedLinkCreatePolicy); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/teampolicies/package-info.java b/src/main/java/com/dropbox/core/v2/teampolicies/package-info.java index 11e6ac203..edcd156ea 100644 --- a/src/main/java/com/dropbox/core/v2/teampolicies/package-info.java +++ b/src/main/java/com/dropbox/core/v2/teampolicies/package-info.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from team_policies.babel */ +/* This file was generated from team_policies.stone */ /** * See None for a list of possible requests for this namespace. diff --git a/src/main/java/com/dropbox/core/v2/users/Account.java b/src/main/java/com/dropbox/core/v2/users/Account.java index 8d363d6d9..96e34600c 100644 --- a/src/main/java/com/dropbox/core/v2/users/Account.java +++ b/src/main/java/com/dropbox/core/v2/users/Account.java @@ -1,27 +1,16 @@ /* DO NOT EDIT */ -/* This file was generated from users.babel */ +/* This file was generated from users.stone */ package com.dropbox.core.v2.users; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; @@ -29,15 +18,9 @@ * The amount of detail revealed about an account depends on the user being * queried and the user making the query. */ -@JsonSerialize(using=Account.Serializer.class) -@JsonDeserialize(using=Account.Deserializer.class) public class Account { // struct Account - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String accountId; protected final Name name; protected final String email; @@ -203,7 +186,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -215,122 +198,103 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(Account.class); - } - - public Serializer(boolean unwrapping) { - super(Account.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(Account value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("account_id", value.accountId); - g.writeObjectField("name", value.name); - g.writeObjectField("email", value.email); - g.writeObjectField("email_verified", value.emailVerified); - g.writeObjectField("disabled", value.disabled); + public void serialize(Account value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("account_id"); + StoneSerializers.string().serialize(value.accountId, g); + g.writeFieldName("name"); + Name.Serializer.INSTANCE.serialize(value.name, g); + g.writeFieldName("email"); + StoneSerializers.string().serialize(value.email, g); + g.writeFieldName("email_verified"); + StoneSerializers.boolean_().serialize(value.emailVerified, g); + g.writeFieldName("disabled"); + StoneSerializers.boolean_().serialize(value.disabled, g); if (value.profilePhotoUrl != null) { - g.writeObjectField("profile_photo_url", value.profilePhotoUrl); + g.writeFieldName("profile_photo_url"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.profilePhotoUrl, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(Account.class); - } - - public Deserializer(boolean unwrapping) { - super(Account.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public Account deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String accountId = null; - Name name = null; - String email = null; - Boolean emailVerified = null; - Boolean disabled = null; - String profilePhotoUrl = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("account_id".equals(_field)) { - accountId = getStringValue(_p); - _p.nextToken(); - } - else if ("name".equals(_field)) { - name = _p.readValueAs(Name.class); - _p.nextToken(); + public Account deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + Account value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_accountId = null; + Name f_name = null; + String f_email = null; + Boolean f_emailVerified = null; + Boolean f_disabled = null; + String f_profilePhotoUrl = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("account_id".equals(field)) { + f_accountId = StoneSerializers.string().deserialize(p); + } + else if ("name".equals(field)) { + f_name = Name.Serializer.INSTANCE.deserialize(p); + } + else if ("email".equals(field)) { + f_email = StoneSerializers.string().deserialize(p); + } + else if ("email_verified".equals(field)) { + f_emailVerified = StoneSerializers.boolean_().deserialize(p); + } + else if ("disabled".equals(field)) { + f_disabled = StoneSerializers.boolean_().deserialize(p); + } + else if ("profile_photo_url".equals(field)) { + f_profilePhotoUrl = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } - else if ("email".equals(_field)) { - email = getStringValue(_p); - _p.nextToken(); + if (f_accountId == null) { + throw new JsonParseException(p, "Required field \"account_id\" missing."); } - else if ("email_verified".equals(_field)) { - emailVerified = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } - else if ("disabled".equals(_field)) { - disabled = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_email == null) { + throw new JsonParseException(p, "Required field \"email\" missing."); } - else if ("profile_photo_url".equals(_field)) { - profilePhotoUrl = getStringValue(_p); - _p.nextToken(); + if (f_emailVerified == null) { + throw new JsonParseException(p, "Required field \"email_verified\" missing."); } - else { - skipValue(_p); + if (f_disabled == null) { + throw new JsonParseException(p, "Required field \"disabled\" missing."); } + value = new Account(f_accountId, f_name, f_email, f_emailVerified, f_disabled, f_profilePhotoUrl); } - - if (accountId == null) { - throw new JsonParseException(_p, "Required field \"account_id\" is missing."); - } - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); - } - if (email == null) { - throw new JsonParseException(_p, "Required field \"email\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (emailVerified == null) { - throw new JsonParseException(_p, "Required field \"email_verified\" is missing."); + if (!collapsed) { + expectEndObject(p); } - if (disabled == null) { - throw new JsonParseException(_p, "Required field \"disabled\" is missing."); - } - - return new Account(accountId, name, email, emailVerified, disabled, profilePhotoUrl); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/users/AccountType.java b/src/main/java/com/dropbox/core/v2/users/AccountType.java index 323c7067a..47b553e8e 100644 --- a/src/main/java/com/dropbox/core/v2/users/AccountType.java +++ b/src/main/java/com/dropbox/core/v2/users/AccountType.java @@ -1,36 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from users.babel */ +/* This file was generated from users.stone */ package com.dropbox.core.v2.users; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * What type of account this user has. */ -@JsonSerialize(using=AccountType.Serializer.class) -@JsonDeserialize(using=AccountType.Deserializer.class) public enum AccountType { // union AccountType /** @@ -46,51 +32,67 @@ public enum AccountType { */ BUSINESS; - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(AccountType.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(AccountType value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(AccountType value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case BASIC: + case BASIC: { g.writeString("basic"); break; - case PRO: + } + case PRO: { g.writeString("pro"); break; - case BUSINESS: + } + case BUSINESS: { g.writeString("business"); break; + } + default: { + throw new IllegalArgumentException("Unrecognized tag: " + value); + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(AccountType.class, getTagMapping(), null); - } @Override - public AccountType deserialize(AccountType _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("basic", AccountType.BASIC); - values.put("pro", AccountType.PRO); - values.put("business", AccountType.BUSINESS); - return Collections.unmodifiableMap(values); + public AccountType deserialize(JsonParser p) throws IOException, JsonParseException { + AccountType value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("basic".equals(tag)) { + value = AccountType.BASIC; + } + else if ("pro".equals(tag)) { + value = AccountType.PRO; + } + else if ("business".equals(tag)) { + value = AccountType.BUSINESS; + } + else { + throw new JsonParseException(p, "Unknown tag: " + tag); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/users/BasicAccount.java b/src/main/java/com/dropbox/core/v2/users/BasicAccount.java index 568c10016..4dc975d6b 100644 --- a/src/main/java/com/dropbox/core/v2/users/BasicAccount.java +++ b/src/main/java/com/dropbox/core/v2/users/BasicAccount.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from users.babel */ +/* This file was generated from users.stone */ package com.dropbox.core.v2.users; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Basic information about any account. */ -@JsonSerialize(using=BasicAccount.Serializer.class) -@JsonDeserialize(using=BasicAccount.Deserializer.class) public class BasicAccount extends Account { // struct BasicAccount - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final boolean isTeammate; protected final String teamMemberId; @@ -257,7 +240,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -269,139 +252,120 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(BasicAccount.class); - } - - public Serializer(boolean unwrapping) { - super(BasicAccount.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(BasicAccount value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("account_id", value.accountId); - g.writeObjectField("name", value.name); - g.writeObjectField("email", value.email); - g.writeObjectField("email_verified", value.emailVerified); - g.writeObjectField("disabled", value.disabled); - g.writeObjectField("is_teammate", value.isTeammate); + public void serialize(BasicAccount value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("account_id"); + StoneSerializers.string().serialize(value.accountId, g); + g.writeFieldName("name"); + Name.Serializer.INSTANCE.serialize(value.name, g); + g.writeFieldName("email"); + StoneSerializers.string().serialize(value.email, g); + g.writeFieldName("email_verified"); + StoneSerializers.boolean_().serialize(value.emailVerified, g); + g.writeFieldName("disabled"); + StoneSerializers.boolean_().serialize(value.disabled, g); + g.writeFieldName("is_teammate"); + StoneSerializers.boolean_().serialize(value.isTeammate, g); if (value.profilePhotoUrl != null) { - g.writeObjectField("profile_photo_url", value.profilePhotoUrl); + g.writeFieldName("profile_photo_url"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.profilePhotoUrl, g); } if (value.teamMemberId != null) { - g.writeObjectField("team_member_id", value.teamMemberId); + g.writeFieldName("team_member_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.teamMemberId, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(BasicAccount.class); - } - - public Deserializer(boolean unwrapping) { - super(BasicAccount.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public BasicAccount deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String accountId = null; - Name name = null; - String email = null; - Boolean emailVerified = null; - Boolean disabled = null; - Boolean isTeammate = null; - String profilePhotoUrl = null; - String teamMemberId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("account_id".equals(_field)) { - accountId = getStringValue(_p); - _p.nextToken(); - } - else if ("name".equals(_field)) { - name = _p.readValueAs(Name.class); - _p.nextToken(); - } - else if ("email".equals(_field)) { - email = getStringValue(_p); - _p.nextToken(); + public BasicAccount deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + BasicAccount value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_accountId = null; + Name f_name = null; + String f_email = null; + Boolean f_emailVerified = null; + Boolean f_disabled = null; + Boolean f_isTeammate = null; + String f_profilePhotoUrl = null; + String f_teamMemberId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("account_id".equals(field)) { + f_accountId = StoneSerializers.string().deserialize(p); + } + else if ("name".equals(field)) { + f_name = Name.Serializer.INSTANCE.deserialize(p); + } + else if ("email".equals(field)) { + f_email = StoneSerializers.string().deserialize(p); + } + else if ("email_verified".equals(field)) { + f_emailVerified = StoneSerializers.boolean_().deserialize(p); + } + else if ("disabled".equals(field)) { + f_disabled = StoneSerializers.boolean_().deserialize(p); + } + else if ("is_teammate".equals(field)) { + f_isTeammate = StoneSerializers.boolean_().deserialize(p); + } + else if ("profile_photo_url".equals(field)) { + f_profilePhotoUrl = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("team_member_id".equals(field)) { + f_teamMemberId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } - else if ("email_verified".equals(_field)) { - emailVerified = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_accountId == null) { + throw new JsonParseException(p, "Required field \"account_id\" missing."); } - else if ("disabled".equals(_field)) { - disabled = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } - else if ("is_teammate".equals(_field)) { - isTeammate = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_email == null) { + throw new JsonParseException(p, "Required field \"email\" missing."); } - else if ("profile_photo_url".equals(_field)) { - profilePhotoUrl = getStringValue(_p); - _p.nextToken(); + if (f_emailVerified == null) { + throw new JsonParseException(p, "Required field \"email_verified\" missing."); } - else if ("team_member_id".equals(_field)) { - teamMemberId = getStringValue(_p); - _p.nextToken(); + if (f_disabled == null) { + throw new JsonParseException(p, "Required field \"disabled\" missing."); } - else { - skipValue(_p); + if (f_isTeammate == null) { + throw new JsonParseException(p, "Required field \"is_teammate\" missing."); } + value = new BasicAccount(f_accountId, f_name, f_email, f_emailVerified, f_disabled, f_isTeammate, f_profilePhotoUrl, f_teamMemberId); } - - if (accountId == null) { - throw new JsonParseException(_p, "Required field \"account_id\" is missing."); - } - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); - } - if (email == null) { - throw new JsonParseException(_p, "Required field \"email\" is missing."); - } - if (emailVerified == null) { - throw new JsonParseException(_p, "Required field \"email_verified\" is missing."); - } - if (disabled == null) { - throw new JsonParseException(_p, "Required field \"disabled\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (isTeammate == null) { - throw new JsonParseException(_p, "Required field \"is_teammate\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new BasicAccount(accountId, name, email, emailVerified, disabled, isTeammate, profilePhotoUrl, teamMemberId); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/users/DbxUserUsersRequests.java b/src/main/java/com/dropbox/core/v2/users/DbxUserUsersRequests.java index 0258b727e..fdce327c4 100644 --- a/src/main/java/com/dropbox/core/v2/users/DbxUserUsersRequests.java +++ b/src/main/java/com/dropbox/core/v2/users/DbxUserUsersRequests.java @@ -1,18 +1,14 @@ /* DO NOT EDIT */ -/* This file was generated from users.babel */ +/* This file was generated from users.stone */ package com.dropbox.core.v2.users; import com.dropbox.core.DbxApiException; import com.dropbox.core.DbxException; -import com.dropbox.core.DbxRequestUtil; +import com.dropbox.core.DbxWrappedException; import com.dropbox.core.http.HttpRequestor; -import com.dropbox.core.json.JsonUtil; import com.dropbox.core.v2.DbxRawClientV2; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JavaType; - import java.util.HashMap; import java.util.List; import java.util.Map; @@ -45,11 +41,12 @@ BasicAccount getAccount(GetAccountArg getAccountArg) throws GetAccountErrorExcep "2/users/get_account", getAccountArg, false, - JsonUtil.createType(BasicAccount.class), - JsonUtil.createType(GetAccountError.class)); + GetAccountArg.Serializer.INSTANCE, + BasicAccount.Serializer.INSTANCE, + GetAccountError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new GetAccountErrorException(ew.getRequestId(), ew.getUserMessage(), (GetAccountError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new GetAccountErrorException(ex.getRequestId(), ex.getUserMessage(), (GetAccountError) ex.getErrorValue()); } } @@ -84,11 +81,12 @@ List getAccountBatch(GetAccountBatchArg getAccountBatchArg) throws "2/users/get_account_batch", getAccountBatchArg, false, - JsonUtil.createType(new TypeReference>() {}), - JsonUtil.createType(GetAccountBatchError.class)); + GetAccountBatchArg.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.list(BasicAccount.Serializer.INSTANCE), + GetAccountBatchError.Serializer.INSTANCE); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new GetAccountBatchErrorException(ew.getRequestId(), ew.getUserMessage(), (GetAccountBatchError) ew.getErrorValue()); + catch (DbxWrappedException ex) { + throw new GetAccountBatchErrorException(ex.getRequestId(), ex.getUserMessage(), (GetAccountBatchError) ex.getErrorValue()); } } @@ -123,11 +121,12 @@ public FullAccount getCurrentAccount() throws DbxException { "2/users/get_current_account", null, false, - JsonUtil.createType(FullAccount.class), - JsonUtil.createType(Void.class)); + com.dropbox.core.stone.StoneSerializers.void_(), + FullAccount.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.void_()); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new DbxApiException(ew.getRequestId(), ew.getUserMessage(), "Unexpected error response for \"get_current_account\": ew.errValue"); + catch (DbxWrappedException ex) { + throw new DbxApiException(ex.getRequestId(), ex.getUserMessage(), "Unexpected error response for \"get_current_account\":" + ex.getErrorValue()); } } @@ -146,11 +145,12 @@ public SpaceUsage getSpaceUsage() throws DbxException { "2/users/get_space_usage", null, false, - JsonUtil.createType(SpaceUsage.class), - JsonUtil.createType(Void.class)); + com.dropbox.core.stone.StoneSerializers.void_(), + SpaceUsage.Serializer.INSTANCE, + com.dropbox.core.stone.StoneSerializers.void_()); } - catch (DbxRequestUtil.ErrorWrapper ew) { - throw new DbxApiException(ew.getRequestId(), ew.getUserMessage(), "Unexpected error response for \"get_space_usage\": ew.errValue"); + catch (DbxWrappedException ex) { + throw new DbxApiException(ex.getRequestId(), ex.getUserMessage(), "Unexpected error response for \"get_space_usage\":" + ex.getErrorValue()); } } } diff --git a/src/main/java/com/dropbox/core/v2/users/FullAccount.java b/src/main/java/com/dropbox/core/v2/users/FullAccount.java index 4053991e4..48d654621 100644 --- a/src/main/java/com/dropbox/core/v2/users/FullAccount.java +++ b/src/main/java/com/dropbox/core/v2/users/FullAccount.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from users.babel */ +/* This file was generated from users.stone */ package com.dropbox.core.v2.users; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Detailed information about the current user's account. */ -@JsonSerialize(using=FullAccount.Serializer.class) -@JsonDeserialize(using=FullAccount.Deserializer.class) public class FullAccount extends Account { // struct FullAccount - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String country; protected final String locale; protected final String referralLink; @@ -441,7 +424,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -453,182 +436,163 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(FullAccount.class); - } - - public Serializer(boolean unwrapping) { - super(FullAccount.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected void serializeFields(FullAccount value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("account_id", value.accountId); - g.writeObjectField("name", value.name); - g.writeObjectField("email", value.email); - g.writeObjectField("email_verified", value.emailVerified); - g.writeObjectField("disabled", value.disabled); - g.writeObjectField("locale", value.locale); - g.writeObjectField("referral_link", value.referralLink); - g.writeObjectField("is_paired", value.isPaired); - g.writeObjectField("account_type", value.accountType); + public void serialize(FullAccount value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("account_id"); + StoneSerializers.string().serialize(value.accountId, g); + g.writeFieldName("name"); + Name.Serializer.INSTANCE.serialize(value.name, g); + g.writeFieldName("email"); + StoneSerializers.string().serialize(value.email, g); + g.writeFieldName("email_verified"); + StoneSerializers.boolean_().serialize(value.emailVerified, g); + g.writeFieldName("disabled"); + StoneSerializers.boolean_().serialize(value.disabled, g); + g.writeFieldName("locale"); + StoneSerializers.string().serialize(value.locale, g); + g.writeFieldName("referral_link"); + StoneSerializers.string().serialize(value.referralLink, g); + g.writeFieldName("is_paired"); + StoneSerializers.boolean_().serialize(value.isPaired, g); + g.writeFieldName("account_type"); + AccountType.Serializer.INSTANCE.serialize(value.accountType, g); if (value.profilePhotoUrl != null) { - g.writeObjectField("profile_photo_url", value.profilePhotoUrl); + g.writeFieldName("profile_photo_url"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.profilePhotoUrl, g); } if (value.country != null) { - g.writeObjectField("country", value.country); + g.writeFieldName("country"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.country, g); } if (value.team != null) { - g.writeObjectField("team", value.team); + g.writeFieldName("team"); + StoneSerializers.nullable(FullTeam.Serializer.INSTANCE).serialize(value.team, g); } if (value.teamMemberId != null) { - g.writeObjectField("team_member_id", value.teamMemberId); + g.writeFieldName("team_member_id"); + StoneSerializers.nullable(StoneSerializers.string()).serialize(value.teamMemberId, g); + } + if (!collapse) { + g.writeEndObject(); } - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(FullAccount.class); - } - - public Deserializer(boolean unwrapping) { - super(FullAccount.class, unwrapping); - } - - @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); } @Override - public FullAccount deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String accountId = null; - Name name = null; - String email = null; - Boolean emailVerified = null; - Boolean disabled = null; - String locale = null; - String referralLink = null; - Boolean isPaired = null; - AccountType accountType = null; - String profilePhotoUrl = null; - String country = null; - FullTeam team = null; - String teamMemberId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("account_id".equals(_field)) { - accountId = getStringValue(_p); - _p.nextToken(); - } - else if ("name".equals(_field)) { - name = _p.readValueAs(Name.class); - _p.nextToken(); - } - else if ("email".equals(_field)) { - email = getStringValue(_p); - _p.nextToken(); - } - else if ("email_verified".equals(_field)) { - emailVerified = _p.getValueAsBoolean(); - _p.nextToken(); - } - else if ("disabled".equals(_field)) { - disabled = _p.getValueAsBoolean(); - _p.nextToken(); + public FullAccount deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + FullAccount value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_accountId = null; + Name f_name = null; + String f_email = null; + Boolean f_emailVerified = null; + Boolean f_disabled = null; + String f_locale = null; + String f_referralLink = null; + Boolean f_isPaired = null; + AccountType f_accountType = null; + String f_profilePhotoUrl = null; + String f_country = null; + FullTeam f_team = null; + String f_teamMemberId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("account_id".equals(field)) { + f_accountId = StoneSerializers.string().deserialize(p); + } + else if ("name".equals(field)) { + f_name = Name.Serializer.INSTANCE.deserialize(p); + } + else if ("email".equals(field)) { + f_email = StoneSerializers.string().deserialize(p); + } + else if ("email_verified".equals(field)) { + f_emailVerified = StoneSerializers.boolean_().deserialize(p); + } + else if ("disabled".equals(field)) { + f_disabled = StoneSerializers.boolean_().deserialize(p); + } + else if ("locale".equals(field)) { + f_locale = StoneSerializers.string().deserialize(p); + } + else if ("referral_link".equals(field)) { + f_referralLink = StoneSerializers.string().deserialize(p); + } + else if ("is_paired".equals(field)) { + f_isPaired = StoneSerializers.boolean_().deserialize(p); + } + else if ("account_type".equals(field)) { + f_accountType = AccountType.Serializer.INSTANCE.deserialize(p); + } + else if ("profile_photo_url".equals(field)) { + f_profilePhotoUrl = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("country".equals(field)) { + f_country = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else if ("team".equals(field)) { + f_team = StoneSerializers.nullable(FullTeam.Serializer.INSTANCE).deserialize(p); + } + else if ("team_member_id".equals(field)) { + f_teamMemberId = StoneSerializers.nullable(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); + } } - else if ("locale".equals(_field)) { - locale = getStringValue(_p); - _p.nextToken(); + if (f_accountId == null) { + throw new JsonParseException(p, "Required field \"account_id\" missing."); } - else if ("referral_link".equals(_field)) { - referralLink = getStringValue(_p); - _p.nextToken(); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } - else if ("is_paired".equals(_field)) { - isPaired = _p.getValueAsBoolean(); - _p.nextToken(); + if (f_email == null) { + throw new JsonParseException(p, "Required field \"email\" missing."); } - else if ("account_type".equals(_field)) { - accountType = _p.readValueAs(AccountType.class); - _p.nextToken(); + if (f_emailVerified == null) { + throw new JsonParseException(p, "Required field \"email_verified\" missing."); } - else if ("profile_photo_url".equals(_field)) { - profilePhotoUrl = getStringValue(_p); - _p.nextToken(); + if (f_disabled == null) { + throw new JsonParseException(p, "Required field \"disabled\" missing."); } - else if ("country".equals(_field)) { - country = getStringValue(_p); - _p.nextToken(); + if (f_locale == null) { + throw new JsonParseException(p, "Required field \"locale\" missing."); } - else if ("team".equals(_field)) { - team = _p.readValueAs(FullTeam.class); - _p.nextToken(); + if (f_referralLink == null) { + throw new JsonParseException(p, "Required field \"referral_link\" missing."); } - else if ("team_member_id".equals(_field)) { - teamMemberId = getStringValue(_p); - _p.nextToken(); + if (f_isPaired == null) { + throw new JsonParseException(p, "Required field \"is_paired\" missing."); } - else { - skipValue(_p); + if (f_accountType == null) { + throw new JsonParseException(p, "Required field \"account_type\" missing."); } + value = new FullAccount(f_accountId, f_name, f_email, f_emailVerified, f_disabled, f_locale, f_referralLink, f_isPaired, f_accountType, f_profilePhotoUrl, f_country, f_team, f_teamMemberId); } - - if (accountId == null) { - throw new JsonParseException(_p, "Required field \"account_id\" is missing."); - } - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); - } - if (email == null) { - throw new JsonParseException(_p, "Required field \"email\" is missing."); - } - if (emailVerified == null) { - throw new JsonParseException(_p, "Required field \"email_verified\" is missing."); - } - if (disabled == null) { - throw new JsonParseException(_p, "Required field \"disabled\" is missing."); - } - if (locale == null) { - throw new JsonParseException(_p, "Required field \"locale\" is missing."); - } - if (referralLink == null) { - throw new JsonParseException(_p, "Required field \"referral_link\" is missing."); - } - if (isPaired == null) { - throw new JsonParseException(_p, "Required field \"is_paired\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (accountType == null) { - throw new JsonParseException(_p, "Required field \"account_type\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new FullAccount(accountId, name, email, emailVerified, disabled, locale, referralLink, isPaired, accountType, profilePhotoUrl, country, team, teamMemberId); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/users/FullTeam.java b/src/main/java/com/dropbox/core/v2/users/FullTeam.java index 966202498..19957a939 100644 --- a/src/main/java/com/dropbox/core/v2/users/FullTeam.java +++ b/src/main/java/com/dropbox/core/v2/users/FullTeam.java @@ -1,43 +1,26 @@ /* DO NOT EDIT */ -/* This file was generated from users.babel */ +/* This file was generated from users.stone */ package com.dropbox.core.v2.users; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.dropbox.core.v2.teampolicies.TeamSharingPolicies; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Detailed information about a team. */ -@JsonSerialize(using=FullTeam.Serializer.class) -@JsonDeserialize(using=FullTeam.Deserializer.class) public class FullTeam extends Team { // struct FullTeam - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final TeamSharingPolicies sharingPolicies; /** @@ -97,7 +80,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -109,96 +92,77 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(FullTeam.class); - } - - public Serializer(boolean unwrapping) { - super(FullTeam.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(FullTeam value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("id", value.id); - g.writeObjectField("name", value.name); - g.writeObjectField("sharing_policies", value.sharingPolicies); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(FullTeam.class); - } - - public Deserializer(boolean unwrapping) { - super(FullTeam.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(FullTeam value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("id"); + StoneSerializers.string().serialize(value.id, g); + g.writeFieldName("name"); + StoneSerializers.string().serialize(value.name, g); + g.writeFieldName("sharing_policies"); + TeamSharingPolicies.Serializer.INSTANCE.serialize(value.sharingPolicies, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public FullTeam deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String id = null; - String name = null; - TeamSharingPolicies sharingPolicies = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("id".equals(_field)) { - id = getStringValue(_p); - _p.nextToken(); + public FullTeam deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + FullTeam value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_id = null; + String f_name = null; + TeamSharingPolicies f_sharingPolicies = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("id".equals(field)) { + f_id = StoneSerializers.string().deserialize(p); + } + else if ("name".equals(field)) { + f_name = StoneSerializers.string().deserialize(p); + } + else if ("sharing_policies".equals(field)) { + f_sharingPolicies = TeamSharingPolicies.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else if ("name".equals(_field)) { - name = getStringValue(_p); - _p.nextToken(); + if (f_id == null) { + throw new JsonParseException(p, "Required field \"id\" missing."); } - else if ("sharing_policies".equals(_field)) { - sharingPolicies = _p.readValueAs(TeamSharingPolicies.class); - _p.nextToken(); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } - else { - skipValue(_p); + if (f_sharingPolicies == null) { + throw new JsonParseException(p, "Required field \"sharing_policies\" missing."); } + value = new FullTeam(f_id, f_name, f_sharingPolicies); } - - if (id == null) { - throw new JsonParseException(_p, "Required field \"id\" is missing."); - } - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (sharingPolicies == null) { - throw new JsonParseException(_p, "Required field \"sharing_policies\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new FullTeam(id, name, sharingPolicies); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/users/GetAccountArg.java b/src/main/java/com/dropbox/core/v2/users/GetAccountArg.java index a42879918..e5fce6672 100644 --- a/src/main/java/com/dropbox/core/v2/users/GetAccountArg.java +++ b/src/main/java/com/dropbox/core/v2/users/GetAccountArg.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from users.babel */ +/* This file was generated from users.stone */ package com.dropbox.core.v2.users; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=GetAccountArg.Serializer.class) -@JsonDeserialize(using=GetAccountArg.Deserializer.class) class GetAccountArg { // struct GetAccountArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String accountId; /** @@ -91,7 +74,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -103,78 +86,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetAccountArg.class); - } - - public Serializer(boolean unwrapping) { - super(GetAccountArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GetAccountArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("account_id", value.accountId); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetAccountArg.class); - } - - public Deserializer(boolean unwrapping) { - super(GetAccountArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GetAccountArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("account_id"); + StoneSerializers.string().serialize(value.accountId, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GetAccountArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String accountId = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("account_id".equals(_field)) { - accountId = getStringValue(_p); - _p.nextToken(); + public GetAccountArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GetAccountArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_accountId = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("account_id".equals(field)) { + f_accountId = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_accountId == null) { + throw new JsonParseException(p, "Required field \"account_id\" missing."); } + value = new GetAccountArg(f_accountId); } - - if (accountId == null) { - throw new JsonParseException(_p, "Required field \"account_id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new GetAccountArg(accountId); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/users/GetAccountBatchArg.java b/src/main/java/com/dropbox/core/v2/users/GetAccountBatchArg.java index 2160b933c..a30186a14 100644 --- a/src/main/java/com/dropbox/core/v2/users/GetAccountBatchArg.java +++ b/src/main/java/com/dropbox/core/v2/users/GetAccountBatchArg.java @@ -1,40 +1,23 @@ /* DO NOT EDIT */ -/* This file was generated from users.babel */ +/* This file was generated from users.stone */ package com.dropbox.core.v2.users; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.util.List; -@JsonSerialize(using=GetAccountBatchArg.Serializer.class) -@JsonDeserialize(using=GetAccountBatchArg.Deserializer.class) class GetAccountBatchArg { // struct GetAccountBatchArg - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final List accountIds; /** @@ -102,7 +85,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -114,86 +97,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetAccountBatchArg.class); - } - - public Serializer(boolean unwrapping) { - super(GetAccountBatchArg.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(GetAccountBatchArg value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("account_ids", value.accountIds); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetAccountBatchArg.class); - } - - public Deserializer(boolean unwrapping) { - super(GetAccountBatchArg.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(GetAccountBatchArg value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("account_ids"); + StoneSerializers.list(StoneSerializers.string()).serialize(value.accountIds, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public GetAccountBatchArg deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - List accountIds = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("account_ids".equals(_field)) { - expectArrayStart(_p); - accountIds = new java.util.ArrayList(); - while (!isArrayEnd(_p)) { - String _x = null; - _x = getStringValue(_p); - _p.nextToken(); - accountIds.add(_x); + public GetAccountBatchArg deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + GetAccountBatchArg value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + List f_accountIds = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("account_ids".equals(field)) { + f_accountIds = StoneSerializers.list(StoneSerializers.string()).deserialize(p); + } + else { + skipValue(p); } - expectArrayEnd(_p); - _p.nextToken(); } - else { - skipValue(_p); + if (f_accountIds == null) { + throw new JsonParseException(p, "Required field \"account_ids\" missing."); } + value = new GetAccountBatchArg(f_accountIds); } - - if (accountIds == null) { - throw new JsonParseException(_p, "Required field \"account_ids\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new GetAccountBatchArg(accountIds); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/users/GetAccountBatchError.java b/src/main/java/com/dropbox/core/v2/users/GetAccountBatchError.java index 7b99093d4..c070b0e2e 100644 --- a/src/main/java/com/dropbox/core/v2/users/GetAccountBatchError.java +++ b/src/main/java/com/dropbox/core/v2/users/GetAccountBatchError.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from users.babel */ +/* This file was generated from users.stone */ package com.dropbox.core.v2.users; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * This class is an open tagged union. Tagged unions instances are always @@ -36,15 +24,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=GetAccountBatchError.Serializer.class) -@JsonDeserialize(using=GetAccountBatchError.Deserializer.class) public final class GetAccountBatchError { // union GetAccountBatchError - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link GetAccountBatchError}. */ @@ -211,7 +193,7 @@ else if (obj instanceof GetAccountBatchError) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -223,71 +205,64 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetAccountBatchError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GetAccountBatchError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case NO_ACCOUNT: + public void serialize(GetAccountBatchError value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case NO_ACCOUNT: { g.writeStartObject(); - g.writeStringField(".tag", "no_account"); - g.writeObjectField("no_account", value.noAccountValue); + writeTag("no_account", g); + g.writeFieldName("no_account"); + StoneSerializers.string().serialize(value.noAccountValue, g); g.writeEndObject(); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetAccountBatchError.class, getTagMapping(), Tag.OTHER); - } @Override - public GetAccountBatchError deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case NO_ACCOUNT: { - String value = null; - expectField(_p, "no_account"); - value = getStringValue(_p); - _p.nextToken(); - return GetAccountBatchError.noAccount(value); - } - case OTHER: { - return GetAccountBatchError.OTHER; - } + public GetAccountBatchError deserialize(JsonParser p) throws IOException, JsonParseException { + GetAccountBatchError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("no_account", GetAccountBatchError.Tag.NO_ACCOUNT); - values.put("other", GetAccountBatchError.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("no_account".equals(tag)) { + String fieldValue = null; + expectField("no_account", p); + fieldValue = StoneSerializers.string().deserialize(p); + value = GetAccountBatchError.noAccount(fieldValue); + } + else { + value = GetAccountBatchError.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/users/GetAccountBatchErrorException.java b/src/main/java/com/dropbox/core/v2/users/GetAccountBatchErrorException.java index ca8b637a7..dd11fed08 100644 --- a/src/main/java/com/dropbox/core/v2/users/GetAccountBatchErrorException.java +++ b/src/main/java/com/dropbox/core/v2/users/GetAccountBatchErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from users.babel */ +/* This file was generated from users.stone */ package com.dropbox.core.v2.users; diff --git a/src/main/java/com/dropbox/core/v2/users/GetAccountError.java b/src/main/java/com/dropbox/core/v2/users/GetAccountError.java index 718b97941..167e234d9 100644 --- a/src/main/java/com/dropbox/core/v2/users/GetAccountError.java +++ b/src/main/java/com/dropbox/core/v2/users/GetAccountError.java @@ -1,33 +1,19 @@ /* DO NOT EDIT */ -/* This file was generated from users.babel */ +/* This file was generated from users.stone */ package com.dropbox.core.v2.users; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -@JsonSerialize(using=GetAccountError.Serializer.class) -@JsonDeserialize(using=GetAccountError.Deserializer.class) public enum GetAccountError { // union GetAccountError /** @@ -44,47 +30,54 @@ public enum GetAccountError { */ UNKNOWN; // *catch_all - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(GetAccountError.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(GetAccountError value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(GetAccountError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value) { - case NO_ACCOUNT: + case NO_ACCOUNT: { g.writeString("no_account"); break; - case UNKNOWN: + } + default: { g.writeString("unknown"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(GetAccountError.class, getTagMapping(), GetAccountError.UNKNOWN); - } @Override - public GetAccountError deserialize(GetAccountError _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - return _tag; - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("no_account", GetAccountError.NO_ACCOUNT); - values.put("unknown", GetAccountError.UNKNOWN); - return Collections.unmodifiableMap(values); + public GetAccountError deserialize(JsonParser p) throws IOException, JsonParseException { + GetAccountError value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); + } + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("no_account".equals(tag)) { + value = GetAccountError.NO_ACCOUNT; + } + else { + value = GetAccountError.UNKNOWN; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/users/GetAccountErrorException.java b/src/main/java/com/dropbox/core/v2/users/GetAccountErrorException.java index 7cc9925b6..53d912814 100644 --- a/src/main/java/com/dropbox/core/v2/users/GetAccountErrorException.java +++ b/src/main/java/com/dropbox/core/v2/users/GetAccountErrorException.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from users.babel */ +/* This file was generated from users.stone */ package com.dropbox.core.v2.users; diff --git a/src/main/java/com/dropbox/core/v2/users/IndividualSpaceAllocation.java b/src/main/java/com/dropbox/core/v2/users/IndividualSpaceAllocation.java index e091f484c..a5cb1f0af 100644 --- a/src/main/java/com/dropbox/core/v2/users/IndividualSpaceAllocation.java +++ b/src/main/java/com/dropbox/core/v2/users/IndividualSpaceAllocation.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from users.babel */ +/* This file was generated from users.stone */ package com.dropbox.core.v2.users; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=IndividualSpaceAllocation.Serializer.class) -@JsonDeserialize(using=IndividualSpaceAllocation.Deserializer.class) public class IndividualSpaceAllocation { // struct IndividualSpaceAllocation - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final long allocated; /** @@ -79,7 +62,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -91,79 +74,59 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(IndividualSpaceAllocation.class); - } - - public Serializer(boolean unwrapping) { - super(IndividualSpaceAllocation.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(IndividualSpaceAllocation value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("allocated", value.allocated); - } - } - - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(IndividualSpaceAllocation.class); - } - - public Deserializer(boolean unwrapping) { - super(IndividualSpaceAllocation.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(IndividualSpaceAllocation value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("allocated"); + StoneSerializers.uInt64().serialize(value.allocated, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public IndividualSpaceAllocation deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - Long allocated = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("allocated".equals(_field)) { - allocated = _p.getLongValue(); - assertUnsigned(_p, allocated); - _p.nextToken(); + public IndividualSpaceAllocation deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + IndividualSpaceAllocation value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Long f_allocated = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("allocated".equals(field)) { + f_allocated = StoneSerializers.uInt64().deserialize(p); + } + else { + skipValue(p); + } } - else { - skipValue(_p); + if (f_allocated == null) { + throw new JsonParseException(p, "Required field \"allocated\" missing."); } + value = new IndividualSpaceAllocation(f_allocated); } - - if (allocated == null) { - throw new JsonParseException(_p, "Required field \"allocated\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - - return new IndividualSpaceAllocation(allocated); + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/users/Name.java b/src/main/java/com/dropbox/core/v2/users/Name.java index 98a70f3d2..ea9df3ae8 100644 --- a/src/main/java/com/dropbox/core/v2/users/Name.java +++ b/src/main/java/com/dropbox/core/v2/users/Name.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from users.babel */ +/* This file was generated from users.stone */ package com.dropbox.core.v2.users; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Representations for a person's name to assist with internationalization. */ -@JsonSerialize(using=Name.Serializer.class) -@JsonDeserialize(using=Name.Deserializer.class) public class Name { // struct Name - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String givenName; protected final String surname; protected final String familiarName; @@ -148,7 +131,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -160,105 +143,86 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(Name.class); - } - - public Serializer(boolean unwrapping) { - super(Name.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(Name value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("given_name", value.givenName); - g.writeObjectField("surname", value.surname); - g.writeObjectField("familiar_name", value.familiarName); - g.writeObjectField("display_name", value.displayName); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(Name.class); - } - - public Deserializer(boolean unwrapping) { - super(Name.class, unwrapping); - } + /** + * For internal use only. + */ + public static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(Name value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("given_name"); + StoneSerializers.string().serialize(value.givenName, g); + g.writeFieldName("surname"); + StoneSerializers.string().serialize(value.surname, g); + g.writeFieldName("familiar_name"); + StoneSerializers.string().serialize(value.familiarName, g); + g.writeFieldName("display_name"); + StoneSerializers.string().serialize(value.displayName, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public Name deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String givenName = null; - String surname = null; - String familiarName = null; - String displayName = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("given_name".equals(_field)) { - givenName = getStringValue(_p); - _p.nextToken(); + public Name deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + Name value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_givenName = null; + String f_surname = null; + String f_familiarName = null; + String f_displayName = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("given_name".equals(field)) { + f_givenName = StoneSerializers.string().deserialize(p); + } + else if ("surname".equals(field)) { + f_surname = StoneSerializers.string().deserialize(p); + } + else if ("familiar_name".equals(field)) { + f_familiarName = StoneSerializers.string().deserialize(p); + } + else if ("display_name".equals(field)) { + f_displayName = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else if ("surname".equals(_field)) { - surname = getStringValue(_p); - _p.nextToken(); + if (f_givenName == null) { + throw new JsonParseException(p, "Required field \"given_name\" missing."); } - else if ("familiar_name".equals(_field)) { - familiarName = getStringValue(_p); - _p.nextToken(); + if (f_surname == null) { + throw new JsonParseException(p, "Required field \"surname\" missing."); } - else if ("display_name".equals(_field)) { - displayName = getStringValue(_p); - _p.nextToken(); + if (f_familiarName == null) { + throw new JsonParseException(p, "Required field \"familiar_name\" missing."); } - else { - skipValue(_p); + if (f_displayName == null) { + throw new JsonParseException(p, "Required field \"display_name\" missing."); } + value = new Name(f_givenName, f_surname, f_familiarName, f_displayName); } - - if (givenName == null) { - throw new JsonParseException(_p, "Required field \"given_name\" is missing."); - } - if (surname == null) { - throw new JsonParseException(_p, "Required field \"surname\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (familiarName == null) { - throw new JsonParseException(_p, "Required field \"familiar_name\" is missing."); + if (!collapsed) { + expectEndObject(p); } - if (displayName == null) { - throw new JsonParseException(_p, "Required field \"display_name\" is missing."); - } - - return new Name(givenName, surname, familiarName, displayName); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/users/SpaceAllocation.java b/src/main/java/com/dropbox/core/v2/users/SpaceAllocation.java index 2430bbe28..64f395118 100644 --- a/src/main/java/com/dropbox/core/v2/users/SpaceAllocation.java +++ b/src/main/java/com/dropbox/core/v2/users/SpaceAllocation.java @@ -1,30 +1,18 @@ /* DO NOT EDIT */ -/* This file was generated from users.babel */ +/* This file was generated from users.stone */ package com.dropbox.core.v2.users; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.UnionJsonDeserializer; -import com.dropbox.core.json.UnionJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.UnionSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; /** * Space is allocated differently based on the type of account. @@ -38,15 +26,9 @@ * tag is introduced that this SDK does not recognized, the {@link #OTHER} value * will be used.

*/ -@JsonSerialize(using=SpaceAllocation.Serializer.class) -@JsonDeserialize(using=SpaceAllocation.Deserializer.class) public final class SpaceAllocation { // union SpaceAllocation - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - /** * Discriminating tag type for {@link SpaceAllocation}. */ @@ -258,7 +240,7 @@ else if (obj instanceof SpaceAllocation) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -270,81 +252,74 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Serializer extends UnionJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SpaceAllocation.class, IndividualSpaceAllocation.class, TeamSpaceAllocation.class); - } + /** + * For internal use only. + */ + static final class Serializer extends UnionSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - public void serialize(SpaceAllocation value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - switch (value.tag) { - case INDIVIDUAL: + public void serialize(SpaceAllocation value, JsonGenerator g) throws IOException, JsonGenerationException { + switch (value.tag()) { + case INDIVIDUAL: { g.writeStartObject(); - g.writeStringField(".tag", "individual"); - getUnwrappingSerializer(IndividualSpaceAllocation.class).serialize(value.individualValue, g, provider); + writeTag("individual", g); + IndividualSpaceAllocation.Serializer.INSTANCE.serialize(value.individualValue, g, true); g.writeEndObject(); break; - case TEAM: + } + case TEAM: { g.writeStartObject(); - g.writeStringField(".tag", "team"); - getUnwrappingSerializer(TeamSpaceAllocation.class).serialize(value.teamValue, g, provider); + writeTag("team", g); + TeamSpaceAllocation.Serializer.INSTANCE.serialize(value.teamValue, g, true); g.writeEndObject(); break; - case OTHER: + } + default: { g.writeString("other"); - break; + } } } - } - - static final class Deserializer extends UnionJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SpaceAllocation.class, getTagMapping(), Tag.OTHER, IndividualSpaceAllocation.class, TeamSpaceAllocation.class); - } @Override - public SpaceAllocation deserialize(Tag _tag, JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - switch (_tag) { - case INDIVIDUAL: { - IndividualSpaceAllocation value = null; - value = readCollapsedStructValue(IndividualSpaceAllocation.class, _p, _ctx); - return SpaceAllocation.individual(value); - } - case TEAM: { - TeamSpaceAllocation value = null; - value = readCollapsedStructValue(TeamSpaceAllocation.class, _p, _ctx); - return SpaceAllocation.team(value); - } - case OTHER: { - return SpaceAllocation.OTHER; - } + public SpaceAllocation deserialize(JsonParser p) throws IOException, JsonParseException { + SpaceAllocation value; + boolean collapsed; + String tag; + if (p.getCurrentToken() == JsonToken.VALUE_STRING) { + collapsed = true; + tag = getStringValue(p); + p.nextToken(); } - // should be impossible to get here - throw new IllegalStateException("Unparsed tag: \"" + _tag + "\""); - } - - private static Map getTagMapping() { - Map values = new HashMap(); - values.put("individual", SpaceAllocation.Tag.INDIVIDUAL); - values.put("team", SpaceAllocation.Tag.TEAM); - values.put("other", SpaceAllocation.Tag.OTHER); - return Collections.unmodifiableMap(values); + else { + collapsed = false; + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + throw new JsonParseException(p, "Required field missing: " + TAG_FIELD); + } + else if ("individual".equals(tag)) { + IndividualSpaceAllocation fieldValue = null; + fieldValue = IndividualSpaceAllocation.Serializer.INSTANCE.deserialize(p, true); + value = SpaceAllocation.individual(fieldValue); + } + else if ("team".equals(tag)) { + TeamSpaceAllocation fieldValue = null; + fieldValue = TeamSpaceAllocation.Serializer.INSTANCE.deserialize(p, true); + value = SpaceAllocation.team(fieldValue); + } + else { + value = SpaceAllocation.OTHER; + skipFields(p); + } + if (!collapsed) { + expectEndObject(p); + } + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/users/SpaceUsage.java b/src/main/java/com/dropbox/core/v2/users/SpaceUsage.java index 9cf496fa4..251e2dc6b 100644 --- a/src/main/java/com/dropbox/core/v2/users/SpaceUsage.java +++ b/src/main/java/com/dropbox/core/v2/users/SpaceUsage.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from users.babel */ +/* This file was generated from users.stone */ package com.dropbox.core.v2.users; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Information about a user's space usage and quota. */ -@JsonSerialize(using=SpaceUsage.Serializer.class) -@JsonDeserialize(using=SpaceUsage.Deserializer.class) public class SpaceUsage { // struct SpaceUsage - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final long used; protected final SpaceAllocation allocation; @@ -103,7 +86,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -115,88 +98,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(SpaceUsage.class); - } - - public Serializer(boolean unwrapping) { - super(SpaceUsage.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(SpaceUsage value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("used", value.used); - g.writeObjectField("allocation", value.allocation); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(SpaceUsage.class); - } - - public Deserializer(boolean unwrapping) { - super(SpaceUsage.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(SpaceUsage value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("used"); + StoneSerializers.uInt64().serialize(value.used, g); + g.writeFieldName("allocation"); + SpaceAllocation.Serializer.INSTANCE.serialize(value.allocation, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public SpaceUsage deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - Long used = null; - SpaceAllocation allocation = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("used".equals(_field)) { - used = _p.getLongValue(); - assertUnsigned(_p, used); - _p.nextToken(); + public SpaceUsage deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + SpaceUsage value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Long f_used = null; + SpaceAllocation f_allocation = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("used".equals(field)) { + f_used = StoneSerializers.uInt64().deserialize(p); + } + else if ("allocation".equals(field)) { + f_allocation = SpaceAllocation.Serializer.INSTANCE.deserialize(p); + } + else { + skipValue(p); + } } - else if ("allocation".equals(_field)) { - allocation = _p.readValueAs(SpaceAllocation.class); - _p.nextToken(); + if (f_used == null) { + throw new JsonParseException(p, "Required field \"used\" missing."); } - else { - skipValue(_p); + if (f_allocation == null) { + throw new JsonParseException(p, "Required field \"allocation\" missing."); } + value = new SpaceUsage(f_used, f_allocation); } - - if (used == null) { - throw new JsonParseException(_p, "Required field \"used\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (allocation == null) { - throw new JsonParseException(_p, "Required field \"allocation\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new SpaceUsage(used, allocation); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/users/Team.java b/src/main/java/com/dropbox/core/v2/users/Team.java index 3a3fa362f..feb32fd66 100644 --- a/src/main/java/com/dropbox/core/v2/users/Team.java +++ b/src/main/java/com/dropbox/core/v2/users/Team.java @@ -1,42 +1,25 @@ /* DO NOT EDIT */ -/* This file was generated from users.babel */ +/* This file was generated from users.stone */ package com.dropbox.core.v2.users; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; /** * Information about a team. */ -@JsonSerialize(using=Team.Serializer.class) -@JsonDeserialize(using=Team.Deserializer.class) public class Team { // struct Team - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final String id; protected final String name; @@ -106,7 +89,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -118,87 +101,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(Team.class); - } - - public Serializer(boolean unwrapping) { - super(Team.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(Team value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("id", value.id); - g.writeObjectField("name", value.name); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(Team.class); - } - - public Deserializer(boolean unwrapping) { - super(Team.class, unwrapping); - } + /** + * For internal use only. + */ + public static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(Team value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("id"); + StoneSerializers.string().serialize(value.id, g); + g.writeFieldName("name"); + StoneSerializers.string().serialize(value.name, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public Team deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - String id = null; - String name = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("id".equals(_field)) { - id = getStringValue(_p); - _p.nextToken(); + public Team deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + Team value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + String f_id = null; + String f_name = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("id".equals(field)) { + f_id = StoneSerializers.string().deserialize(p); + } + else if ("name".equals(field)) { + f_name = StoneSerializers.string().deserialize(p); + } + else { + skipValue(p); + } } - else if ("name".equals(_field)) { - name = getStringValue(_p); - _p.nextToken(); + if (f_id == null) { + throw new JsonParseException(p, "Required field \"id\" missing."); } - else { - skipValue(_p); + if (f_name == null) { + throw new JsonParseException(p, "Required field \"name\" missing."); } + value = new Team(f_id, f_name); } - - if (id == null) { - throw new JsonParseException(_p, "Required field \"id\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (name == null) { - throw new JsonParseException(_p, "Required field \"name\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new Team(id, name); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/users/TeamSpaceAllocation.java b/src/main/java/com/dropbox/core/v2/users/TeamSpaceAllocation.java index a836f479b..47151c89c 100644 --- a/src/main/java/com/dropbox/core/v2/users/TeamSpaceAllocation.java +++ b/src/main/java/com/dropbox/core/v2/users/TeamSpaceAllocation.java @@ -1,39 +1,22 @@ /* DO NOT EDIT */ -/* This file was generated from users.babel */ +/* This file was generated from users.stone */ package com.dropbox.core.v2.users; -import com.dropbox.core.json.JsonReadException; -import com.dropbox.core.json.JsonReader; -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.json.StructJsonDeserializer; -import com.dropbox.core.json.StructJsonSerializer; +import com.dropbox.core.stone.StoneSerializers; +import com.dropbox.core.stone.StructSerializer; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -@JsonSerialize(using=TeamSpaceAllocation.Serializer.class) -@JsonDeserialize(using=TeamSpaceAllocation.Deserializer.class) public class TeamSpaceAllocation { // struct TeamSpaceAllocation - // ProGuard work-around since we declare serializers in annotation - static final Serializer SERIALIZER = new Serializer(); - static final Deserializer DESERIALIZER = new Deserializer(); - protected final long used; protected final long allocated; @@ -93,7 +76,7 @@ else if (obj.getClass().equals(this.getClass())) { @Override public String toString() { - return serialize(false); + return Serializer.INSTANCE.serialize(this, false); } /** @@ -105,89 +88,68 @@ public String toString() { * @return Formatted, multiline String representation of this object */ public String toStringMultiline() { - return serialize(true); - } - - private String serialize(boolean longForm) { - try { - return JsonUtil.getMapper(longForm).writeValueAsString(this); - } - catch (JsonProcessingException ex) { - throw new RuntimeException("Failed to serialize object", ex); - } - } - - static final class Serializer extends StructJsonSerializer { - private static final long serialVersionUID = 0L; - - public Serializer() { - super(TeamSpaceAllocation.class); - } - - public Serializer(boolean unwrapping) { - super(TeamSpaceAllocation.class, unwrapping); - } - - @Override - protected JsonSerializer asUnwrapping() { - return new Serializer(true); - } - - @Override - protected void serializeFields(TeamSpaceAllocation value, JsonGenerator g, SerializerProvider provider) throws IOException, JsonProcessingException { - g.writeObjectField("used", value.used); - g.writeObjectField("allocated", value.allocated); - } + return Serializer.INSTANCE.serialize(this, true); } - static final class Deserializer extends StructJsonDeserializer { - private static final long serialVersionUID = 0L; - - public Deserializer() { - super(TeamSpaceAllocation.class); - } - - public Deserializer(boolean unwrapping) { - super(TeamSpaceAllocation.class, unwrapping); - } + /** + * For internal use only. + */ + static final class Serializer extends StructSerializer { + public static final Serializer INSTANCE = new Serializer(); @Override - protected JsonDeserializer asUnwrapping() { - return new Deserializer(true); + public void serialize(TeamSpaceAllocation value, JsonGenerator g, boolean collapse) throws IOException, JsonGenerationException { + if (!collapse) { + g.writeStartObject(); + } + g.writeFieldName("used"); + StoneSerializers.uInt64().serialize(value.used, g); + g.writeFieldName("allocated"); + StoneSerializers.uInt64().serialize(value.allocated, g); + if (!collapse) { + g.writeEndObject(); + } } @Override - public TeamSpaceAllocation deserializeFields(JsonParser _p, DeserializationContext _ctx) throws IOException, JsonParseException { - - Long used = null; - Long allocated = null; - - while (_p.getCurrentToken() == JsonToken.FIELD_NAME) { - String _field = _p.getCurrentName(); - _p.nextToken(); - if ("used".equals(_field)) { - used = _p.getLongValue(); - assertUnsigned(_p, used); - _p.nextToken(); + public TeamSpaceAllocation deserialize(JsonParser p, boolean collapsed) throws IOException, JsonParseException { + TeamSpaceAllocation value; + String tag = null; + if (!collapsed) { + expectStartObject(p); + tag = readTag(p); + } + if (tag == null) { + Long f_used = null; + Long f_allocated = null; + while (p.getCurrentToken() == JsonToken.FIELD_NAME) { + String field = p.getCurrentName(); + p.nextToken(); + if ("used".equals(field)) { + f_used = StoneSerializers.uInt64().deserialize(p); + } + else if ("allocated".equals(field)) { + f_allocated = StoneSerializers.uInt64().deserialize(p); + } + else { + skipValue(p); + } } - else if ("allocated".equals(_field)) { - allocated = _p.getLongValue(); - assertUnsigned(_p, allocated); - _p.nextToken(); + if (f_used == null) { + throw new JsonParseException(p, "Required field \"used\" missing."); } - else { - skipValue(_p); + if (f_allocated == null) { + throw new JsonParseException(p, "Required field \"allocated\" missing."); } + value = new TeamSpaceAllocation(f_used, f_allocated); } - - if (used == null) { - throw new JsonParseException(_p, "Required field \"used\" is missing."); + else { + throw new JsonParseException(p, "No subtype found that matches tag: \"" + tag + "\""); } - if (allocated == null) { - throw new JsonParseException(_p, "Required field \"allocated\" is missing."); + if (!collapsed) { + expectEndObject(p); } - - return new TeamSpaceAllocation(used, allocated); + return value; } } } diff --git a/src/main/java/com/dropbox/core/v2/users/package-info.java b/src/main/java/com/dropbox/core/v2/users/package-info.java index 1c4f86092..25d8eb3d2 100644 --- a/src/main/java/com/dropbox/core/v2/users/package-info.java +++ b/src/main/java/com/dropbox/core/v2/users/package-info.java @@ -1,5 +1,5 @@ /* DO NOT EDIT */ -/* This file was generated from users.babel */ +/* This file was generated from users.stone */ /** * This namespace contains endpoints and data types for user management. diff --git a/src/test/java/com/dropbox/core/ITUtil.java b/src/test/java/com/dropbox/core/ITUtil.java new file mode 100644 index 000000000..b29248a91 --- /dev/null +++ b/src/test/java/com/dropbox/core/ITUtil.java @@ -0,0 +1,173 @@ +package com.dropbox.core; + +import static org.testng.Assert.*; + +import java.nio.charset.Charset; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; +import java.util.Random; +import java.util.TimeZone; +import java.util.concurrent.TimeUnit; + +import com.squareup.okhttp.OkHttpClient; + +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeSuite; + +import com.dropbox.core.DbxAuthInfo; +import com.dropbox.core.DbxRequestConfig; +import com.dropbox.core.http.HttpRequestor; +import com.dropbox.core.http.OkHttpRequestor; +import com.dropbox.core.http.StandardHttpRequestor; +import com.dropbox.core.json.JsonReader; +import com.dropbox.core.v1.DbxClientV1; +import com.dropbox.core.v2.DbxClientV2; +import com.dropbox.core.v2.files.DeleteErrorException; + +// integration test utility class +public final class ITUtil { + private static final String AUTH_INFO_FILE_PROPERTY = "com.dropbox.test.authInfoFile"; + private static final String AUTH_INFO_FILE = System.getProperty(AUTH_INFO_FILE_PROPERTY); + private static final Random RAND = new Random(0L); + private static final long READ_TIMEOUT = TimeUnit.SECONDS.toMillis(20); + private static final int MAX_RETRIES = 3; + private static final Charset UTF8 = Charset.forName("UTF-8"); + private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH.mm.ss"; + private static final TimeZone UTC = TimeZone.getTimeZone("UTC"); + + public static DbxRequestConfig.Builder newRequestConfig() { + DbxRequestConfig.Builder builder = DbxRequestConfig.newBuilder("sdk-test") + // enable auto-retry to avoid flakiness + .withAutoRetryEnabled(MAX_RETRIES) + .withUserLocaleFrom(Locale.US); + + String okHttp = System.getProperty("com.dropbox.test.okHttp"); + if (okHttp != null && !okHttp.equals("true") && !okHttp.equals("false")) { + fail("Invalid value for System property \"okHttp\"." + + " Expected \"true\" or \"false\", got \"" + okHttp + "\"."); + } + + if ("true".equals(okHttp)) { + builder.withHttpRequestor(newOkHttpRequestor()); + } else { + builder.withHttpRequestor(newStandardHttpRequestor()); + } + + return builder; + } + + public static HttpRequestor newOkHttpRequestor() { + OkHttpClient httpClient = OkHttpRequestor.INSTANCE.getClient().clone(); + httpClient.setReadTimeout(READ_TIMEOUT, TimeUnit.MILLISECONDS); + return new OkHttpRequestor(httpClient); + } + + public static HttpRequestor newStandardHttpRequestor() { + StandardHttpRequestor.Config config = StandardHttpRequestor.Config.builder() + .withReadTimeout(READ_TIMEOUT, TimeUnit.MILLISECONDS) + .build(); + return new StandardHttpRequestor(config); + } + + private static class AuthContainer { + public static final DbxAuthInfo AUTH = loadAuth(); + + private static DbxAuthInfo loadAuth() { + if (AUTH_INFO_FILE == null) { + fail("System property \"" + AUTH_INFO_FILE_PROPERTY + "\" not set."); + } + try { + return DbxAuthInfo.Reader.readFromFile(AUTH_INFO_FILE); + } catch (JsonReader.FileLoadException ex) { + fail("Error reading auth info from \"" + AUTH_INFO_FILE + "\"", ex); + throw new RuntimeException(ex); + } + } + } + + public static DbxAuthInfo getAuth() { + return AuthContainer.AUTH; + } + + public static DbxClientV1 newClientV1() { + return newClientV1(newRequestConfig()); + } + + public static DbxClientV1 newClientV1(DbxRequestConfig.Builder config) { + return newClientV1(config.build()); + } + + public static DbxClientV1 newClientV1(DbxRequestConfig config) { + DbxAuthInfo auth = getAuth(); + return new DbxClientV1( + config, + auth.getAccessToken(), + auth.getHost() + ); + } + + public static DbxClientV2 newClientV2() { + return newClientV2(newRequestConfig()); + } + + public static DbxClientV2 newClientV2(DbxRequestConfig.Builder config) { + return newClientV2(config.build()); + } + + public static DbxClientV2 newClientV2(DbxRequestConfig config) { + DbxAuthInfo auth = getAuth(); + return new DbxClientV2( + config, + auth.getAccessToken(), + auth.getHost() + ); + } + + private static final class RootContainer { + public static String ROOT = "/test/dropbox-sdk-java/" + format(new Date()); + } + + public static String root(Class clazz) { + return RootContainer.ROOT + "/" + clazz.getCanonicalName(); + } + + public static String path(Class clazz, String path) { + if (!path.startsWith("/") && !path.isEmpty()) { + path = "/" + path; + } + return root(clazz) + path; + } + + public static String format(Date date) { + DateFormat format = new SimpleDateFormat(DATE_FORMAT); + format.setTimeZone(UTC); + return format.format(date); + } + + public static byte [] randomBytes(int num) { + byte [] data = new byte[num]; + RAND.nextBytes(data); + return data; + } + + public static byte [] toBytes(String content) { + return content.getBytes(UTF8); + } + + @BeforeSuite + @AfterSuite(alwaysRun=true) + public static void deleteRoot() throws Exception { + try { + newClientV2().files().delete(RootContainer.ROOT); + } catch (DeleteErrorException ex) { + if (ex.errorValue.isPathLookup() && + ex.errorValue.getPathLookupValue().isNotFound()) { + // ignore + } else { + throw ex; + } + } + } +} diff --git a/src/test/java/com/dropbox/core/json/JsonUtilTest.java b/src/test/java/com/dropbox/core/stone/StoneSerializersTest.java similarity index 74% rename from src/test/java/com/dropbox/core/json/JsonUtilTest.java rename to src/test/java/com/dropbox/core/stone/StoneSerializersTest.java index 824f19b2c..aa7348c8c 100644 --- a/src/test/java/com/dropbox/core/json/JsonUtilTest.java +++ b/src/test/java/com/dropbox/core/stone/StoneSerializersTest.java @@ -1,9 +1,8 @@ -package com.dropbox.core.json; +package com.dropbox.core.stone; import static org.testng.Assert.*; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; import org.testng.annotations.Test; @@ -11,42 +10,41 @@ import java.util.Date; import java.util.TimeZone; -public class JsonUtilTest { +public class StoneSerializersTest { private static final TimeZone UTC = TimeZone.getTimeZone("UTC"); private static final String LONG_DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; private static final String SHORT_DATE_TIME_FORMAT = "yyyy-MM-dd"; @Test public void testV2Timestamps() throws Exception { - // v2 allows 2 different formats for Babel Timestamp fields: + // v2 allows 2 different formats for Stone Timestamp fields: // // DateTime format: Timestamp("%Y-%m-%dT%H:%M:%SZ") // Date format: Timestamp("%Y-%m-%d") // // The SDKs should be able to handle both formats. - ObjectMapper mapper = JsonUtil.getMapper(); // LONG FORMAT DESERIALIZATION String expectedTimestamp = "2016-03-08T21:38:04Z"; Date expected = fromTimestampString(expectedTimestamp); - Date actual = mapper.readValue(quoted(expectedTimestamp).getBytes("UTF-8"), Date.class); + Date actual = StoneSerializers.timestamp().deserialize(quoted(expectedTimestamp)); assertEquals(actual, expected); // LONG FORMAT SERIALIZATION - String actualTimestamp = mapper.writeValueAsString(expected); + String actualTimestamp = StoneSerializers.timestamp().serialize(expected); assertEquals(actualTimestamp, quoted(expectedTimestamp)); // SHORT FORMAT DESERIALIZATION String shortTimestamp = "2011-02-03"; expected = fromTimestampString(shortTimestamp); - actual = mapper.readValue(quoted(shortTimestamp).getBytes("UTF-8"), Date.class); + actual = StoneSerializers.timestamp().deserialize(quoted(shortTimestamp)); assertEquals(actual, expected); // SHORT FORMAT SERIALIZATION - actualTimestamp = mapper.writeValueAsString(expected); + actualTimestamp = StoneSerializers.timestamp().serialize(expected); // we always format to long-form expectedTimestamp = toTimestampString(expected); @@ -55,15 +53,19 @@ public void testV2Timestamps() throws Exception { @Test(expectedExceptions = JsonProcessingException.class) public void testV2BadLongTimestamp() throws Exception { - ObjectMapper mapper = JsonUtil.getMapper(); // we don't support milliseconds - mapper.readValue(quoted("2016-03-08T21:38:04.352+0500"), Date.class); + StoneSerializers.timestamp().deserialize(quoted("2016-03-08T21:38:04.352+0500")); } @Test(expectedExceptions = JsonProcessingException.class) public void testV2BadShortTimestamp() throws Exception { - ObjectMapper mapper = JsonUtil.getMapper(); - mapper.readValue(quoted("2016/03/08"), Date.class); + StoneSerializers.timestamp().deserialize(quoted("2016/03/08")); + } + + @Test + public void testDeserializeNonEmptyVoidType() throws Exception { + StoneSerializers.void_().deserialize("{\".tag\":\"foo\"}"); + StoneSerializers.void_().deserialize(quoted("bar")); } private static String quoted(String value) { diff --git a/src/test/java/com/dropbox/core/v1/DbxClientV1IT.java b/src/test/java/com/dropbox/core/v1/DbxClientV1IT.java index bbda3e0c7..9850fe244 100644 --- a/src/test/java/com/dropbox/core/v1/DbxClientV1IT.java +++ b/src/test/java/com/dropbox/core/v1/DbxClientV1IT.java @@ -3,14 +3,10 @@ import static org.testng.Assert.*; import static com.dropbox.core.util.StringUtil.jq; -import com.dropbox.core.DbxAuthInfo; import com.dropbox.core.DbxException; -import com.dropbox.core.DbxRequestConfig; import com.dropbox.core.DbxStreamWriter; +import com.dropbox.core.ITUtil; import com.dropbox.core.RetryException; -import com.dropbox.core.http.HttpRequestor; -import com.dropbox.core.http.OkHttpRequestor; -import com.dropbox.core.json.JsonReader; import com.dropbox.core.util.Dumpable; import com.dropbox.core.util.IOUtil; @@ -34,51 +30,17 @@ import java.util.*; // integration test -public class DbxClientV1IT -{ +public class DbxClientV1IT { private String testFolder; private DbxClientV1 client; - private static DbxRequestConfig.Builder createRequestConfig() { - DbxRequestConfig.Builder builder = DbxRequestConfig.newBuilder("sdk-test"); - - String okHttp = System.getProperty("okHttp"); - if (okHttp != null && !okHttp.equals("true") && !okHttp.equals("false")) { - throw new RuntimeException("Invalid value for System property \"okHttp\"." + - " Expected \"true\" or \"false\", got " + jq(okHttp) + "."); - } - - if ("true".equals(okHttp)) { - builder.withHttpRequestor(OkHttpRequestor.INSTANCE); - } - - return builder; - } - - /** * Every test must explicitly invoke this function so the reporting. */ // I tried using an @BeforeMethod annotation, but when I did that, any exceptions that this // method threw weren't reported in the output. - private void init() - throws DbxException - { - String authInfoFile = System.getProperty("dbxAuthInfoFile"); - if (authInfoFile == null) { - throw new RuntimeException("System property \"dbxAuthInfoFile\" not set."); - } - - DbxAuthInfo authInfo; - try { - authInfo = DbxAuthInfo.Reader.readFromFile(authInfoFile); - } - catch (JsonReader.FileLoadException ex) { - throw new RuntimeException("Error reading auth info from \"" + authInfoFile + "\": " + ex.getMessage()); - } - - DbxRequestConfig requestConfig = createRequestConfig().build(); - DbxClientV1 client = new DbxClientV1(requestConfig, authInfo.getAccessToken(), authInfo.getHost()); + private void init() throws DbxException { + DbxClientV1 client = ITUtil.newClientV1(); String timestamp = new SimpleDateFormat("yyyy-MM-dd HH.mm.ss").format(new Date()); String basePath = "/Java SDK Tests/" + timestamp; @@ -97,9 +59,7 @@ private void init() } @AfterMethod - private void cleanup() - throws DbxException - { + private void cleanup() throws DbxException { if (client != null) { client.delete(testFolder); } @@ -107,13 +67,11 @@ private void cleanup() testFolder = null; } - private String p(String path) - { + private String p(String path) { return this.testFolder + "/" + path; } - private String p() - { + private String p() { return this.testFolder; } @@ -162,8 +120,7 @@ private DbxEntry.File uploadFile(String path, int length, DbxWriteMode writeMode return client.uploadFile(path, writeMode, length, new ByteArrayInputStream(generateRandomBytes(length))); } - private static byte[] generateRandomBytes(int numBytes) - { + private static byte[] generateRandomBytes(int numBytes) { byte[] data = new byte[numBytes]; Random random = new Random(); for (int i = 0; i < numBytes; i++) { @@ -608,14 +565,12 @@ public void testThumbnail() } } - private static DbxEntry.File removeMediaInfo(DbxEntry.File e) - { + private static DbxEntry.File removeMediaInfo(DbxEntry.File e) { return new DbxEntry.File(e.path, e.iconName, e.mightHaveThumbnail, e.numBytes, e.humanSize, e.lastModified, e.clientMtime, e.rev); } - private static ImageReader getImageReaderForFormat(DbxThumbnailFormat format) - { + private static ImageReader getImageReaderForFormat(DbxThumbnailFormat format) { Iterator readers = ImageIO.getImageReadersByFormatName(format.ident); if (!readers.hasNext()) { @@ -629,9 +584,7 @@ private static ImageReader getImageReaderForFormat(DbxThumbnailFormat format) } @Test - public void testChunkedUpload() - throws DbxException, IOException - { + public void testChunkedUpload() throws DbxException, IOException { init(); byte[] contents = StringUtil.stringToUtf8("A simple test file"); @@ -689,9 +642,7 @@ public void testChunkedUpload() } @Test - public void testCopyFile() - throws DbxException, IOException - { + public void testCopyFile() throws DbxException, IOException { init(); String source = p("copy m" + E_ACCENT + ".txt"); @@ -708,9 +659,7 @@ public void testCopyFile() } @Test - public void testCopyFolder() - throws DbxException, IOException - { + public void testCopyFolder() throws DbxException, IOException { init(); String source = p("some folder"); @@ -729,9 +678,7 @@ public void testCopyFolder() } @Test - public void testCopyEmptyFolder() - throws DbxException, IOException - { + public void testCopyEmptyFolder() throws DbxException, IOException { init(); String source = p("empty folder"); @@ -748,9 +695,7 @@ public void testCopyEmptyFolder() } @Test - public void testCreateFolder() - throws DbxException, IOException - { + public void testCreateFolder() throws DbxException, IOException { init(); DbxEntry.WithChildren mwc = client.getMetadataWithChildren(p()); @@ -765,9 +710,7 @@ public void testCreateFolder() } @Test - public void testDelete() - throws DbxException, IOException - { + public void testDelete() throws DbxException, IOException { init(); String path = p("delete m" + E_ACCENT + ".txt"); @@ -781,9 +724,7 @@ public void testDelete() } @Test - public void testMoveFile() - throws DbxException, IOException - { + public void testMoveFile() throws DbxException, IOException { init(); String source = p("move me.txt"); @@ -802,9 +743,7 @@ public void testMoveFile() } @Test - public void testMoveFolder() - throws DbxException, IOException - { + public void testMoveFolder() throws DbxException, IOException { init(); String source = p("some folder"); @@ -827,9 +766,7 @@ public void testMoveFolder() } @Test - public void testMoveEmptyFolder() - throws DbxException, IOException - { + public void testMoveEmptyFolder() throws DbxException, IOException { init(); String source = p("empty folder"); diff --git a/src/test/java/com/dropbox/core/v2/DataTypeSerializationTest.java b/src/test/java/com/dropbox/core/v2/DataTypeSerializationTest.java deleted file mode 100644 index 0b956a41c..000000000 --- a/src/test/java/com/dropbox/core/v2/DataTypeSerializationTest.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.dropbox.core.v2; - -import static org.testng.Assert.*; - -import com.dropbox.core.json.JsonUtil; -import com.dropbox.core.v2.files.CommitInfo; -import com.dropbox.core.v2.files.DeletedMetadata; -import com.dropbox.core.v2.files.Dimensions; -import com.dropbox.core.v2.files.FileMetadata; -import com.dropbox.core.v2.files.FileSharingInfo; -import com.dropbox.core.v2.files.FolderMetadata; -import com.dropbox.core.v2.files.MediaInfo; -import com.dropbox.core.v2.files.MediaMetadata; -import com.dropbox.core.v2.files.Metadata; -import com.dropbox.core.v2.files.WriteMode; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import org.testng.annotations.Test; - -import java.util.Date; - -public class DataTypeSerializationTest { - private static final ObjectMapper JSON = JsonUtil.getMapper(); - - @Test - public void testDateTimestamp() throws Exception { - Date clientModified = new Date(1452816000000L); // 2016-01-15 - CommitInfo expected = CommitInfo.newBuilder("/path") - .withClientModified(clientModified) - .build(); - - String json = JSON.writeValueAsString(expected); - CommitInfo actual = JSON.readValue(json, CommitInfo.class); - - assertEquals(actual, expected); - - // explicitly use long date - json = "{\"path\":\"/path\",\"client_modified\":\"2016-01-15T00:00:00Z\"}"; - actual = JSON.readValue(json, CommitInfo.class); - - assertEquals(actual, expected); - - // use short date - json = "{\"path\":\"/path\",\"client_modified\":\"2016-01-15\"}"; - actual = JSON.readValue(json, CommitInfo.class); - - assertEquals(actual, expected); - } - - @Test - public void testEnumeratedSubtypes() throws Exception { - FileMetadata file = FileMetadata.newBuilder( - "foo.PNG", - "/path/foo.png", - "/path/foo.PNG", - "id:fyte8AYWx_AAAAAAAAAfgg", - new Date(1457477907029L), - new Date(1457479027750L), - "3cee38735597", - 18480 - ) - .withParentSharedFolderId("2") - .withSharingInfo(new FileSharingInfo(false, "2")) - .withMediaInfo( - MediaInfo.metadata( - MediaMetadata.newBuilder() - .withDimensions(new Dimensions(344, 373)) - .withTimeTaken(new Date(1457477906315L)) - .build() - ) - ) - .build(); - - FolderMetadata folder = new FolderMetadata( - "/Photos", - "/photos", - "/Photos", - "id:fyte8AYWx_AAAAAAAAAf8w" - ); - - DeletedMetadata deleted = new DeletedMetadata( - "Old.log", - "/logs/old.log", - "/logs/Old.log" - ); - - Metadata metadata = new Metadata( - "generic", - "/generic", - "/generic" - ); - - String json = JSON.writeValueAsString(file); - Metadata actual = JSON.readValue(json, Metadata.class); - - assertEquals(actual.getClass(), FileMetadata.class); - assertEquals(actual, file); - - json = JSON.writeValueAsString(folder); - actual = JSON.readValue(json, Metadata.class); - - assertEquals(actual.getClass(), FolderMetadata.class); - assertEquals(actual, folder); - - json = JSON.writeValueAsString(deleted); - actual = JSON.readValue(json, Metadata.class); - - assertEquals(actual.getClass(), DeletedMetadata.class); - assertEquals(actual, deleted); - - json = JSON.writeValueAsString(metadata); - actual = JSON.readValue(json, Metadata.class); - - assertEquals(actual.getClass(), Metadata.class); - assertEquals(actual, metadata); - - // check that we can deserialize as the specific type if necessary. - json = JSON.writeValueAsString(file); - actual = JSON.readValue(json, FileMetadata.class); - - assertEquals(actual.getClass(), FileMetadata.class); - assertEquals(actual, file); - } - - @Test - public void testOptionalPrimitives() throws Exception { - // make sure optional primitives are deserialized properly - CommitInfo expected = CommitInfo.newBuilder("/foo/bar.txt") - .build(); - - String json = "{\"path\":\"/foo/bar.txt\"}"; - CommitInfo actual = JSON.readValue(json, CommitInfo.class); - - assertEquals(actual, expected); - - // set the optional fields - expected = CommitInfo.newBuilder("/foo/bar.txt") - .withMode(WriteMode.update("123456789")) - .withAutorename(true) - .withClientModified(new Date(123456789000L)) - .withMute(true) - .build(); - - json = JSON.writeValueAsString(expected); - actual = JSON.readValue(json, CommitInfo.class); - - assertEquals(actual, expected); - } -} diff --git a/src/test/java/com/dropbox/core/v2/DbxClientV2IT.java b/src/test/java/com/dropbox/core/v2/DbxClientV2IT.java new file mode 100644 index 000000000..060080de4 --- /dev/null +++ b/src/test/java/com/dropbox/core/v2/DbxClientV2IT.java @@ -0,0 +1,276 @@ +package com.dropbox.core.v2; + +import static org.testng.Assert.*; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.util.Date; +import java.util.Locale; + +import org.testng.annotations.Test; + +import com.dropbox.core.BadRequestException; +import com.dropbox.core.DbxApiException; +import com.dropbox.core.DbxDownloader; +import com.dropbox.core.ITUtil; +import com.dropbox.core.v2.files.FileMetadata; +import com.dropbox.core.v2.files.GetMetadataError; +import com.dropbox.core.v2.files.GetMetadataErrorException; +import com.dropbox.core.v2.files.LookupError; +import com.dropbox.core.v2.files.Metadata; +import com.dropbox.core.v2.files.WriteMode; +import com.dropbox.core.v2.users.BasicAccount; +import com.dropbox.core.v2.users.FullAccount; + +public class DbxClientV2IT { + @Test + public void testAccountInfo() throws Exception { + DbxClientV2 client = ITUtil.newClientV2(); + + FullAccount full = client.users().getCurrentAccount(); + assertNotNull(full); + assertNotNull(full.getName()); + assertNotNull(full.getAccountId()); + + BasicAccount basic = client.users().getAccount(full.getAccountId()); + assertNotNull(basic); + assertNotNull(basic.getName()); + assertEquals(basic.getAccountId(), full.getAccountId()); + } + + @Test + public void testUploadAndDownload() throws Exception { + DbxClientV2 client = ITUtil.newClientV2(); + + byte [] contents = ITUtil.randomBytes(1024); + String filename = "testUploadAndDownload.dat"; + String path = ITUtil.path(getClass(), "/" + filename); + + FileMetadata metadata = client.files().uploadBuilder(path) + .withAutorename(false) + .withMode(WriteMode.ADD) + .withMute(true) + .uploadAndFinish(new ByteArrayInputStream(contents)); + + assertEquals(metadata.getName(), filename); + assertEquals(metadata.getPathLower(), path.toLowerCase()); + assertEquals(metadata.getSize(), contents.length); + + Metadata actual = client.files().getMetadata(path); + assertTrue(actual instanceof FileMetadata, actual.getClass().getCanonicalName()); + assertEquals(actual, metadata); + + DbxDownloader downloader = client.files().download(path); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + downloader.download(out); + + byte [] actualContents = out.toByteArray(); + FileMetadata actualResult = downloader.getResult(); + + assertEquals(actualResult, metadata); + assertEquals(actualContents, contents); + + Metadata deleted = client.files().delete(path); + assertEquals(deleted, metadata); + } + + @Test + public void testRangeDownload() throws Exception { + DbxClientV2 client = ITUtil.newClientV2(); + + byte [] contents = ITUtil.randomBytes(500); + String path = ITUtil.path(getClass(), "/testRangeDownload.dat"); + + FileMetadata metadata = client.files().uploadBuilder(path) + .withAutorename(false) + .withMode(WriteMode.OVERWRITE) + .withMute(true) + .uploadAndFinish(new ByteArrayInputStream(contents)); + + assertEquals(metadata.getSize(), contents.length); + + assertRangeDownload(client, path, contents, 0, contents.length); + assertRangeDownload(client, path, contents, 0, 200); + assertRangeDownload(client, path, contents, 300, 200); + assertRangeDownload(client, path, contents, 499, 1); + assertRangeDownload(client, path, contents, 0, 600); + assertRangeDownload(client, path, contents, 250, null); + } + + @Test + public void testDownloadBuilder() throws Exception { + DbxClientV2 client = ITUtil.newClientV2(); + String now = ITUtil.format(new Date()); + + byte [] rtfV1 = ITUtil.toBytes("{\rtf1 sample {\b v1} (" + now + ")}"); + byte [] rtfV2 = ITUtil.toBytes("{\rtf1 sample {\b v2} (" + now + ")}"); + + String path = ITUtil.path(getClass(), "/testDownloadBuilder/" + now + ".rtf"); + + FileMetadata metadataV1 = client.files().uploadBuilder(path) + .withAutorename(false) + .withMode(WriteMode.ADD) + .withMute(true) + .uploadAndFinish(new ByteArrayInputStream(rtfV1)); + + assertEquals(metadataV1.getPathLower(), path.toLowerCase()); + + FileMetadata metadataV2 = client.files().uploadBuilder(path) + .withAutorename(false) + .withMode(WriteMode.OVERWRITE) + .withMute(true) + .uploadAndFinish(new ByteArrayInputStream(rtfV2)); + + assertEquals(metadataV2.getPathLower(), path.toLowerCase()); + + // ensure we have separate revisions + assertNotEquals(metadataV1.getRev(), metadataV2.getRev()); + + // now use download builder to set revision and make sure it works properly + ByteArrayOutputStream out = new ByteArrayOutputStream(); + client.files().downloadBuilder(path) + .withRev(metadataV1.getRev()) + .download(out); + assertEquals(out.toByteArray(), rtfV1); + + out = new ByteArrayOutputStream(); + client.files().downloadBuilder(path) + .withRev(metadataV2.getRev()) + .download(out); + assertEquals(out.toByteArray(), rtfV2); + + // ensure we still keep the non-builder optional route in our generator (for + // backwards-compatibility) + out = new ByteArrayOutputStream(); + client.files().download(path, metadataV1.getRev()).download(out); + assertEquals(out.toByteArray(), rtfV1); + + out = new ByteArrayOutputStream(); + client.files().download(path, metadataV2.getRev()).download(out); + assertEquals(out.toByteArray(), rtfV2); + + // and ensure we keep the required-only route + out = new ByteArrayOutputStream(); + client.files().download(path).download(out); + assertEquals(out.toByteArray(), rtfV2); + } + + @Test(expectedExceptions={GetMetadataErrorException.class}) + public void testError409() throws Exception { + DbxClientV2 client = ITUtil.newClientV2(); + + String path = ITUtil.path(getClass(), "/testError409/" + ITUtil.format(new Date())); + + try { + client.files().getMetadata(path); + } catch (GetMetadataErrorException ex) { + assertNotNull(ex.getRequestId()); + if (ex.getUserMessage() != null) { + assertNotNull(ex.getUserMessage().getLocale()); + assertNotNull(ex.getUserMessage().getText()); + assertNotNull(ex.getUserMessage().toString()); + } + + GetMetadataError err = ex.errorValue; + assertNotNull(err); + assertEquals(err.tag(), GetMetadataError.Tag.PATH); + assertTrue(err.isPath()); + + LookupError lookup = err.getPathValue(); + assertNotNull(lookup); + assertEquals(lookup.tag(), LookupError.Tag.NOT_FOUND); + assertTrue(lookup.isNotFound()); + assertFalse(lookup.isNotFile()); + assertFalse(lookup.isOther()); + assertFalse(lookup.isMalformedPath()); + + // raise so test can confirm an exception was thrown + throw ex; + } + } + + @Test(expectedExceptions={BadRequestException.class}) + public void testError400() throws Exception { + DbxClientV2 client = ITUtil.newClientV2(); + + // NOTE: if we become more lenient on the server, this test will have to change. + String badCursor = "thisisabadcursor_dropbox-sdk-java_test"; + + try { + client.files().listFolderContinue(badCursor); + } catch (BadRequestException ex) { + assertNotNull(ex.getRequestId()); + throw ex; + } + } + + @Test(enabled=false) // re-enable after T90620 is fixed + public void testUserLocale() throws Exception { + assertUserMessageLocale(Locale.ENGLISH); // en + assertUserMessageLocale(Locale.UK); // en-UK + assertUserMessageLocale(Locale.FRENCH); // fr + assertUserMessageLocale(Locale.FRANCE); // fr-FR + + // Use user's Dropbox locale preference + DbxClientV2 client = ITUtil.newClientV2(ITUtil.newRequestConfig().withUserLocaleFromPreferences()); + try { + client.sharing().getFolderMetadata("-1"); + } catch (DbxApiException ex) { + assertNotNull(ex.getUserMessage()); + assertNotNull(ex.getUserMessage().getLocale()); + assertNotEquals(ex.getUserMessage().getLocale(), ""); // make sure something is specified + } + } + + private static void assertRangeDownload(DbxClientV2 client, String path, byte [] contents, int start, Integer length) throws Exception { + ByteArrayOutputStream out = new ByteArrayOutputStream(contents.length); + byte [] expected; + if (length != null) { + expected = new byte[Math.min(length, contents.length - start)]; + client.files().downloadBuilder(path) + .range(start, length.intValue()) + .download(out); + } else { + expected = new byte[contents.length - start]; + client.files().downloadBuilder(path) + .range(start) + .download(out); + } + + System.arraycopy(contents, start, expected, 0, expected.length); + byte [] actual = out.toByteArray(); + + assertEquals(actual, expected); + } + + private static void assertUserMessageLocale(Locale locale) throws Exception { + DbxClientV2 client = ITUtil.newClientV2(ITUtil.newRequestConfig().withUserLocaleFrom(locale)); + try { + client.sharing().getFolderMetadata("-1"); + } catch (DbxApiException ex) { + assertNotNull(ex.getUserMessage()); + assertNotNull(ex.getUserMessage().getLocale()); + if (ex.getUserMessage().getLocale().contains("-")) { + // TODO: update this test to properly support language tags when we upgrade away + // from Java 6 + assertEquals(ex.getUserMessage().getLocale(), toLanguageTag(locale)); + } else { + // omit the country code + assertEquals(ex.getUserMessage().getLocale(), locale.getLanguage()); + } + } + } + + private static String toLanguageTag(Locale locale) { + StringBuilder sb = new StringBuilder(); + + sb.append(locale.getLanguage().toLowerCase()); + + if (!locale.getCountry().isEmpty()) { + sb.append("-"); + sb.append(locale.getCountry().toUpperCase()); + } + + return sb.toString(); + } +} diff --git a/src/test/java/com/dropbox/core/v2/DbxClientV2Test.java b/src/test/java/com/dropbox/core/v2/DbxClientV2Test.java index c38c094ec..db080284e 100644 --- a/src/test/java/com/dropbox/core/v2/DbxClientV2Test.java +++ b/src/test/java/com/dropbox/core/v2/DbxClientV2Test.java @@ -2,9 +2,9 @@ import static org.mockito.Mockito.*; import static org.testng.Assert.*; +import static com.dropbox.core.v2.files.FilesSerializers.serializer; import com.dropbox.core.http.HttpRequestor; -import com.dropbox.core.json.JsonUtil; import com.dropbox.core.v2.files.FileMetadata; import com.dropbox.core.v2.files.Metadata; import com.dropbox.core.util.IOUtil; @@ -14,8 +14,6 @@ import com.dropbox.core.DbxRequestConfig; import com.dropbox.core.RetryException; -import com.fasterxml.jackson.databind.ObjectMapper; - import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.mockito.Matchers; @@ -35,7 +33,6 @@ import java.util.TreeMap; public class DbxClientV2Test { - private static final ObjectMapper JSON = JsonUtil.getMapper(); // default config private static DbxRequestConfig.Builder createRequestConfig() { @@ -323,14 +320,16 @@ private static Iterable anyHeaders() { return Matchers.>any(); } - private static byte [] serialize(Object obj) { - assertNotNull(obj); + private static byte [] serialize(Metadata metadata) { + assertNotNull(metadata); + ByteArrayOutputStream out = new ByteArrayOutputStream(); try { - return JSON.writeValueAsBytes(obj); + serializer(Metadata.class).serialize(metadata, out); } catch (Exception ex) { - fail("unserializable type: " + obj.getClass(), ex); + fail("unserializable type: " + metadata.getClass(), ex); return null; } + return out.toByteArray(); } } diff --git a/src/test/java/com/dropbox/core/v2/files/DataTypeSerializationTest.java b/src/test/java/com/dropbox/core/v2/files/DataTypeSerializationTest.java new file mode 100644 index 000000000..3d7c77c2b --- /dev/null +++ b/src/test/java/com/dropbox/core/v2/files/DataTypeSerializationTest.java @@ -0,0 +1,196 @@ +package com.dropbox.core.v2.files; + +import static org.testng.Assert.*; + +import java.io.IOException; + +import org.testng.annotations.Test; + +import java.util.Date; + +public class DataTypeSerializationTest { + + @Test + public void testPreClassInitializationDeserialization() throws Exception { + // verify that we can deserialize JSON for a class that has not yet been initialized + // (e.g. no instances or fields have been accessed for this class yet) + String json = "{\"reason\":{\".tag\":\"conflict\",\"conflict\":\"file\"},\"upload_session_id\":\"uploadid:12345\"}"; + UploadWriteFailed actual = UploadWriteFailed.Serializer.INSTANCE.deserialize(json); + assertEquals(actual.getUploadSessionId(), "uploadid:12345"); + assertEquals(actual.getReason().tag(), WriteError.Tag.CONFLICT); + assertEquals(actual.getReason().getConflictValue(), WriteConflictError.FILE); + } + + @Test + public void testCatchAllDeserialization() throws Exception { + String json = "{\".tag\":\"path\",\"path\":\"test_unknown_tag\"}"; + ListFolderError actual = ListFolderError.Serializer.INSTANCE.deserialize(json); + assertEquals(actual.tag(), ListFolderError.Tag.PATH); + assertEquals(actual.getPathValue(), LookupError.OTHER); + + json = "{\".tag\":\"path\",\"path\":{\".tag\":\"test_unknown_tag\",\"test\":true}}"; + actual = ListFolderError.Serializer.INSTANCE.deserialize(json); + assertEquals(actual.tag(), ListFolderError.Tag.PATH); + assertEquals(actual.getPathValue(), LookupError.OTHER); + + json = "\"test_unknown_tag\""; + actual = ListFolderError.Serializer.INSTANCE.deserialize(json); + assertNotNull(actual); + assertEquals(actual.tag(), ListFolderError.Tag.OTHER); + } + + @Test(expectedExceptions={IOException.class}) + public void testNoCatchAllDeserialization() throws Exception { + String json = "\"fake_img_format\""; + // ThumbnailFormat union has no catch-all + ThumbnailFormat.Serializer.INSTANCE.deserialize(json); + } + + @Test + public void testOutOfOrderFields() throws Exception { + String json = "{\"width\":1024,\"height\":768}"; + Dimensions expected = new Dimensions(768, 1024); + Dimensions actual = Dimensions.Serializer.INSTANCE.deserialize(json); + + assertEquals(actual, expected); + + json = "{\"height\":768,\"width\":1024}"; + actual = Dimensions.Serializer.INSTANCE.deserialize(json); + + assertEquals(actual, expected); + } + + @Test + public void testUnknownStructFields() throws Exception { + String json = "{\"height\":768,\"alpha\":0.5,\"width\":1024,\"foo\":{\"bar\":[1, 2, 3],\"baz\":false}}"; + Dimensions expected = new Dimensions(768, 1024); + Dimensions actual = Dimensions.Serializer.INSTANCE.deserialize(json); + + assertEquals(actual, expected); + } + + @Test + public void testDateTimestamp() throws Exception { + Date clientModified = new Date(1452816000000L); // 2016-01-15 + CommitInfo expected = CommitInfo.newBuilder("/path") + .withClientModified(clientModified) + .build(); + + String json = CommitInfo.Serializer.INSTANCE.serialize(expected); + CommitInfo actual = CommitInfo.Serializer.INSTANCE.deserialize(json); + + assertEquals(actual, expected); + + // explicitly use long date + json = "{\"path\":\"/path\",\"client_modified\":\"2016-01-15T00:00:00Z\"}"; + actual = CommitInfo.Serializer.INSTANCE.deserialize(json); + + assertEquals(actual, expected); + + // use short date + json = "{\"path\":\"/path\",\"client_modified\":\"2016-01-15\"}"; + actual = CommitInfo.Serializer.INSTANCE.deserialize(json); + + assertEquals(actual, expected); + } + + @Test + public void testEnumeratedSubtypes() throws Exception { + FileMetadata file = FileMetadata.newBuilder( + "foo.PNG", + "/path/foo.png", + "/path/foo.PNG", + "id:fyte8AYWx_AAAAAAAAAfgg", + new Date(1457477907029L), + new Date(1457479027750L), + "3cee38735597", + 18480 + ) + .withParentSharedFolderId("2") + .withSharingInfo(new FileSharingInfo(false, "2")) + .withMediaInfo( + MediaInfo.metadata( + MediaMetadata.newBuilder() + .withDimensions(new Dimensions(344, 373)) + .withTimeTaken(new Date(1457477906315L)) + .build() + ) + ) + .build(); + + FolderMetadata folder = new FolderMetadata( + "/Photos", + "/photos", + "/Photos", + "id:fyte8AYWx_AAAAAAAAAf8w" + ); + + DeletedMetadata deleted = new DeletedMetadata( + "Old.log", + "/logs/old.log", + "/logs/Old.log" + ); + + Metadata metadata = new Metadata( + "generic", + "/generic", + "/generic" + ); + + String json = FileMetadata.Serializer.INSTANCE.serialize(file); + Metadata actual = Metadata.Serializer.INSTANCE.deserialize(json); + + assertEquals(actual.getClass(), FileMetadata.class); + assertEquals(actual, file); + + json = FolderMetadata.Serializer.INSTANCE.serialize(folder); + actual = Metadata.Serializer.INSTANCE.deserialize(json); + + assertEquals(actual.getClass(), FolderMetadata.class); + assertEquals(actual, folder); + + json = DeletedMetadata.Serializer.INSTANCE.serialize(deleted); + actual = Metadata.Serializer.INSTANCE.deserialize(json); + + assertEquals(actual.getClass(), DeletedMetadata.class); + assertEquals(actual, deleted); + + json = Metadata.Serializer.INSTANCE.serialize(metadata); + actual = Metadata.Serializer.INSTANCE.deserialize(json); + + assertEquals(actual.getClass(), Metadata.class); + assertEquals(actual, metadata); + + // check that we can deserialize as the specific type if necessary. + json = FileMetadata.Serializer.INSTANCE.serialize(file); + actual = FileMetadata.Serializer.INSTANCE.deserialize(json); + + assertEquals(actual.getClass(), FileMetadata.class); + assertEquals(actual, file); + } + + @Test + public void testOptionalPrimitives() throws Exception { + // make sure optional primitives are deserialized properly + CommitInfo expected = CommitInfo.newBuilder("/foo/bar.txt") + .build(); + + String json = "{\"path\":\"/foo/bar.txt\"}"; + CommitInfo actual = CommitInfo.Serializer.INSTANCE.deserialize(json); + + assertEquals(actual, expected); + + // set the optional fields + expected = CommitInfo.newBuilder("/foo/bar.txt") + .withMode(WriteMode.update("123456789")) + .withAutorename(true) + .withClientModified(new Date(123456789000L)) + .withMute(true) + .build(); + + json = CommitInfo.Serializer.INSTANCE.serialize(expected); + actual = CommitInfo.Serializer.INSTANCE.deserialize(json); + + assertEquals(actual, expected); + } +} diff --git a/src/test/java/com/dropbox/core/v2/files/FilesSerializers.java b/src/test/java/com/dropbox/core/v2/files/FilesSerializers.java new file mode 100644 index 000000000..4632b2ccd --- /dev/null +++ b/src/test/java/com/dropbox/core/v2/files/FilesSerializers.java @@ -0,0 +1,21 @@ +package com.dropbox.core.v2.files; + +import static org.testng.Assert.fail; + +import com.dropbox.core.stone.StoneSerializer; + +/** + * Since serializers are often package private, expose them through + * this utility class. + */ +public final class FilesSerializers { + @SuppressWarnings("unchecked") + public static StoneSerializer serializer(Class dataType) { + if (Metadata.class.isAssignableFrom(dataType)) { + return (StoneSerializer) Metadata.Serializer.INSTANCE; + } else { + fail("Required serializer not added to FilesSerializers: " + dataType); + return null; + } + } +}