• 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

55.56
/src/main/java/com/smartsheet/api/models/Sheet.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.List;
20

21
/**
22
 * Represents the Sheet object.
23
 */
24
public class Sheet extends AbstractSheet<Row, Column, Cell> {
25

26
    public Sheet() {
1✔
27
    }
1✔
28

29
    /**
30
     * Constructor that takes a sheet Id
31
     *
32
     * @param id the id
33
     */
34
    public Sheet(Long id) {
×
35
        setId(id);
×
36
    }
×
37

38
    /**
39
     * A convenience class to make a {@link Sheet} object with the necessary fields to create the sheet by posting it
40
     * to smartsheet.
41
     */
42
    public static class CreateSheetBuilder {
1✔
43
        private List<Column> columns;
44
        private String name;
45

46
        /**
47
         * Sets the columns for the sheet being created.
48
         *
49
         * @param columns The columns to create with this sheet.
50
         * @return the creates the builder
51
         */
52
        public CreateSheetBuilder setColumns(List<Column> columns) {
53
            this.columns = columns;
1✔
54
            return this;
1✔
55
        }
56

57
        /**
58
         * Sets the name for the sheet being created.
59
         *
60
         * @param name The name for the sheet being created.
61
         * @return the creates the builder
62
         */
63
        public CreateSheetBuilder setName(String name) {
64
            this.name = name;
1✔
65
            return this;
1✔
66
        }
67

68
        /**
69
         * Returns the list of columns.
70
         *
71
         * @return the columns
72
         */
73
        public List<Column> getColumns() {
74
            return columns;
×
75
        }
76

77
        /**
78
         * Returns the name for the sheet.
79
         *
80
         * @return the name
81
         */
82
        public String getName() {
83
            return name;
×
84
        }
85

86
        /**
87
         * Creates a sheet by using the values from setters in this builder.
88
         *
89
         * @return the sheet
90
         */
91
        public Sheet build() {
92
            if (columns == null || name == null) {
1✔
93
                throw new InstantiationError();
×
94
            }
95

96
            return new Sheet().setColumns(columns).setSheetName(name);
1✔
97
        }
98
    }
99

100
    /**
101
     * A class to simplify the creation of a sheet from another sheet or another template.
102
     */
103
    public static class CreateFromTemplateOrSheetBuilder {
1✔
104
        private String name;
105
        private Long fromId;
106

107
        /**
108
         * Sets the name for the sheet being created.
109
         *
110
         * @param name The name for the sheet being created.
111
         * @return the creates the from template or sheet builder
112
         */
113
        public CreateFromTemplateOrSheetBuilder setName(String name) {
114
            this.name = name;
1✔
115
            return this;
1✔
116
        }
117

118
        /**
119
         * Returns the name for the sheet.
120
         *
121
         * @return the name
122
         */
123
        public String getName() {
124
            return name;
×
125
        }
126

127
        /**
128
         * Set the from Id.
129
         *
130
         * @param id the id
131
         * @return the creates the from template or sheet builder
132
         */
133
        public CreateFromTemplateOrSheetBuilder setFromId(Long id) {
134
            this.fromId = id;
1✔
135
            return this;
1✔
136
        }
137

138
        /**
139
         * Gets the from id.
140
         *
141
         * @return the from id
142
         */
143
        public Long getFromId() {
144
            return fromId;
×
145
        }
146

147
        /**
148
         * Creates a sheet by using the values from setters in this builder.
149
         *
150
         * @return the sheet
151
         */
152
        public Sheet build() {
153
            if (fromId == null || name == null) {
1✔
154
                throw new InstantiationError();
×
155
            }
156
            return new Sheet().setFromId(fromId).setSheetName(name);
1✔
157
        }
158
    }
159

160
    /**
161
     * The Class UpdateSheetBuilder.
162
     */
163
    public static class UpdateSheetBuilder {
1✔
164
        private String sheetName;
165
        private Long id;
166
        private SheetUserSettings userSettings;
167
        private ProjectSettings projectSettings;
168

169
        /**
170
         * Get the user settings
171
         *
172
         * @return the user setting
173
         */
174
        public SheetUserSettings getUserSettings() {
175
            return userSettings;
×
176
        }
177

178
        /**
179
         * Set the user settings
180
         *
181
         * @param userSettings the sheet user settings
182
         * @return the updateSheetBuilder object
183
         */
184
        public UpdateSheetBuilder setUserSettings(SheetUserSettings userSettings) {
185
            this.userSettings = userSettings;
×
186
            return this;
×
187
        }
188

189
        /**
190
         * Get the project settings
191
         *
192
         * @return the project settings
193
         */
194
        public ProjectSettings getProjectSettings() {
195
            return projectSettings;
×
196
        }
197

198
        /**
199
         * Set the project settings
200
         *
201
         * @param projectSettings the sheet project settings
202
         * @return the updateSheetBuilder object
203
         */
204
        public UpdateSheetBuilder setProjectSettings(ProjectSettings projectSettings) {
205
            this.projectSettings = projectSettings;
×
206
            return this;
×
207
        }
208

209
        /**
210
         * Get the id of the sheet
211
         *
212
         * @return the id
213
         */
214
        public Long getSheetId() {
215
            return id;
×
216
        }
217

218
        /**
219
         * Set the sheet id
220
         *
221
         * @param sheetId the sheet id
222
         * @return the updateSheetBuilder object
223
         */
224
        public UpdateSheetBuilder setSheetId(Long sheetId) {
225
            this.id = sheetId;
×
226
            return this;
×
227
        }
228

229
        /**
230
         * Name.
231
         *
232
         * @param name the name
233
         * @return the update sheet builder
234
         */
235
        public UpdateSheetBuilder setName(String name) {
236
            this.sheetName = name;
1✔
237
            return this;
1✔
238
        }
239

240
        /**
241
         * Gets the sheet name.
242
         *
243
         * @return the sheet name
244
         */
245
        public String getName() {
246
            return sheetName;
×
247
        }
248

249
        /**
250
         * Builds the.
251
         *
252
         * @return the sheet
253
         */
254
        public Sheet build() {
255
            if (sheetName == null) {
1✔
256
                throw new InstantiationError();
×
257
            }
258
            return new Sheet()
1✔
259
                    .setSheetName(sheetName)
1✔
260
                    .setSheetId(id)
1✔
261
                    .setUserSettings(userSettings)
1✔
262
                    .setProjectSettings(projectSettings);
1✔
263
        }
264
    }
265
}
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