• 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

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

25
/**
26
 * Represents the Sheet object.
27
 */
28
public class Sheet extends AbstractSheet<Row, Column, Cell> {
29

30
    public Sheet() {
1✔
31
    }
1✔
32

33
    /**
34
     * Constructor that takes a sheet Id
35
     *
36
     * @param id the id
37
     */
38
    public Sheet(Long id) {
×
39
        setId(id);
×
40
    }
×
41

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

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

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

72
        /**
73
         * Returns the list of columns.
74
         *
75
         * @return the columns
76
         */
77
        public List<Column> getColumns() {
78
            return columns;
×
79
        }
80

81
        /**
82
         * Returns the name for the sheet.
83
         *
84
         * @return the name
85
         */
86
        public String getName() {
87
            return name;
×
88
        }
89

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

100
            return new Sheet().setColumns(columns).setSheetName(name);
1✔
101
        }
102
    }
103

104
    /**
105
     * A class to simplify the creation of a sheet from another sheet or another template.
106
     *
107
     */
108
    public static class CreateFromTemplateOrSheetBuilder {
1✔
109
        private String name;
110
        private Long fromId;
111

112
        /**
113
         * Sets the name for the sheet being created.
114
         *
115
         * @param name The name for the sheet being created.
116
         * @return the creates the from template or sheet builder
117
         */
118
        public CreateFromTemplateOrSheetBuilder setName(String name) {
119
            this.name = name;
1✔
120
            return this;
1✔
121
        }
122

123
        /**
124
         * Returns the name for the sheet.
125
         *
126
         * @return the name
127
         */
128
        public String getName() {
129
            return name;
×
130
        }
131

132
        /**
133
         * Set the from Id.
134
         *
135
         * @param id the id
136
         * @return the creates the from template or sheet builder
137
         */
138
        public CreateFromTemplateOrSheetBuilder setFromId(Long id) {
139
            this.fromId = id;
1✔
140
            return this;
1✔
141
        }
142

143
        /**
144
         * Gets the from id.
145
         *
146
         * @return the from id
147
         */
148
        public Long getFromId() {
149
            return fromId;
×
150
        }
151

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

165
    /**
166
     * The Class UpdateSheetBuilder.
167
     */
168
    public static class UpdateSheetBuilder {
1✔
169
        private String sheetName;
170
        private Long id;
171
        private SheetUserSettings userSettings;
172
        private ProjectSettings projectSettings;
173

174
        /**
175
         * Get the user settings
176
         * @return the user setting
177
         */
178
        public SheetUserSettings getUserSettings() {
179
            return userSettings;
×
180
        }
181

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

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

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

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

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

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

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

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