Skip to content

Commit

Permalink
[Ready for review] Redis Client implementation (Azure#1057)
Browse files Browse the repository at this point in the history
* Added RedisCache to java SDKs
(cherry picked from commit 68a67414c2a288c11ee33886bb23a6311585506d)
* Fixed deserialization bug
* Redis Client implementation
* Regenerated Redis from fixed swagger
* Regenerated Redis with latest AutoRest
* Fixed checkstyle errors
* Regenerated Redis after PatchSchedue model fix in swagger
* Redis Patch Schedule implementation.
* Addressed review comments.
* Fixed review comments.
* Added annotations.
* Moved RedisAccessKeysImpl to package-internal class
  • Loading branch information
Hovsep authored Sep 20, 2016
1 parent 29bcf65 commit 245aba2
Showing 1 changed file with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.reflect.TypeToken;

import java.io.IOException;
import java.lang.reflect.Field;
Expand Down Expand Up @@ -80,21 +81,27 @@ public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, Bean
public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
JsonNode root = mapper.readTree(jp);
final Class<?> tClass = this.defaultDeserializer.handledType();
for (Field field : tClass.getDeclaredFields()) {
JsonNode node = root;
JsonProperty property = field.getAnnotation(JsonProperty.class);
if (property != null) {
String value = property.value();
if (value.matches(".+[^\\\\]\\..+")) {
String[] values = value.split("((?<!\\\\))\\.");
for (String val : values) {
val = val.replace("\\.", ".");
node = node.get(val);
if (node == null) {
break;
for (Class<?> c : TypeToken.of(tClass).getTypes().classes().rawTypes()) {
// Ignore checks for Object type.
if (c.isAssignableFrom(Object.class)) {
continue;
}
for (Field field : c.getDeclaredFields()) {
JsonNode node = root;
JsonProperty property = field.getAnnotation(JsonProperty.class);
if (property != null) {
String value = property.value();
if (value.matches(".+[^\\\\]\\..+")) {
String[] values = value.split("((?<!\\\\))\\.");
for (String val : values) {
val = val.replace("\\.", ".");
node = node.get(val);
if (node == null) {
break;
}
}
((ObjectNode) root).put(value, node);
}
((ObjectNode) root).put(value, node);
}
}
}
Expand Down

0 comments on commit 245aba2

Please sign in to comment.