• 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

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

22
import java.util.ArrayList;
23
import java.util.List;
24

25
/**
26
 * Represents the Cell object that holds data in a sheet.
27
 */
28
public class Cell {
29

30
    /**
31
     * Represents the column columnType.
32
     */
33
    private ColumnType columnType;
34

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

40
    /**
41
     * Represents the value.
42
     */
43
    private Object value;
44

45
    /**
46
     * is an object representation of the cell's value and is currently used for adding or updating predecessor cell values
47
     */
48
    private ObjectValue objectValue;
49

50
    /**
51
     * Represents the display value.
52
     */
53
    private String displayValue;
54

55
    /**
56
     * Represents the column ID for this cell.
57
     */
58
    private Long columnId;
59

60
    /**
61
     * Represents the row ID for this cell.
62
     */
63
    private Long rowId;
64

65
    /**
66
     * Represents the hyperlink to a URL, sheet, or report.
67
     */
68
    private Hyperlink hyperlink;
69

70
    /**
71
     * Represents an inbound link from a cell in another sheet.
72
     */
73
    private CellLink linkInFromCell;
74

75
    /**
76
     * Represents an array of CellLink objects.
77
     */
78
    private List<CellLink> linksOutToCells;
79

80
    /**
81
     * Represents the format descriptor describing this cell’s conditional format.
82
     */
83
    private String conditionalFormat;
84

85
    /**
86
     * the image that the cell contains. Only returned if the cell contains an image.
87
     */
88
    private Image image;
89

90
    /**
91
     * The formula for the cell.
92
     */
93
    private String formula;
94

95
    /**
96
     * Represents the strict flag.
97
     */
98
    private Boolean strict;
99

100
    /**
101
     * Represents the {@link Format} for this cell.
102
     */
103
    private Format format;
104

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

112
    /**
113
     * Default constructor
114
     */
115
    public Cell() {
1✔
116
    }
1✔
117

118
    /**
119
     * Construct a cell with specified column id
120
     *
121
     * @param id Column id
122
     */
123
    public Cell(Long id) {
×
124
        this.columnId = id;
×
125
    }
×
126

127
    /**
128
     * Gets the column columnType.
129
     *
130
     * @return the columnType
131
     */
132
    public ColumnType getColumnType() {
133
        return type;
1✔
134
    }
135

136
    /**
137
     * Sets the column columnType.
138
     *
139
     * @param columnType the new columnType
140
     */
141
    public Cell setColumnType(ColumnType columnType) {
142
        this.type = columnType;
1✔
143
        return this;
1✔
144
    }
145

146
    /**
147
     * Gets the column columnType.
148
     *
149
     * @return the columnType
150
     */
151
    public ColumnType getType() {
152
        return type;
×
153
    }
154

155
    /**
156
     * Sets the column columnType.
157
     *
158
     * @param type the new columnType
159
     */
160
    public Cell setType(ColumnType type) {
161
        this.type = type;
1✔
162
        return this;
1✔
163
    }
164

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

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

184
    /**
185
     * Get object representation of the cell's value
186
     *
187
     * @return objectValue
188
     */
189
    public ObjectValue getObjectValue() {
190
        return objectValue;
×
191
    }
192

193
    /**
194
     * Set object representation of the cell's value
195
     */
196
    public Cell setObjectValue(ObjectValue objectValue) {
197
        this.objectValue = objectValue;
×
198
        return this;
×
199
    }
200

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

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

220
    /**
221
     * Gets the column id for this cell.
222
     *
223
     * @return the column id
224
     */
225
    public Long getColumnId() {
226
        return columnId;
1✔
227
    }
228

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

239
    /**
240
     * Gets the row id for this cell.
241
     *
242
     * @return the row id
243
     */
244
    public Long getRowId() {
245
        return rowId;
×
246
    }
247

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

258
    /**
259
     * Gets the formula for this cell.
260
     *
261
     * @return the formula
262
     */
263
    public String getFormula() {
264
        return formula;
×
265
    }
266

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

278
    /**
279
     * Gets the strict value for this cell.
280
     *
281
     * @return the strict
282
     * @see <a href="https://smartsheet.redoc.ly/tag/columnsRelated">Column Types</a>
283
     */
284
    public Boolean getStrict() {
285
        return strict;
×
286
    }
287

288
    /**
289
     * Sets the strict formatting rule for this cell.
290
     *
291
     * @param strict the new strict
292
     * @see <a href="https://smartsheet.redoc.ly/tag/columnsRelated">Column Types</a>
293
     */
294
    public Cell setStrict(Boolean strict) {
295
        this.strict = strict;
×
296
        return this;
×
297
    }
298

299
    /**
300
     * @return the {@link Format}
301
     */
302
    public Format getFormat() {
303
        return format;
×
304
    }
305

306
    /**
307
     * @param format the {@link Format} to set
308
     */
309
    public Cell setFormat(Format format) {
310
        this.format = format;
×
311
        return this;
×
312
    }
313

314
    /**
315
     * @return hyperlink to a URL, sheet, or report
316
     */
317
    public com.smartsheet.api.models.Hyperlink getHyperlink() {
318
        return hyperlink;
×
319
    }
320

321
    /**
322
     * @param hyperlink hyperlink to a URL, sheet, or report to set
323
     */
324
    public Cell setHyperlink(Hyperlink hyperlink) {
325
        this.hyperlink = hyperlink;
×
326
        return this;
×
327
    }
328

329
    /**
330
     * @return inbound link from a cell in another sheet
331
     */
332
    public CellLink getLinkInFromCell() {
333
        return linkInFromCell;
×
334
    }
335

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

344
    /**
345
     * @return array of CellLink objects
346
     */
347
    public List<CellLink> getLinksOutToCells() {
348
        return linksOutToCells;
×
349
    }
350

351
    /**
352
     * @param linksOutToCells array of CellLink objects
353
     */
354
    public Cell setLinksOutToCells(List<CellLink> linksOutToCells) {
355
        this.linksOutToCells = linksOutToCells;
×
356
        return this;
×
357
    }
358

359
    /**
360
     * @return the format descriptor describing this cell’s conditional format
361
     */
362
    public String getConditionalFormat() {
363
        return conditionalFormat;
×
364
    }
365

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

374
    /**
375
     * Gets the image for this cell.
376
     *
377
     * @return image
378
     */
379
    public Image getImage() {
380
        return image;
×
381
    }
382

383
    /**
384
     * Sets the image for this cell.
385
     */
386
    public Cell setImage(Image image) {
387
        this.image = image;
×
388
        return this;
×
389
    }
390

391
    /**
392
     * Gets the value of the overrideValidation flag.
393
     *
394
     * @return the overrideValidation flag
395
     */
396
    public Boolean getOverrideValidation() {
397
        return overrideValidation;
×
398
    }
399

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

411
    /**
412
     * A convenience class for quickly creating a List of cells to add.
413
     */
414
    public static class AddRowCellsBuilder {
×
415

416
        /**
417
         * The cells.
418
         */
419
        List<Cell> cells = new ArrayList<>();
×
420

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

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

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

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

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

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

509
        /**
510
         * The cells.
511
         */
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

© 2025 Coveralls, Inc