com.facebook.model
Class GraphObject.Factory

java.lang.Object
  extended by com.facebook.model.GraphObject.Factory
Enclosing interface:
GraphObject

public static final class GraphObject.Factory
extends Object

Creates proxies that implement GraphObject, GraphObjectList, and their derived types. These proxies allow access to underlying collections and name/value property bags via strongly-typed property getters and setters.

This supports get/set properties that use primitive types, JSON types, Date, other GraphObject types, Iterable, Collection, List, and GraphObjectList.


Method Summary
static GraphObject create()
          Creates a GraphObject proxy that initially contains no data.
static
<T extends GraphObject>
T
create(Class<T> graphObjectClass)
          Creates a GraphObject-derived proxy that initially contains no data.
static GraphObject create(JSONObject json)
          Creates a GraphObject proxy that provides typed access to the data in an underlying JSONObject.
static
<T extends GraphObject>
T
create(JSONObject json, Class<T> graphObjectClass)
          Creates a GraphObject-derived proxy that provides typed access to the data in an underlying JSONObject.
static
<T> GraphObjectList<T>
createList(Class<T> graphObjectClass)
          Creates a GraphObjectList-derived proxy that initially contains no data.
static
<T> GraphObjectList<T>
createList(JSONArray array, Class<T> graphObjectClass)
          Creates a GraphObjectList-derived proxy that provides typed access to the data in an underlying JSONArray.
static boolean hasSameId(GraphObject a, GraphObject b)
          Determines if two GraphObjects represent the same underlying graph object, based on their IDs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static GraphObject create(JSONObject json)
Creates a GraphObject proxy that provides typed access to the data in an underlying JSONObject.

Parameters:
json - the JSONObject containing the data to be exposed
Returns:
a GraphObject that represents the underlying data
Throws:
FacebookException - If the passed in Class is not a valid GraphObject interface

create

public static <T extends GraphObject> T create(JSONObject json,
                                               Class<T> graphObjectClass)
Creates a GraphObject-derived proxy that provides typed access to the data in an underlying JSONObject.

Parameters:
json - the JSONObject containing the data to be exposed
graphObjectClass - the GraphObject-derived type to return
Returns:
a graphObjectClass that represents the underlying data
Throws:
FacebookException - If the passed in Class is not a valid GraphObject interface

create

public static GraphObject create()
Creates a GraphObject proxy that initially contains no data.

Returns:
a GraphObject with no data
Throws:
FacebookException - If the passed in Class is not a valid GraphObject interface

create

public static <T extends GraphObject> T create(Class<T> graphObjectClass)
Creates a GraphObject-derived proxy that initially contains no data.

Parameters:
graphObjectClass - the GraphObject-derived type to return
Returns:
a graphObjectClass with no data
Throws:
FacebookException - If the passed in Class is not a valid GraphObject interface

hasSameId

public static boolean hasSameId(GraphObject a,
                                GraphObject b)
Determines if two GraphObjects represent the same underlying graph object, based on their IDs.

Parameters:
a - a graph object
b - another graph object
Returns:
true if both graph objects have an ID and it is the same ID, false otherwise

createList

public static <T> GraphObjectList<T> createList(JSONArray array,
                                                Class<T> graphObjectClass)
Creates a GraphObjectList-derived proxy that provides typed access to the data in an underlying JSONArray.

Parameters:
array - the JSONArray containing the data to be exposed
graphObjectClass - the GraphObject-derived type to return
Returns:
a graphObjectClass that represents the underlying data
Throws:
FacebookException - If the passed in Class is not a valid GraphObject interface

createList

public static <T> GraphObjectList<T> createList(Class<T> graphObjectClass)
Creates a GraphObjectList-derived proxy that initially contains no data.

Parameters:
graphObjectClass - the GraphObject-derived type to return
Returns:
a GraphObjectList with no data
Throws:
FacebookException - If the passed in Class is not a valid GraphObject interface