001package com.box.sdkgen.schemas.collection;
002
003import com.box.sdkgen.internal.NullableFieldTracker;
004import com.box.sdkgen.internal.SerializableObject;
005import com.box.sdkgen.serialization.json.EnumWrapper;
006import com.fasterxml.jackson.annotation.JsonFilter;
007import com.fasterxml.jackson.annotation.JsonProperty;
008import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
009import com.fasterxml.jackson.databind.annotation.JsonSerialize;
010import java.util.Objects;
011
012/**
013 * A collection of items, including files and folders.
014 *
015 * <p>Currently, the only collection available is the `favorites` collection.
016 *
017 * <p>The contents of a collection can be explored in a similar way to which the contents of a
018 * folder is explored.
019 */
020@JsonFilter("nullablePropertyFilter")
021public class Collection extends SerializableObject {
022
023  /** The unique identifier for this collection. */
024  protected String id;
025
026  /** The value will always be `collection`. */
027  @JsonDeserialize(using = CollectionTypeField.CollectionTypeFieldDeserializer.class)
028  @JsonSerialize(using = CollectionTypeField.CollectionTypeFieldSerializer.class)
029  protected EnumWrapper<CollectionTypeField> type;
030
031  /** The name of the collection. */
032  @JsonDeserialize(using = CollectionNameField.CollectionNameFieldDeserializer.class)
033  @JsonSerialize(using = CollectionNameField.CollectionNameFieldSerializer.class)
034  protected EnumWrapper<CollectionNameField> name;
035
036  /**
037   * The type of the collection. This is used to determine the proper visual treatment for
038   * collections.
039   */
040  @JsonDeserialize(
041      using = CollectionCollectionTypeField.CollectionCollectionTypeFieldDeserializer.class)
042  @JsonSerialize(
043      using = CollectionCollectionTypeField.CollectionCollectionTypeFieldSerializer.class)
044  @JsonProperty("collection_type")
045  protected EnumWrapper<CollectionCollectionTypeField> collectionType;
046
047  public Collection() {
048    super();
049  }
050
051  protected Collection(Builder builder) {
052    super();
053    this.id = builder.id;
054    this.type = builder.type;
055    this.name = builder.name;
056    this.collectionType = builder.collectionType;
057    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
058  }
059
060  public String getId() {
061    return id;
062  }
063
064  public EnumWrapper<CollectionTypeField> getType() {
065    return type;
066  }
067
068  public EnumWrapper<CollectionNameField> getName() {
069    return name;
070  }
071
072  public EnumWrapper<CollectionCollectionTypeField> getCollectionType() {
073    return collectionType;
074  }
075
076  @Override
077  public boolean equals(Object o) {
078    if (this == o) {
079      return true;
080    }
081    if (o == null || getClass() != o.getClass()) {
082      return false;
083    }
084    Collection casted = (Collection) o;
085    return Objects.equals(id, casted.id)
086        && Objects.equals(type, casted.type)
087        && Objects.equals(name, casted.name)
088        && Objects.equals(collectionType, casted.collectionType);
089  }
090
091  @Override
092  public int hashCode() {
093    return Objects.hash(id, type, name, collectionType);
094  }
095
096  @Override
097  public String toString() {
098    return "Collection{"
099        + "id='"
100        + id
101        + '\''
102        + ", "
103        + "type='"
104        + type
105        + '\''
106        + ", "
107        + "name='"
108        + name
109        + '\''
110        + ", "
111        + "collectionType='"
112        + collectionType
113        + '\''
114        + "}";
115  }
116
117  public static class Builder extends NullableFieldTracker {
118
119    protected String id;
120
121    protected EnumWrapper<CollectionTypeField> type;
122
123    protected EnumWrapper<CollectionNameField> name;
124
125    protected EnumWrapper<CollectionCollectionTypeField> collectionType;
126
127    public Builder id(String id) {
128      this.id = id;
129      return this;
130    }
131
132    public Builder type(CollectionTypeField type) {
133      this.type = new EnumWrapper<CollectionTypeField>(type);
134      return this;
135    }
136
137    public Builder type(EnumWrapper<CollectionTypeField> type) {
138      this.type = type;
139      return this;
140    }
141
142    public Builder name(CollectionNameField name) {
143      this.name = new EnumWrapper<CollectionNameField>(name);
144      return this;
145    }
146
147    public Builder name(EnumWrapper<CollectionNameField> name) {
148      this.name = name;
149      return this;
150    }
151
152    public Builder collectionType(CollectionCollectionTypeField collectionType) {
153      this.collectionType = new EnumWrapper<CollectionCollectionTypeField>(collectionType);
154      return this;
155    }
156
157    public Builder collectionType(EnumWrapper<CollectionCollectionTypeField> collectionType) {
158      this.collectionType = collectionType;
159      return this;
160    }
161
162    public Collection build() {
163      return new Collection(this);
164    }
165  }
166}