• 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

19.19
/src/main/java/com/smartsheet/api/models/Cell.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
import com.smartsheet.api.models.enums.ColumnType;
24
import com.smartsheet.api.models.format.Format;
25

26
import java.util.ArrayList;
27
import java.util.List;
28

29
/**
30
 * Represents the Cell object that holds data in a sheet.
31
 */
32
public class Cell {
33

34
    /**
35
     * Represents the column columnType.
36
     */
37
    private ColumnType columnType;
38

39
    /**
40
     * Represents the column columnType.
41
     */
42
    private ColumnType type;
43

44
    /**
45
     * Represents the value.
46
     */
47
    private Object value;
48

49
    /**
50
     * is an object representation of the cell's value and is currently used for adding or updating predecessor cell values
51
     */
52
    private ObjectValue objectValue;
53

54
    /**
55
     * Represents the display value.
56
     */
57
    private String displayValue;
58

59
    /**
60
     * Represents the column ID for this cell.
61
     */
62
    private Long columnId;
63

64
    /**
65
     * Represents the row ID for this cell.
66
     */
67
    private Long rowId;
68

69
    /**
70
     * Represents the hyperlink to a URL, sheet, or report.
71
     */
72
    private Hyperlink hyperlink;
73

74
    /**
75
     * Represents an inbound link from a cell in another sheet.
76
     */
77
    private CellLink linkInFromCell;
78

79
    /**
80
     * Represents an array of CellLink objects.
81
     */
82
    private List<CellLink> linksOutToCells;
83

84
    /**
85
     * Represents the format descriptor describing this cell’s conditional format.
86
     */
87
    private String conditionalFormat;
88

89
    /**
90
     * the image that the cell contains. Only returned if the cell contains an image.
91
     */
92
    private Image image;
93

94
    /**
95
     * The formula for the cell.
96
     */
97
    private String formula;
98

99
    /**
100
     * Represents the strict flag.
101
     */
102
    private Boolean strict;
103

104
    /**
105
     * Represents the {@link Format} for this cell.
106
     */
107
    private Format format;
108

109
    /**
110
     * ((Admin only) Flag indicating whether the cell value can contain a value outside of the validation
111
     * limits (value = true). When using this parameter, you must also set strict to false to bypass
112
     * value type checking. This property is honored for POST or PUT actions that update rows.
113
     */
114
    private Boolean overrideValidation;
115

116
    /**
117
     * Default constructor
118
     */
119
    public Cell() {
1✔
120
    }
1✔
121

122
    /**
123
     * Construct a cell with specified column id
124
     *
125
     * @param id Column id
126
     */
127
    public Cell(Long id) {
×
128
        this.columnId = id;
×
129
    }
×
130

131
    /**
132
     * Gets the column columnType.
133
     *
134
     * @return the columnType
135
     */
136
    public ColumnType getColumnType() {
137
        return type;
1✔
138
    }
139

140
    /**
141
     * Sets the column columnType.
142
     *
143
     * @param columnType the new columnType
144
     */
145
    public Cell setColumnType(ColumnType columnType) {
146
        this.type = columnType;
1✔
147
        return this;
1✔
148
    }
149

150
    /**
151
     * Gets the column columnType.
152
     *
153
     * @return the columnType
154
     */
155
    public ColumnType getType() {
156
        return type;
×
157
    }
158

159
    /**
160
     * Sets the column columnType.
161
     *
162
     * @param type the new columnType
163
     */
164
    public Cell setType(ColumnType type) {
165
        this.type = type;
1✔
166
        return this;
1✔
167
    }
168

169
    /**
170
     * Gets the value. Can be one of columnType {@link String}, {@link Number}, or {@link Boolean}
171
     *
172
     * @return the value
173
     */
174
    public Object getValue() {
175
        return value;
1✔
176
    }
177

178
    /**
179
     * Sets the value. Can be one of columnType {@link String}, {@link Number}, or {@link Boolean}
180
     *
181
     * @param value the new value
182
     */
183
    public Cell setValue(Object value) {
184
        this.value = value;
1✔
185
        return this;
1✔
186
    }
187

188
    /**
189
     * Get object representation of the cell's value
190
     *
191
     * @return objectValue
192
     */
193
    public ObjectValue getObjectValue() {
194
        return objectValue;
×
195
    }
196

197
    /**
198
     * Set object representation of the cell's value
199
     */
200
    public Cell setObjectValue(ObjectValue objectValue) {
201
        this.objectValue = objectValue;
×
202
        return this;
×
203
    }
204

205
    /**
206
     * Gets the display value used on special columns such as "Contact List".
207
     *
208
     * @return the display value
209
     */
210
    public String getDisplayValue() {
211
        return displayValue;
×
212
    }
213

214
    /**
215
     * Sets the display value used on columns special columns such as "Contact List".
216
     *
217
     * @param displayValue the new display value
218
     */
219
    public Cell setDisplayValue(String displayValue) {
220
        this.displayValue = displayValue;
1✔
221
        return this;
1✔
222
    }
223

224
    /**
225
     * Gets the column id for this cell.
226
     *
227
     * @return the column id
228
     */
229
    public Long getColumnId() {
230
        return columnId;
1✔
231
    }
232

233
    /**
234
     * Sets the column id for this cell.
235
     *
236
     * @param columnId the new column id
237
     */
238
    public Cell setColumnId(Long columnId) {
239
        this.columnId = columnId;
1✔
240
        return this;
1✔
241
    }
242

243
    /**
244
     * Gets the row id for this cell.
245
     *
246
     * @return the row id
247
     */
248
    public Long getRowId() {
249
        return rowId;
×
250
    }
251

252
    /**
253
     * Sets the row id for this cell.
254
     *
255
     * @param rowId the new row id
256
     */
257
    public Cell setRowId(Long rowId) {
258
        this.rowId = rowId;
1✔
259
        return this;
1✔
260
    }
261

262
    /**
263
     * Gets the formula for this cell.
264
     *
265
     * @return the formula
266
     */
267
    public String getFormula() {
268
        return formula;
×
269
    }
270

271
    /**
272
     * Sets the formula for this cell.
273
     *
274
     * @param formula the new formula
275
     * @see <a href="http://help.smartsheet.com/customer/portal/articles/775363-using-formulas">Using Formulas</a>
276
     */
277
    public Cell setFormula(String formula) {
278
        this.formula = formula;
1✔
279
        return this;
1✔
280
    }
281

282
    /**
283
     * Gets the strict value for this cell.
284
     *
285
     * @return the strict
286
     * @see <a href="http://www.smartsheet.com/developers/api-documentation#h.lay2yj3x1pp8">Column Types</a>
287
     */
288
    public Boolean getStrict() {
289
        return strict;
×
290
    }
291

292
    /**
293
     * Sets the strict formatting rule for this cell.
294
     *
295
     * @param strict the new strict
296
     * @see <a href="http://www.smartsheet.com/developers/api-documentation#h.lay2yj3x1pp8">Column Types</a>
297
     */
298
    public Cell setStrict(Boolean strict) {
299
        this.strict = strict;
×
300
        return this;
×
301
    }
302

303
    /**
304
     * @return the {@link Format}
305
     */
306
    public Format getFormat() {
307
        return format;
×
308
    }
309

310
    /**
311
     * @param format the {@link Format} to set
312
     */
313
    public Cell setFormat(Format format) {
314
        this.format = format;
×
315
        return this;
×
316
    }
317

318
    /**
319
     * @return hyperlink to a URL, sheet, or report
320
     */
321
    public com.smartsheet.api.models.Hyperlink getHyperlink() {
322
        return hyperlink;
×
323
    }
324

325
    /**
326
     * @param hyperlink hyperlink to a URL, sheet, or report to set
327
     */
328
    public Cell setHyperlink(Hyperlink hyperlink) {
329
        this.hyperlink = hyperlink;
×
330
        return this;
×
331
    }
332

333
    /**
334
     * @return inbound link from a cell in another sheet
335
     */
336
    public CellLink getLinkInFromCell() {
337
        return linkInFromCell;
×
338
    }
339

340
    /**
341
     * @param linkInFromCell inbound link from a cell in another sheet to set
342
     */
343
    public Cell setLinkInFromCell(CellLink linkInFromCell) {
344
        this.linkInFromCell = linkInFromCell;
×
345
        return this;
×
346
    }
347

348
    /**
349
     * @return array of CellLink objects
350
     */
351
    public List<CellLink> getLinksOutToCells() {
352
        return linksOutToCells;
×
353
    }
354

355
    /**
356
     * @param linksOutToCells array of CellLink objects
357
     */
358
    public Cell setLinksOutToCells(List<CellLink> linksOutToCells) {
359
        this.linksOutToCells = linksOutToCells;
×
360
        return this;
×
361
    }
362

363
    /**
364
     * @return the format descriptor describing this cell’s conditional format
365
     */
366
    public String getConditionalFormat() {
367
        return conditionalFormat;
×
368
    }
369

370
    /**
371
     * @param conditionalFormat the format descriptor describing this cell’s conditional format to set
372
     */
373
    public Cell setConditionalFormat(String conditionalFormat) {
374
        this.conditionalFormat = conditionalFormat;
×
375
        return this;
×
376
    }
377

378
    /**
379
     * Gets the image for this cell.
380
     *
381
     * @return image
382
     */
383
    public Image getImage() {
384
        return image;
×
385
    }
386

387
    /**
388
     * Sets the image for this cell.
389
     */
390
    public Cell setImage(Image image) {
391
        this.image = image;
×
392
        return this;
×
393
    }
394

395
    /**
396
     * Gets the value of the overrideValidation flag.
397
     *
398
     * @return the overrideValidation flag
399
     */
400
    public Boolean getOverrideValidation() {
401
        return overrideValidation;
×
402
    }
403

404
    /**
405
     * Sets the value of the overrideValidation flag.
406
     *
407
     * @param overrideValidation the new overrideValidation
408
     * @return the Cell
409
     */
410
    public Cell setOverrideValidation(Boolean overrideValidation) {
411
        this.overrideValidation = overrideValidation;
×
412
        return this;
×
413
    }
414

415
    /**
416
     * A convenience class for quickly creating a List of cells to add.
417
     */
418
    public static class AddRowCellsBuilder {
×
419

420
        /** The cells. */
421
        List<Cell> cells = new ArrayList<>();
×
422

423
        /**
424
         * Adds the cell.
425
         *
426
         * @param columnId the column id
427
         * @param value the value
428
         * @param strict the strict
429
         * @param hyperlink the hyperlink
430
         * @param linkInFromCell the link
431
         * @return the add row cells builder
432
         */
433
        public AddRowCellsBuilder addCell(
434
                Long columnId,
435
                Object value,
436
                Boolean strict,
437
                Hyperlink hyperlink,
438
                CellLink linkInFromCell
439
        ) {
440
            Cell cell = new Cell()
×
441
                    .setColumnId(columnId)
×
442
                    .setValue(value)
×
443
                    .setStrict(strict)
×
444
                    .setHyperlink(hyperlink)
×
445
                    .setLinkInFromCell(linkInFromCell);
×
446
            cells.add(cell);
×
447
            return this;
×
448
        }
449

450
        /**
451
         * Adds the cell
452
         *
453
         * @param columnId the column id
454
         * @param value the value
455
         * @param strict the strict
456
         * @param hyperlink the hyperlink
457
         * @param linkInFromCell the link
458
         * @param overrideValidation the overrideValidation flag
459
         * @return the add row cells builder
460
         */
461
        public AddRowCellsBuilder addCell(
462
                Long columnId,
463
                Object value,
464
                Boolean strict,
465
                Hyperlink hyperlink,
466
                CellLink linkInFromCell,
467
                Boolean overrideValidation
468
        ) {
469
            Cell cell = new Cell()
×
470
                    .setColumnId(columnId)
×
471
                    .setValue(value)
×
472
                    .setStrict(strict)
×
473
                    .setHyperlink(hyperlink)
×
474
                    .setLinkInFromCell(linkInFromCell)
×
475
                    .setOverrideValidation(overrideValidation);
×
476
            cells.add(cell);
×
477
            return this;
×
478
        }
479

480
        /**
481
         * Adds the cell.
482
         *
483
         * @param columnId the column id
484
         * @param value the value
485
         * @return the builder
486
         */
487
        public AddRowCellsBuilder addCell(Long columnId, Object value) {
488
            addCell(columnId, value, true, null, null);
×
489
            return this;
×
490
        }
491

492
        public List<Cell> getCells() {
493
            return cells;
×
494
        }
495

496
        /**
497
         * Returns the list of cells.
498
         *
499
         * @return the list
500
         */
501
        public List<Cell> build() {
502
            return cells;
×
503
        }
504
    }
505

506
    /**
507
     * A convenience class for quickly creating a List of cells to update.
508
     */
509
    public static class UpdateRowCellsBuilder {
×
510

511
        /** The cells. */
512
        List<Cell> cells = new ArrayList<>();
×
513

514
        /**
515
         * Adds the cell.
516
         *
517
         * @param columnId the column id
518
         * @param value the value
519
         * @param strict the strict
520
         * @param hyperlink the hyperlink
521
         * @param linkInFromCell the link
522
         * @return the update row cells builder
523
         */
524
        public UpdateRowCellsBuilder addCell(Long columnId, Object value, Boolean strict, Hyperlink hyperlink, CellLink linkInFromCell) {
525
            Cell cell = new Cell()
×
526
                    .setColumnId(columnId)
×
527
                    .setValue(value)
×
528
                    .setStrict(strict)
×
529
                    .setHyperlink(hyperlink)
×
530
                    .setLinkInFromCell(linkInFromCell);
×
531
            cells.add(cell);
×
532
            return this;
×
533
        }
534

535
        /**
536
         * Adds the cell.
537
         *
538
         * @param columnId the column id
539
         * @param value the value
540
         * @param strict the strict
541
         * @param hyperlink the hyperlink
542
         * @param linkInFromCell the link
543
         * @param overrideValidation the overrideValidation flag
544
         * @return the update row cells builder
545
         */
546
        public UpdateRowCellsBuilder addCell(
547
                Long columnId,
548
                Object value,
549
                Boolean strict,
550
                Hyperlink hyperlink,
551
                CellLink linkInFromCell,
552
                Boolean overrideValidation
553
        ) {
554
            Cell cell = new Cell()
×
555
                    .setColumnId(columnId)
×
556
                    .setValue(value)
×
557
                    .setStrict(strict)
×
558
                    .setHyperlink(hyperlink)
×
559
                    .setLinkInFromCell(linkInFromCell)
×
560
                    .setOverrideValidation(overrideValidation);
×
561
            cells.add(cell);
×
562
            return this;
×
563
        }
564

565
        /**
566
         * Adds the cell.
567
         *
568
         * @param columnId the column id
569
         * @param value the value
570
         * @return the update row cells builder
571
         */
572
        public UpdateRowCellsBuilder addCell(Long columnId, Object value) {
573
            addCell(columnId, value, true, null, null);
×
574
            return this;
×
575
        }
576

577
        public List<Cell> getCells() {
578
            return cells;
×
579
        }
580

581
        /**
582
         * Returns the list of cells.
583
         *
584
         * @return the list
585
         */
586
        public List<Cell> build() {
587
            return cells;
×
588
        }
589
    }
590
}
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