-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f7ae87
commit d18a048
Showing
5 changed files
with
392 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/io/weaviate/client/base/util/GroupHitDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.weaviate.client.base.util; | ||
|
||
import com.google.gson.JsonDeserializationContext; | ||
import com.google.gson.JsonDeserializer; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
import com.google.gson.JsonParseException; | ||
import com.google.gson.reflect.TypeToken; | ||
import io.weaviate.client.v1.graphql.model.GraphQLGetBaseObject; | ||
import java.lang.reflect.Type; | ||
import java.util.Map; | ||
|
||
public class GroupHitDeserializer implements JsonDeserializer<GraphQLGetBaseObject.Additional.Group.GroupHit> { | ||
|
||
@Override | ||
public GraphQLGetBaseObject.Additional.Group.GroupHit deserialize(JsonElement json, Type typeOfT, | ||
JsonDeserializationContext context) throws JsonParseException { | ||
JsonObject jsonObject = json.getAsJsonObject(); | ||
|
||
GraphQLGetBaseObject.Additional.Group.GroupHit.AdditionalGroupHit additional = | ||
context.deserialize(jsonObject.get("_additional"), GraphQLGetBaseObject.Additional.Group.GroupHit.AdditionalGroupHit.class); | ||
|
||
// Remove _additional from the JSON object | ||
jsonObject.remove("_additional"); | ||
|
||
// Deserialize the rest into a Map | ||
Type mapType = new TypeToken<Map<String, Object>>() {}.getType(); | ||
Map<String, Object> properties = context.deserialize(jsonObject, mapType); | ||
|
||
return new GraphQLGetBaseObject.Additional.Group.GroupHit(properties, additional); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.