• 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

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

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

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

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

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

73
        /**
74
         * Gets the admin.
75
         *
76
         * @return the admin
77
         */
78
        public Boolean getAdmin() {
79
            return admin;
×
80
        }
81

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

91
        /**
92
         * @return the firstName
93
         */
94
        public String getFirstName() {
95
            return firstName;
×
96
        }
97

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

107
        /**
108
         * @return the lastName
109
         */
110
        public String getLastName() {
111
            return lastName;
×
112
        }
113

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

123
        /**
124
         * @return the groupAdmin
125
         */
126
        public Boolean getGroupAdmin() {
127
            return groupAdmin;
×
128
        }
129

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

139
        /**
140
         * @return the resourceViewer
141
         */
142
        public Boolean getResourceViewer() {
143
            return resourceViewer;
×
144
        }
145

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

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

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

174
            return user;
×
175
        }
176

177
    }
178

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

343
        /**
344
         * Get the email of the user
345
         *
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
         *
355
         * @param email the email
356
         * @return the builder
357
         */
358
        public NewGroupMemberBuilder setEmail(String email) {
359
            this.email = email;
×
360
            return this;
×
361
        }
362

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

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