Skip to content

Commit b854fe8

Browse files
Merge pull request #1022 from watson-developer-cloud/message-output-fix
Make Assistant v2 MessageOutput dynamic to capture extra keys
2 parents 2b50475 + 8568b36 commit b854fe8

File tree

1 file changed

+21
-13
lines changed
  • assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v2/model

1 file changed

+21
-13
lines changed

assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v2/model/MessageOutput.java

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,28 @@
1212
*/
1313
package com.ibm.watson.developer_cloud.assistant.v2.model;
1414

15-
import java.util.List;
15+
import com.google.gson.reflect.TypeToken;
16+
import com.ibm.watson.developer_cloud.service.model.DynamicModel;
17+
import com.ibm.watson.developer_cloud.util.GsonSerializationHelper;
1618

17-
import com.ibm.watson.developer_cloud.service.model.GenericModel;
19+
import java.lang.reflect.Type;
20+
import java.util.List;
1821

1922
/**
2023
* Assistant output to be rendered or processed by the client.
2124
*/
22-
public class MessageOutput extends GenericModel {
25+
public class MessageOutput extends DynamicModel {
2326

24-
private List<DialogRuntimeResponseGeneric> generic;
25-
private List<RuntimeIntent> intents;
26-
private List<RuntimeEntity> entities;
27-
private List<DialogNodeAction> actions;
28-
private MessageOutputDebug debug;
27+
private Type genericType = new TypeToken<List<DialogRuntimeResponseGeneric>>() {
28+
}.getType();
29+
private Type intentsType = new TypeToken<List<RuntimeIntent>>() {
30+
}.getType();
31+
private Type entitiesType = new TypeToken<List<RuntimeEntity>>() {
32+
}.getType();
33+
private Type actionsType = new TypeToken<List<DialogNodeAction>>() {
34+
}.getType();
35+
private Type debugType = new TypeToken<MessageOutputDebug>() {
36+
}.getType();
2937

3038
/**
3139
* Gets the generic.
@@ -36,7 +44,7 @@ public class MessageOutput extends GenericModel {
3644
* @return the generic
3745
*/
3846
public List<DialogRuntimeResponseGeneric> getGeneric() {
39-
return generic;
47+
return GsonSerializationHelper.serializeDynamicModelProperty(this.get("generic"), genericType);
4048
}
4149

4250
/**
@@ -47,7 +55,7 @@ public List<DialogRuntimeResponseGeneric> getGeneric() {
4755
* @return the intents
4856
*/
4957
public List<RuntimeIntent> getIntents() {
50-
return intents;
58+
return GsonSerializationHelper.serializeDynamicModelProperty(this.get("intents"), intentsType);
5159
}
5260

5361
/**
@@ -58,7 +66,7 @@ public List<RuntimeIntent> getIntents() {
5866
* @return the entities
5967
*/
6068
public List<RuntimeEntity> getEntities() {
61-
return entities;
69+
return GsonSerializationHelper.serializeDynamicModelProperty(this.get("entities"), entitiesType);
6270
}
6371

6472
/**
@@ -69,7 +77,7 @@ public List<RuntimeEntity> getEntities() {
6977
* @return the actions
7078
*/
7179
public List<DialogNodeAction> getActions() {
72-
return actions;
80+
return GsonSerializationHelper.serializeDynamicModelProperty(this.get("actions"), actionsType);
7381
}
7482

7583
/**
@@ -80,6 +88,6 @@ public List<DialogNodeAction> getActions() {
8088
* @return the debug
8189
*/
8290
public MessageOutputDebug getDebug() {
83-
return debug;
91+
return GsonSerializationHelper.serializeDynamicModelProperty(this.get("debug"), debugType);
8492
}
8593
}

0 commit comments

Comments
 (0)