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