• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

smartsheet / smartsheet-java-sdk / #55

02 Oct 2024 07:40PM UTC coverage: 60.548% (+0.7%) from 59.836%
#55

push

github

web-flow
Release prep for 3.2.1 (#103)

4156 of 6864 relevant lines covered (60.55%)

0.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.48
/src/main/java/com/smartsheet/api/models/Discussion.java
1
/*
2
 * Copyright (C) 2024 Smartsheet
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package com.smartsheet.api.models;
18

19
import com.smartsheet.api.models.enums.ParentType;
20

21
import java.util.Date;
22
import java.util.List;
23

24
/**
25
 * Represents the Discussion object.
26
 *
27
 * @see <a href="http://help.smartsheet.com/customer/portal/articles/504767-using-discussions">Help Using Discussions</a>
28
 */
29
public class Discussion extends IdentifiableModel<Long> {
30
    /**
31
     * Represents the title for the discussion.
32
     */
33
    private String title;
34

35
    /**
36
     * Represents the comments for the discussion.
37
     */
38
    private List<Comment> comments;
39

40
    /**
41
     * Represents the comment for the discussion (outbound only - singular "comment")
42
     */
43
    private Comment comment;
44

45
    /**
46
     * Represents the comment attachments.
47
     */
48
    private List<Attachment> commentAttachments;
49

50
    /**
51
     * The number of comments in the discussion.
52
     */
53
    private Integer commentCount;
54

55
    /**
56
     * Represents the date a comment was last added to a discussion.
57
     */
58
    private Date lastCommentedAt;
59

60
    /**
61
     * Represents the last user that left a comment in the discussion.
62
     */
63
    private User lastCommentedUser;
64

65
    /**
66
     * Users permission on the Discussion
67
     */
68
    private String accessLevel;
69

70
    /**
71
     * Represents ID of the directly associated row or sheet.
72
     */
73
    private Long parentId;
74

75
    /**
76
     * Represents the “SHEET” or “ROW”: present only when the direct association is not clear.
77
     */
78
    private ParentType parentType;
79

80
    /**
81
     * Represents the User object containing name and email of the creator of the Discussion.
82
     */
83
    private User createdBy;
84

85
    /**
86
     * Represents the status of the Discussion.
87
     */
88
    private Boolean readOnly;
89

90
    /**
91
     * Constructors
92
     */
93
    public Discussion() {
1✔
94
    }
1✔
95

96
    public Discussion(String commentText) {
×
97
        comment.setText(commentText);
×
98
    }
×
99

100
    /**
101
     * Gets the read only status
102
     *
103
     * @return the read only status
104
     */
105
    public Boolean getReadOnly() {
106
        return readOnly;
1✔
107
    }
108

109
    /**
110
     * Sets the read only status.
111
     *
112
     * @param readOnly the read only status
113
     */
114
    public Discussion setReadOnly(Boolean readOnly) {
115
        this.readOnly = readOnly;
1✔
116
        return this;
1✔
117
    }
118

119
    /**
120
     * Gets the created by
121
     *
122
     * @return the created by
123
     */
124
    public User getCreatedBy() {
125
        return createdBy;
1✔
126
    }
127

128
    /**
129
     * Sets the created by.
130
     *
131
     * @param createdBy the created by
132
     */
133
    public Discussion setCreatedBy(User createdBy) {
134
        this.createdBy = createdBy;
1✔
135
        return this;
1✔
136
    }
137

138
    /**
139
     * Gets the title for the discussion.
140
     *
141
     * @return the title
142
     */
143
    public String getTitle() {
144
        return title;
1✔
145
    }
146

147
    /**
148
     * Sets the title for the discussion.
149
     *
150
     * @param title the new title
151
     */
152
    public Discussion setTitle(String title) {
153
        this.title = title;
1✔
154
        return this;
1✔
155
    }
156

157
    /**
158
     * Gets the comments for the discussion.
159
     *
160
     * @return the comments
161
     */
162
    public List<Comment> getComments() {
163
        return comments;
1✔
164
    }
165

166
    /**
167
     * Sets the comments for the discussion.
168
     *
169
     * @param comments the new comments
170
     */
171
    public Discussion setComments(List<Comment> comments) {
172
        this.comments = comments;
1✔
173
        return this;
1✔
174
    }
175

176
    /**
177
     * Gets the comment for the discussion.
178
     *
179
     * @return the comment
180
     */
181
    public Comment getComment() {
182
        return comment;
1✔
183
    }
184

185
    /**
186
     * Sets the comment for the discussion (outbound only, i.e. POST - will otherwise be null).
187
     *
188
     * @param comment the new comment
189
     */
190
    public Discussion setComment(Comment comment) {
191
        this.comment = comment;
×
192
        return this;
×
193
    }
194

195
    /**
196
     * Gets the comment attachments.
197
     *
198
     * @return the comment attachments
199
     */
200
    public List<Attachment> getCommentAttachments() {
201
        return commentAttachments;
1✔
202
    }
203

204
    /**
205
     * Sets the comment attachments.
206
     *
207
     * @param commentAttachments the new comment attachments
208
     */
209
    public Discussion setCommentAttachments(List<Attachment> commentAttachments) {
210
        this.commentAttachments = commentAttachments;
1✔
211
        return this;
1✔
212
    }
213

214
    /**
215
     * Gets the discussion comment count
216
     *
217
     * @return the comment count
218
     */
219
    public Integer getCommentCount() {
220
        return commentCount;
1✔
221
    }
222

223
    /**
224
     * Sets the discussion comment count
225
     *
226
     * @param commentCount the new comment count
227
     * @return the Discussion
228
     */
229
    public Discussion setCommentCount(Integer commentCount) {
230
        this.commentCount = commentCount;
×
231
        return this;
×
232
    }
233

234
    /**
235
     * Gets the date a comment was last added to a discussion..
236
     *
237
     * @return the last commented at
238
     */
239
    public Date getLastCommentedAt() {
240
        return lastCommentedAt;
1✔
241
    }
242

243
    /**
244
     * Sets the date a comment was last added to a discussion.
245
     *
246
     * @param lastCommentedAt the new last commented at
247
     */
248
    public Discussion setLastCommentedAt(Date lastCommentedAt) {
249
        this.lastCommentedAt = lastCommentedAt;
1✔
250
        return this;
1✔
251
    }
252

253
    /**
254
     * Gets the user that last commented in the discussion.
255
     *
256
     * @return the last commented user
257
     */
258
    public User getLastCommentedUser() {
259
        return lastCommentedUser;
1✔
260
    }
261

262
    /**
263
     * Sets the user that last commented in the discussion.
264
     *
265
     * @param lastCommentedUser the new last commented user
266
     */
267
    public Discussion setLastCommentedUser(User lastCommentedUser) {
268
        this.lastCommentedUser = lastCommentedUser;
1✔
269
        return this;
1✔
270
    }
271

272
    /**
273
     * Gets the access level.
274
     *
275
     * @return the access level
276
     */
277
    public String getAccessLevel() {
278
        return accessLevel;
1✔
279
    }
280

281
    /**
282
     * Sets the access level.
283
     *
284
     * @param accessLevel the new access level
285
     */
286
    public Discussion setAccessLevel(String accessLevel) {
287
        this.accessLevel = accessLevel;
1✔
288
        return this;
1✔
289
    }
290

291
    /**
292
     * Gets the ID of the directly associated row or sheet
293
     *
294
     * @return the parent ID
295
     */
296
    public Long getParentId() {
297
        return parentId;
1✔
298
    }
299

300
    /**
301
     * Sets the ID of the directly associated row or sheet
302
     *
303
     * @param parentId the new access level
304
     */
305
    public Discussion setParentId(Long parentId) {
306
        this.parentId = parentId;
1✔
307
        return this;
1✔
308
    }
309

310
    /**
311
     * Gets the type to row or sheet
312
     *
313
     * @return the parent type
314
     */
315
    public ParentType getParentType() {
316
        return parentType;
1✔
317
    }
318

319
    /**
320
     * Sets the type to row or sheet
321
     *
322
     * @param parentType the new access level
323
     */
324
    public Discussion setParentType(ParentType parentType) {
325
        this.parentType = parentType;
1✔
326
        return this;
1✔
327
    }
328

329
    /**
330
     * A convenience class to help generate discussion object with the appropriate fields for adding a discussion to
331
     * a sheet.
332
     */
333
    public static class CreateDiscussionBuilder {
1✔
334
        private String title;
335
        private Comment comment;
336

337
        /**
338
         * Sets the title for the discussion.
339
         *
340
         * @param title the title
341
         * @return the creates the discussion builder
342
         */
343
        public CreateDiscussionBuilder setTitle(String title) {
344
            this.title = title;
1✔
345
            return this;
1✔
346
        }
347

348
        /**
349
         * Sets the comments for the discussion.
350
         *
351
         * @param comment the comments
352
         * @return the creates the discussion builder
353
         */
354
        public CreateDiscussionBuilder setComment(Comment comment) {
355
            this.comment = comment;
1✔
356
            return this;
1✔
357
        }
358

359
        /**
360
         * Gets the title.
361
         *
362
         * @return the title
363
         */
364
        public String getTitle() {
365
            return title;
×
366
        }
367

368
        /**
369
         * Gets the comments.
370
         *
371
         * @return the comments
372
         */
373
        public Comment getComment() {
374
            return comment;
×
375
        }
376

377
        /**
378
         * Builds the.
379
         *
380
         * @return the discussion
381
         */
382
        public Discussion build() {
383
            if (title == null || comment == null) {
1✔
384
                throw new InstantiationError("A title and comment is required.");
×
385
            }
386

387
            Discussion discussion = new Discussion();
1✔
388
            discussion.title = title;
1✔
389
            discussion.comment = comment;
1✔
390
            return discussion;
1✔
391
        }
392
    }
393
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc