001package com.box.sdkgen.schemas.weblink;
002
003import com.box.sdkgen.internal.Nullable;
004import com.box.sdkgen.internal.utils.DateTimeUtils;
005import com.box.sdkgen.schemas.foldermini.FolderMini;
006import com.box.sdkgen.schemas.usermini.UserMini;
007import com.box.sdkgen.schemas.weblinkbase.WebLinkBaseTypeField;
008import com.box.sdkgen.schemas.weblinkmini.WebLinkMini;
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/**
018 * Web links are objects that point to URLs. These objects are also known as bookmarks within the
019 * Box web application.
020 *
021 * <p>Web link objects are treated similarly to file objects, they will also support most actions
022 * that apply to regular files.
023 */
024@JsonFilter("nullablePropertyFilter")
025public class WebLink extends WebLinkMini {
026
027  protected FolderMini parent;
028
029  /** The description accompanying the web link. This is visible within the Box web application. */
030  protected String description;
031
032  @JsonProperty("path_collection")
033  protected WebLinkPathCollectionField pathCollection;
034
035  /** When this file was created on Box’s servers. */
036  @JsonProperty("created_at")
037  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
038  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
039  protected OffsetDateTime createdAt;
040
041  /** When this file was last updated on the Box servers. */
042  @JsonProperty("modified_at")
043  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
044  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
045  protected OffsetDateTime modifiedAt;
046
047  /** When this file was moved to the trash. */
048  @JsonProperty("trashed_at")
049  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
050  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
051  @Nullable
052  protected OffsetDateTime trashedAt;
053
054  /** When this file will be permanently deleted. */
055  @JsonProperty("purged_at")
056  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
057  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
058  @Nullable
059  protected OffsetDateTime purgedAt;
060
061  @JsonProperty("created_by")
062  protected UserMini createdBy;
063
064  @JsonProperty("modified_by")
065  protected UserMini modifiedBy;
066
067  @JsonProperty("owned_by")
068  protected UserMini ownedBy;
069
070  @JsonProperty("shared_link")
071  protected WebLinkSharedLinkField sharedLink;
072
073  /**
074   * Whether this item is deleted or not. Values include `active`, `trashed` if the file has been
075   * moved to the trash, and `deleted` if the file has been permanently deleted.
076   */
077  @JsonDeserialize(using = WebLinkItemStatusField.WebLinkItemStatusFieldDeserializer.class)
078  @JsonSerialize(using = WebLinkItemStatusField.WebLinkItemStatusFieldSerializer.class)
079  @JsonProperty("item_status")
080  protected EnumWrapper<WebLinkItemStatusField> itemStatus;
081
082  public WebLink(@JsonProperty("id") String id) {
083    super(id);
084  }
085
086  protected WebLink(Builder builder) {
087    super(builder);
088    this.parent = builder.parent;
089    this.description = builder.description;
090    this.pathCollection = builder.pathCollection;
091    this.createdAt = builder.createdAt;
092    this.modifiedAt = builder.modifiedAt;
093    this.trashedAt = builder.trashedAt;
094    this.purgedAt = builder.purgedAt;
095    this.createdBy = builder.createdBy;
096    this.modifiedBy = builder.modifiedBy;
097    this.ownedBy = builder.ownedBy;
098    this.sharedLink = builder.sharedLink;
099    this.itemStatus = builder.itemStatus;
100    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
101  }
102
103  public FolderMini getParent() {
104    return parent;
105  }
106
107  public String getDescription() {
108    return description;
109  }
110
111  public WebLinkPathCollectionField getPathCollection() {
112    return pathCollection;
113  }
114
115  public OffsetDateTime getCreatedAt() {
116    return createdAt;
117  }
118
119  public OffsetDateTime getModifiedAt() {
120    return modifiedAt;
121  }
122
123  public OffsetDateTime getTrashedAt() {
124    return trashedAt;
125  }
126
127  public OffsetDateTime getPurgedAt() {
128    return purgedAt;
129  }
130
131  public UserMini getCreatedBy() {
132    return createdBy;
133  }
134
135  public UserMini getModifiedBy() {
136    return modifiedBy;
137  }
138
139  public UserMini getOwnedBy() {
140    return ownedBy;
141  }
142
143  public WebLinkSharedLinkField getSharedLink() {
144    return sharedLink;
145  }
146
147  public EnumWrapper<WebLinkItemStatusField> getItemStatus() {
148    return itemStatus;
149  }
150
151  @Override
152  public boolean equals(Object o) {
153    if (this == o) {
154      return true;
155    }
156    if (o == null || getClass() != o.getClass()) {
157      return false;
158    }
159    WebLink casted = (WebLink) o;
160    return Objects.equals(id, casted.id)
161        && Objects.equals(type, casted.type)
162        && Objects.equals(etag, casted.etag)
163        && Objects.equals(url, casted.url)
164        && Objects.equals(sequenceId, casted.sequenceId)
165        && Objects.equals(name, casted.name)
166        && Objects.equals(parent, casted.parent)
167        && Objects.equals(description, casted.description)
168        && Objects.equals(pathCollection, casted.pathCollection)
169        && Objects.equals(createdAt, casted.createdAt)
170        && Objects.equals(modifiedAt, casted.modifiedAt)
171        && Objects.equals(trashedAt, casted.trashedAt)
172        && Objects.equals(purgedAt, casted.purgedAt)
173        && Objects.equals(createdBy, casted.createdBy)
174        && Objects.equals(modifiedBy, casted.modifiedBy)
175        && Objects.equals(ownedBy, casted.ownedBy)
176        && Objects.equals(sharedLink, casted.sharedLink)
177        && Objects.equals(itemStatus, casted.itemStatus);
178  }
179
180  @Override
181  public int hashCode() {
182    return Objects.hash(
183        id,
184        type,
185        etag,
186        url,
187        sequenceId,
188        name,
189        parent,
190        description,
191        pathCollection,
192        createdAt,
193        modifiedAt,
194        trashedAt,
195        purgedAt,
196        createdBy,
197        modifiedBy,
198        ownedBy,
199        sharedLink,
200        itemStatus);
201  }
202
203  @Override
204  public String toString() {
205    return "WebLink{"
206        + "id='"
207        + id
208        + '\''
209        + ", "
210        + "type='"
211        + type
212        + '\''
213        + ", "
214        + "etag='"
215        + etag
216        + '\''
217        + ", "
218        + "url='"
219        + url
220        + '\''
221        + ", "
222        + "sequenceId='"
223        + sequenceId
224        + '\''
225        + ", "
226        + "name='"
227        + name
228        + '\''
229        + ", "
230        + "parent='"
231        + parent
232        + '\''
233        + ", "
234        + "description='"
235        + description
236        + '\''
237        + ", "
238        + "pathCollection='"
239        + pathCollection
240        + '\''
241        + ", "
242        + "createdAt='"
243        + createdAt
244        + '\''
245        + ", "
246        + "modifiedAt='"
247        + modifiedAt
248        + '\''
249        + ", "
250        + "trashedAt='"
251        + trashedAt
252        + '\''
253        + ", "
254        + "purgedAt='"
255        + purgedAt
256        + '\''
257        + ", "
258        + "createdBy='"
259        + createdBy
260        + '\''
261        + ", "
262        + "modifiedBy='"
263        + modifiedBy
264        + '\''
265        + ", "
266        + "ownedBy='"
267        + ownedBy
268        + '\''
269        + ", "
270        + "sharedLink='"
271        + sharedLink
272        + '\''
273        + ", "
274        + "itemStatus='"
275        + itemStatus
276        + '\''
277        + "}";
278  }
279
280  public static class Builder extends WebLinkMini.Builder {
281
282    protected FolderMini parent;
283
284    protected String description;
285
286    protected WebLinkPathCollectionField pathCollection;
287
288    protected OffsetDateTime createdAt;
289
290    protected OffsetDateTime modifiedAt;
291
292    protected OffsetDateTime trashedAt;
293
294    protected OffsetDateTime purgedAt;
295
296    protected UserMini createdBy;
297
298    protected UserMini modifiedBy;
299
300    protected UserMini ownedBy;
301
302    protected WebLinkSharedLinkField sharedLink;
303
304    protected EnumWrapper<WebLinkItemStatusField> itemStatus;
305
306    public Builder(String id) {
307      super(id);
308    }
309
310    public Builder parent(FolderMini parent) {
311      this.parent = parent;
312      return this;
313    }
314
315    public Builder description(String description) {
316      this.description = description;
317      return this;
318    }
319
320    public Builder pathCollection(WebLinkPathCollectionField pathCollection) {
321      this.pathCollection = pathCollection;
322      return this;
323    }
324
325    public Builder createdAt(OffsetDateTime createdAt) {
326      this.createdAt = createdAt;
327      return this;
328    }
329
330    public Builder modifiedAt(OffsetDateTime modifiedAt) {
331      this.modifiedAt = modifiedAt;
332      return this;
333    }
334
335    public Builder trashedAt(OffsetDateTime trashedAt) {
336      this.trashedAt = trashedAt;
337      this.markNullableFieldAsSet("trashed_at");
338      return this;
339    }
340
341    public Builder purgedAt(OffsetDateTime purgedAt) {
342      this.purgedAt = purgedAt;
343      this.markNullableFieldAsSet("purged_at");
344      return this;
345    }
346
347    public Builder createdBy(UserMini createdBy) {
348      this.createdBy = createdBy;
349      return this;
350    }
351
352    public Builder modifiedBy(UserMini modifiedBy) {
353      this.modifiedBy = modifiedBy;
354      return this;
355    }
356
357    public Builder ownedBy(UserMini ownedBy) {
358      this.ownedBy = ownedBy;
359      return this;
360    }
361
362    public Builder sharedLink(WebLinkSharedLinkField sharedLink) {
363      this.sharedLink = sharedLink;
364      return this;
365    }
366
367    public Builder itemStatus(WebLinkItemStatusField itemStatus) {
368      this.itemStatus = new EnumWrapper<WebLinkItemStatusField>(itemStatus);
369      return this;
370    }
371
372    public Builder itemStatus(EnumWrapper<WebLinkItemStatusField> itemStatus) {
373      this.itemStatus = itemStatus;
374      return this;
375    }
376
377    @Override
378    public Builder type(WebLinkBaseTypeField type) {
379      this.type = new EnumWrapper<WebLinkBaseTypeField>(type);
380      return this;
381    }
382
383    @Override
384    public Builder type(EnumWrapper<WebLinkBaseTypeField> type) {
385      this.type = type;
386      return this;
387    }
388
389    @Override
390    public Builder etag(String etag) {
391      this.etag = etag;
392      return this;
393    }
394
395    @Override
396    public Builder url(String url) {
397      this.url = url;
398      return this;
399    }
400
401    @Override
402    public Builder sequenceId(String sequenceId) {
403      this.sequenceId = sequenceId;
404      return this;
405    }
406
407    @Override
408    public Builder name(String name) {
409      this.name = name;
410      return this;
411    }
412
413    public WebLink build() {
414      if (this.type == null) {
415        this.type = new EnumWrapper<WebLinkBaseTypeField>(WebLinkBaseTypeField.WEB_LINK);
416      }
417      return new WebLink(this);
418    }
419  }
420}