Package com.restfb
Class Connection<T>
java.lang.Object
com.restfb.Connection<T>
- Type Parameters:
T- The Facebook type
Represents a Graph API Connection type.
- Author:
- Mark Allen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classIterator over connection pages. -
Constructor Summary
ConstructorsConstructorDescriptionConnection(FacebookClient facebookClient, String json, Class<T> connectionType) Creates a connection with the givenjsonObject. -
Method Summary
Modifier and TypeMethodDescriptionbooleanprotected Connection<T>Fetches the next page of the connection.getData()Data for this connection.fetch the currently usedgetJson()returns the JSON this connection is based on, it can be used for debug logs for exampleThis connection's "next page of data" URL.getOrder()returns the order of the elementsThis connection's "previous page of data" URL.Returns the metadata of the response that created thisConnection.provides the total count of elements, if FB provides them (API ≥ v2.0)return the typed summary.inthashCode()booleanhasNext()Does this connection have a next page of data?booleanDoes this connection have a previous page of data?iterator()voidreplaceFacebookClient(FacebookClient facebookClient) replace the current facebookclient with the new one.voidsetNextPageUrl(String nextPageUrl) Override the next page URL - use at your own riskvoidsetPreviousPageUrl(String previousPageUrl) Override the previous page URL - use at your own riskvoidsetResponseMetadata(ResponseMetadata responseMetadata) Attaches response metadata to this connection.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Connection
Creates a connection with the givenjsonObject.- Parameters:
facebookClient- TheFacebookClientused to fetch additional pages and map data to JSON objects.json- Raw JSON which must include adatafield that holds a JSON array and optionally apagingfield that holds a JSON object with next/previous page URLs.connectionType- Connection type token.- Throws:
FacebookJsonMappingException- If the providedjsonis invalid.- Since:
- 1.6.7
-
-
Method Details
-
iterator
-
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
-
toString
-
equals
-
hashCode
-
getData
Data for this connection.- Returns:
- Data for this connection.
-
getPreviousPageUrl
This connection's "previous page of data" URL.- Returns:
- This connection's "previous page of data" URL, or
nullif there is no previous page. - Since:
- 1.5.3
-
getNextPageUrl
This connection's "next page of data" URL.- Returns:
- This connection's "next page of data" URL, or
nullif there is no next page. - Since:
- 1.5.3
-
hasPrevious
Does this connection have a previous page of data?- Returns:
trueif there is a previous page of data for this connection,falseotherwise.
-
hasNext
Does this connection have a next page of data?- Returns:
trueif there is a next page of data for this connection,falseotherwise.
-
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
returns the order of the elements- Returns:
- the order of the elements
-
getBeforeCursor
-
getAfterCursor
-
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
replace the current facebookclient with the new one.- Parameters:
facebookClient- the new FacebookClient
-
getJson
returns the JSON this connection is based on, it can be used for debug logs for example- Returns:
- JSON as String the connection is based on
-
getResponseMetadata
Returns the metadata of the response that created thisConnection.- Returns:
- response metadata or
nullif unavailable
-
setResponseMetadata
Attaches response metadata to this connection.- Parameters:
responseMetadata- metadata captured while fetching the connection
-
setNextPageUrl
Override the next page URL - use at your own risk- Parameters:
nextPageUrl- Custom next Page URL as String
-
setPreviousPageUrl
Override the previous page URL - use at your own risk- Parameters:
previousPageUrl- Custom previous Page URL as String
-
getFacebookClient
fetch the currently used- Returns:
- the used FacebookClient
-