Hi Jeff,
What I am trying to achieve, is that I make a request to /photos which
returns a a list of JSON objects
with a prev & next URL as part of the descriptive data. Once I make
the request, I will have a PagedLater<Photo>
object that I can iterate on, if I come to the end of the current data
set, I can use paging to fetch the next page
to iterate on, or go backwards. The inside each photo, the same will
occur for the comments or any other Paged List data set.
From your comment below, I implemented the code
PagedLater<Photo> photoRequest =
batcher.graph(fbEventID+ "/photos", Photo.class);
produces a compiler error, "can not convert from GraphRequest<Photo>
to PagedLater<Photo>"
So I used the code in the BatchFB docs, (Note: the example in the user
manual has a syntax error)
Later<List<Photo>> photoRequest =
batcher.graph(fbEventID+ "/photos", new
TypeReference<List<Photo>>(){});
which produces the following error when the get is processed..
Can not deserialize instance of java.util.ArrayList out of
START_OBJECT token
at [Source: N/A; line: -1, column: -1]
Later I changed the code to be
Later<Paged<Photo>> photoRequest =
batcher.graph("/" + fbEventID+ "/photos", new
TypeReference<Paged<Photo>>(){});
Paged<Photo> photos = photoRequest.get();
Which seemed to work different / better, in that it was complaining
about the internal paged object comments.
Can not construct instance of com.googlecode.batchfb.PagedLater,
problem: abstract types can only be instantiated with additional type
information
at [Source: N/A; line: -1, column: -1] (through reference chain:
com.googlecode.batchfb.type.Paged["data"]-
>com.CloudTvApps.PicRollr.shared.FBObjects.Photo["comments"])
My Photo class is defined as
public class Photo
{
public long id;
@JsonProperty("from")
public Owner from;
public String picture;
public String source;
public int height;
public int width;
@JsonProperty("images")
public List<Image> images;
public String link; /
public String icon; //
public String created_time; //
public String position;
public String updated_time; //
@JsonProperty("comments")
PagedLater<Comment> comments;
and my comments class is defined as
public long id;
@JsonProperty("from")
public Owner from;
public String message;
public Boolean can_remove;
public String created_time;
What am I doing wrong.. ??
Thank you
-John G
On Jan 15, 8:59 am, Jeff Schnitzer <
j...@infohazard.org> wrote:
> I'm not quite sure what you want to do here, but note that
> PagedLater<T> extends Later<List<T>>. So creating a
> PagedLater<List<T>> is actually a Later<List<List<T>>, almost
> certainly not what you had in mind.
>
> The best way of getting photos is like this:
>
> PagedLater<Photo> photos = batcher.paged(fbEventID+"/photos", Photo.class);
>
> For the "under the covers" view of the Jackson magic, this is
> effectively the same as:
>
> Later<Paged<Photo>> photos = batcher.graph(fbEventID+"/photos", new
> TypeReference<Paged<Photo>>(){});
>
> TypeReference is one of the clever ways Jackson works around erasure
> in Java generics (boo!). I wrote up how this works here:
>
>
http://code.google.com/p/batchfb/wiki/UserGuide#Generics_and_TypeRefe...