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

smartsheet / smartsheet-java-sdk / #43

24 Aug 2023 10:26PM UTC coverage: 50.427% (-0.02%) from 50.442%
#43

push

github-actions

web-flow
Fix Checkstyle violations in api/models Classes (#57)

This will fix ~900 violations

189 of 189 new or added lines in 59 files covered. (100.0%)

3423 of 6788 relevant lines covered (50.43%)

0.5 hits per line

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

43.56
/src/main/java/com/smartsheet/api/models/Share.java
1
package com.smartsheet.api.models;
2

3
/*
4
 * #[license]
5
 * Smartsheet SDK for Java
6
 * %%
7
 * Copyright (C) 2023 Smartsheet
8
 * %%
9
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12
 *
13
 *      http://www.apache.org/licenses/LICENSE-2.0
14
 *
15
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20
 * %[license]
21
 */
22

23
import com.smartsheet.api.models.enums.AccessLevel;
24
import com.smartsheet.api.models.enums.ShareScope;
25
import com.smartsheet.api.models.enums.ShareType;
26

27
import java.util.Date;
28

29
/**
30
 * Represents a Share Object.
31
 * @see <a href="http://help.smartsheet.com/customer/portal/articles/520104-sharing-sheets">Sharing Sheets</a>
32
 */
33
public class Share extends NamedModel<String> {
1✔
34
    /**
35
     * Represents the access level for this specific share.
36
     */
37
    private AccessLevel accessLevel;
38

39
    /**
40
     * Represents the email for this specific share.
41
     */
42
    private String email;
43

44
    /**
45
     * Represents the userId if the share is of type {@link ShareType#USER}
46
     */
47
    private Long userId;
48

49
    /**
50
     * Represents the groupId if the share is of type {@link ShareType#GROUP}
51
     */
52
    private Long groupId;
53

54
    /**
55
     * Indicates what type of share this is.
56
     */
57
    private ShareType type;
58

59
    /**
60
     * The scope of this share. One of the following values:
61
     *    ITEM: an item-level share (i.e., the specific object to which the Share applies is shared with the user or group)
62
     *    WORKSPACE: a workspace-level share (i.e., the workspace that contains the object to which the Share
63
     *    applies is shared with the user or group)
64
     */
65
    private ShareScope scope;
66

67
    /**
68
     * Time that the share was created.
69
     */
70
    private Date createdAt;
71

72
    /**
73
     * Time that the share was modified.
74
     */
75
    private Date modifiedAt;
76

77
    /**
78
     * Represents the subject of the email that will optionally be sent to notify the recipient.
79
     */
80
    private String subject;
81

82
    /**
83
     * Represents the message to be included in the body of the email.
84
     */
85
    private String message;
86

87
    /**
88
     * Represents the flag to indicate whether or not to send a copy of the email to the sharer of the sheet.
89
     */
90
    private Boolean ccMe;
91

92
    /**
93
     * Provide an 'override' of setName (returns Share not NamedModel)
94
     *
95
     * @param name the new name
96
     */
97
    public Share setName(String name) {
98
        super.setName(name);
1✔
99
        return this;
1✔
100
    }
101

102
    /**
103
     * Gets the subject of the email that will optionally be sent to notify the recipient.
104
     *
105
     * @return the subject
106
     */
107
    public String getSubject() {
108
        return subject;
1✔
109
    }
110

111
    /**
112
     * Sets the subject of the email that will optionally be sent to notify the recipient.
113
     *
114
     * @param subject the subject of the email
115
     */
116
    public Share setSubject(String subject) {
117
        this.subject = subject;
×
118
        return this;
×
119
    }
120

121
    /**
122
     * Gets the message to be included in the body of the email.
123
     *
124
     * @return the message
125
     */
126
    public String getMessage() {
127
        return message;
1✔
128
    }
129

130
    /**
131
     * Sets the message to be included in the body of the email.
132
     *
133
     * @param message the message
134
     */
135
    public Share setMessage(String message) {
136
        this.message = message;
×
137
        return this;
×
138
    }
139

140
    /**
141
     * Gets the flag to indicate whether or not to send a copy of the email to the sharer
142
     *
143
     * @return the flag for CC
144
     */
145
    public Boolean isCcMe() {
146
        return ccMe;
1✔
147
    }
148

149
    /**
150
     * Sets the flag to indicate whether or not to send a copy of the email to the sharer.
151
     *
152
     * @param ccMe the flag for CC
153
     */
154
    public Share setCcMe(Boolean ccMe) {
155
        this.ccMe = ccMe;
×
156
        return this;
×
157
    }
158

159
    /**
160
     * Gets the access level for this specific share.
161
     *
162
     * @return the access level
163
     */
164
    public AccessLevel getAccessLevel() {
165
        return accessLevel;
1✔
166
    }
167

168
    /**
169
     * Sets the access level for this specific share.
170
     *
171
     * @param accessLevel the new access level
172
     */
173
    public Share setAccessLevel(AccessLevel accessLevel) {
174
        this.accessLevel = accessLevel;
1✔
175
        return this;
1✔
176
    }
177

178
    /**
179
     * Gets the email for this specific share.
180
     *
181
     * @return the email
182
     */
183
    public String getEmail() {
184
        return email;
1✔
185
    }
186

187
    /**
188
     * Sets the email for this specific share.
189
     *
190
     * @param email the new email
191
     */
192
    public Share setEmail(String email) {
193
        this.email = email;
1✔
194
        return this;
1✔
195
    }
196

197
    /**
198
     * Get the scope of this share. One of ITEM or WORKSPACE
199
     *
200
     * @return scope
201
     */
202
    public ShareScope getScope() {
203
        return scope;
1✔
204
    }
205

206
    /**
207
     * Set the scope of this share. One of ITEM or WORKSPACE
208
     */
209
    public Share setScope(ShareScope scope) {
210
        this.scope = scope;
×
211
        return this;
×
212
    }
213

214
    /**
215
     * Gets the time that the share was created
216
     *
217
     * @return createdAt
218
     */
219
    public Date getCreatedAt() {
220
        return createdAt;
1✔
221
    }
222

223
    /**
224
     * Sets the time that the share was created
225
     */
226
    public Share setCreatedAt(Date createdAt) {
227
        this.createdAt = createdAt;
×
228
        return this;
×
229
    }
230

231
    /**
232
     * Gets the time that the share was last modified
233
     *
234
     * @return modifiedAt
235
     */
236
    public Date getModifiedAt() {
237
        return modifiedAt;
1✔
238
    }
239

240
    /**
241
     * Sets the time that the share was last modified
242
     */
243
    public Share setModifiedAt(Date modifiedAt) {
244
        this.modifiedAt = modifiedAt;
×
245
        return this;
×
246
    }
247

248
    /**
249
     * @return the userId, <code>null</code> if is {@link ShareType#GROUP}
250
     */
251
    public Long getUserId() {
252
        return userId;
1✔
253
    }
254

255
    /**
256
     * @param userId the userId to set
257
     */
258
    public Share setUserId(Long userId) {
259
        this.userId = userId;
1✔
260
        return this;
1✔
261
    }
262

263
    /**
264
     * @return the groupId, <code>null</code> if is {@link ShareType#USER}
265
     */
266
    public Long getGroupId() {
267
        return groupId;
1✔
268
    }
269

270
    /**
271
     * @param groupId the groupId to set
272
     */
273
    public Share setGroupId(Long groupId) {
274
        this.groupId = groupId;
1✔
275
        return this;
1✔
276
    }
277

278
    /**
279
     * @return the type
280
     */
281
    public ShareType getType() {
282
        return type;
1✔
283
    }
284

285
    /**
286
     * @param type the {@link ShareType} to set
287
     */
288
    public Share setType(ShareType type) {
289
        this.type = type;
1✔
290
        return this;
1✔
291
    }
292

293
    /**
294
     * A convenience class for creating a {@link Share} with the necessary fields for sharing the sheet to one user.
295
     */
296
    public static class ShareToOneUserBuilder {
×
297
        private AccessLevel accessLevel;
298
        private String email;
299

300
        /**
301
         * Access level for this specific share.
302
         *
303
         * @param accessLevel the access level
304
         * @return the share to one builder
305
         */
306
        public ShareToOneUserBuilder setAccessLevel(AccessLevel accessLevel) {
307
            this.accessLevel = accessLevel;
×
308
            return this;
×
309
        }
310

311
        /**
312
         * Email address for this specific share.
313
         *
314
         * @param email the email
315
         * @return the share to one builder
316
         */
317
        public ShareToOneUserBuilder setEmail(String email) {
318
            this.email = email;
×
319
            return this;
×
320
        }
321

322
        /**
323
         * Gets the access level.
324
         *
325
         * @return the access level
326
         */
327
        public AccessLevel getAccessLevel() {
328
            return accessLevel;
×
329
        }
330

331
        /**
332
         * Gets the email.
333
         *
334
         * @return the email
335
         */
336
        public String getEmail() {
337
            return email;
×
338
        }
339

340
        /**
341
         * Builds the {@link Share} object.
342
         *
343
         * @return the share
344
         */
345
        public Share build() {
346
            if (accessLevel == null || email == null) {
×
347
                throw new InstantiationError("emailAddress and accessLevel are required");
×
348
            }
349

350
            Share share = new Share();
×
351
            share.accessLevel = accessLevel;
×
352
            share.email = email;
×
353
            return share;
×
354
        }
355
    }
356

357
    /**
358
     * A convenience class for creating a {@link Share} with the necessary fields for sharing the sheet to one {@link Group}.
359
     */
360
    public static class ShareToOneGroupBuilder {
×
361
        private AccessLevel accessLevel;
362
        private Long groupId;
363

364
        /**
365
         * Access level for this specific share.
366
         *
367
         * @param accessLevel the access level
368
         * @return the share to one builder
369
         */
370
        public ShareToOneGroupBuilder setAccessLevel(AccessLevel accessLevel) {
371
            this.accessLevel = accessLevel;
×
372
            return this;
×
373
        }
374

375
        /**
376
         * Group Id for this share.
377
         *
378
         * @param groupId the group Id.
379
         * @return the share to one builder
380
         */
381
        public ShareToOneGroupBuilder setGroupId(Long groupId) {
382
            this.groupId = groupId;
×
383
            return this;
×
384
        }
385

386
        /**
387
         * Gets the access level.
388
         *
389
         * @return the access level
390
         */
391
        public AccessLevel getAccessLevel() {
392
            return accessLevel;
×
393
        }
394

395
        /**
396
         * Gets the group Id.
397
         *
398
         * @return the group Id
399
         */
400
        public Long getGroupId() {
401
            return groupId;
×
402
        }
403

404
        /**
405
         * Builds the {@link Share} object.
406
         *
407
         * @return the share
408
         */
409
        public Share build() {
410
            if (accessLevel == null || groupId == null) {
×
411
                throw new InstantiationError("You must provide a groupId and accessLevel");
×
412
            }
413

414
            Share share = new Share();
×
415
            share.accessLevel = accessLevel;
×
416
            share.groupId = groupId;
×
417
            return share;
×
418
        }
419
    }
420

421
    /**
422
     * A convenience class for creating a {@link Share} with the necessary fields to update a specific share.
423
     */
424
    public static class UpdateShareBuilder {
×
425
        private AccessLevel accessLevel;
426
        private String id;
427

428
        /**
429
         * Share Id for this specific share.
430
         *
431
         * @return the builder
432
         */
433
        public String getShareId() {
434
            return id;
×
435
        }
436

437
        /**
438
         * Set the Share ID
439
         */
440
        public UpdateShareBuilder setShareId(String shareId) {
441
            this.id = shareId;
×
442
            return this;
×
443
        }
444

445
        /**
446
         * Access level for the share.
447
         *
448
         * @param accessLevel the access level
449
         * @return the update share builder
450
         */
451
        public UpdateShareBuilder setAccessLevel(AccessLevel accessLevel) {
452
            this.accessLevel = accessLevel;
×
453
            return this;
×
454
        }
455

456
        /**
457
         * Gets the access level.
458
         *
459
         * @return the access level
460
         */
461
        public AccessLevel getAccessLevel() {
462
            return accessLevel;
×
463
        }
464

465
        /**
466
         * Builds the {@link Share} object.
467
         *
468
         * @return the share
469
         */
470
        public Share build() {
471
            if (accessLevel == null || id == null) {
×
472
                throw new InstantiationError("The access level and share id must be specified.");
×
473
            }
474

475
            Share share = new Share();
×
476
            share.accessLevel = accessLevel;
×
477
            share.setId(id);
×
478
            return share;
×
479
        }
480
    }
481

482
    /**
483
     * A convenience class for creating a {@link Share} with the necessary fields to create a {@link ShareType#USER} {@link Share}.
484
     * You must set one and only of of emailAddress and userId.
485
     */
486
    public static class CreateUserShareBuilder {
1✔
487
        private String email;
488
        private AccessLevel accessLevel;
489

490
        /**
491
         * Email address for the {@link ShareType#USER} share.
492
         *
493
         * @param emailAddress the email address
494
         * @return the {@link CreateUserShareBuilder}
495
         */
496
        public CreateUserShareBuilder setEmailAddress(String emailAddress) {
497
            this.email = emailAddress;
1✔
498
            return this;
1✔
499
        }
500

501
        /**
502
         * Gets the email address.
503
         *
504
         * @return the email address
505
         */
506
        public String getEmailAddress() {
507
            return email;
×
508
        }
509

510
        /**
511
         * Gets the access level
512
         *
513
         * @return the access level
514
         */
515
        public AccessLevel getAccessLevel() {
516
            return accessLevel;
×
517
        }
518

519
        /**
520
         * Sets the access level
521
         *
522
         * @param accessLevel the access level
523
         */
524
        public CreateUserShareBuilder setAccessLevel(AccessLevel accessLevel) {
525
            this.accessLevel = accessLevel;
1✔
526
            return this;
1✔
527
        }
528

529
        /**
530
         * Builds the {@link Share} object.
531
         *
532
         * @return the share
533
         */
534
        public Share build() {
535
            if (accessLevel == null || email == null) {
1✔
536
                throw new InstantiationError("emailAddress and accessLevel are required");
×
537
            }
538

539
            Share share = new Share();
1✔
540
            share.email = email;
1✔
541
            share.accessLevel = accessLevel;
1✔
542
            return share;
1✔
543
        }
544
    }
545

546
    /**
547
     * A convenience class for creating a {@link Share} with the necessary fields to create a {@link ShareType#GROUP} {@link Share}.
548
     * You must set groupId
549
     */
550
    public static class CreateGroupShareBuilder {
1✔
551
        private AccessLevel accessLevel;
552
        private Long groupId;
553

554
        /**
555
         * Access level for this specific share.
556
         *
557
         * @param accessLevel the access level
558
         * @return the group share builder
559
         */
560
        public CreateGroupShareBuilder setAccessLevel(AccessLevel accessLevel) {
561
            this.accessLevel = accessLevel;
1✔
562
            return this;
1✔
563
        }
564

565
        /**
566
         * Group Id for this share.
567
         *
568
         * @param groupId the group Id.
569
         * @return the group share builder
570
         */
571
        public CreateGroupShareBuilder setGroupId(Long groupId) {
572
            this.groupId = groupId;
1✔
573
            return this;
1✔
574
        }
575

576
        /**
577
         * Gets the access level.
578
         *
579
         * @return the access level
580
         */
581
        public AccessLevel getAccessLevel() {
582
            return accessLevel;
×
583
        }
584

585
        /**
586
         * Gets the group Id.
587
         *
588
         * @return the group Id
589
         */
590
        public Long getGroupId() {
591
            return groupId;
×
592
        }
593

594
        /**
595
         * Builds the {@link Share} object.
596
         *
597
         * @return the share
598
         */
599
        public Share build() {
600
            if (accessLevel == null || groupId == null) {
1✔
601
                throw new InstantiationError("You must provide a groupId and accessLevel");
×
602
            }
603

604
            Share share = new Share();
1✔
605
            share.accessLevel = accessLevel;
1✔
606
            share.groupId = groupId;
1✔
607
            return share;
1✔
608
        }
609
    }
610
}
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

© 2026 Coveralls, Inc