Skip to content
Browse files

try to add support for unknown fields, store them in a map

  • Loading branch information...
1 parent f0145ba commit d9689c47c7b9e3959ef61065da74aaf5fc1c8fa5 @sdouglass committed
View
26 src/main/java/org/springframework/social/tumblr/api/BaseEntity.java
@@ -0,0 +1,26 @@
+package org.springframework.social.tumblr.api;
+
+import org.codehaus.jackson.annotate.JsonAnySetter;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Tumblr adds new fields to their response. Set up a map
+ * and method for collecting the values for these new fields
+ * to avoid deserialization errors and still make the new
+ * values available.
+ */
+public class BaseEntity {
+
+ private Map<String, Object> properties = new HashMap<String, Object>();
+
+ @JsonAnySetter
+ public void setProperty(String key, Object value) {
+ properties.put(key, value);
+ }
+
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+}
View
2 src/main/java/org/springframework/social/tumblr/api/BlogInfo.java
@@ -1,6 +1,6 @@
package org.springframework.social.tumblr.api;
-public class BlogInfo {
+public class BlogInfo extends BaseEntity {
private String name;
private String url;
View
2 src/main/java/org/springframework/social/tumblr/api/ChatMessage.java
@@ -1,6 +1,6 @@
package org.springframework.social.tumblr.api;
-public class ChatMessage {
+public class ChatMessage extends BaseEntity {
private String label;
private String name;
View
2 src/main/java/org/springframework/social/tumblr/api/Follower.java
@@ -1,6 +1,6 @@
package org.springframework.social.tumblr.api;
-public class Follower {
+public class Follower extends BaseEntity {
private String name;
private String url;
View
2 src/main/java/org/springframework/social/tumblr/api/Photo.java
@@ -2,7 +2,7 @@
import java.util.List;
-public class Photo {
+public class Photo extends BaseEntity {
private String caption;
private List<PhotoSize> sizes;
View
2 src/main/java/org/springframework/social/tumblr/api/Post.java
@@ -2,7 +2,7 @@
import java.util.List;
-public class Post {
+public class Post extends BaseEntity {
private long id;
private String blogName;
View
2 src/main/java/org/springframework/social/tumblr/api/UserInfo.java
@@ -2,7 +2,7 @@
import java.util.List;
-public class UserInfo {
+public class UserInfo extends BaseEntity {
private int following;
private String defaultPostFormat;
View
2 src/main/java/org/springframework/social/tumblr/api/UserInfoBlog.java
@@ -2,7 +2,7 @@
import java.util.Date;
-public class UserInfoBlog {
+public class UserInfoBlog extends BaseEntity {
private String name;
private String url;

0 comments on commit d9689c4

Please sign in to comment.
Something went wrong with that request. Please try again.