001package com.box.sdkgen.schemas.termsofservice;
002
003import com.box.sdkgen.internal.utils.DateTimeUtils;
004import com.box.sdkgen.schemas.termsofservicebase.TermsOfServiceBase;
005import com.box.sdkgen.schemas.termsofservicebase.TermsOfServiceBaseTypeField;
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.time.OffsetDateTime;
012import java.util.Objects;
013
014/** The root-level record that is supposed to represent a single Terms of Service. */
015@JsonFilter("nullablePropertyFilter")
016public class TermsOfService extends TermsOfServiceBase {
017
018  /** Whether these terms are enabled or not. */
019  @JsonDeserialize(using = TermsOfServiceStatusField.TermsOfServiceStatusFieldDeserializer.class)
020  @JsonSerialize(using = TermsOfServiceStatusField.TermsOfServiceStatusFieldSerializer.class)
021  protected EnumWrapper<TermsOfServiceStatusField> status;
022
023  protected TermsOfServiceEnterpriseField enterprise;
024
025  /** Whether to apply these terms to managed users or external users. */
026  @JsonDeserialize(using = TermsOfServiceTosTypeField.TermsOfServiceTosTypeFieldDeserializer.class)
027  @JsonSerialize(using = TermsOfServiceTosTypeField.TermsOfServiceTosTypeFieldSerializer.class)
028  @JsonProperty("tos_type")
029  protected EnumWrapper<TermsOfServiceTosTypeField> tosType;
030
031  /**
032   * The text for your terms and conditions. This text could be empty if the `status` is set to
033   * `disabled`.
034   */
035  protected String text;
036
037  /** When the legal item was created. */
038  @JsonProperty("created_at")
039  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
040  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
041  protected OffsetDateTime createdAt;
042
043  /** When the legal item was modified. */
044  @JsonProperty("modified_at")
045  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
046  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
047  protected OffsetDateTime modifiedAt;
048
049  public TermsOfService(@JsonProperty("id") String id) {
050    super(id);
051  }
052
053  protected TermsOfService(Builder builder) {
054    super(builder);
055    this.status = builder.status;
056    this.enterprise = builder.enterprise;
057    this.tosType = builder.tosType;
058    this.text = builder.text;
059    this.createdAt = builder.createdAt;
060    this.modifiedAt = builder.modifiedAt;
061    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
062  }
063
064  public EnumWrapper<TermsOfServiceStatusField> getStatus() {
065    return status;
066  }
067
068  public TermsOfServiceEnterpriseField getEnterprise() {
069    return enterprise;
070  }
071
072  public EnumWrapper<TermsOfServiceTosTypeField> getTosType() {
073    return tosType;
074  }
075
076  public String getText() {
077    return text;
078  }
079
080  public OffsetDateTime getCreatedAt() {
081    return createdAt;
082  }
083
084  public OffsetDateTime getModifiedAt() {
085    return modifiedAt;
086  }
087
088  @Override
089  public boolean equals(Object o) {
090    if (this == o) {
091      return true;
092    }
093    if (o == null || getClass() != o.getClass()) {
094      return false;
095    }
096    TermsOfService casted = (TermsOfService) o;
097    return Objects.equals(id, casted.id)
098        && Objects.equals(type, casted.type)
099        && Objects.equals(status, casted.status)
100        && Objects.equals(enterprise, casted.enterprise)
101        && Objects.equals(tosType, casted.tosType)
102        && Objects.equals(text, casted.text)
103        && Objects.equals(createdAt, casted.createdAt)
104        && Objects.equals(modifiedAt, casted.modifiedAt);
105  }
106
107  @Override
108  public int hashCode() {
109    return Objects.hash(id, type, status, enterprise, tosType, text, createdAt, modifiedAt);
110  }
111
112  @Override
113  public String toString() {
114    return "TermsOfService{"
115        + "id='"
116        + id
117        + '\''
118        + ", "
119        + "type='"
120        + type
121        + '\''
122        + ", "
123        + "status='"
124        + status
125        + '\''
126        + ", "
127        + "enterprise='"
128        + enterprise
129        + '\''
130        + ", "
131        + "tosType='"
132        + tosType
133        + '\''
134        + ", "
135        + "text='"
136        + text
137        + '\''
138        + ", "
139        + "createdAt='"
140        + createdAt
141        + '\''
142        + ", "
143        + "modifiedAt='"
144        + modifiedAt
145        + '\''
146        + "}";
147  }
148
149  public static class Builder extends TermsOfServiceBase.Builder {
150
151    protected EnumWrapper<TermsOfServiceStatusField> status;
152
153    protected TermsOfServiceEnterpriseField enterprise;
154
155    protected EnumWrapper<TermsOfServiceTosTypeField> tosType;
156
157    protected String text;
158
159    protected OffsetDateTime createdAt;
160
161    protected OffsetDateTime modifiedAt;
162
163    public Builder(String id) {
164      super(id);
165    }
166
167    public Builder status(TermsOfServiceStatusField status) {
168      this.status = new EnumWrapper<TermsOfServiceStatusField>(status);
169      return this;
170    }
171
172    public Builder status(EnumWrapper<TermsOfServiceStatusField> status) {
173      this.status = status;
174      return this;
175    }
176
177    public Builder enterprise(TermsOfServiceEnterpriseField enterprise) {
178      this.enterprise = enterprise;
179      return this;
180    }
181
182    public Builder tosType(TermsOfServiceTosTypeField tosType) {
183      this.tosType = new EnumWrapper<TermsOfServiceTosTypeField>(tosType);
184      return this;
185    }
186
187    public Builder tosType(EnumWrapper<TermsOfServiceTosTypeField> tosType) {
188      this.tosType = tosType;
189      return this;
190    }
191
192    public Builder text(String text) {
193      this.text = text;
194      return this;
195    }
196
197    public Builder createdAt(OffsetDateTime createdAt) {
198      this.createdAt = createdAt;
199      return this;
200    }
201
202    public Builder modifiedAt(OffsetDateTime modifiedAt) {
203      this.modifiedAt = modifiedAt;
204      return this;
205    }
206
207    @Override
208    public Builder type(TermsOfServiceBaseTypeField type) {
209      this.type = new EnumWrapper<TermsOfServiceBaseTypeField>(type);
210      return this;
211    }
212
213    @Override
214    public Builder type(EnumWrapper<TermsOfServiceBaseTypeField> type) {
215      this.type = type;
216      return this;
217    }
218
219    public TermsOfService build() {
220      if (this.type == null) {
221        this.type =
222            new EnumWrapper<TermsOfServiceBaseTypeField>(
223                TermsOfServiceBaseTypeField.TERMS_OF_SERVICE);
224      }
225      return new TermsOfService(this);
226    }
227  }
228}