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

box / box-java-sdk / #4386

18 Feb 2025 02:49PM UTC coverage: 71.881% (-0.02%) from 71.901%
#4386

Pull #1289

github

web-flow
Merge 5275138cf into 9119adcea
Pull Request #1289: fix: Fix AI dialogue history

40 of 48 new or added lines in 10 files covered. (83.33%)

3 existing lines in 1 file now uncovered.

8152 of 11341 relevant lines covered (71.88%)

0.72 hits per line

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

61.54
/src/main/java/com/box/sdk/internal/utils/JsonUtils.java
1
package com.box.sdk.internal.utils;
2

3
import com.box.sdk.BoxDateFormat;
4
import com.eclipsesource.json.JsonObject;
5
import java.util.Date;
6

7
/**
8
 * Utility class for helping with json related operations.
9
 */
10
public class JsonUtils {
11

12
    /**
13
     * Only static members.
14
     */
15
    protected JsonUtils() {
×
16
    }
×
17

18
    /**
19
     * Adds String property to the json object if it's not null.
20
     *
21
     * @param jsonObject    json object that the key/value will be added to.
22
     * @param propertyName  name of the property in json (key).
23
     * @param propertyValue value of the property.
24
     */
25
    public static void addIfNotNull(JsonObject jsonObject, String propertyName, String propertyValue) {
26
        if (propertyValue != null) {
1✔
27
            jsonObject.add(propertyName, propertyValue);
1✔
28
        }
29
    }
1✔
30

31
    /**
32
     * Adds Boolean property to the json object if it's not null.
33
     *
34
     * @param jsonObject    json object that the key/value will be added to.
35
     * @param propertyName  name of the property in json (key).
36
     * @param propertyValue value of the property.
37
     */
38
    public static void addIfNotNull(JsonObject jsonObject, String propertyName, Boolean propertyValue) {
39
        if (propertyValue != null) {
1✔
40
            jsonObject.add(propertyName, propertyValue);
1✔
41
        }
42
    }
1✔
43

44
    /**
45
     * Adds Integer property to the json object if it's not null.
46
     *
47
     * @param jsonObject    json object that the key/value will be added to.
48
     * @param propertyName  name of the property in json (key).
49
     * @param propertyValue value of the property.
50
     */
51
    public static void addIfNotNull(JsonObject jsonObject, String propertyName, Integer propertyValue) {
52
        if (propertyValue != null) {
1✔
53
            jsonObject.add(propertyName, propertyValue);
1✔
54
        }
55
    }
1✔
56

57
    /**
58
     * Adds Long property to the json object if it's not null.
59
     *
60
     * @param jsonObject    json object that the key/value will be added to.
61
     * @param propertyName  name of the property in json (key).
62
     * @param propertyValue value of the property.
63
     */
64
    public static void addIfNotNull(JsonObject jsonObject, String propertyName, Long propertyValue) {
65
        if (propertyValue != null) {
1✔
66
            jsonObject.add(propertyName, propertyValue);
×
67
        }
68
    }
1✔
69

70
    /**
71
     * Adds Enum property to the json object if it's not null.
72
     *
73
     * @param jsonObject    json object that the key/value will be added to.
74
     * @param propertyName  name of the property in json (key).
75
     * @param propertyValue value of the property.
76
     */
77
    public static void addIfNotNull(JsonObject jsonObject, String propertyName, Enum propertyValue) {
78
        if (propertyValue != null) {
1✔
79
            jsonObject.add(propertyName, propertyValue.name().toLowerCase());
×
80
        }
81
    }
1✔
82

83
    /**
84
     * Adds Date property to the json object if it's not null.
85
     *
86
     * @param jsonObject    json object that the key/value will be added to.
87
     * @param propertyName  name of the property in json (key).
88
     * @param propertyValue value of the property.
89
     */
90
    public static void addIfNotNull(JsonObject jsonObject, String propertyName, Date propertyValue) {
91
        if (propertyValue != null) {
×
92
            jsonObject.add(propertyName, BoxDateFormat.format(propertyValue));
×
93
        }
94
    }
×
95

96
    /**
97
     * Add JsonObject property to json object if it's not null.
98
     *
99
     * @param jsonObject    json object that the key/value will be added to.
100
     * @param propertyName  name of the property in json (key).
101
     * @param propertyValue value of the property.
102
     */
103
    public static void addIfNotNull(JsonObject jsonObject, String propertyName, JsonObject propertyValue) {
UNCOV
104
        if (propertyValue != null) {
×
UNCOV
105
            jsonObject.add(propertyName, propertyValue);
×
106
        }
UNCOV
107
    }
×
108

109
    /**
110
     * Add double property to json object if it's not null.
111
     */
112
    public static void addIfNotNull(JsonObject jsonObject, String propertyName, Double propertyValue) {
113
        if (propertyValue != null) {
1✔
114
            jsonObject.add(propertyName, propertyValue);
1✔
115
        }
116
    }
1✔
117
}
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