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