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