001package com.box.sdkgen.schemas.trashfolder;
002
003import com.box.sdkgen.internal.Nullable;
004import com.box.sdkgen.internal.NullableFieldTracker;
005import com.box.sdkgen.internal.SerializableObject;
006import com.box.sdkgen.internal.utils.DateTimeUtils;
007import com.box.sdkgen.schemas.foldermini.FolderMini;
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/** Represents a trashed folder. */
018@JsonFilter("nullablePropertyFilter")
019public class TrashFolder extends SerializableObject {
020
021  /**
022   * The unique identifier that represent a folder.
023   *
024   * <p>The ID for any folder can be determined by visiting a folder in the web application and
025   * copying the ID from the URL. For example, for the URL `https://*.app.box.com/folders/123` the
026   * `folder_id` is `123`.
027   */
028  protected final String id;
029
030  /**
031   * The HTTP `etag` of this folder. This can be used within some API endpoints in the `If-Match`
032   * and `If-None-Match` headers to only perform changes on the folder if (no) changes have
033   * happened.
034   */
035  @Nullable protected String etag;
036
037  /** The value will always be `folder`. */
038  @JsonDeserialize(using = TrashFolderTypeField.TrashFolderTypeFieldDeserializer.class)
039  @JsonSerialize(using = TrashFolderTypeField.TrashFolderTypeFieldSerializer.class)
040  protected EnumWrapper<TrashFolderTypeField> type;
041
042  @JsonProperty("sequence_id")
043  protected String sequenceId;
044
045  /** The name of the folder. */
046  protected final String name;
047
048  /**
049   * The date and time when the folder was created. This value may be `null` for some folders such
050   * as the root folder or the trash folder.
051   */
052  @JsonProperty("created_at")
053  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
054  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
055  @Nullable
056  protected OffsetDateTime createdAt;
057
058  /**
059   * The date and time when the folder was last updated. This value may be `null` for some folders
060   * such as the root folder or the trash folder.
061   */
062  @JsonProperty("modified_at")
063  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
064  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
065  @Nullable
066  protected OffsetDateTime modifiedAt;
067
068  protected final String description;
069
070  /**
071   * The folder size in bytes.
072   *
073   * <p>Be careful parsing this integer as its value can get very large.
074   */
075  protected final long size;
076
077  @JsonProperty("path_collection")
078  protected final TrashFolderPathCollectionField pathCollection;
079
080  @JsonProperty("created_by")
081  protected final UserMini createdBy;
082
083  @JsonProperty("modified_by")
084  protected final UserMini modifiedBy;
085
086  /** The time at which this folder was put in the trash. */
087  @JsonProperty("trashed_at")
088  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
089  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
090  @Nullable
091  protected OffsetDateTime trashedAt;
092
093  /** The time at which this folder is expected to be purged from the trash. */
094  @JsonProperty("purged_at")
095  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
096  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
097  @Nullable
098  protected OffsetDateTime purgedAt;
099
100  /** The date and time at which this folder was originally created. */
101  @JsonProperty("content_created_at")
102  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
103  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
104  @Nullable
105  protected OffsetDateTime contentCreatedAt;
106
107  /** The date and time at which this folder was last updated. */
108  @JsonProperty("content_modified_at")
109  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
110  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
111  @Nullable
112  protected OffsetDateTime contentModifiedAt;
113
114  @JsonProperty("owned_by")
115  protected final UserMini ownedBy;
116
117  /**
118   * The shared link for this folder. This will be `null` if a folder has been trashed, since the
119   * link will no longer be active.
120   */
121  @JsonProperty("shared_link")
122  @Nullable
123  protected String sharedLink;
124
125  /**
126   * The folder upload email for this folder. This will be `null` if a folder has been trashed,
127   * since the upload will no longer work.
128   */
129  @JsonProperty("folder_upload_email")
130  @Nullable
131  protected String folderUploadEmail;
132
133  protected FolderMini parent;
134
135  /**
136   * Defines if this item has been deleted or not.
137   *
138   * <p>* `active` when the item has is not in the trash * `trashed` when the item has been moved to
139   * the trash but not deleted * `deleted` when the item has been permanently deleted.
140   */
141  @JsonDeserialize(using = TrashFolderItemStatusField.TrashFolderItemStatusFieldDeserializer.class)
142  @JsonSerialize(using = TrashFolderItemStatusField.TrashFolderItemStatusFieldSerializer.class)
143  @JsonProperty("item_status")
144  protected final EnumWrapper<TrashFolderItemStatusField> itemStatus;
145
146  public TrashFolder(
147      String id,
148      String name,
149      String description,
150      long size,
151      TrashFolderPathCollectionField pathCollection,
152      UserMini createdBy,
153      UserMini modifiedBy,
154      UserMini ownedBy,
155      TrashFolderItemStatusField itemStatus) {
156    super();
157    this.id = id;
158    this.name = name;
159    this.description = description;
160    this.size = size;
161    this.pathCollection = pathCollection;
162    this.createdBy = createdBy;
163    this.modifiedBy = modifiedBy;
164    this.ownedBy = ownedBy;
165    this.itemStatus = new EnumWrapper<TrashFolderItemStatusField>(itemStatus);
166    this.type = new EnumWrapper<TrashFolderTypeField>(TrashFolderTypeField.FOLDER);
167  }
168
169  public TrashFolder(
170      @JsonProperty("id") String id,
171      @JsonProperty("name") String name,
172      @JsonProperty("description") String description,
173      @JsonProperty("size") long size,
174      @JsonProperty("path_collection") TrashFolderPathCollectionField pathCollection,
175      @JsonProperty("created_by") UserMini createdBy,
176      @JsonProperty("modified_by") UserMini modifiedBy,
177      @JsonProperty("owned_by") UserMini ownedBy,
178      @JsonProperty("item_status") EnumWrapper<TrashFolderItemStatusField> itemStatus) {
179    super();
180    this.id = id;
181    this.name = name;
182    this.description = description;
183    this.size = size;
184    this.pathCollection = pathCollection;
185    this.createdBy = createdBy;
186    this.modifiedBy = modifiedBy;
187    this.ownedBy = ownedBy;
188    this.itemStatus = itemStatus;
189    this.type = new EnumWrapper<TrashFolderTypeField>(TrashFolderTypeField.FOLDER);
190  }
191
192  protected TrashFolder(Builder builder) {
193    super();
194    this.id = builder.id;
195    this.etag = builder.etag;
196    this.type = builder.type;
197    this.sequenceId = builder.sequenceId;
198    this.name = builder.name;
199    this.createdAt = builder.createdAt;
200    this.modifiedAt = builder.modifiedAt;
201    this.description = builder.description;
202    this.size = builder.size;
203    this.pathCollection = builder.pathCollection;
204    this.createdBy = builder.createdBy;
205    this.modifiedBy = builder.modifiedBy;
206    this.trashedAt = builder.trashedAt;
207    this.purgedAt = builder.purgedAt;
208    this.contentCreatedAt = builder.contentCreatedAt;
209    this.contentModifiedAt = builder.contentModifiedAt;
210    this.ownedBy = builder.ownedBy;
211    this.sharedLink = builder.sharedLink;
212    this.folderUploadEmail = builder.folderUploadEmail;
213    this.parent = builder.parent;
214    this.itemStatus = builder.itemStatus;
215    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
216  }
217
218  public String getId() {
219    return id;
220  }
221
222  public String getEtag() {
223    return etag;
224  }
225
226  public EnumWrapper<TrashFolderTypeField> getType() {
227    return type;
228  }
229
230  public String getSequenceId() {
231    return sequenceId;
232  }
233
234  public String getName() {
235    return name;
236  }
237
238  public OffsetDateTime getCreatedAt() {
239    return createdAt;
240  }
241
242  public OffsetDateTime getModifiedAt() {
243    return modifiedAt;
244  }
245
246  public String getDescription() {
247    return description;
248  }
249
250  public long getSize() {
251    return size;
252  }
253
254  public TrashFolderPathCollectionField getPathCollection() {
255    return pathCollection;
256  }
257
258  public UserMini getCreatedBy() {
259    return createdBy;
260  }
261
262  public UserMini getModifiedBy() {
263    return modifiedBy;
264  }
265
266  public OffsetDateTime getTrashedAt() {
267    return trashedAt;
268  }
269
270  public OffsetDateTime getPurgedAt() {
271    return purgedAt;
272  }
273
274  public OffsetDateTime getContentCreatedAt() {
275    return contentCreatedAt;
276  }
277
278  public OffsetDateTime getContentModifiedAt() {
279    return contentModifiedAt;
280  }
281
282  public UserMini getOwnedBy() {
283    return ownedBy;
284  }
285
286  public String getSharedLink() {
287    return sharedLink;
288  }
289
290  public String getFolderUploadEmail() {
291    return folderUploadEmail;
292  }
293
294  public FolderMini getParent() {
295    return parent;
296  }
297
298  public EnumWrapper<TrashFolderItemStatusField> getItemStatus() {
299    return itemStatus;
300  }
301
302  @Override
303  public boolean equals(Object o) {
304    if (this == o) {
305      return true;
306    }
307    if (o == null || getClass() != o.getClass()) {
308      return false;
309    }
310    TrashFolder casted = (TrashFolder) o;
311    return Objects.equals(id, casted.id)
312        && Objects.equals(etag, casted.etag)
313        && Objects.equals(type, casted.type)
314        && Objects.equals(sequenceId, casted.sequenceId)
315        && Objects.equals(name, casted.name)
316        && Objects.equals(createdAt, casted.createdAt)
317        && Objects.equals(modifiedAt, casted.modifiedAt)
318        && Objects.equals(description, casted.description)
319        && Objects.equals(size, casted.size)
320        && Objects.equals(pathCollection, casted.pathCollection)
321        && Objects.equals(createdBy, casted.createdBy)
322        && Objects.equals(modifiedBy, casted.modifiedBy)
323        && Objects.equals(trashedAt, casted.trashedAt)
324        && Objects.equals(purgedAt, casted.purgedAt)
325        && Objects.equals(contentCreatedAt, casted.contentCreatedAt)
326        && Objects.equals(contentModifiedAt, casted.contentModifiedAt)
327        && Objects.equals(ownedBy, casted.ownedBy)
328        && Objects.equals(sharedLink, casted.sharedLink)
329        && Objects.equals(folderUploadEmail, casted.folderUploadEmail)
330        && Objects.equals(parent, casted.parent)
331        && Objects.equals(itemStatus, casted.itemStatus);
332  }
333
334  @Override
335  public int hashCode() {
336    return Objects.hash(
337        id,
338        etag,
339        type,
340        sequenceId,
341        name,
342        createdAt,
343        modifiedAt,
344        description,
345        size,
346        pathCollection,
347        createdBy,
348        modifiedBy,
349        trashedAt,
350        purgedAt,
351        contentCreatedAt,
352        contentModifiedAt,
353        ownedBy,
354        sharedLink,
355        folderUploadEmail,
356        parent,
357        itemStatus);
358  }
359
360  @Override
361  public String toString() {
362    return "TrashFolder{"
363        + "id='"
364        + id
365        + '\''
366        + ", "
367        + "etag='"
368        + etag
369        + '\''
370        + ", "
371        + "type='"
372        + type
373        + '\''
374        + ", "
375        + "sequenceId='"
376        + sequenceId
377        + '\''
378        + ", "
379        + "name='"
380        + name
381        + '\''
382        + ", "
383        + "createdAt='"
384        + createdAt
385        + '\''
386        + ", "
387        + "modifiedAt='"
388        + modifiedAt
389        + '\''
390        + ", "
391        + "description='"
392        + description
393        + '\''
394        + ", "
395        + "size='"
396        + size
397        + '\''
398        + ", "
399        + "pathCollection='"
400        + pathCollection
401        + '\''
402        + ", "
403        + "createdBy='"
404        + createdBy
405        + '\''
406        + ", "
407        + "modifiedBy='"
408        + modifiedBy
409        + '\''
410        + ", "
411        + "trashedAt='"
412        + trashedAt
413        + '\''
414        + ", "
415        + "purgedAt='"
416        + purgedAt
417        + '\''
418        + ", "
419        + "contentCreatedAt='"
420        + contentCreatedAt
421        + '\''
422        + ", "
423        + "contentModifiedAt='"
424        + contentModifiedAt
425        + '\''
426        + ", "
427        + "ownedBy='"
428        + ownedBy
429        + '\''
430        + ", "
431        + "sharedLink='"
432        + sharedLink
433        + '\''
434        + ", "
435        + "folderUploadEmail='"
436        + folderUploadEmail
437        + '\''
438        + ", "
439        + "parent='"
440        + parent
441        + '\''
442        + ", "
443        + "itemStatus='"
444        + itemStatus
445        + '\''
446        + "}";
447  }
448
449  public static class Builder extends NullableFieldTracker {
450
451    protected final String id;
452
453    protected String etag;
454
455    protected EnumWrapper<TrashFolderTypeField> type;
456
457    protected String sequenceId;
458
459    protected final String name;
460
461    protected OffsetDateTime createdAt;
462
463    protected OffsetDateTime modifiedAt;
464
465    protected final String description;
466
467    protected final long size;
468
469    protected final TrashFolderPathCollectionField pathCollection;
470
471    protected final UserMini createdBy;
472
473    protected final UserMini modifiedBy;
474
475    protected OffsetDateTime trashedAt;
476
477    protected OffsetDateTime purgedAt;
478
479    protected OffsetDateTime contentCreatedAt;
480
481    protected OffsetDateTime contentModifiedAt;
482
483    protected final UserMini ownedBy;
484
485    protected String sharedLink;
486
487    protected String folderUploadEmail;
488
489    protected FolderMini parent;
490
491    protected final EnumWrapper<TrashFolderItemStatusField> itemStatus;
492
493    public Builder(
494        String id,
495        String name,
496        String description,
497        long size,
498        TrashFolderPathCollectionField pathCollection,
499        UserMini createdBy,
500        UserMini modifiedBy,
501        UserMini ownedBy,
502        TrashFolderItemStatusField itemStatus) {
503      super();
504      this.id = id;
505      this.name = name;
506      this.description = description;
507      this.size = size;
508      this.pathCollection = pathCollection;
509      this.createdBy = createdBy;
510      this.modifiedBy = modifiedBy;
511      this.ownedBy = ownedBy;
512      this.itemStatus = new EnumWrapper<TrashFolderItemStatusField>(itemStatus);
513    }
514
515    public Builder(
516        String id,
517        String name,
518        String description,
519        long size,
520        TrashFolderPathCollectionField pathCollection,
521        UserMini createdBy,
522        UserMini modifiedBy,
523        UserMini ownedBy,
524        EnumWrapper<TrashFolderItemStatusField> itemStatus) {
525      super();
526      this.id = id;
527      this.name = name;
528      this.description = description;
529      this.size = size;
530      this.pathCollection = pathCollection;
531      this.createdBy = createdBy;
532      this.modifiedBy = modifiedBy;
533      this.ownedBy = ownedBy;
534      this.itemStatus = itemStatus;
535    }
536
537    public Builder etag(String etag) {
538      this.etag = etag;
539      this.markNullableFieldAsSet("etag");
540      return this;
541    }
542
543    public Builder type(TrashFolderTypeField type) {
544      this.type = new EnumWrapper<TrashFolderTypeField>(type);
545      return this;
546    }
547
548    public Builder type(EnumWrapper<TrashFolderTypeField> type) {
549      this.type = type;
550      return this;
551    }
552
553    public Builder sequenceId(String sequenceId) {
554      this.sequenceId = sequenceId;
555      return this;
556    }
557
558    public Builder createdAt(OffsetDateTime createdAt) {
559      this.createdAt = createdAt;
560      this.markNullableFieldAsSet("created_at");
561      return this;
562    }
563
564    public Builder modifiedAt(OffsetDateTime modifiedAt) {
565      this.modifiedAt = modifiedAt;
566      this.markNullableFieldAsSet("modified_at");
567      return this;
568    }
569
570    public Builder trashedAt(OffsetDateTime trashedAt) {
571      this.trashedAt = trashedAt;
572      this.markNullableFieldAsSet("trashed_at");
573      return this;
574    }
575
576    public Builder purgedAt(OffsetDateTime purgedAt) {
577      this.purgedAt = purgedAt;
578      this.markNullableFieldAsSet("purged_at");
579      return this;
580    }
581
582    public Builder contentCreatedAt(OffsetDateTime contentCreatedAt) {
583      this.contentCreatedAt = contentCreatedAt;
584      this.markNullableFieldAsSet("content_created_at");
585      return this;
586    }
587
588    public Builder contentModifiedAt(OffsetDateTime contentModifiedAt) {
589      this.contentModifiedAt = contentModifiedAt;
590      this.markNullableFieldAsSet("content_modified_at");
591      return this;
592    }
593
594    public Builder sharedLink(String sharedLink) {
595      this.sharedLink = sharedLink;
596      this.markNullableFieldAsSet("shared_link");
597      return this;
598    }
599
600    public Builder folderUploadEmail(String folderUploadEmail) {
601      this.folderUploadEmail = folderUploadEmail;
602      this.markNullableFieldAsSet("folder_upload_email");
603      return this;
604    }
605
606    public Builder parent(FolderMini parent) {
607      this.parent = parent;
608      return this;
609    }
610
611    public TrashFolder build() {
612      if (this.type == null) {
613        this.type = new EnumWrapper<TrashFolderTypeField>(TrashFolderTypeField.FOLDER);
614      }
615      return new TrashFolder(this);
616    }
617  }
618}