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

box / box-java-sdk / #3992

06 Sep 2024 01:11PM UTC coverage: 71.703% (-0.7%) from 72.441%
#3992

push

github

web-flow
feat: Support AI Agent (#1265)

248 of 452 new or added lines in 14 files covered. (54.87%)

3 existing lines in 3 files now uncovered.

7921 of 11047 relevant lines covered (71.7%)

0.72 hits per line

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

58.33
/src/main/java/com/box/sdk/BoxAIAgent.java
1
package com.box.sdk;
2

3
import com.eclipsesource.json.JsonObject;
4
import com.eclipsesource.json.JsonValue;
5

6
public abstract class BoxAIAgent extends BoxJSONObject {
7
    /**
8
     * The type of the AI agent.
9
     * Value can be "ai_agent_ask" or "ai_agent_text_gen".
10
     */
11
    private String type;
12

13
    /**
14
     * Constructs an AI agent with default settings.
15
     * @param type The type of the AI agent.
16
     *            Value can be "ai_agent_ask" or "ai_agent_text_gen".
17
     */
18
    public BoxAIAgent(String type) {
NEW
19
        super();
×
NEW
20
        this.type = type;
×
NEW
21
    }
×
22

23
    /**
24
     * Constructs an AI agent with default settings.
25
     * @param jsonObject JSON object representing the AI agent.
26
     */
27
    public BoxAIAgent(JsonObject jsonObject) {
28
        super(jsonObject);
1✔
29
    }
1✔
30

31
    /**
32
     * Constructs an AI agent with default settings.
33
     * @param jsonObject JSON object representing the AI agent.
34
     */
35
    public static BoxAIAgent parse(JsonObject jsonObject) {
36
        String type = jsonObject.get("type").asString();
1✔
37
        if (type.equals(BoxAIAgentAsk.TYPE)) {
1✔
38
            return new BoxAIAgentAsk(jsonObject);
1✔
39
        } else if (type.equals(BoxAIAgentTextGen.TYPE)) {
1✔
40
            return new BoxAIAgentTextGen(jsonObject);
1✔
41
        } else {
NEW
42
            throw new IllegalArgumentException("Invalid AI agent type: " + type);
×
43
        }
44
    }
45

46
    /**
47
     * Gets the type of the AI agent.
48
     * @return The type of the AI agent.
49
     */
50
    public String getType() {
51
        return type;
1✔
52
    }
53

54
    /**
55
     * Sets the type of the AI agent.
56
     * @param type The type of the AI agent.
57
     */
58
    public void setType(String type) {
NEW
59
        this.type = type;
×
NEW
60
    }
×
61

62
    @Override
63
    void parseJSONMember(JsonObject.Member member) {
64
        super.parseJSONMember(member);
1✔
65
        String memberName = member.getName();
1✔
66
        JsonValue value = member.getValue();
1✔
67
        if (memberName.equals("type")) {
1✔
68
            this.type = value.asString();
1✔
69
        }
70
    }
1✔
71

72
    public JsonObject getJSONObject() {
NEW
73
        JsonObject jsonObject = new JsonObject();
×
NEW
74
        jsonObject.add("type", this.type);
×
NEW
75
        return jsonObject;
×
76
    }
77

78
    /**
79
     * The type of the AI agent for asking questions.
80
     */
81
    public enum Mode {
1✔
82
        /**
83
         * The type of AI agent used to handle queries.
84
         */
85
        ASK("ask"),
1✔
86
        /**
87
         * The type of AI agent used for generating text.
88
         */
89
        TEXT_GEN("text_gen");
1✔
90

91
        private final String value;
92

93
        Mode(String value) {
1✔
94
            this.value = value;
1✔
95
        }
1✔
96

97
        static BoxAIAgent.Mode fromJSONValue(String value) {
NEW
98
            if (value.equals("ask")) {
×
NEW
99
                return ASK;
×
NEW
100
            } else if (value.equals("text_gen")) {
×
NEW
101
                return TEXT_GEN;
×
102
            } else {
NEW
103
                throw new IllegalArgumentException("Invalid AI agent mode: " + value);
×
104
            }
105
        }
106

107
        String toJSONValue() {
NEW
108
            return this.value;
×
109
        }
110

111
        @Override
112
        public String toString() {
113
            return this.value;
1✔
114
        }
115
    }
116
}
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