Permalink
Browse files

moved deserializers to static classes of containers to cut down on files

  • Loading branch information...
mattupstate committed Jun 25, 2011
1 parent d84b12c commit ff0c4be14fa03baf188dd00e622d292a823a8c50
@@ -1,13 +1,27 @@
package org.springframework.social.instagram.api.impl;
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.DeserializationContext;
import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.springframework.social.instagram.api.InstagramProfile;
-@JsonDeserialize(using=InstagramProfileContainerDeserializer.class)
+@JsonDeserialize(using=InstagramProfileContainer.InstagramProfileContainerDeserializer.class)
public class InstagramProfileContainer extends AbstractInstagramResponseContainer<InstagramProfile>{
public InstagramProfileContainer(InstagramProfile profile) {
super(profile);
}
+ public static class InstagramProfileContainerDeserializer extends AbstractInstagramDeserializer<InstagramProfileContainer> {
+
+ @Override
+ public InstagramProfileContainer deserialize(JsonParser jp, DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+ return deserializeResponseObject(jp, InstagramProfileContainer.class, InstagramProfile.class);
+ }
+
+ }
}
@@ -1,13 +1,27 @@
package org.springframework.social.instagram.api.impl;
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.DeserializationContext;
import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.springframework.social.instagram.api.Media;
-@JsonDeserialize(using=MediaContainerDeserializer.class)
+@JsonDeserialize(using=MediaContainer.MediaContainerDeserializer.class)
public class MediaContainer extends AbstractInstagramResponseContainer<Media> {
public MediaContainer(Media media) {
super(media);
}
-
+
+ public static class MediaContainerDeserializer extends AbstractInstagramDeserializer<MediaContainer> {
+ @Override
+ public MediaContainer deserialize(JsonParser jp, DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+ // TODO Auto-generated method stub
+ return deserializeResponseObject(jp, MediaContainer.class, Media.class);
+ }
+ }
+
}
@@ -1,19 +1,26 @@
package org.springframework.social.instagram.api.impl;
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.DeserializationContext;
import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.springframework.social.instagram.api.Relationship;
-@JsonDeserialize(using=RelationshipContainerDeserializer.class)
-public class RelationshipContainer {
-
- private Relationship relationship;
+@JsonDeserialize(using=RelationshipContainer.RelationshipContainerDeserializer.class)
+public class RelationshipContainer extends AbstractInstagramResponseContainer<Relationship> {
public RelationshipContainer(Relationship relationship) {
- this.relationship = relationship;
- }
-
- public Relationship getRelationship() {
- return relationship;
+ super(relationship);
}
+ public static class RelationshipContainerDeserializer extends AbstractInstagramDeserializer<RelationshipContainer> {
+
+ @Override public RelationshipContainer deserialize(JsonParser jp, DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+ return deserializeResponseObject(jp, RelationshipContainer.class, Relationship.class);
+ }
+ }
+
}
@@ -1,13 +1,28 @@
package org.springframework.social.instagram.api.impl;
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.DeserializationContext;
import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.springframework.social.instagram.api.Tag;
-@JsonDeserialize(using=TagContainerDeserializer.class)
+@JsonDeserialize(using=TagContainer.TagContainerDeserializer.class)
public class TagContainer extends AbstractInstagramResponseContainer<Tag> {
public TagContainer(Tag tag) {
super(tag);
}
+ public static class TagContainerDeserializer extends AbstractInstagramDeserializer<TagContainer> {
+
+ @Override
+ public TagContainer deserialize(JsonParser jp, DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+ return deserializeResponseObject(jp, TagContainer.class, Tag.class);
+ }
+
+ }
+
}
@@ -74,7 +74,7 @@ public PagedMediaList getRecentMedia(long userId, long maxId, long minId, long m
public Relationship getRelationship(long userId) {
requireUserAuthorization();
- return get(buildUri(USERS_ENDPOINT + Long.toString(userId) + "/relationship/"), RelationshipContainer.class).getRelationship();
+ return get(buildUri(USERS_ENDPOINT + Long.toString(userId) + "/relationship/"), RelationshipContainer.class).getObject();
}
public void followUser(long userId) {

0 comments on commit ff0c4be

Please sign in to comment.