001package com.box.sdkgen.schemas.folder; 002 003import com.box.sdkgen.internal.Nullable; 004import com.box.sdkgen.internal.utils.DateTimeUtils; 005import com.box.sdkgen.schemas.folderbase.FolderBaseTypeField; 006import com.box.sdkgen.schemas.foldermini.FolderMini; 007import com.box.sdkgen.schemas.items.Items; 008import com.box.sdkgen.schemas.usermini.UserMini; 009import com.box.sdkgen.serialization.json.EnumWrapper; 010import com.fasterxml.jackson.annotation.JsonFilter; 011import com.fasterxml.jackson.annotation.JsonProperty; 012import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 013import com.fasterxml.jackson.databind.annotation.JsonSerialize; 014import java.time.OffsetDateTime; 015import java.util.Objects; 016 017/** A standard representation of a folder, as returned from any folder API endpoints by default. */ 018@JsonFilter("nullablePropertyFilter") 019public class Folder extends FolderMini { 020 021 /** 022 * The date and time when the folder was created. This value may be `null` for some folders such 023 * as the root folder or the trash folder. 024 */ 025 @JsonProperty("created_at") 026 @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class) 027 @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class) 028 @Nullable 029 protected OffsetDateTime createdAt; 030 031 /** 032 * The date and time when the folder was last updated. This value may be `null` for some folders 033 * such as the root folder or the trash folder. 034 */ 035 @JsonProperty("modified_at") 036 @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class) 037 @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class) 038 @Nullable 039 protected OffsetDateTime modifiedAt; 040 041 protected String description; 042 043 /** 044 * The folder size in bytes. 045 * 046 * <p>Be careful parsing this integer as its value can get very large. 047 */ 048 protected Long size; 049 050 @JsonProperty("path_collection") 051 protected FolderPathCollectionField pathCollection; 052 053 @JsonProperty("created_by") 054 protected UserMini createdBy; 055 056 @JsonProperty("modified_by") 057 protected UserMini modifiedBy; 058 059 /** The time at which this folder was put in the trash. */ 060 @JsonProperty("trashed_at") 061 @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class) 062 @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class) 063 @Nullable 064 protected OffsetDateTime trashedAt; 065 066 /** The time at which this folder is expected to be purged from the trash. */ 067 @JsonProperty("purged_at") 068 @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class) 069 @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class) 070 @Nullable 071 protected OffsetDateTime purgedAt; 072 073 /** The date and time at which this folder was originally created. */ 074 @JsonProperty("content_created_at") 075 @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class) 076 @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class) 077 @Nullable 078 protected OffsetDateTime contentCreatedAt; 079 080 /** The date and time at which this folder was last updated. */ 081 @JsonProperty("content_modified_at") 082 @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class) 083 @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class) 084 @Nullable 085 protected OffsetDateTime contentModifiedAt; 086 087 @JsonProperty("owned_by") 088 protected UserMini ownedBy; 089 090 @JsonProperty("shared_link") 091 @Nullable 092 protected FolderSharedLinkField sharedLink; 093 094 /** 095 * The `folder_upload_email` parameter is not `null` if one of the following options is **true**: 096 * 097 * <p>* The **Allow uploads to this folder via email** and the **Only allow email uploads from 098 * collaborators in this folder** are [enabled for a folder in the Admin 099 * Console](https://support.box.com/hc/en-us/articles/360043697534-Upload-to-Box-Through-Email), 100 * and the user has at least **Upload** permissions granted. 101 * 102 * <p>* The **Allow uploads to this folder via email** setting is enabled for a folder in the 103 * Admin Console, and the **Only allow email uploads from collaborators in this folder** setting 104 * is deactivated (unchecked). 105 * 106 * <p>If the conditions are not met, the parameter will have the following value: 107 * `folder_upload_email: null`. 108 */ 109 @JsonProperty("folder_upload_email") 110 @Nullable 111 protected FolderFolderUploadEmailField folderUploadEmail; 112 113 @Nullable protected FolderMini parent; 114 115 /** 116 * Defines if this item has been deleted or not. 117 * 118 * <p>* `active` when the item has is not in the trash * `trashed` when the item has been moved to 119 * the trash but not deleted * `deleted` when the item has been permanently deleted. 120 */ 121 @JsonDeserialize(using = FolderItemStatusField.FolderItemStatusFieldDeserializer.class) 122 @JsonSerialize(using = FolderItemStatusField.FolderItemStatusFieldSerializer.class) 123 @JsonProperty("item_status") 124 protected EnumWrapper<FolderItemStatusField> itemStatus; 125 126 @JsonProperty("item_collection") 127 protected Items itemCollection; 128 129 public Folder(@JsonProperty("id") String id) { 130 super(id); 131 } 132 133 protected Folder(Builder builder) { 134 super(builder); 135 this.createdAt = builder.createdAt; 136 this.modifiedAt = builder.modifiedAt; 137 this.description = builder.description; 138 this.size = builder.size; 139 this.pathCollection = builder.pathCollection; 140 this.createdBy = builder.createdBy; 141 this.modifiedBy = builder.modifiedBy; 142 this.trashedAt = builder.trashedAt; 143 this.purgedAt = builder.purgedAt; 144 this.contentCreatedAt = builder.contentCreatedAt; 145 this.contentModifiedAt = builder.contentModifiedAt; 146 this.ownedBy = builder.ownedBy; 147 this.sharedLink = builder.sharedLink; 148 this.folderUploadEmail = builder.folderUploadEmail; 149 this.parent = builder.parent; 150 this.itemStatus = builder.itemStatus; 151 this.itemCollection = builder.itemCollection; 152 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 153 } 154 155 public OffsetDateTime getCreatedAt() { 156 return createdAt; 157 } 158 159 public OffsetDateTime getModifiedAt() { 160 return modifiedAt; 161 } 162 163 public String getDescription() { 164 return description; 165 } 166 167 public Long getSize() { 168 return size; 169 } 170 171 public FolderPathCollectionField getPathCollection() { 172 return pathCollection; 173 } 174 175 public UserMini getCreatedBy() { 176 return createdBy; 177 } 178 179 public UserMini getModifiedBy() { 180 return modifiedBy; 181 } 182 183 public OffsetDateTime getTrashedAt() { 184 return trashedAt; 185 } 186 187 public OffsetDateTime getPurgedAt() { 188 return purgedAt; 189 } 190 191 public OffsetDateTime getContentCreatedAt() { 192 return contentCreatedAt; 193 } 194 195 public OffsetDateTime getContentModifiedAt() { 196 return contentModifiedAt; 197 } 198 199 public UserMini getOwnedBy() { 200 return ownedBy; 201 } 202 203 public FolderSharedLinkField getSharedLink() { 204 return sharedLink; 205 } 206 207 public FolderFolderUploadEmailField getFolderUploadEmail() { 208 return folderUploadEmail; 209 } 210 211 public FolderMini getParent() { 212 return parent; 213 } 214 215 public EnumWrapper<FolderItemStatusField> getItemStatus() { 216 return itemStatus; 217 } 218 219 public Items getItemCollection() { 220 return itemCollection; 221 } 222 223 @Override 224 public boolean equals(Object o) { 225 if (this == o) { 226 return true; 227 } 228 if (o == null || getClass() != o.getClass()) { 229 return false; 230 } 231 Folder casted = (Folder) o; 232 return Objects.equals(id, casted.id) 233 && Objects.equals(etag, casted.etag) 234 && Objects.equals(type, casted.type) 235 && Objects.equals(sequenceId, casted.sequenceId) 236 && Objects.equals(name, casted.name) 237 && Objects.equals(createdAt, casted.createdAt) 238 && Objects.equals(modifiedAt, casted.modifiedAt) 239 && Objects.equals(description, casted.description) 240 && Objects.equals(size, casted.size) 241 && Objects.equals(pathCollection, casted.pathCollection) 242 && Objects.equals(createdBy, casted.createdBy) 243 && Objects.equals(modifiedBy, casted.modifiedBy) 244 && Objects.equals(trashedAt, casted.trashedAt) 245 && Objects.equals(purgedAt, casted.purgedAt) 246 && Objects.equals(contentCreatedAt, casted.contentCreatedAt) 247 && Objects.equals(contentModifiedAt, casted.contentModifiedAt) 248 && Objects.equals(ownedBy, casted.ownedBy) 249 && Objects.equals(sharedLink, casted.sharedLink) 250 && Objects.equals(folderUploadEmail, casted.folderUploadEmail) 251 && Objects.equals(parent, casted.parent) 252 && Objects.equals(itemStatus, casted.itemStatus) 253 && Objects.equals(itemCollection, casted.itemCollection); 254 } 255 256 @Override 257 public int hashCode() { 258 return Objects.hash( 259 id, 260 etag, 261 type, 262 sequenceId, 263 name, 264 createdAt, 265 modifiedAt, 266 description, 267 size, 268 pathCollection, 269 createdBy, 270 modifiedBy, 271 trashedAt, 272 purgedAt, 273 contentCreatedAt, 274 contentModifiedAt, 275 ownedBy, 276 sharedLink, 277 folderUploadEmail, 278 parent, 279 itemStatus, 280 itemCollection); 281 } 282 283 @Override 284 public String toString() { 285 return "Folder{" 286 + "id='" 287 + id 288 + '\'' 289 + ", " 290 + "etag='" 291 + etag 292 + '\'' 293 + ", " 294 + "type='" 295 + type 296 + '\'' 297 + ", " 298 + "sequenceId='" 299 + sequenceId 300 + '\'' 301 + ", " 302 + "name='" 303 + name 304 + '\'' 305 + ", " 306 + "createdAt='" 307 + createdAt 308 + '\'' 309 + ", " 310 + "modifiedAt='" 311 + modifiedAt 312 + '\'' 313 + ", " 314 + "description='" 315 + description 316 + '\'' 317 + ", " 318 + "size='" 319 + size 320 + '\'' 321 + ", " 322 + "pathCollection='" 323 + pathCollection 324 + '\'' 325 + ", " 326 + "createdBy='" 327 + createdBy 328 + '\'' 329 + ", " 330 + "modifiedBy='" 331 + modifiedBy 332 + '\'' 333 + ", " 334 + "trashedAt='" 335 + trashedAt 336 + '\'' 337 + ", " 338 + "purgedAt='" 339 + purgedAt 340 + '\'' 341 + ", " 342 + "contentCreatedAt='" 343 + contentCreatedAt 344 + '\'' 345 + ", " 346 + "contentModifiedAt='" 347 + contentModifiedAt 348 + '\'' 349 + ", " 350 + "ownedBy='" 351 + ownedBy 352 + '\'' 353 + ", " 354 + "sharedLink='" 355 + sharedLink 356 + '\'' 357 + ", " 358 + "folderUploadEmail='" 359 + folderUploadEmail 360 + '\'' 361 + ", " 362 + "parent='" 363 + parent 364 + '\'' 365 + ", " 366 + "itemStatus='" 367 + itemStatus 368 + '\'' 369 + ", " 370 + "itemCollection='" 371 + itemCollection 372 + '\'' 373 + "}"; 374 } 375 376 public static class Builder extends FolderMini.Builder { 377 378 protected OffsetDateTime createdAt; 379 380 protected OffsetDateTime modifiedAt; 381 382 protected String description; 383 384 protected Long size; 385 386 protected FolderPathCollectionField pathCollection; 387 388 protected UserMini createdBy; 389 390 protected UserMini modifiedBy; 391 392 protected OffsetDateTime trashedAt; 393 394 protected OffsetDateTime purgedAt; 395 396 protected OffsetDateTime contentCreatedAt; 397 398 protected OffsetDateTime contentModifiedAt; 399 400 protected UserMini ownedBy; 401 402 protected FolderSharedLinkField sharedLink; 403 404 protected FolderFolderUploadEmailField folderUploadEmail; 405 406 protected FolderMini parent; 407 408 protected EnumWrapper<FolderItemStatusField> itemStatus; 409 410 protected Items itemCollection; 411 412 public Builder(String id) { 413 super(id); 414 } 415 416 public Builder createdAt(OffsetDateTime createdAt) { 417 this.createdAt = createdAt; 418 this.markNullableFieldAsSet("created_at"); 419 return this; 420 } 421 422 public Builder modifiedAt(OffsetDateTime modifiedAt) { 423 this.modifiedAt = modifiedAt; 424 this.markNullableFieldAsSet("modified_at"); 425 return this; 426 } 427 428 public Builder description(String description) { 429 this.description = description; 430 return this; 431 } 432 433 public Builder size(Long size) { 434 this.size = size; 435 return this; 436 } 437 438 public Builder pathCollection(FolderPathCollectionField pathCollection) { 439 this.pathCollection = pathCollection; 440 return this; 441 } 442 443 public Builder createdBy(UserMini createdBy) { 444 this.createdBy = createdBy; 445 return this; 446 } 447 448 public Builder modifiedBy(UserMini modifiedBy) { 449 this.modifiedBy = modifiedBy; 450 return this; 451 } 452 453 public Builder trashedAt(OffsetDateTime trashedAt) { 454 this.trashedAt = trashedAt; 455 this.markNullableFieldAsSet("trashed_at"); 456 return this; 457 } 458 459 public Builder purgedAt(OffsetDateTime purgedAt) { 460 this.purgedAt = purgedAt; 461 this.markNullableFieldAsSet("purged_at"); 462 return this; 463 } 464 465 public Builder contentCreatedAt(OffsetDateTime contentCreatedAt) { 466 this.contentCreatedAt = contentCreatedAt; 467 this.markNullableFieldAsSet("content_created_at"); 468 return this; 469 } 470 471 public Builder contentModifiedAt(OffsetDateTime contentModifiedAt) { 472 this.contentModifiedAt = contentModifiedAt; 473 this.markNullableFieldAsSet("content_modified_at"); 474 return this; 475 } 476 477 public Builder ownedBy(UserMini ownedBy) { 478 this.ownedBy = ownedBy; 479 return this; 480 } 481 482 public Builder sharedLink(FolderSharedLinkField sharedLink) { 483 this.sharedLink = sharedLink; 484 this.markNullableFieldAsSet("shared_link"); 485 return this; 486 } 487 488 public Builder folderUploadEmail(FolderFolderUploadEmailField folderUploadEmail) { 489 this.folderUploadEmail = folderUploadEmail; 490 this.markNullableFieldAsSet("folder_upload_email"); 491 return this; 492 } 493 494 public Builder parent(FolderMini parent) { 495 this.parent = parent; 496 this.markNullableFieldAsSet("parent"); 497 return this; 498 } 499 500 public Builder itemStatus(FolderItemStatusField itemStatus) { 501 this.itemStatus = new EnumWrapper<FolderItemStatusField>(itemStatus); 502 return this; 503 } 504 505 public Builder itemStatus(EnumWrapper<FolderItemStatusField> itemStatus) { 506 this.itemStatus = itemStatus; 507 return this; 508 } 509 510 public Builder itemCollection(Items itemCollection) { 511 this.itemCollection = itemCollection; 512 return this; 513 } 514 515 @Override 516 public Builder etag(String etag) { 517 this.etag = etag; 518 this.markNullableFieldAsSet("etag"); 519 return this; 520 } 521 522 @Override 523 public Builder type(FolderBaseTypeField type) { 524 this.type = new EnumWrapper<FolderBaseTypeField>(type); 525 return this; 526 } 527 528 @Override 529 public Builder type(EnumWrapper<FolderBaseTypeField> type) { 530 this.type = type; 531 return this; 532 } 533 534 @Override 535 public Builder sequenceId(String sequenceId) { 536 this.sequenceId = sequenceId; 537 return this; 538 } 539 540 @Override 541 public Builder name(String name) { 542 this.name = name; 543 return this; 544 } 545 546 public Folder build() { 547 if (this.type == null) { 548 this.type = new EnumWrapper<FolderBaseTypeField>(FolderBaseTypeField.FOLDER); 549 } 550 return new Folder(this); 551 } 552 } 553}