Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to retrieve multi primes
- Loading branch information
Adam Dougal
committed
Mar 8, 2016
1 parent
2f3c961
commit 2e9937a
Showing
17 changed files
with
321 additions
and
62 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
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
16 changes: 16 additions & 0 deletions
16
java-client/src/main/java/org/scassandra/http/client/types/GsonExactMatchSerialiser.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,16 @@ | ||
package org.scassandra.http.client.types; | ||
|
||
import com.google.gson.*; | ||
import org.scassandra.http.client.MultiPrimeRequest; | ||
|
||
import java.lang.reflect.Type; | ||
|
||
public class GsonExactMatchSerialiser implements JsonSerializer<MultiPrimeRequest.ExactMatch> { | ||
@Override | ||
public JsonElement serialize(MultiPrimeRequest.ExactMatch src, Type typeOfSrc, JsonSerializationContext context) { | ||
JsonObject jsonObject = new JsonObject(); | ||
jsonObject.add("matcher", context.serialize(src.matcher())); | ||
jsonObject.addProperty("type", src.type().toString()); | ||
return jsonObject; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...-client/src/main/java/org/scassandra/http/client/types/GsonVariableMatchDeserialiser.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,24 @@ | ||
package org.scassandra.http.client.types; | ||
|
||
import com.google.gson.*; | ||
import org.scassandra.http.client.MultiPrimeRequest; | ||
|
||
import java.lang.reflect.Type; | ||
|
||
public class GsonVariableMatchDeserialiser implements JsonDeserializer<MultiPrimeRequest.VariableMatch> { | ||
@Override | ||
public MultiPrimeRequest.VariableMatch deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { | ||
JsonObject jsonObject = (JsonObject) json; | ||
|
||
String type = jsonObject.get("type").getAsString(); | ||
|
||
if (type.equalsIgnoreCase("any")) { | ||
return new MultiPrimeRequest.AnyMatch(); | ||
} else if (type.equalsIgnoreCase("exact")) { | ||
String matcher = jsonObject.get("matcher").getAsString(); | ||
return new MultiPrimeRequest.ExactMatch(matcher); | ||
} else { | ||
throw new JsonParseException("Unexpected variable matcher type received: " + type); | ||
} | ||
} | ||
} |
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.