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

smartsheet / smartsheet-java-sdk / #41

24 Aug 2023 04:59PM UTC coverage: 50.458% (+0.01%) from 50.444%
#41

push

github-actions

web-flow
Fix Checkstyle Violations in "Impl" Classes (#53)

241 of 241 new or added lines in 32 files covered. (100.0%)

3417 of 6772 relevant lines covered (50.46%)

0.5 hits per line

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

81.1
/src/main/java/com/smartsheet/api/models/AbstractSheet.java
1
package com.smartsheet.api.models;
2

3
/*
4
 * #[license]
5
 * Smartsheet Java SDK
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.fasterxml.jackson.annotation.JsonIgnore;
24
import com.smartsheet.api.models.enums.AccessLevel;
25
import com.smartsheet.api.models.enums.AttachmentType;
26
import com.smartsheet.api.models.enums.ResourceManagementType;
27

28
import java.util.Date;
29
import java.util.EnumSet;
30
import java.util.List;
31

32
public abstract class AbstractSheet<TRow extends AbstractRow<TColumn, TCell>, TColumn extends Column, TCell extends Cell>
1✔
33
        extends NamedModel<Long> {
34

35
    /**
36
     * Represents the ID of the sheet/template from which the sheet was created.
37
     */
38
    private Long fromId;
39

40
    /**
41
     * Represents the owner id of the owner.
42
     */
43
    private Long ownerId;
44

45
    /**
46
     * Represents the access level for the sheet.
47
     */
48
    private AccessLevel accessLevel;
49

50
    /**
51
     * Represents the attachments for the sheet.
52
     */
53
    private List<Attachment> attachments;
54

55
    /**
56
     * Represents the columns for the sheet.
57
     */
58
    private List<TColumn> columns;
59

60
    /**
61
     * Get a list of contact references used by MULTI_CONTACT columns in this sheet
62
     */
63
    private List<ContactObjectValue> contactReferences;
64

65
    /**
66
     * Represents the creation timestamp for the sheet.
67
     */
68
    private Date createdAt;
69

70
    /**
71
     * Get a list of cross sheet references used by this sheet
72
     */
73
    private List<CrossSheetReference> crossSheetReferences;
74

75
    /**
76
     * Represents the dependencies enabled flag.
77
     *
78
     * @see <a href="http://help.smartsheet.com/customer/portal/articles/765727-using-the-dependencies-functionality">
79
     * Dependencies Functionality</a>
80
     */
81
    private Boolean dependenciesEnabled;
82

83
    /**
84
     * Represents the discussions for the sheet.
85
     */
86
    private List<Discussion> discussions;
87

88
    /**
89
     * Represents effective attachment options.
90
     */
91
    private EnumSet<AttachmentType> effectiveAttachmentOptions;
92

93
    /**
94
     * Identifies if the sheet is marked as favorite.
95
     */
96
    private Boolean favorite;
97

98
    /**
99
     * List of sheet filters
100
     */
101
    private List<SheetFilter> filters;
102

103
    /**
104
     * Represents the Gantt enabled flag.
105
     */
106
    private Boolean ganttEnabled;
107

108
    /**
109
     * Indicates whether a sheet summary is present
110
     */
111
    private Boolean hasSummaryFields;
112

113
    /**
114
     * Represents the modification timestamp for the sheet.
115
     */
116
    private Date modifiedAt;
117

118
    /**
119
     * Represents the owner of the sheet.
120
     */
121
    private String owner;
122

123
    /**
124
     * Represents the direct URL to the sheet.
125
     */
126
    private String permalink;
127

128
    /**
129
     * Represents projects settings for a dependency-enabled sheet
130
     */
131
    private ProjectSettings projectSettings;
132

133
    /**
134
     * Represents the read only flag for the sheet.
135
     */
136
    private Boolean readOnly;
137

138
    /**
139
     * A flag that indicates if resource management is enabled for a sheet.
140
     */
141
    private Boolean resourceManagementEnabled;
142

143
    /**
144
     * A flag that indicates if resource management is enabled for a sheet.
145
     */
146
    private ResourceManagementType resourceManagementType;
147

148
    /**
149
     * Represents the rows for the sheet.
150
     */
151
    private List<TRow> rows;
152

153
    /**
154
     * Identifies if it is enabled to show parent rows for filters.
155
     */
156
    private Boolean showParentRowsForFilters;
157

158
    /**
159
     * Represents the source of the sheet.
160
     */
161
    private Source source;
162

163
    /**
164
     * A SheetSummary object containing a list of defined fields and values for the sheet.
165
     */
166
    private SheetSummary summary;
167

168
    /**
169
     * Represents the total number of rows in the sheet.
170
     */
171
    private Integer totalRowCount;
172

173
    /**
174
     * A SheetUserPermissions object indicating what summary operations are possible for the current user
175
     */
176
    private SheetUserPermissions userPermissions;
177

178
    /**
179
     * Represents the user settings.
180
     */
181
    private SheetUserSettings userSettings;
182

183
    /**
184
     * Represents the version for the sheet
185
     */
186
    private Integer version;
187

188
    /**
189
     * A Workspace object containing Id and Name (if this sheet is in a Workspace)
190
     */
191
    private Workspace workspace;
192

193
    /**
194
     * Gets the ID of the sheet/template from which the sheet was created.
195
     *
196
     * @return the from id
197
     */
198
    public Long getFromId() {
199
        return fromId;
1✔
200
    }
201

202
    /**
203
     * Sets the ID of the sheet/template from which the sheet was created.
204
     *
205
     * @param fromId the new from id
206
     */
207
    @SuppressWarnings("unchecked")
208
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setFromId(Long fromId) {
209
        this.fromId = fromId;
1✔
210
        return (T) this;
1✔
211
    }
212

213
    /**
214
     * Gets the owner id.
215
     *
216
     * @return the ownerid
217
     */
218
    public Long getOwnerId() {
219
        return ownerId;
1✔
220
    }
221

222
    /**
223
     * Sets the owner id.
224
     *
225
     * @param ownerId the owner id
226
     */
227
    @SuppressWarnings("unchecked")
228
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setOwnerId(long ownerId) {
229
        this.ownerId = ownerId;
1✔
230
        return (T) this;
1✔
231
    }
232

233
    /**
234
     * Gets the access level for the sheet.
235
     *
236
     * @return the access level
237
     */
238
    public AccessLevel getAccessLevel() {
239
        return accessLevel;
1✔
240
    }
241

242
    /**
243
     * Sets the access level for the sheet.
244
     *
245
     * @param accessLevel the new access level
246
     */
247
    @SuppressWarnings("unchecked")
248
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setAccessLevel(AccessLevel accessLevel) {
249
        this.accessLevel = accessLevel;
1✔
250
        return (T) this;
1✔
251
    }
252

253
    /**
254
     * Gets the attachments for the sheet.
255
     *
256
     * @return the attachments
257
     */
258
    public List<Attachment> getAttachments() {
259
        return attachments;
1✔
260
    }
261

262
    /**
263
     * Sets the attachments for the sheet.
264
     *
265
     * @param attachments the new attachments
266
     */
267
    @SuppressWarnings("unchecked")
268
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setAttachments(List<Attachment> attachments) {
269
        this.attachments = attachments;
1✔
270
        return (T) this;
1✔
271
    }
272

273
    /**
274
     * Gets the columns for the sheet.
275
     *
276
     * @return the columns
277
     */
278
    public List<TColumn> getColumns() {
279
        return columns;
1✔
280
    }
281

282
    /**
283
     * Sets the columns for the sheet.
284
     *
285
     * @param columns the new columns
286
     */
287
    @SuppressWarnings("unchecked")
288
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setColumns(List<TColumn> columns) {
289
        this.columns = columns;
1✔
290
        return (T) this;
1✔
291
    }
292

293
    /**
294
     * Sets contact references used by MULTI_CONTACT_LIST columns
295
     *
296
     * @return contact references
297
     */
298
    public List<ContactObjectValue> getContactReferences() {
299
        return contactReferences;
1✔
300
    }
301

302
    /**
303
     * Sets contact references used by MULTI_CONTACT_LIST columns
304
     *
305
     * @param contactReferences
306
     */
307
    @SuppressWarnings("unchecked")
308
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setContactReferences(List<ContactObjectValue> contactReferences) {
309
        this.contactReferences = contactReferences;
×
310
        return (T) this;
×
311
    }
312

313
    /**
314
     * Gets the date and time the sheet was created.
315
     *
316
     * @return the created at
317
     */
318
    public Date getCreatedAt() {
319
        return createdAt;
1✔
320
    }
321

322
    /**
323
     * Sets the date and time the sheet was created.
324
     *
325
     * @param createdAt the new created at
326
     */
327
    @SuppressWarnings("unchecked")
328
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setCreatedAt(Date createdAt) {
329
        this.createdAt = createdAt;
1✔
330
        return (T) this;
1✔
331
    }
332

333
    /**
334
     * Gets the list of cross sheet references used by this sheet
335
     *
336
     * @return the cross sheet references
337
     */
338
    public List<CrossSheetReference> getCrossSheetReferences() {
339
        return crossSheetReferences;
1✔
340
    }
341

342
    /**
343
     * Sets the list of cross sheet references used by this sheet
344
     *
345
     * @param crossSheetReferences the cross sheet references
346
     */
347
    @SuppressWarnings("unchecked")
348
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setCrossSheetReferences(List<CrossSheetReference> crossSheetReferences) {
349
        this.crossSheetReferences = crossSheetReferences;
×
350
        return (T) this;
×
351
    }
352

353
    /**
354
     * Gets the dependencies enabled flag.
355
     *
356
     * @return the dependencies enabled
357
     */
358
    public Boolean getDependenciesEnabled() {
359
        return dependenciesEnabled;
1✔
360
    }
361

362
    /**
363
     * Sets the dependencies enabled flag.
364
     *
365
     * @param dependenciesEnabled the new dependencies enabled
366
     */
367
    @SuppressWarnings("unchecked")
368
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setDependenciesEnabled(Boolean dependenciesEnabled) {
369
        this.dependenciesEnabled = dependenciesEnabled;
1✔
370
        return (T) this;
1✔
371
    }
372

373
    /**
374
     * Gets the discussions for the sheet.
375
     *
376
     * @return the discussions
377
     */
378
    public List<Discussion> getDiscussions() {
379
        return discussions;
1✔
380
    }
381

382
    /**
383
     * Sets the discussions for the sheet.
384
     *
385
     * @param discussions the new discussions
386
     */
387
    @SuppressWarnings("unchecked")
388
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setDiscussions(List<Discussion> discussions) {
389
        this.discussions = discussions;
1✔
390
        return (T) this;
1✔
391
    }
392

393
    /**
394
     * Gets the effective attachment options.
395
     *
396
     * @return list of attachment types
397
     */
398
    public EnumSet<AttachmentType> getEffectiveAttachmentOptions() {
399
        return effectiveAttachmentOptions;
1✔
400
    }
401

402
    /**
403
     * Sets the effective attachment options.
404
     *
405
     * @param effectiveAttachmentOptions the effective attachment options
406
     */
407
    @SuppressWarnings("unchecked")
408
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setEffectiveAttachmentOptions(EnumSet<AttachmentType> effectiveAttachmentOptions) {
409
        this.effectiveAttachmentOptions = effectiveAttachmentOptions;
×
410
        return (T) this;
×
411
    }
412

413
    /**
414
     * True if the sheet is a favorite sheet.
415
     *
416
     * @return the favorite
417
     */
418
    public Boolean isFavorite() {
419
        return favorite;
1✔
420
    }
421

422
    /**
423
     * Sets the favorite sheet
424
     *
425
     * @param favorite the favorite
426
     */
427
    @SuppressWarnings("unchecked")
428
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setFavorite(Boolean favorite) {
429
        this.favorite = favorite;
×
430
        return (T) this;
×
431
    }
432

433
    /**
434
     * Get the list of sheet filters for this sheet.
435
     *
436
     * @return the list of SheetFilters
437
     */
438
    public List<SheetFilter> getFilters() {
439
        return filters;
1✔
440
    }
441

442
    /**
443
     * Sets the list of sheet filters for this sheet.
444
     *
445
     * @param filters the list of SheetFilters
446
     */
447
    @SuppressWarnings("unchecked")
448
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setFilters(List<SheetFilter> filters) {
449
        this.filters = filters;
×
450
        return (T) this;
×
451
    }
452

453
    /**
454
     * Gets the gantt enabled flag.
455
     *
456
     * @return the gantt enabled flag
457
     */
458
    public Boolean getGanttEnabled() {
459
        return ganttEnabled;
1✔
460
    }
461

462
    /**
463
     * Sets the gantt enabled flag.
464
     *
465
     * @param ganttEnabled the new gantt enabled flag
466
     */
467
    @SuppressWarnings("unchecked")
468
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setGanttEnabled(Boolean ganttEnabled) {
469
        this.ganttEnabled = ganttEnabled;
1✔
470
        return (T) this;
1✔
471
    }
472

473
    /**
474
     * Gets flag indicating whether a sheet summary is present
475
     *
476
     * @return hasSheetSummary
477
     */
478
    public Boolean getHasSummaryFields() {
479
        return hasSummaryFields;
1✔
480
    }
481

482
    /**
483
     * Sets flag indicating whether a sheet summary is present
484
     *
485
     * @param hasSummaryFields
486
     */
487
    @SuppressWarnings("unchecked")
488
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setHasSummaryFields(Boolean hasSummaryFields) {
489
        this.hasSummaryFields = hasSummaryFields;
×
490
        return (T) this;
×
491
    }
492

493
    /**
494
     * Gets the date and time the sheet was last modified.
495
     *
496
     * @return the modified at
497
     */
498
    public Date getModifiedAt() {
499
        return modifiedAt;
1✔
500
    }
501

502
    /**
503
     * Sets the date and time the sheet was last modified.
504
     *
505
     * @param modifiedAt the new modified at
506
     */
507
    @SuppressWarnings("unchecked")
508
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setModifiedAt(Date modifiedAt) {
509
        this.modifiedAt = modifiedAt;
1✔
510
        return (T) this;
1✔
511
    }
512

513
    /**
514
     * Provide an 'override' of setName (returns AbstractSheet not NamedModel)
515
     *
516
     * @param name the new name
517
     */
518
    public AbstractSheet<TRow, TColumn, TCell> setName(String name) {
519
        super.setName(name);
1✔
520
        return this;
1✔
521
    }
522

523
    /**
524
     * version of setName that returns this type
525
     *
526
     * @param name the new name
527
     * @return this
528
     */
529
    @SuppressWarnings("unchecked")
530
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setSheetName(String name) {
531
        super.setName(name);
1✔
532
        return (T) this;
1✔
533
    }
534

535
    /**
536
     * version of setId that returns this type
537
     * @param id the new sheet ID
538
     * @return this
539
     */
540
    @JsonIgnore(false)
541
    @SuppressWarnings("unchecked")
542
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setSheetId(Long id) {
543
        super.setId(id);
1✔
544
        return (T) this;
1✔
545
    }
546

547
    /**
548
     * Gets the owner email.
549
     *
550
     * @return the owner email
551
     */
552
    public String getOwner() {
553
        return owner;
1✔
554
    }
555

556
    /**
557
     * Sets the owner
558
     *
559
     * @param owner the owner email
560
     */
561
    @SuppressWarnings("unchecked")
562
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setOwner(String owner) {
563
        this.owner = owner;
1✔
564
        return (T) this;
1✔
565
    }
566

567
    /**
568
     * Gets the permalink for the sheet.
569
     *
570
     * @return the permalink
571
     */
572
    public String getPermalink() {
573
        return permalink;
1✔
574
    }
575

576
    /**
577
     * Sets the permalink for the sheet.
578
     *
579
     * @param permalink the new permalink
580
     */
581
    @SuppressWarnings("unchecked")
582
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setPermalink(String permalink) {
583
        this.permalink = permalink;
1✔
584
        return (T) this;
1✔
585
    }
586

587
    /**
588
     * Gets the project settings.
589
     *
590
     * @return the project settings
591
     */
592
    public ProjectSettings getProjectSettings() {
593
        return projectSettings;
1✔
594
    }
595

596
    /**
597
     * Sets the project settings.
598
     *
599
     * @param projectSettings the project settings
600
     */
601
    @SuppressWarnings("unchecked")
602
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setProjectSettings(ProjectSettings projectSettings) {
603
        this.projectSettings = projectSettings;
1✔
604
        return (T) this;
1✔
605
    }
606

607
    /**
608
     * Gets the read only flag for the sheet.
609
     *
610
     * @return the read only
611
     */
612
    public Boolean getReadOnly() {
613
        return readOnly;
1✔
614
    }
615

616
    /**
617
     * Sets the read only flag for the sheet.
618
     *
619
     * @param readOnly the new read only
620
     */
621
    @SuppressWarnings("unchecked")
622
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setReadOnly(Boolean readOnly) {
623
        this.readOnly = readOnly;
1✔
624
        return (T) this;
1✔
625
    }
626

627
    /**
628
     * @return the flag indicating if resource management is enabled.
629
     */
630
    public Boolean getResourceManagementEnabled() {
631
        return resourceManagementEnabled;
1✔
632
    }
633

634
    /**
635
     * @param resourceManagementEnabled the resourceManagementEnabled to set
636
     */
637
    @SuppressWarnings("unchecked")
638
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setResourceManagementEnabled(Boolean resourceManagementEnabled) {
639
        this.resourceManagementEnabled = resourceManagementEnabled;
×
640
        return (T) this;
×
641
    }
642

643
    /**
644
     * Gets the resource management type for the sheet.
645
     *
646
     * @return the resource management type
647
     */
648
    public ResourceManagementType getResourceManagementType() {
649
        return resourceManagementType;
1✔
650
    }
651

652
    /**
653
     * Sets the access level for the sheet.
654
     */
655
    @SuppressWarnings("unchecked")
656
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setResourceManagementType(ResourceManagementType resourceManagementType) {
657
        this.resourceManagementType = resourceManagementType;
×
658
        return (T) this;
×
659
    }
660

661
    /**
662
     * Gets the rows for the sheet.
663
     *
664
     * @return the rows
665
     */
666
    public List<TRow> getRows() {
667
        return rows;
1✔
668
    }
669

670
    /**
671
     * Sets the rows for the sheet.
672
     *
673
     * @param rows the new rows
674
     */
675
    @SuppressWarnings("unchecked")
676
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setRows(List<TRow> rows) {
677
        this.rows = rows;
1✔
678
        return (T) this;
1✔
679
    }
680

681
    /**
682
     * True if show parent rows for filters.
683
     *
684
     * @return the show parent row for filters
685
     */
686
    public Boolean getShowParentRowsForFilters() {
687
        return showParentRowsForFilters;
1✔
688
    }
689

690
    /**
691
     * Sets the show parent rows for filters.
692
     *
693
     * @param showParentRowsForFilters the show parent rows for filters
694
     */
695
    @SuppressWarnings("unchecked")
696
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setShowParentRowsForFilters(Boolean showParentRowsForFilters) {
697
        this.showParentRowsForFilters = showParentRowsForFilters;
×
698
        return (T) this;
×
699
    }
700

701
    /**
702
     * Gets the source.
703
     *
704
     * @return the source
705
     */
706
    public Source getSource() {
707
        return source;
1✔
708
    }
709

710
    /**
711
     * Sets the source.
712
     *
713
     * @param source the source
714
     */
715
    @SuppressWarnings("unchecked")
716
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setSource(Source source) {
717
        this.source = source;
1✔
718
        return (T) this;
1✔
719
    }
720

721
    /**
722
     * Gets the sheet summary if one exists for this sheet
723
     *
724
     * @return sheetSummary
725
     */
726
    public SheetSummary getSummary() {
727
        return summary;
1✔
728
    }
729

730
    /**
731
     * Sets the sheet summary if one exists for this sheet
732
     */
733
    @SuppressWarnings("unchecked")
734
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setSummary(SheetSummary summary) {
735
        this.summary = summary;
×
736
        return (T) this;
×
737
    }
738

739
    /**
740
     * Gets the total row count for the sheet.
741
     *
742
     * @return the total row count
743
     */
744
    public Integer getTotalRowCount() {
745
        return totalRowCount;
1✔
746
    }
747

748
    /**
749
     * Sets the total row count.
750
     *
751
     * @param totalRowCount the total row count
752
     */
753
    @SuppressWarnings("unchecked")
754
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setTotalRowCount(Integer totalRowCount) {
755
        this.totalRowCount = totalRowCount;
1✔
756
        return (T) this;
1✔
757
    }
758

759
    /**
760
     * Gets the sheet user permissions
761
     *
762
     * @return userPermissions
763
     */
764
    public SheetUserPermissions getUserPermissions() {
765
        return userPermissions;
1✔
766
    }
767

768
    /**
769
     * Sets the sheet user permissions
770
     */
771
    @SuppressWarnings("unchecked")
772
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setUserPermissions(SheetUserPermissions userPermissions) {
773
        this.userPermissions = userPermissions;
×
774
        return (T) this;
×
775
    }
776

777
    /**
778
     * Gets the sheet user settings.
779
     *
780
     * @return the user settings
781
     */
782
    public SheetUserSettings getUserSettings() {
783
        return userSettings;
1✔
784
    }
785

786
    /**
787
     * Sets the user settings.
788
     *
789
     * @param userSettings the user settings
790
     */
791
    @SuppressWarnings("unchecked")
792
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setUserSettings(SheetUserSettings userSettings) {
793
        this.userSettings = userSettings;
1✔
794
        return (T) this;
1✔
795
    }
796

797
    /**
798
     * Gets the version for the sheet.
799
     *
800
     * @return the version
801
     */
802
    public Integer getVersion() {
803
        return version;
1✔
804
    }
805

806
    /**
807
     * Sets the version for the sheet.
808
     *
809
     * @param version the new version
810
     */
811
    @SuppressWarnings("unchecked")
812
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setVersion(Integer version) {
813
        this.version = version;
1✔
814
        return (T) this;
1✔
815
    }
816

817
    /**
818
     * Gets a workspace object containing the name and id of the workspace containing this sheet
819
     *
820
     * @return workspace
821
     */
822
    public Workspace getWorkspace() {
823
        return workspace;
1✔
824
    }
825

826
    /**
827
     * Sets a workspace object containing the name and id of the workspace containing this sheet
828
     */
829
    @SuppressWarnings("unchecked")
830
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setWorkspace(Workspace workspace) {
831
        this.workspace = workspace;
×
832
        return (T) this;
×
833
    }
834

835
    /**
836
     * Get a column by index.
837
     *
838
     * @param index the column index
839
     * @return the column by index
840
     */
841
    public TColumn getColumnByIndex(int index) {
842
        if (columns == null) {
1✔
843
            return null;
1✔
844
        }
845

846
        TColumn result = null;
1✔
847
        for (TColumn column : columns) {
1✔
848
            if (column.getIndex() == index) {
1✔
849
                result = column;
1✔
850
                break;
1✔
851
            }
852
        }
1✔
853
        return result;
1✔
854
    }
855

856
    /**
857
     * Get a {@link Column} by ID.
858
     *
859
     * @param columnId the column id
860
     * @return the column by id
861
     */
862
    public TColumn getColumnById(long columnId) {
863
        if (columns == null) {
1✔
864
            return null;
1✔
865
        }
866

867
        TColumn result = null;
1✔
868
        for (TColumn column : columns) {
1✔
869
            if (column.getId() == columnId) {
1✔
870
                result = column;
1✔
871
                break;
1✔
872
            }
873
        }
1✔
874
        return result;
1✔
875
    }
876

877
    /**
878
     * Get a {@link Row} by row number.
879
     *
880
     * @param rowNumber the row number
881
     * @return the row by row number
882
     */
883
    public TRow getRowByRowNumber(int rowNumber) {
884
        if (rows == null) {
1✔
885
            return null;
1✔
886
        }
887

888
        TRow result = null;
1✔
889
        for (TRow row : rows) {
1✔
890
            if (row.getRowNumber() == rowNumber) {
1✔
891
                result = row;
1✔
892
                break;
1✔
893
            }
894
        }
1✔
895
        return result;
1✔
896
    }
897
}
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