• 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

81.1
/src/main/java/com/smartsheet/api/models/AbstractSheet.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 com.fasterxml.jackson.annotation.JsonIgnore;
20
import com.smartsheet.api.models.enums.AccessLevel;
21
import com.smartsheet.api.models.enums.AttachmentType;
22
import com.smartsheet.api.models.enums.ResourceManagementType;
23

24
import java.util.Date;
25
import java.util.EnumSet;
26
import java.util.List;
27

28
public abstract class AbstractSheet<TRow extends AbstractRow<TColumn, TCell>, TColumn extends Column, TCell extends Cell>
1✔
29
        extends NamedModel<Long> {
30

31
    /**
32
     * Represents the ID of the sheet/template from which the sheet was created.
33
     */
34
    private Long fromId;
35

36
    /**
37
     * Represents the owner id of the owner.
38
     */
39
    private Long ownerId;
40

41
    /**
42
     * Represents the access level for the sheet.
43
     */
44
    private AccessLevel accessLevel;
45

46
    /**
47
     * Represents the attachments for the sheet.
48
     */
49
    private List<Attachment> attachments;
50

51
    /**
52
     * Represents the columns for the sheet.
53
     */
54
    private List<TColumn> columns;
55

56
    /**
57
     * Get a list of contact references used by MULTI_CONTACT columns in this sheet
58
     */
59
    private List<ContactObjectValue> contactReferences;
60

61
    /**
62
     * Represents the creation timestamp for the sheet.
63
     */
64
    private Date createdAt;
65

66
    /**
67
     * Get a list of cross sheet references used by this sheet
68
     */
69
    private List<CrossSheetReference> crossSheetReferences;
70

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

79
    /**
80
     * Represents the discussions for the sheet.
81
     */
82
    private List<Discussion> discussions;
83

84
    /**
85
     * Represents effective attachment options.
86
     */
87
    private EnumSet<AttachmentType> effectiveAttachmentOptions;
88

89
    /**
90
     * Identifies if the sheet is marked as favorite.
91
     */
92
    private Boolean favorite;
93

94
    /**
95
     * List of sheet filters
96
     */
97
    private List<SheetFilter> filters;
98

99
    /**
100
     * Represents the Gantt enabled flag.
101
     */
102
    private Boolean ganttEnabled;
103

104
    /**
105
     * Indicates whether a sheet summary is present
106
     */
107
    private Boolean hasSummaryFields;
108

109
    /**
110
     * Represents the modification timestamp for the sheet.
111
     */
112
    private Date modifiedAt;
113

114
    /**
115
     * Represents the owner of the sheet.
116
     */
117
    private String owner;
118

119
    /**
120
     * Represents the direct URL to the sheet.
121
     */
122
    private String permalink;
123

124
    /**
125
     * Represents projects settings for a dependency-enabled sheet
126
     */
127
    private ProjectSettings projectSettings;
128

129
    /**
130
     * Represents the read only flag for the sheet.
131
     */
132
    private Boolean readOnly;
133

134
    /**
135
     * A flag that indicates if resource management is enabled for a sheet.
136
     */
137
    private Boolean resourceManagementEnabled;
138

139
    /**
140
     * A flag that indicates if resource management is enabled for a sheet.
141
     */
142
    private ResourceManagementType resourceManagementType;
143

144
    /**
145
     * Represents the rows for the sheet.
146
     */
147
    private List<TRow> rows;
148

149
    /**
150
     * Identifies if it is enabled to show parent rows for filters.
151
     */
152
    private Boolean showParentRowsForFilters;
153

154
    /**
155
     * Represents the source of the sheet.
156
     */
157
    private Source source;
158

159
    /**
160
     * A SheetSummary object containing a list of defined fields and values for the sheet.
161
     */
162
    private SheetSummary summary;
163

164
    /**
165
     * Represents the total number of rows in the sheet.
166
     */
167
    private Integer totalRowCount;
168

169
    /**
170
     * A SheetUserPermissions object indicating what summary operations are possible for the current user
171
     */
172
    private SheetUserPermissions userPermissions;
173

174
    /**
175
     * Represents the user settings.
176
     */
177
    private SheetUserSettings userSettings;
178

179
    /**
180
     * Represents the version for the sheet
181
     */
182
    private Integer version;
183

184
    /**
185
     * A Workspace object containing Id and Name (if this sheet is in a Workspace)
186
     */
187
    private Workspace workspace;
188

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

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

209
    /**
210
     * Gets the owner id.
211
     *
212
     * @return the ownerid
213
     */
214
    public Long getOwnerId() {
215
        return ownerId;
1✔
216
    }
217

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

229
    /**
230
     * Gets the access level for the sheet.
231
     *
232
     * @return the access level
233
     */
234
    public AccessLevel getAccessLevel() {
235
        return accessLevel;
1✔
236
    }
237

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

249
    /**
250
     * Gets the attachments for the sheet.
251
     *
252
     * @return the attachments
253
     */
254
    public List<Attachment> getAttachments() {
255
        return attachments;
1✔
256
    }
257

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

269
    /**
270
     * Gets the columns for the sheet.
271
     *
272
     * @return the columns
273
     */
274
    public List<TColumn> getColumns() {
275
        return columns;
1✔
276
    }
277

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

289
    /**
290
     * Sets contact references used by MULTI_CONTACT_LIST columns
291
     *
292
     * @return contact references
293
     */
294
    public List<ContactObjectValue> getContactReferences() {
295
        return contactReferences;
1✔
296
    }
297

298
    /**
299
     * Sets contact references used by MULTI_CONTACT_LIST columns
300
     */
301
    @SuppressWarnings("unchecked")
302
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setContactReferences(List<ContactObjectValue> contactReferences) {
303
        this.contactReferences = contactReferences;
×
304
        return (T) this;
×
305
    }
306

307
    /**
308
     * Gets the date and time the sheet was created.
309
     *
310
     * @return the created at
311
     */
312
    public Date getCreatedAt() {
313
        return createdAt;
1✔
314
    }
315

316
    /**
317
     * Sets the date and time the sheet was created.
318
     *
319
     * @param createdAt the new created at
320
     */
321
    @SuppressWarnings("unchecked")
322
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setCreatedAt(Date createdAt) {
323
        this.createdAt = createdAt;
1✔
324
        return (T) this;
1✔
325
    }
326

327
    /**
328
     * Gets the list of cross sheet references used by this sheet
329
     *
330
     * @return the cross sheet references
331
     */
332
    public List<CrossSheetReference> getCrossSheetReferences() {
333
        return crossSheetReferences;
1✔
334
    }
335

336
    /**
337
     * Sets the list of cross sheet references used by this sheet
338
     *
339
     * @param crossSheetReferences the cross sheet references
340
     */
341
    @SuppressWarnings("unchecked")
342
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setCrossSheetReferences(List<CrossSheetReference> crossSheetReferences) {
343
        this.crossSheetReferences = crossSheetReferences;
×
344
        return (T) this;
×
345
    }
346

347
    /**
348
     * Gets the dependencies enabled flag.
349
     *
350
     * @return the dependencies enabled
351
     */
352
    public Boolean getDependenciesEnabled() {
353
        return dependenciesEnabled;
1✔
354
    }
355

356
    /**
357
     * Sets the dependencies enabled flag.
358
     *
359
     * @param dependenciesEnabled the new dependencies enabled
360
     */
361
    @SuppressWarnings("unchecked")
362
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setDependenciesEnabled(Boolean dependenciesEnabled) {
363
        this.dependenciesEnabled = dependenciesEnabled;
1✔
364
        return (T) this;
1✔
365
    }
366

367
    /**
368
     * Gets the discussions for the sheet.
369
     *
370
     * @return the discussions
371
     */
372
    public List<Discussion> getDiscussions() {
373
        return discussions;
1✔
374
    }
375

376
    /**
377
     * Sets the discussions for the sheet.
378
     *
379
     * @param discussions the new discussions
380
     */
381
    @SuppressWarnings("unchecked")
382
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setDiscussions(List<Discussion> discussions) {
383
        this.discussions = discussions;
1✔
384
        return (T) this;
1✔
385
    }
386

387
    /**
388
     * Gets the effective attachment options.
389
     *
390
     * @return list of attachment types
391
     */
392
    public EnumSet<AttachmentType> getEffectiveAttachmentOptions() {
393
        return effectiveAttachmentOptions;
1✔
394
    }
395

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

409
    /**
410
     * True if the sheet is a favorite sheet.
411
     *
412
     * @return the favorite
413
     */
414
    public Boolean isFavorite() {
415
        return favorite;
1✔
416
    }
417

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

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

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

449
    /**
450
     * Gets the gantt enabled flag.
451
     *
452
     * @return the gantt enabled flag
453
     */
454
    public Boolean getGanttEnabled() {
455
        return ganttEnabled;
1✔
456
    }
457

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

469
    /**
470
     * Gets flag indicating whether a sheet summary is present
471
     *
472
     * @return hasSheetSummary
473
     */
474
    public Boolean getHasSummaryFields() {
475
        return hasSummaryFields;
1✔
476
    }
477

478
    /**
479
     * Sets flag indicating whether a sheet summary is present
480
     */
481
    @SuppressWarnings("unchecked")
482
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setHasSummaryFields(Boolean hasSummaryFields) {
483
        this.hasSummaryFields = hasSummaryFields;
×
484
        return (T) this;
×
485
    }
486

487
    /**
488
     * Gets the date and time the sheet was last modified.
489
     *
490
     * @return the modified at
491
     */
492
    public Date getModifiedAt() {
493
        return modifiedAt;
1✔
494
    }
495

496
    /**
497
     * Sets the date and time the sheet was last modified.
498
     *
499
     * @param modifiedAt the new modified at
500
     */
501
    @SuppressWarnings("unchecked")
502
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setModifiedAt(Date modifiedAt) {
503
        this.modifiedAt = modifiedAt;
1✔
504
        return (T) this;
1✔
505
    }
506

507
    /**
508
     * Provide an 'override' of setName (returns AbstractSheet not NamedModel)
509
     *
510
     * @param name the new name
511
     */
512
    public AbstractSheet<TRow, TColumn, TCell> setName(String name) {
513
        super.setName(name);
1✔
514
        return this;
1✔
515
    }
516

517
    /**
518
     * version of setName that returns this type
519
     *
520
     * @param name the new name
521
     * @return this
522
     */
523
    @SuppressWarnings("unchecked")
524
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setSheetName(String name) {
525
        super.setName(name);
1✔
526
        return (T) this;
1✔
527
    }
528

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

542
    /**
543
     * Gets the owner email.
544
     *
545
     * @return the owner email
546
     */
547
    public String getOwner() {
548
        return owner;
1✔
549
    }
550

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

562
    /**
563
     * Gets the permalink for the sheet.
564
     *
565
     * @return the permalink
566
     */
567
    public String getPermalink() {
568
        return permalink;
1✔
569
    }
570

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

582
    /**
583
     * Gets the project settings.
584
     *
585
     * @return the project settings
586
     */
587
    public ProjectSettings getProjectSettings() {
588
        return projectSettings;
1✔
589
    }
590

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

602
    /**
603
     * Gets the read only flag for the sheet.
604
     *
605
     * @return the read only
606
     */
607
    public Boolean getReadOnly() {
608
        return readOnly;
1✔
609
    }
610

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

622
    /**
623
     * @return the flag indicating if resource management is enabled.
624
     */
625
    public Boolean getResourceManagementEnabled() {
626
        return resourceManagementEnabled;
1✔
627
    }
628

629
    /**
630
     * @param resourceManagementEnabled the resourceManagementEnabled to set
631
     */
632
    @SuppressWarnings("unchecked")
633
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setResourceManagementEnabled(Boolean resourceManagementEnabled) {
634
        this.resourceManagementEnabled = resourceManagementEnabled;
×
635
        return (T) this;
×
636
    }
637

638
    /**
639
     * Gets the resource management type for the sheet.
640
     *
641
     * @return the resource management type
642
     */
643
    public ResourceManagementType getResourceManagementType() {
644
        return resourceManagementType;
1✔
645
    }
646

647
    /**
648
     * Sets the access level for the sheet.
649
     */
650
    @SuppressWarnings("unchecked")
651
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setResourceManagementType(ResourceManagementType resourceManagementType) {
652
        this.resourceManagementType = resourceManagementType;
×
653
        return (T) this;
×
654
    }
655

656
    /**
657
     * Gets the rows for the sheet.
658
     *
659
     * @return the rows
660
     */
661
    public List<TRow> getRows() {
662
        return rows;
1✔
663
    }
664

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

676
    /**
677
     * True if show parent rows for filters.
678
     *
679
     * @return the show parent row for filters
680
     */
681
    public Boolean getShowParentRowsForFilters() {
682
        return showParentRowsForFilters;
1✔
683
    }
684

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

696
    /**
697
     * Gets the source.
698
     *
699
     * @return the source
700
     */
701
    public Source getSource() {
702
        return source;
1✔
703
    }
704

705
    /**
706
     * Sets the source.
707
     *
708
     * @param source the source
709
     */
710
    @SuppressWarnings("unchecked")
711
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setSource(Source source) {
712
        this.source = source;
1✔
713
        return (T) this;
1✔
714
    }
715

716
    /**
717
     * Gets the sheet summary if one exists for this sheet
718
     *
719
     * @return sheetSummary
720
     */
721
    public SheetSummary getSummary() {
722
        return summary;
1✔
723
    }
724

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

734
    /**
735
     * Gets the total row count for the sheet.
736
     *
737
     * @return the total row count
738
     */
739
    public Integer getTotalRowCount() {
740
        return totalRowCount;
1✔
741
    }
742

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

754
    /**
755
     * Gets the sheet user permissions
756
     *
757
     * @return userPermissions
758
     */
759
    public SheetUserPermissions getUserPermissions() {
760
        return userPermissions;
1✔
761
    }
762

763
    /**
764
     * Sets the sheet user permissions
765
     */
766
    @SuppressWarnings("unchecked")
767
    public <T extends AbstractSheet<TRow, TColumn, TCell>> T setUserPermissions(SheetUserPermissions userPermissions) {
768
        this.userPermissions = userPermissions;
×
769
        return (T) this;
×
770
    }
771

772
    /**
773
     * Gets the sheet user settings.
774
     *
775
     * @return the user settings
776
     */
777
    public SheetUserSettings getUserSettings() {
778
        return userSettings;
1✔
779
    }
780

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

792
    /**
793
     * Gets the version for the sheet.
794
     *
795
     * @return the version
796
     */
797
    public Integer getVersion() {
798
        return version;
1✔
799
    }
800

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

812
    /**
813
     * Gets a workspace object containing the name and id of the workspace containing this sheet
814
     *
815
     * @return workspace
816
     */
817
    public Workspace getWorkspace() {
818
        return workspace;
1✔
819
    }
820

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

830
    /**
831
     * Get a column by index.
832
     *
833
     * @param index the column index
834
     * @return the column by index
835
     */
836
    public TColumn getColumnByIndex(int index) {
837
        if (columns == null) {
1✔
838
            return null;
1✔
839
        }
840

841
        TColumn result = null;
1✔
842
        for (TColumn column : columns) {
1✔
843
            if (column.getIndex() == index) {
1✔
844
                result = column;
1✔
845
                break;
1✔
846
            }
847
        }
1✔
848
        return result;
1✔
849
    }
850

851
    /**
852
     * Get a {@link Column} by ID.
853
     *
854
     * @param columnId the column id
855
     * @return the column by id
856
     */
857
    public TColumn getColumnById(long columnId) {
858
        if (columns == null) {
1✔
859
            return null;
1✔
860
        }
861

862
        TColumn result = null;
1✔
863
        for (TColumn column : columns) {
1✔
864
            if (column.getId() == columnId) {
1✔
865
                result = column;
1✔
866
                break;
1✔
867
            }
868
        }
1✔
869
        return result;
1✔
870
    }
871

872
    /**
873
     * Get a {@link Row} by row number.
874
     *
875
     * @param rowNumber the row number
876
     * @return the row by row number
877
     */
878
    public TRow getRowByRowNumber(int rowNumber) {
879
        if (rows == null) {
1✔
880
            return null;
1✔
881
        }
882

883
        TRow result = null;
1✔
884
        for (TRow row : rows) {
1✔
885
            if (row.getRowNumber() == rowNumber) {
1✔
886
                result = row;
1✔
887
                break;
1✔
888
            }
889
        }
1✔
890
        return result;
1✔
891
    }
892
}
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