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