001package com.box.sdkgen.schemas.taskassignment;
002
003import com.box.sdkgen.internal.NullableFieldTracker;
004import com.box.sdkgen.internal.SerializableObject;
005import com.box.sdkgen.internal.utils.DateTimeUtils;
006import com.box.sdkgen.schemas.filemini.FileMini;
007import com.box.sdkgen.schemas.usermini.UserMini;
008import com.box.sdkgen.serialization.json.EnumWrapper;
009import com.fasterxml.jackson.annotation.JsonFilter;
010import com.fasterxml.jackson.annotation.JsonProperty;
011import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
012import com.fasterxml.jackson.databind.annotation.JsonSerialize;
013import java.time.OffsetDateTime;
014import java.util.Objects;
015
016/** A task assignment defines which task is assigned to which user to complete. */
017@JsonFilter("nullablePropertyFilter")
018public class TaskAssignment extends SerializableObject {
019
020  /** The unique identifier for this task assignment. */
021  protected String id;
022
023  /** The value will always be `task_assignment`. */
024  @JsonDeserialize(using = TaskAssignmentTypeField.TaskAssignmentTypeFieldDeserializer.class)
025  @JsonSerialize(using = TaskAssignmentTypeField.TaskAssignmentTypeFieldSerializer.class)
026  protected EnumWrapper<TaskAssignmentTypeField> type;
027
028  protected FileMini item;
029
030  @JsonProperty("assigned_to")
031  protected UserMini assignedTo;
032
033  /**
034   * A message that will is included with the task assignment. This is visible to the assigned user
035   * in the web and mobile UI.
036   */
037  protected String message;
038
039  /**
040   * The date at which this task assignment was completed. This will be `null` if the task is not
041   * completed yet.
042   */
043  @JsonProperty("completed_at")
044  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
045  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
046  protected OffsetDateTime completedAt;
047
048  /** The date at which this task was assigned to the user. */
049  @JsonProperty("assigned_at")
050  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
051  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
052  protected OffsetDateTime assignedAt;
053
054  /** The date at which the assigned user was reminded of this task assignment. */
055  @JsonProperty("reminded_at")
056  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
057  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
058  protected OffsetDateTime remindedAt;
059
060  /**
061   * The current state of the assignment. The available states depend on the `action` value of the
062   * task object.
063   */
064  @JsonDeserialize(
065      using =
066          TaskAssignmentResolutionStateField.TaskAssignmentResolutionStateFieldDeserializer.class)
067  @JsonSerialize(
068      using = TaskAssignmentResolutionStateField.TaskAssignmentResolutionStateFieldSerializer.class)
069  @JsonProperty("resolution_state")
070  protected EnumWrapper<TaskAssignmentResolutionStateField> resolutionState;
071
072  @JsonProperty("assigned_by")
073  protected UserMini assignedBy;
074
075  public TaskAssignment() {
076    super();
077  }
078
079  protected TaskAssignment(Builder builder) {
080    super();
081    this.id = builder.id;
082    this.type = builder.type;
083    this.item = builder.item;
084    this.assignedTo = builder.assignedTo;
085    this.message = builder.message;
086    this.completedAt = builder.completedAt;
087    this.assignedAt = builder.assignedAt;
088    this.remindedAt = builder.remindedAt;
089    this.resolutionState = builder.resolutionState;
090    this.assignedBy = builder.assignedBy;
091    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
092  }
093
094  public String getId() {
095    return id;
096  }
097
098  public EnumWrapper<TaskAssignmentTypeField> getType() {
099    return type;
100  }
101
102  public FileMini getItem() {
103    return item;
104  }
105
106  public UserMini getAssignedTo() {
107    return assignedTo;
108  }
109
110  public String getMessage() {
111    return message;
112  }
113
114  public OffsetDateTime getCompletedAt() {
115    return completedAt;
116  }
117
118  public OffsetDateTime getAssignedAt() {
119    return assignedAt;
120  }
121
122  public OffsetDateTime getRemindedAt() {
123    return remindedAt;
124  }
125
126  public EnumWrapper<TaskAssignmentResolutionStateField> getResolutionState() {
127    return resolutionState;
128  }
129
130  public UserMini getAssignedBy() {
131    return assignedBy;
132  }
133
134  @Override
135  public boolean equals(Object o) {
136    if (this == o) {
137      return true;
138    }
139    if (o == null || getClass() != o.getClass()) {
140      return false;
141    }
142    TaskAssignment casted = (TaskAssignment) o;
143    return Objects.equals(id, casted.id)
144        && Objects.equals(type, casted.type)
145        && Objects.equals(item, casted.item)
146        && Objects.equals(assignedTo, casted.assignedTo)
147        && Objects.equals(message, casted.message)
148        && Objects.equals(completedAt, casted.completedAt)
149        && Objects.equals(assignedAt, casted.assignedAt)
150        && Objects.equals(remindedAt, casted.remindedAt)
151        && Objects.equals(resolutionState, casted.resolutionState)
152        && Objects.equals(assignedBy, casted.assignedBy);
153  }
154
155  @Override
156  public int hashCode() {
157    return Objects.hash(
158        id,
159        type,
160        item,
161        assignedTo,
162        message,
163        completedAt,
164        assignedAt,
165        remindedAt,
166        resolutionState,
167        assignedBy);
168  }
169
170  @Override
171  public String toString() {
172    return "TaskAssignment{"
173        + "id='"
174        + id
175        + '\''
176        + ", "
177        + "type='"
178        + type
179        + '\''
180        + ", "
181        + "item='"
182        + item
183        + '\''
184        + ", "
185        + "assignedTo='"
186        + assignedTo
187        + '\''
188        + ", "
189        + "message='"
190        + message
191        + '\''
192        + ", "
193        + "completedAt='"
194        + completedAt
195        + '\''
196        + ", "
197        + "assignedAt='"
198        + assignedAt
199        + '\''
200        + ", "
201        + "remindedAt='"
202        + remindedAt
203        + '\''
204        + ", "
205        + "resolutionState='"
206        + resolutionState
207        + '\''
208        + ", "
209        + "assignedBy='"
210        + assignedBy
211        + '\''
212        + "}";
213  }
214
215  public static class Builder extends NullableFieldTracker {
216
217    protected String id;
218
219    protected EnumWrapper<TaskAssignmentTypeField> type;
220
221    protected FileMini item;
222
223    protected UserMini assignedTo;
224
225    protected String message;
226
227    protected OffsetDateTime completedAt;
228
229    protected OffsetDateTime assignedAt;
230
231    protected OffsetDateTime remindedAt;
232
233    protected EnumWrapper<TaskAssignmentResolutionStateField> resolutionState;
234
235    protected UserMini assignedBy;
236
237    public Builder id(String id) {
238      this.id = id;
239      return this;
240    }
241
242    public Builder type(TaskAssignmentTypeField type) {
243      this.type = new EnumWrapper<TaskAssignmentTypeField>(type);
244      return this;
245    }
246
247    public Builder type(EnumWrapper<TaskAssignmentTypeField> type) {
248      this.type = type;
249      return this;
250    }
251
252    public Builder item(FileMini item) {
253      this.item = item;
254      return this;
255    }
256
257    public Builder assignedTo(UserMini assignedTo) {
258      this.assignedTo = assignedTo;
259      return this;
260    }
261
262    public Builder message(String message) {
263      this.message = message;
264      return this;
265    }
266
267    public Builder completedAt(OffsetDateTime completedAt) {
268      this.completedAt = completedAt;
269      return this;
270    }
271
272    public Builder assignedAt(OffsetDateTime assignedAt) {
273      this.assignedAt = assignedAt;
274      return this;
275    }
276
277    public Builder remindedAt(OffsetDateTime remindedAt) {
278      this.remindedAt = remindedAt;
279      return this;
280    }
281
282    public Builder resolutionState(TaskAssignmentResolutionStateField resolutionState) {
283      this.resolutionState = new EnumWrapper<TaskAssignmentResolutionStateField>(resolutionState);
284      return this;
285    }
286
287    public Builder resolutionState(
288        EnumWrapper<TaskAssignmentResolutionStateField> resolutionState) {
289      this.resolutionState = resolutionState;
290      return this;
291    }
292
293    public Builder assignedBy(UserMini assignedBy) {
294      this.assignedBy = assignedBy;
295      return this;
296    }
297
298    public TaskAssignment build() {
299      return new TaskAssignment(this);
300    }
301  }
302}