• 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

83.05
/src/main/java/com/smartsheet/api/models/Group.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 java.util.Date;
20
import java.util.List;
21

22
/**
23
 * Represents a Group Object.
24
 *
25
 * @see <a href="http://help.smartsheet.com/customer/portal/articles/1554165-managing-groups-team-enterprise-only-">Managing groups</a>
26
 */
27
public class Group extends NamedModel<Long> {
28

29
    /**
30
     * The description of the group.
31
     */
32
    private String description;
33

34
    /**
35
     * The email address of the owner of the group.
36
     */
37
    private String owner;
38

39
    /**
40
     * The id of the owner of the group.
41
     */
42
    private Long ownerId;
43

44
    /**
45
     * The date when the group was created.
46
     */
47
    private Date createdAt;
48

49
    /**
50
     * The date when the group was last modified.
51
     */
52
    private Date modifiedAt;
53

54
    /**
55
     * The list of members in the group.
56
     */
57
    private List<GroupMember> members;
58

59
    /**
60
     * Constructors
61
     */
62
    public Group() {
1✔
63
    }
1✔
64

65
    public Group(Long id) {
×
66
        setId(id);
×
67
    }
×
68

69
    /**
70
     * Provide an 'override' of setName (returns Group not NamedModel)
71
     *
72
     * @param name the new name
73
     */
74
    public Group setName(String name) {
75
        super.setName(name);
1✔
76
        return this;
1✔
77
    }
78

79
    /**
80
     * @return the description of the group
81
     */
82
    public String getDescription() {
83
        return description;
1✔
84
    }
85

86
    /**
87
     * @param description the description to set
88
     */
89
    public Group setDescription(String description) {
90
        this.description = description;
1✔
91
        return this;
1✔
92
    }
93

94
    /**
95
     * @return the email address of the owner
96
     */
97
    public String getOwner() {
98
        return owner;
1✔
99
    }
100

101
    /**
102
     * @param owner the owner email address to set
103
     */
104
    public Group setOwner(String owner) {
105
        this.owner = owner;
1✔
106
        return this;
1✔
107
    }
108

109
    /**
110
     * @return the id of the owner of the group.
111
     */
112
    public Long getOwnerId() {
113
        return ownerId;
1✔
114
    }
115

116
    /**
117
     * @param ownerId the owner Id to set
118
     */
119
    public Group setOwnerId(Long ownerId) {
120
        this.ownerId = ownerId;
1✔
121
        return this;
1✔
122
    }
123

124
    /**
125
     * @return the createdAt {@link Date}
126
     */
127
    public Date getCreatedAt() {
128
        return createdAt;
1✔
129
    }
130

131
    /**
132
     * @param createdAt the createdAt {@link Date} to set
133
     */
134
    public Group setCreatedAt(Date createdAt) {
135
        this.createdAt = createdAt;
1✔
136
        return this;
1✔
137
    }
138

139
    /**
140
     * @return the modifiedAt {@link Date}
141
     */
142
    public Date getModifiedAt() {
143
        return modifiedAt;
1✔
144
    }
145

146
    /**
147
     * @param modifiedAt the modifiedAt {@link Date} to set
148
     */
149
    public Group setModifiedAt(Date modifiedAt) {
150
        this.modifiedAt = modifiedAt;
1✔
151
        return this;
1✔
152
    }
153

154
    /**
155
     * @return the {@link List} of {@link Group}s
156
     */
157
    public List<GroupMember> getMembers() {
158
        return members;
1✔
159
    }
160

161
    /**
162
     * @param members the {@link List} of {@link User}s to set
163
     */
164
    public Group setMembers(List<GroupMember> members) {
165
        this.members = members;
1✔
166
        return this;
1✔
167
    }
168

169
    /**
170
     * A convenience class to make a {@link Group} object with the necessary fields to create the group by posting it
171
     * to smartsheet.
172
     */
173
    public static class CreateGroupBuilder {
1✔
174
        private List<GroupMember> members;
175
        private String name;
176
        private String description;
177

178
        /**
179
         * Sets the members for the group being created.
180
         *
181
         * @param members The {@link List} of {@link Group}s to add as members of this group.
182
         * @return the creates the builder
183
         */
184
        public CreateGroupBuilder setMembers(List<GroupMember> members) {
185
            this.members = members;
1✔
186
            return this;
1✔
187
        }
188

189
        /**
190
         * Sets the name for the {@link Group} being created.
191
         *
192
         * @param name The name for the {@link Group} being created.
193
         * @return the creates the builder
194
         */
195
        public CreateGroupBuilder setName(String name) {
196
            this.name = name;
1✔
197
            return this;
1✔
198
        }
199

200
        /**
201
         * Returns the list of members.
202
         *
203
         * @return the columns
204
         */
205
        public List<GroupMember> getMembers() {
206
            return members;
1✔
207
        }
208

209
        /**
210
         * Returns the name for the group.
211
         *
212
         * @return the name
213
         */
214
        public String getName() {
215
            return name;
×
216
        }
217

218
        /**
219
         * Creates a user by using the values from setters in this builder.
220
         *
221
         * @return the sheet
222
         */
223
        public Group build() {
224
            Group group = new Group();
1✔
225

226
            if (name == null) {
1✔
227
                throw new InstantiationError();
×
228
            }
229
            group.setName(name);
1✔
230
            group.setMembers(members);
1✔
231
            group.setDescription(description);
1✔
232
            return group;
1✔
233
        }
234

235
        /**
236
         * @return the description of the group
237
         */
238
        public String getDescription() {
239
            return description;
×
240
        }
241

242
        /**
243
         * @param description the description to set
244
         * @return the builder
245
         */
246
        public CreateGroupBuilder setDescription(String description) {
247
            this.description = description;
1✔
248
            return this;
1✔
249
        }
250
    }
251

252
    /**
253
     * A convenience class to update a {@link Group} object with the necessary fields to create the group by putting it
254
     * to smartsheet.
255
     */
256
    public static class UpdateGroupBuilder {
1✔
257
        private String name;
258
        private String description;
259
        private Long id;
260

261
        /**
262
         * Sets the name for the {@link Group} being created.
263
         *
264
         * @param name The name for the {@link Group} being created.
265
         * @return the creates the builder
266
         */
267
        public UpdateGroupBuilder setName(String name) {
268
            this.name = name;
1✔
269
            return this;
1✔
270
        }
271

272
        /**
273
         * Returns the name for the group.
274
         *
275
         * @return the name
276
         */
277
        public String getName() {
278
            return name;
×
279
        }
280

281
        /**
282
         * Creates a user by using the values from setters in this builder.
283
         *
284
         * @return the sheet
285
         */
286
        public Group build() {
287
            Group group = new Group();
1✔
288

289
            if (name == null || id == null) {
1✔
290
                throw new InstantiationError();
×
291
            }
292
            group.setDescription(description);
1✔
293
            group.setName(name);
1✔
294
            group.setId(id);
1✔
295
            return group;
1✔
296
        }
297

298
        /**
299
         * @return the description of the group
300
         */
301
        public String getDescription() {
302
            return description;
×
303
        }
304

305
        /**
306
         * @param description the description to set
307
         * @return the builder
308
         */
309
        public UpdateGroupBuilder setDescription(String description) {
310
            this.description = description;
1✔
311
            return this;
1✔
312
        }
313

314
        /**
315
         * @return the id of the {@link Group}
316
         */
317
        public Long getId() {
318
            return id;
×
319
        }
320

321
        /**
322
         * @param id the id to set
323
         * @return the builder
324
         */
325
        public UpdateGroupBuilder setId(Long id) {
326
            this.id = id;
1✔
327
            return this;
1✔
328
        }
329
    }
330
}
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