Package com.restfb
Class Connection<T>
- java.lang.Object
-
- com.restfb.Connection<T>
-
- Type Parameters:
T
- The Facebook type
public class Connection<T> extends Object implements Iterable<List<T>>
Represents a Graph API Connection type.- Author:
- Mark Allen
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
Connection.Itr<T>
Iterator over connection pages.
-
Constructor Summary
Constructors Constructor Description Connection(FacebookClient facebookClient, String json, Class<T> connectionType)
Creates a connection with the givenjsonObject
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object object)
protected Connection<T>
fetchNextPage()
Fetches the next page of the connection.String
getAfterCursor()
String
getBeforeCursor()
List<T>
getData()
Data for this connection.String
getNextPageUrl()
This connection's "next page of data" URL.String
getOrder()
returns the order of the elementsString
getPreviousPageUrl()
This connection's "previous page of data" URL.Long
getTotalCount()
provides the total count of elements, if FB provides them (API ≥ v2.0)T
getTypedSummary()
return the typed summary.int
hashCode()
boolean
hasNext()
Does this connection have a next page of data?boolean
hasPrevious()
Does this connection have a previous page of data?ConnectionIterator<T>
iterator()
void
replaceFacebookClient(FacebookClient facebookClient)
replace the current facebookclient with the new one.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
Connection
public Connection(FacebookClient facebookClient, String json, Class<T> connectionType)
Creates a connection with the givenjsonObject
.- Parameters:
facebookClient
- TheFacebookClient
used to fetch additional pages and map data to JSON objects.json
- Raw JSON which must include adata
field that holds a JSON array and optionally apaging
field that holds a JSON object with next/previous page URLs.connectionType
- Connection type token.- Throws:
FacebookJsonMappingException
- If the providedjson
is invalid.- Since:
- 1.6.7
-
-
Method Detail
-
iterator
public ConnectionIterator<T> iterator()
- Specified by:
iterator
in interfaceIterable<T>
- Since:
- 1.6.7
- See Also:
Iterable.iterator()
-
fetchNextPage
protected Connection<T> fetchNextPage()
Fetches the next page of the connection. Designed to be used byConnection.Itr
.- Returns:
- The next page of the connection.
- Since:
- 1.6.7
-
getPreviousPageUrl
public String getPreviousPageUrl()
This connection's "previous page of data" URL.- Returns:
- This connection's "previous page of data" URL, or
null
if there is no previous page. - Since:
- 1.5.3
-
getNextPageUrl
public String getNextPageUrl()
This connection's "next page of data" URL.- Returns:
- This connection's "next page of data" URL, or
null
if there is no next page. - Since:
- 1.5.3
-
hasPrevious
public boolean hasPrevious()
Does this connection have a previous page of data?- Returns:
true
if there is a previous page of data for this connection,false
otherwise.
-
hasNext
public boolean hasNext()
Does this connection have a next page of data?- Returns:
true
if there is a next page of data for this connection,false
otherwise.
-
getTotalCount
public Long getTotalCount()
provides the total count of elements, if FB provides them (API ≥ v2.0)- Returns:
- the total count of elements if present
- Since:
- 1.6.16
-
getOrder
public String getOrder()
returns the order of the elements- Returns:
- the order of the elements
-
getBeforeCursor
public String getBeforeCursor()
-
getAfterCursor
public String getAfterCursor()
-
getTypedSummary
public T getTypedSummary()
return the typed summary.For some connections, there is summary object that contains almost the same fields as the type that is used in the connection. For example ad insights fill the summary that way (if you use the right query parameter)
- Returns:
- the typed summary, may be null
-
replaceFacebookClient
public void replaceFacebookClient(FacebookClient facebookClient)
replace the current facebookclient with the new one.- Parameters:
facebookClient
- the new FacebookClient
-
-