• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

smartsheet / smartsheet-java-sdk / #68

14 Jul 2026 06:50AM UTC coverage: 59.734% (-0.06%) from 59.797%
#68

push

github

web-flow
Merge pull request #184 from smartsheet/add-missing-fields

Add missing fields

0 of 9 new or added lines in 2 files covered. (0.0%)

1 existing line in 1 file now uncovered.

4532 of 7587 relevant lines covered (59.73%)

0.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/smartsheet/api/internal/json/ChildrenResourceDeserializer.java
1
/*
2
 * Copyright (C) 2025 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.internal.json;
18

19
import com.fasterxml.jackson.core.JsonParser;
20
import com.fasterxml.jackson.core.JsonProcessingException;
21
import com.fasterxml.jackson.core.JsonToken;
22
import com.fasterxml.jackson.databind.DeserializationContext;
23
import com.fasterxml.jackson.databind.JsonDeserializer;
24
import com.fasterxml.jackson.databind.JsonNode;
25
import com.fasterxml.jackson.databind.ObjectMapper;
26
import com.smartsheet.api.models.Folder;
27
import com.smartsheet.api.models.Report;
28
import com.smartsheet.api.models.Sheet;
29
import com.smartsheet.api.models.Sight;
30
import com.smartsheet.api.models.Template;
31
import com.smartsheet.api.models.enums.ChildResourceType;
32

33
import java.io.IOException;
34
import java.util.ArrayList;
35
import java.util.List;
36

37
/**
38
 * Custom deserializer for children resources that deserializes each item based
39
 * on its resourceType property.
40
 * Items can be deserialized as Sheet, Folder, Report, Sight, or Template objects.
41
 */
42
public class ChildrenResourceDeserializer extends JsonDeserializer<List<Object>> {
×
43

44
    @Override
45
    public List<Object> deserialize(JsonParser jp, DeserializationContext ctxt)
46
            throws IOException, JsonProcessingException {
47

48
        List<Object> children = new ArrayList<>();
×
49

50
        if (jp.getCurrentToken() == JsonToken.START_ARRAY) {
×
51
            // Use the same ObjectMapper from the deserialization context to maintain
52
            // configuration
53
            ObjectMapper mapper = (ObjectMapper) jp.getCodec();
×
54

55
            while (jp.nextToken() != JsonToken.END_ARRAY) {
×
56
                if (jp.getCurrentToken() == JsonToken.START_OBJECT) {
×
57
                    JsonNode node = jp.readValueAsTree();
×
58
                    JsonNode resourceTypeNode = node.get("resourceType");
×
59

60
                    if (resourceTypeNode != null && resourceTypeNode.isTextual()) {
×
61
                        Object child = null;
×
62

63
                        try {
NEW
64
                            ChildResourceType resourceType = mapper.treeToValue(resourceTypeNode, ChildResourceType.class);
×
65

UNCOV
66
                            switch (resourceType) {
×
67
                                case SHEET:
68
                                    child = mapper.treeToValue(node, Sheet.class);
×
69
                                    break;
×
70
                                case FOLDER:
71
                                    child = mapper.treeToValue(node, Folder.class);
×
72
                                    break;
×
73
                                case REPORT:
74
                                    child = mapper.treeToValue(node, Report.class);
×
75
                                    break;
×
76
                                case SIGHT:
77
                                    child = mapper.treeToValue(node, Sight.class);
×
78
                                    break;
×
79
                                case TEMPLATE:
NEW
80
                                    child = mapper.treeToValue(node, Template.class);
×
NEW
81
                                    break;
×
82
                                default:
83
                                    // If a new resource type is introduced that this version of the SDK doesn't
84
                                    // support,
85
                                    // fall back to a generic object representation
86
                                    child = mapper.treeToValue(node, Object.class);
×
87
                                    break;
88
                            }
89
                        } catch (Exception e) {
×
90
                            // If deserialization fails, fall back to generic object
91
                            child = mapper.treeToValue(node, Object.class);
×
92
                        }
×
93

94
                        if (child != null) {
×
95
                            children.add(child);
×
96
                        }
97
                    } else {
×
98
                        // No resourceType property found, add as generic object
99
                        Object child = mapper.treeToValue(node, Object.class);
×
100
                        children.add(child);
×
101
                    }
102
                }
×
103
            }
104
        }
105

106
        return children;
×
107
    }
108
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc