001package com.box.sdkgen.schemas.searchresultwithsharedlinkitem; 002 003import com.box.sdkgen.internal.OneOfThree; 004import com.box.sdkgen.schemas.collection.Collection; 005import com.box.sdkgen.schemas.filefull.FileFull; 006import com.box.sdkgen.schemas.folderfull.FolderFull; 007import com.box.sdkgen.schemas.foldermini.FolderMini; 008import com.box.sdkgen.schemas.usermini.UserMini; 009import com.box.sdkgen.schemas.weblink.WebLink; 010import com.box.sdkgen.serialization.json.EnumWrapper; 011import com.box.sdkgen.serialization.json.JsonManager; 012import com.fasterxml.jackson.core.JsonParser; 013import com.fasterxml.jackson.databind.DeserializationContext; 014import com.fasterxml.jackson.databind.JsonDeserializer; 015import com.fasterxml.jackson.databind.JsonMappingException; 016import com.fasterxml.jackson.databind.JsonNode; 017import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 018import com.fasterxml.jackson.databind.annotation.JsonSerialize; 019import java.io.IOException; 020import java.time.OffsetDateTime; 021import java.util.List; 022 023@JsonDeserialize( 024 using = SearchResultWithSharedLinkItem.SearchResultWithSharedLinkItemDeserializer.class) 025@JsonSerialize(using = OneOfThree.OneOfThreeSerializer.class) 026public class SearchResultWithSharedLinkItem extends OneOfThree<FileFull, FolderFull, WebLink> { 027 028 protected final List<Collection> collections; 029 030 protected final List<String> allowedSharedLinkAccessLevels; 031 032 protected final String description; 033 034 protected final OffsetDateTime createdAt; 035 036 protected final OffsetDateTime modifiedAt; 037 038 protected final OffsetDateTime trashedAt; 039 040 protected final OffsetDateTime purgedAt; 041 042 protected final UserMini createdBy; 043 044 protected final UserMini modifiedBy; 045 046 protected final UserMini ownedBy; 047 048 protected final FolderMini parent; 049 050 protected final String itemStatus; 051 052 protected final String sequenceId; 053 054 protected final String name; 055 056 protected final String id; 057 058 protected final String etag; 059 060 protected final String type; 061 062 public SearchResultWithSharedLinkItem(FileFull fileFull) { 063 super(fileFull, null, null); 064 this.collections = fileFull.getCollections(); 065 this.allowedSharedLinkAccessLevels = 066 EnumWrapper.convertToString(fileFull.getAllowedSharedLinkAccessLevels()); 067 this.description = fileFull.getDescription(); 068 this.createdAt = fileFull.getCreatedAt(); 069 this.modifiedAt = fileFull.getModifiedAt(); 070 this.trashedAt = fileFull.getTrashedAt(); 071 this.purgedAt = fileFull.getPurgedAt(); 072 this.createdBy = fileFull.getCreatedBy(); 073 this.modifiedBy = fileFull.getModifiedBy(); 074 this.ownedBy = fileFull.getOwnedBy(); 075 this.parent = fileFull.getParent(); 076 this.itemStatus = EnumWrapper.convertToString(fileFull.getItemStatus()); 077 this.sequenceId = fileFull.getSequenceId(); 078 this.name = fileFull.getName(); 079 this.id = fileFull.getId(); 080 this.etag = fileFull.getEtag(); 081 this.type = EnumWrapper.convertToString(fileFull.getType()); 082 } 083 084 public SearchResultWithSharedLinkItem(FolderFull folderFull) { 085 super(null, folderFull, null); 086 this.collections = folderFull.getCollections(); 087 this.allowedSharedLinkAccessLevels = 088 EnumWrapper.convertToString(folderFull.getAllowedSharedLinkAccessLevels()); 089 this.description = folderFull.getDescription(); 090 this.createdAt = folderFull.getCreatedAt(); 091 this.modifiedAt = folderFull.getModifiedAt(); 092 this.trashedAt = folderFull.getTrashedAt(); 093 this.purgedAt = folderFull.getPurgedAt(); 094 this.createdBy = folderFull.getCreatedBy(); 095 this.modifiedBy = folderFull.getModifiedBy(); 096 this.ownedBy = folderFull.getOwnedBy(); 097 this.parent = folderFull.getParent(); 098 this.itemStatus = EnumWrapper.convertToString(folderFull.getItemStatus()); 099 this.sequenceId = folderFull.getSequenceId(); 100 this.name = folderFull.getName(); 101 this.id = folderFull.getId(); 102 this.etag = folderFull.getEtag(); 103 this.type = EnumWrapper.convertToString(folderFull.getType()); 104 } 105 106 public SearchResultWithSharedLinkItem(WebLink webLink) { 107 super(null, null, webLink); 108 this.collections = webLink.getCollections(); 109 this.allowedSharedLinkAccessLevels = 110 EnumWrapper.convertToString(webLink.getAllowedSharedLinkAccessLevels()); 111 this.description = webLink.getDescription(); 112 this.createdAt = webLink.getCreatedAt(); 113 this.modifiedAt = webLink.getModifiedAt(); 114 this.trashedAt = webLink.getTrashedAt(); 115 this.purgedAt = webLink.getPurgedAt(); 116 this.createdBy = webLink.getCreatedBy(); 117 this.modifiedBy = webLink.getModifiedBy(); 118 this.ownedBy = webLink.getOwnedBy(); 119 this.parent = webLink.getParent(); 120 this.itemStatus = EnumWrapper.convertToString(webLink.getItemStatus()); 121 this.sequenceId = webLink.getSequenceId(); 122 this.name = webLink.getName(); 123 this.id = webLink.getId(); 124 this.etag = webLink.getEtag(); 125 this.type = EnumWrapper.convertToString(webLink.getType()); 126 } 127 128 public boolean isFileFull() { 129 return value0 != null; 130 } 131 132 public FileFull getFileFull() { 133 return value0; 134 } 135 136 public boolean isFolderFull() { 137 return value1 != null; 138 } 139 140 public FolderFull getFolderFull() { 141 return value1; 142 } 143 144 public boolean isWebLink() { 145 return value2 != null; 146 } 147 148 public WebLink getWebLink() { 149 return value2; 150 } 151 152 public List<Collection> getCollections() { 153 return collections; 154 } 155 156 public List<String> getAllowedSharedLinkAccessLevels() { 157 return allowedSharedLinkAccessLevels; 158 } 159 160 public String getDescription() { 161 return description; 162 } 163 164 public OffsetDateTime getCreatedAt() { 165 return createdAt; 166 } 167 168 public OffsetDateTime getModifiedAt() { 169 return modifiedAt; 170 } 171 172 public OffsetDateTime getTrashedAt() { 173 return trashedAt; 174 } 175 176 public OffsetDateTime getPurgedAt() { 177 return purgedAt; 178 } 179 180 public UserMini getCreatedBy() { 181 return createdBy; 182 } 183 184 public UserMini getModifiedBy() { 185 return modifiedBy; 186 } 187 188 public UserMini getOwnedBy() { 189 return ownedBy; 190 } 191 192 public FolderMini getParent() { 193 return parent; 194 } 195 196 public String getItemStatus() { 197 return itemStatus; 198 } 199 200 public String getSequenceId() { 201 return sequenceId; 202 } 203 204 public String getName() { 205 return name; 206 } 207 208 public String getId() { 209 return id; 210 } 211 212 public String getEtag() { 213 return etag; 214 } 215 216 public String getType() { 217 return type; 218 } 219 220 static class SearchResultWithSharedLinkItemDeserializer 221 extends JsonDeserializer<SearchResultWithSharedLinkItem> { 222 223 public SearchResultWithSharedLinkItemDeserializer() { 224 super(); 225 } 226 227 @Override 228 public SearchResultWithSharedLinkItem deserialize(JsonParser jp, DeserializationContext ctxt) 229 throws IOException { 230 JsonNode node = JsonManager.jsonToSerializedData(jp); 231 JsonNode discriminant0 = node.get("type"); 232 if (!(discriminant0 == null)) { 233 switch (discriminant0.asText()) { 234 case "file": 235 return new SearchResultWithSharedLinkItem( 236 JsonManager.deserialize(node, FileFull.class)); 237 case "folder": 238 return new SearchResultWithSharedLinkItem( 239 JsonManager.deserialize(node, FolderFull.class)); 240 case "web_link": 241 return new SearchResultWithSharedLinkItem(JsonManager.deserialize(node, WebLink.class)); 242 } 243 } 244 throw new JsonMappingException(jp, "Unable to deserialize SearchResultWithSharedLinkItem"); 245 } 246 } 247}