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

box / box-java-sdk / #4040

17 Oct 2024 12:51PM CUT coverage: 71.745% (-0.002%) from 71.747%
#4040

push

github

web-flow
chore: release 4.12.0 (#1267)

8039 of 11205 relevant lines covered (71.74%)

0.72 hits per line

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

0.0
/src/main/java/com/box/sdk/BoxRecentItem.java
1
package com.box.sdk;
2

3
import com.eclipsesource.json.JsonObject;
4
import com.eclipsesource.json.JsonValue;
5
import java.net.MalformedURLException;
6
import java.net.URL;
7
import java.text.ParseException;
8
import java.util.Date;
9

10
/**
11
 * Represents an individual recent item.
12
 *
13
 * <p>Unless otherwise noted, the methods in this class can throw an unchecked {@link BoxAPIException} (unchecked
14
 * meaning that the compiler won't force you to handle it) if an error occurs. If you wish to implement custom error
15
 * handling for errors related to the Box REST API, you should capture this exception explicitly.*
16
 */
17
public class BoxRecentItem extends BoxJSONObject {
×
18
    private String type;
19
    private String interactionType;
20
    private BoxItem.Info item;
21
    private Date interactedAt;
22
    private URL interactionSharedLink;
23
    private BoxAPIConnection api;
24

25
    /**
26
     * Construct a BoxRecentItem.
27
     *
28
     * @param jsonObject the parsed JSON object.
29
     * @param api        the API connection to be used to fetch interacted item
30
     */
31
    public BoxRecentItem(JsonObject jsonObject, BoxAPIConnection api) {
32
        super(jsonObject);
×
33
        this.api = api;
×
34
    }
×
35

36
    @Override
37
    protected void parseJSONMember(JsonObject.Member member) {
38
        super.parseJSONMember(member);
×
39

40
        String memberName = member.getName();
×
41
        JsonValue value = member.getValue();
×
42
        try {
43
            if (memberName.equals("type")) {
×
44
                this.type = value.asString();
×
45
            } else if (memberName.equals("interaction_type")) {
×
46
                this.interactionType = value.asString();
×
47
            } else if (memberName.equals("item")) {
×
48
                String id = value.asObject().get("id").asString();
×
49
                this.item = new BoxFile(this.api, id).new Info(value.asObject());
×
50
            } else if (memberName.equals("interacted_at")) {
×
51
                this.interactedAt = BoxDateFormat.parse(value.asString());
×
52
            } else if (memberName.equals("interaction_shared_link")) {
×
53
                this.interactionSharedLink = new URL(value.asString());
×
54
            }
55
        } catch (ParseException e) {
×
56
            assert false : "A ParseException indicates a bug in the SDK.";
×
57
        } catch (MalformedURLException e) {
×
58
            assert false : "A ParseException indicates a bug in the SDK.";
×
59
        }
×
60
    }
×
61

62
    /**
63
     * Get item type.
64
     *
65
     * @return type of item
66
     */
67
    public String getType() {
68
        return this.type;
×
69
    }
70

71
    /**
72
     * Get interaction type.
73
     *
74
     * @return interaction type
75
     */
76
    public String getInteractionType() {
77
        return this.interactionType;
×
78
    }
79

80
    /**
81
     * Get the item which was interacted with.
82
     *
83
     * @return box item
84
     */
85
    public BoxItem.Info getItem() {
86
        return this.item;
×
87
    }
88

89
    /**
90
     * Get the interaction date.
91
     *
92
     * @return interaction date
93
     */
94
    public Date getInteractedAt() {
95
        return this.interactedAt;
×
96
    }
97

98
    /**
99
     * Get the shared link, if the item was accessed through a shared link.
100
     *
101
     * @return shared link
102
     */
103
    public URL getInteractionSharedLink() {
104
        return this.interactionSharedLink;
×
105
    }
106

107
}
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