• 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

1.33
/src/main/java/com/smartsheet/api/models/User.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
/**
24
 * Represents the User object.
25
 * @see <a href="http://help.smartsheet.com/customer/portal/articles/795920-managing-users-team-enterprise-only-">Help
26
 * Managing Users</a>
27
 * @see <a href="http://help.smartsheet.com/customer/portal/articles/520100-user-types">User Types Help</a>
28
 */
29
public class User extends UserModelWithName {
1✔
30

31
    /**
32
     * A convenience class for making a {@link User} object with the appropriate fields for adding the user.
33
     */
34
    public static class AddUserBuilder {
×
35
        private Boolean admin;
36
        private String emailAddress;
37
        private Boolean licensedSheetCreator;
38
        private Boolean groupAdmin;
39
        private Boolean resourceViewer;
40
        private String firstName;
41
        private String lastName;
42

43
        /**
44
         * Sets the admin flag which allows managing users and accounts.
45
         *
46
         * @param admin the admin
47
         * @return the adds the user builder
48
         */
49
        public AddUserBuilder setAdmin(Boolean admin) {
50
            this.admin = admin;
×
51
            return this;
×
52
        }
53

54
        /**
55
         * Sets the licensed sheet creator flag that allows creating and owning sheets.
56
         *
57
         * @param licensedSheetCreator the licensed sheet creator
58
         * @return the adds the user builder
59
         */
60
        public AddUserBuilder setLicensedSheetCreator(Boolean licensedSheetCreator) {
61
            this.licensedSheetCreator = licensedSheetCreator;
×
62
            return this;
×
63
        }
64

65
        /**
66
         * Sets the email for the user.
67
         *
68
         * @param email the email
69
         * @return the adds the user builder
70
         */
71
        public AddUserBuilder setEmail(String email) {
72
            this.emailAddress = email;
×
73
            return this;
×
74
        }
75

76
        /**
77
         * Gets the admin.
78
         *
79
         * @return the admin
80
         */
81
        public Boolean getAdmin() {
82
            return admin;
×
83
        }
84

85
        /**
86
         * Gets the licensed sheet creator.
87
         *
88
         * @return the licensed sheet creator
89
         */
90
        public Boolean getLicensedSheetCreator() {
91
            return licensedSheetCreator;
×
92
        }
93

94
        /**
95
         * @return the firstName
96
         */
97
        public String getFirstName() {
98
            return firstName;
×
99
        }
100

101
        /**
102
         * @param firstName the firstName to set
103
         * @return the builder
104
         */
105
        public AddUserBuilder setFirstName(String firstName) {
106
            this.firstName = firstName;
×
107
            return this;
×
108
        }
109

110
        /**
111
         * @return the lastName
112
         */
113
        public String getLastName() {
114
            return lastName;
×
115
        }
116

117
        /**
118
         * @param lastName the lastName to set
119
         * @return the builder
120
         */
121
        public AddUserBuilder setLastName(String lastName) {
122
            this.lastName = lastName;
×
123
            return this;
×
124
        }
125

126
        /**
127
         * @return the groupAdmin
128
         */
129
        public Boolean getGroupAdmin() {
130
            return groupAdmin;
×
131
        }
132

133
        /**
134
         * @param groupAdmin the groupAdmin to set
135
         * @return the builder
136
         */
137
        public AddUserBuilder setGroupAdmin(Boolean groupAdmin) {
138
            this.groupAdmin = groupAdmin;
×
139
            return this;
×
140
        }
141

142
        /**
143
         * @return the resourceViewer
144
         */
145
        public Boolean getResourceViewer() {
146
            return resourceViewer;
×
147
        }
148

149
        /**
150
         * @param resourceViewer the resourceViewer to set
151
         * @return the builder
152
         */
153
        public AddUserBuilder setResourceViewer(Boolean resourceViewer) {
154
            this.resourceViewer = resourceViewer;
×
155
            return this;
×
156
        }
157

158
        /**
159
         * Builds the {@link User} object using the required fields.
160
         *
161
         * @return the user
162
         */
163
        public User build() {
164
            if (admin == null || emailAddress == null || licensedSheetCreator == null) {
×
165
                throw new InstantiationError();
×
166
            }
167

168
            User user = new User();
×
169
            user.setAdmin(admin);
×
170
            user.setLicensedSheetCreator(licensedSheetCreator);
×
171
            user.setGroupAdmin(groupAdmin);
×
172
            user.setResourceViewer(resourceViewer);
×
173
            user.setFirstName(firstName);
×
174
            user.setLastName(lastName);
×
175
            user.setEmail(emailAddress);
×
176

177
            return user;
×
178
        }
179

180
    }
181

182
    /**
183
     * A convenience class for making a {@link User} object with the appropriate fields for updating a user.
184
     */
185
    public static class UpdateUserBuilder {
×
186
        private Boolean admin;
187
        private Boolean licensedSheetCreator;
188
        private Boolean groupAdmin;
189
        private Boolean resourceViewer;
190
        private String firstName;
191
        private String lastName;
192
        private Long id;
193

194
        /**
195
         * Get the id of the user
196
         * @return the id
197
         */
198
        public Long getUserId() {
199
            return id;
×
200
        }
201

202
        /**
203
         * Set the user id
204
         * @param userId the user id
205
         * @return the updateSheetBuilder object
206
         */
207
        public UpdateUserBuilder setUserId(Long userId) {
208
            this.id = userId;
×
209
            return this;
×
210
        }
211

212
        /**
213
         * Sets the admin flag which allows managing users and accounts.
214
         *
215
         * @param admin the admin
216
         * @return the update user builder
217
         */
218
        public UpdateUserBuilder setAdmin(Boolean admin) {
219
            this.admin = admin;
×
220
            return this;
×
221
        }
222

223
        /**
224
         * Licensed sheet creator.
225
         *
226
         * @param licensedSheetCreator the licensed sheet creator
227
         * @return the update user builder
228
         */
229
        public UpdateUserBuilder setLicensedSheetCreator(Boolean licensedSheetCreator) {
230
            this.licensedSheetCreator = licensedSheetCreator;
×
231
            return this;
×
232
        }
233

234
        /**
235
         * Gets the admin.
236
         *
237
         * @return the admin
238
         */
239
        public Boolean getAdmin() {
240
            return admin;
×
241
        }
242

243
        /**
244
         * Gets the licensed sheet creator.
245
         *
246
         * @return the licensed sheet creator
247
         */
248
        public Boolean getLicensedSheetCreator() {
249
            return licensedSheetCreator;
×
250
        }
251

252
        /**
253
         * @return the firstName
254
         */
255
        public String getFirstName() {
256
            return firstName;
×
257
        }
258

259
        /**
260
         * @param firstName the firstName to set
261
         * @return the builder
262
         */
263
        public UpdateUserBuilder setFirstName(String firstName) {
264
            this.firstName = firstName;
×
265
            return this;
×
266
        }
267

268
        /**
269
         * @return the lastName
270
         */
271
        public String getLastName() {
272
            return lastName;
×
273
        }
274

275
        /**
276
         * @param lastName the lastName to set
277
         * @return the builder
278
         */
279
        public UpdateUserBuilder setLastName(String lastName) {
280
            this.lastName = lastName;
×
281
            return this;
×
282
        }
283

284
        /**
285
         * @return the groupAdmin
286
         */
287
        public Boolean getGroupAdmin() {
288
            return groupAdmin;
×
289
        }
290

291
        /**
292
         * @param groupAdmin the groupAdmin to set
293
         * @return the builder
294
         */
295
        public UpdateUserBuilder setGroupAdmin(Boolean groupAdmin) {
296
            this.groupAdmin = groupAdmin;
×
297
            return this;
×
298
        }
299

300
        /**
301
         * @return the resourceViewer
302
         */
303
        public Boolean getResourceViewer() {
304
            return resourceViewer;
×
305
        }
306

307
        /**
308
         * @param resourceViewer the resourceViewer to set
309
         * @return the builder
310
         */
311
        public UpdateUserBuilder setResourceViewer(Boolean resourceViewer) {
312
            this.resourceViewer = resourceViewer;
×
313
            return this;
×
314
        }
315

316
        /**
317
         * Builds the {@link User}.
318
         *
319
         * @return the user
320
         */
321
        public User build() {
322
            if (admin == null || licensedSheetCreator == null || id == null) {
×
323
                throw new InstantiationError("An admin, licensed sheet creator and user Id must be set");
×
324
            }
325

326
            User user = new User();
×
327
            user.setFirstName(firstName);
×
328
            user.setLastName(lastName);
×
329
            user.setAdmin(admin);
×
330
            user.setLicensedSheetCreator(licensedSheetCreator);
×
331
            user.setGroupAdmin(groupAdmin);
×
332
            user.setResourceViewer(resourceViewer);
×
333
            user.setId(id);
×
334
            return user;
×
335
        }
336
    }
337

338
    /**
339
     * A convenience class for making a GroupMember object with the appropriate fields for adding to a {@link Group}.
340
     */
341
    public static class NewGroupMemberBuilder {
×
342
        private String email;
343

344
        /**
345
         * Get the email of the user
346
         * @return email the email
347
         */
348
        public String getEmail() {
349
            return email;
×
350
        }
351

352
        /**
353
         * Set the email id of the user
354
         * @param email the email
355
         * @return the builder
356
         */
357
        public NewGroupMemberBuilder setEmail(String email) {
358
            this.email = email;
×
359
            return this;
×
360
        }
361

362
        /**
363
         * Build a User
364
         */
365
        public User build() {
366
            if (email == null) {
×
367
                throw new InstantiationError("An email address must be set.");
×
368
            }
369

370
            User user = new User();
×
371
            user.setEmail(email);
×
372
            return user;
×
373
        }
374
    }
375
}
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