Skip to content

Commit

Permalink
fix(Discovery): Add GenericQueryAggregation classes
Browse files Browse the repository at this point in the history
This class acts as a catch-all in cases where we can't identify the returned query aggregation. This prevents circular deserialization in the adapter.
  • Loading branch information
lpatino10 committed Nov 21, 2019
1 parent a4298bd commit 11f04fb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public QueryAggregation deserialize(JsonElement json, Type typeOfT, JsonDeserial
} else if (aggregationType.equals(AggregationType.TOP_HITS.getName())) {
aggregation = GsonSingleton.getGson().fromJson(json, TopHits.class);
} else {
aggregation = GsonSingleton.getGson().fromJson(json, QueryAggregation.class);
aggregation = GsonSingleton.getGson().fromJson(json, GenericQueryAggregation.class);
}

return aggregation;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.ibm.watson.discovery.v1.query;

import com.ibm.watson.discovery.v1.model.QueryAggregation;

/**
* Catch-all class for query aggregations which can't be identified and deserialized to a known class.
*/
public class GenericQueryAggregation extends QueryAggregation {
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public QueryAggregation deserialize(JsonElement json, Type typeOfT, JsonDeserial
} else if (aggregationType.equals(AggregationType.TOP_HITS.getName())) {
aggregation = GsonSingleton.getGson().fromJson(json, QueryTopHitsAggregation.class);
} else {
aggregation = GsonSingleton.getGson().fromJson(json, QueryAggregation.class);
aggregation = GsonSingleton.getGson().fromJson(json, GenericQueryAggregation.class);
}

return aggregation;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.ibm.watson.discovery.v2.query;

import com.ibm.watson.discovery.v2.model.QueryAggregation;

/**
* Catch-all class for query aggregations which can't be identified and deserialized to a known class.
*/
public class GenericQueryAggregation extends QueryAggregation {
}

0 comments on commit 11f04fb

Please sign in to comment.