001package com.box.sdkgen.schemas.folderbase;
002
003import com.box.sdkgen.internal.Nullable;
004import com.box.sdkgen.internal.NullableFieldTracker;
005import com.box.sdkgen.internal.SerializableObject;
006import com.box.sdkgen.serialization.json.EnumWrapper;
007import com.fasterxml.jackson.annotation.JsonFilter;
008import com.fasterxml.jackson.annotation.JsonProperty;
009import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
010import com.fasterxml.jackson.databind.annotation.JsonSerialize;
011import java.util.Objects;
012
013/**
014 * The bare basic representation of a folder, the minimal amount of fields returned when using the
015 * `fields` query parameter.
016 */
017@JsonFilter("nullablePropertyFilter")
018public class FolderBase extends SerializableObject {
019
020  /**
021   * The unique identifier that represent a folder.
022   *
023   * <p>The ID for any folder can be determined by visiting a folder in the web application and
024   * copying the ID from the URL. For example, for the URL `https://*.app.box.com/folders/123` the
025   * `folder_id` is `123`.
026   */
027  protected final String id;
028
029  /**
030   * The HTTP `etag` of this folder. This can be used within some API endpoints in the `If-Match`
031   * and `If-None-Match` headers to only perform changes on the folder if (no) changes have
032   * happened.
033   */
034  @Nullable protected String etag;
035
036  /** The value will always be `folder`. */
037  @JsonDeserialize(using = FolderBaseTypeField.FolderBaseTypeFieldDeserializer.class)
038  @JsonSerialize(using = FolderBaseTypeField.FolderBaseTypeFieldSerializer.class)
039  protected EnumWrapper<FolderBaseTypeField> type;
040
041  public FolderBase(@JsonProperty("id") String id) {
042    super();
043    this.id = id;
044    this.type = new EnumWrapper<FolderBaseTypeField>(FolderBaseTypeField.FOLDER);
045  }
046
047  protected FolderBase(Builder builder) {
048    super();
049    this.id = builder.id;
050    this.etag = builder.etag;
051    this.type = builder.type;
052    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
053  }
054
055  public String getId() {
056    return id;
057  }
058
059  public String getEtag() {
060    return etag;
061  }
062
063  public EnumWrapper<FolderBaseTypeField> getType() {
064    return type;
065  }
066
067  @Override
068  public boolean equals(Object o) {
069    if (this == o) {
070      return true;
071    }
072    if (o == null || getClass() != o.getClass()) {
073      return false;
074    }
075    FolderBase casted = (FolderBase) o;
076    return Objects.equals(id, casted.id)
077        && Objects.equals(etag, casted.etag)
078        && Objects.equals(type, casted.type);
079  }
080
081  @Override
082  public int hashCode() {
083    return Objects.hash(id, etag, type);
084  }
085
086  @Override
087  public String toString() {
088    return "FolderBase{"
089        + "id='"
090        + id
091        + '\''
092        + ", "
093        + "etag='"
094        + etag
095        + '\''
096        + ", "
097        + "type='"
098        + type
099        + '\''
100        + "}";
101  }
102
103  public static class Builder extends NullableFieldTracker {
104
105    protected final String id;
106
107    protected String etag;
108
109    protected EnumWrapper<FolderBaseTypeField> type;
110
111    public Builder(String id) {
112      super();
113      this.id = id;
114    }
115
116    public Builder etag(String etag) {
117      this.etag = etag;
118      this.markNullableFieldAsSet("etag");
119      return this;
120    }
121
122    public Builder type(FolderBaseTypeField type) {
123      this.type = new EnumWrapper<FolderBaseTypeField>(type);
124      return this;
125    }
126
127    public Builder type(EnumWrapper<FolderBaseTypeField> type) {
128      this.type = type;
129      return this;
130    }
131
132    public FolderBase build() {
133      if (this.type == null) {
134        this.type = new EnumWrapper<FolderBaseTypeField>(FolderBaseTypeField.FOLDER);
135      }
136      return new FolderBase(this);
137    }
138  }
139}