001package com.box.sdkgen.schemas.metadatatemplate;
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.List;
011import java.util.Objects;
012
013/** A template for metadata that can be applied to files and folders. */
014@JsonFilter("nullablePropertyFilter")
015public class MetadataTemplate extends SerializableObject {
016
017  /** The ID of the metadata template. */
018  protected final String id;
019
020  /** The value will always be `metadata_template`. */
021  @JsonDeserialize(using = MetadataTemplateTypeField.MetadataTemplateTypeFieldDeserializer.class)
022  @JsonSerialize(using = MetadataTemplateTypeField.MetadataTemplateTypeFieldSerializer.class)
023  protected EnumWrapper<MetadataTemplateTypeField> type;
024
025  /**
026   * The scope of the metadata template can either be `global` or `enterprise_*`. The `global` scope
027   * is used for templates that are available to any Box enterprise. The `enterprise_*` scope
028   * represents templates that have been created within a specific enterprise, where `*` will be the
029   * ID of that enterprise.
030   */
031  protected String scope;
032
033  /**
034   * A unique identifier for the template. This identifier is unique across the `scope` of the
035   * enterprise to which the metadata template is being applied, yet is not necessarily unique
036   * across different enterprises.
037   */
038  protected String templateKey;
039
040  /** The display name of the template. This can be seen in the Box web app and mobile apps. */
041  protected String displayName;
042
043  /**
044   * Defines if this template is visible in the Box web app UI, or if it is purely intended for
045   * usage through the API.
046   */
047  protected Boolean hidden;
048
049  /**
050   * An ordered list of template fields which are part of the template. Each field can be a regular
051   * text field, date field, number field, as well as a single or multi-select list.
052   */
053  protected List<MetadataTemplateFieldsField> fields;
054
055  /** Whether or not to include the metadata when a file or folder is copied. */
056  protected Boolean copyInstanceOnItemCopy;
057
058  public MetadataTemplate(@JsonProperty("id") String id) {
059    super();
060    this.id = id;
061    this.type =
062        new EnumWrapper<MetadataTemplateTypeField>(MetadataTemplateTypeField.METADATA_TEMPLATE);
063  }
064
065  protected MetadataTemplate(Builder builder) {
066    super();
067    this.id = builder.id;
068    this.type = builder.type;
069    this.scope = builder.scope;
070    this.templateKey = builder.templateKey;
071    this.displayName = builder.displayName;
072    this.hidden = builder.hidden;
073    this.fields = builder.fields;
074    this.copyInstanceOnItemCopy = builder.copyInstanceOnItemCopy;
075    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
076  }
077
078  public String getId() {
079    return id;
080  }
081
082  public EnumWrapper<MetadataTemplateTypeField> getType() {
083    return type;
084  }
085
086  public String getScope() {
087    return scope;
088  }
089
090  public String getTemplateKey() {
091    return templateKey;
092  }
093
094  public String getDisplayName() {
095    return displayName;
096  }
097
098  public Boolean getHidden() {
099    return hidden;
100  }
101
102  public List<MetadataTemplateFieldsField> getFields() {
103    return fields;
104  }
105
106  public Boolean getCopyInstanceOnItemCopy() {
107    return copyInstanceOnItemCopy;
108  }
109
110  @Override
111  public boolean equals(Object o) {
112    if (this == o) {
113      return true;
114    }
115    if (o == null || getClass() != o.getClass()) {
116      return false;
117    }
118    MetadataTemplate casted = (MetadataTemplate) o;
119    return Objects.equals(id, casted.id)
120        && Objects.equals(type, casted.type)
121        && Objects.equals(scope, casted.scope)
122        && Objects.equals(templateKey, casted.templateKey)
123        && Objects.equals(displayName, casted.displayName)
124        && Objects.equals(hidden, casted.hidden)
125        && Objects.equals(fields, casted.fields)
126        && Objects.equals(copyInstanceOnItemCopy, casted.copyInstanceOnItemCopy);
127  }
128
129  @Override
130  public int hashCode() {
131    return Objects.hash(
132        id, type, scope, templateKey, displayName, hidden, fields, copyInstanceOnItemCopy);
133  }
134
135  @Override
136  public String toString() {
137    return "MetadataTemplate{"
138        + "id='"
139        + id
140        + '\''
141        + ", "
142        + "type='"
143        + type
144        + '\''
145        + ", "
146        + "scope='"
147        + scope
148        + '\''
149        + ", "
150        + "templateKey='"
151        + templateKey
152        + '\''
153        + ", "
154        + "displayName='"
155        + displayName
156        + '\''
157        + ", "
158        + "hidden='"
159        + hidden
160        + '\''
161        + ", "
162        + "fields='"
163        + fields
164        + '\''
165        + ", "
166        + "copyInstanceOnItemCopy='"
167        + copyInstanceOnItemCopy
168        + '\''
169        + "}";
170  }
171
172  public static class Builder extends NullableFieldTracker {
173
174    protected final String id;
175
176    protected EnumWrapper<MetadataTemplateTypeField> type;
177
178    protected String scope;
179
180    protected String templateKey;
181
182    protected String displayName;
183
184    protected Boolean hidden;
185
186    protected List<MetadataTemplateFieldsField> fields;
187
188    protected Boolean copyInstanceOnItemCopy;
189
190    public Builder(String id) {
191      super();
192      this.id = id;
193    }
194
195    public Builder type(MetadataTemplateTypeField type) {
196      this.type = new EnumWrapper<MetadataTemplateTypeField>(type);
197      return this;
198    }
199
200    public Builder type(EnumWrapper<MetadataTemplateTypeField> type) {
201      this.type = type;
202      return this;
203    }
204
205    public Builder scope(String scope) {
206      this.scope = scope;
207      return this;
208    }
209
210    public Builder templateKey(String templateKey) {
211      this.templateKey = templateKey;
212      return this;
213    }
214
215    public Builder displayName(String displayName) {
216      this.displayName = displayName;
217      return this;
218    }
219
220    public Builder hidden(Boolean hidden) {
221      this.hidden = hidden;
222      return this;
223    }
224
225    public Builder fields(List<MetadataTemplateFieldsField> fields) {
226      this.fields = fields;
227      return this;
228    }
229
230    public Builder copyInstanceOnItemCopy(Boolean copyInstanceOnItemCopy) {
231      this.copyInstanceOnItemCopy = copyInstanceOnItemCopy;
232      return this;
233    }
234
235    public MetadataTemplate build() {
236      if (this.type == null) {
237        this.type =
238            new EnumWrapper<MetadataTemplateTypeField>(MetadataTemplateTypeField.METADATA_TEMPLATE);
239      }
240      return new MetadataTemplate(this);
241    }
242  }
243}