001package com.box.sdkgen.schemas.comment;
002
003import com.box.sdkgen.internal.utils.DateTimeUtils;
004import com.box.sdkgen.schemas.commentbase.CommentBase;
005import com.box.sdkgen.schemas.commentbase.CommentBaseTypeField;
006import com.box.sdkgen.schemas.usermini.UserMini;
007import com.box.sdkgen.serialization.json.EnumWrapper;
008import com.fasterxml.jackson.annotation.JsonFilter;
009import com.fasterxml.jackson.annotation.JsonProperty;
010import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
011import com.fasterxml.jackson.databind.annotation.JsonSerialize;
012import java.time.OffsetDateTime;
013import java.util.Objects;
014
015/** Standard representation of a comment. */
016@JsonFilter("nullablePropertyFilter")
017public class Comment extends CommentBase {
018
019  /** Whether or not this comment is a reply to another comment. */
020  @JsonProperty("is_reply_comment")
021  protected Boolean isReplyComment;
022
023  /** The text of the comment, as provided by the user. */
024  protected String message;
025
026  @JsonProperty("created_by")
027  protected UserMini createdBy;
028
029  /** The time this comment was created. */
030  @JsonProperty("created_at")
031  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
032  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
033  protected OffsetDateTime createdAt;
034
035  /** The time this comment was last modified. */
036  @JsonProperty("modified_at")
037  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
038  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
039  protected OffsetDateTime modifiedAt;
040
041  protected CommentItemField item;
042
043  public Comment() {
044    super();
045  }
046
047  protected Comment(Builder builder) {
048    super(builder);
049    this.isReplyComment = builder.isReplyComment;
050    this.message = builder.message;
051    this.createdBy = builder.createdBy;
052    this.createdAt = builder.createdAt;
053    this.modifiedAt = builder.modifiedAt;
054    this.item = builder.item;
055    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
056  }
057
058  public Boolean getIsReplyComment() {
059    return isReplyComment;
060  }
061
062  public String getMessage() {
063    return message;
064  }
065
066  public UserMini getCreatedBy() {
067    return createdBy;
068  }
069
070  public OffsetDateTime getCreatedAt() {
071    return createdAt;
072  }
073
074  public OffsetDateTime getModifiedAt() {
075    return modifiedAt;
076  }
077
078  public CommentItemField getItem() {
079    return item;
080  }
081
082  @Override
083  public boolean equals(Object o) {
084    if (this == o) {
085      return true;
086    }
087    if (o == null || getClass() != o.getClass()) {
088      return false;
089    }
090    Comment casted = (Comment) o;
091    return Objects.equals(id, casted.id)
092        && Objects.equals(type, casted.type)
093        && Objects.equals(isReplyComment, casted.isReplyComment)
094        && Objects.equals(message, casted.message)
095        && Objects.equals(createdBy, casted.createdBy)
096        && Objects.equals(createdAt, casted.createdAt)
097        && Objects.equals(modifiedAt, casted.modifiedAt)
098        && Objects.equals(item, casted.item);
099  }
100
101  @Override
102  public int hashCode() {
103    return Objects.hash(id, type, isReplyComment, message, createdBy, createdAt, modifiedAt, item);
104  }
105
106  @Override
107  public String toString() {
108    return "Comment{"
109        + "id='"
110        + id
111        + '\''
112        + ", "
113        + "type='"
114        + type
115        + '\''
116        + ", "
117        + "isReplyComment='"
118        + isReplyComment
119        + '\''
120        + ", "
121        + "message='"
122        + message
123        + '\''
124        + ", "
125        + "createdBy='"
126        + createdBy
127        + '\''
128        + ", "
129        + "createdAt='"
130        + createdAt
131        + '\''
132        + ", "
133        + "modifiedAt='"
134        + modifiedAt
135        + '\''
136        + ", "
137        + "item='"
138        + item
139        + '\''
140        + "}";
141  }
142
143  public static class Builder extends CommentBase.Builder {
144
145    protected Boolean isReplyComment;
146
147    protected String message;
148
149    protected UserMini createdBy;
150
151    protected OffsetDateTime createdAt;
152
153    protected OffsetDateTime modifiedAt;
154
155    protected CommentItemField item;
156
157    public Builder isReplyComment(Boolean isReplyComment) {
158      this.isReplyComment = isReplyComment;
159      return this;
160    }
161
162    public Builder message(String message) {
163      this.message = message;
164      return this;
165    }
166
167    public Builder createdBy(UserMini createdBy) {
168      this.createdBy = createdBy;
169      return this;
170    }
171
172    public Builder createdAt(OffsetDateTime createdAt) {
173      this.createdAt = createdAt;
174      return this;
175    }
176
177    public Builder modifiedAt(OffsetDateTime modifiedAt) {
178      this.modifiedAt = modifiedAt;
179      return this;
180    }
181
182    public Builder item(CommentItemField item) {
183      this.item = item;
184      return this;
185    }
186
187    @Override
188    public Builder id(String id) {
189      this.id = id;
190      return this;
191    }
192
193    @Override
194    public Builder type(CommentBaseTypeField type) {
195      this.type = new EnumWrapper<CommentBaseTypeField>(type);
196      return this;
197    }
198
199    @Override
200    public Builder type(EnumWrapper<CommentBaseTypeField> type) {
201      this.type = type;
202      return this;
203    }
204
205    public Comment build() {
206      return new Comment(this);
207    }
208  }
209}