Package com.adobe.granite.socialgraph
Interface GraphNode
-
- All Superinterfaces:
java.util.Map<java.lang.String,java.lang.Object>
@ProviderType public interface GraphNode extends java.util.Map<java.lang.String,java.lang.Object>
TheGraphNode
represents a user in the social graph.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description Relationship
createRelationshipTo(GraphNode other, java.lang.String type)
Creates a relationship to the given node.void
delete()
Deletes this graph node and all outgoing relationships.<T> T
get(java.lang.String name, java.lang.Class<T> type)
Get a named property and convert it into the given type.<T> T
get(java.lang.String name, T defaultValue)
Get a named property and convert it into the given type.java.lang.String
getId()
Returns the id of this node.Relationship
getRelationship(Direction dir, GraphNode node, java.lang.String type)
Returns the relationship between this and the give node in the specified direction and type.java.lang.Iterable<Relationship>
getRelationships(Direction dir, java.lang.String... types)
Returns the relationships attached to this node of the specific type and direction.Resource
getResource()
Returns the resource of object addressed by id ornull
if it does not exist.boolean
isVirtual()
Deprecated.virtual nodes are no longer supported.
-
-
-
Method Detail
-
getId
java.lang.String getId()
Returns the id of this node.- Returns:
- the id.
-
getResource
Resource getResource()
Returns the resource of object addressed by id ornull
if it does not exist.- Returns:
- the resource.
-
isVirtual
@Deprecated boolean isVirtual()
Deprecated.virtual nodes are no longer supported.Specifies tha this node is virtual and is not (and will never be) backed by a persistence object.- Returns:
true
if this node is virtual.
-
createRelationshipTo
Relationship createRelationshipTo(GraphNode other, java.lang.String type)
Creates a relationship to the given node.- Parameters:
other
- the other nodetype
- the type of the relationship- Returns:
- the relationship
- Throws:
java.lang.IllegalArgumentException
- if the relationship already existsSocialGraphException
- if an error during this operation occurs.
-
delete
void delete()
Deletes this graph node and all outgoing relationships. TODO: specify what should happen to incoming relationships
-
getRelationships
java.lang.Iterable<Relationship> getRelationships(Direction dir, java.lang.String... types)
Returns the relationships attached to this node of the specific type and direction.- Parameters:
dir
- the directiontypes
- the types of relationships to return.- Returns:
- a collection of relationships
-
getRelationship
Relationship getRelationship(Direction dir, GraphNode node, java.lang.String type)
Returns the relationship between this and the give node in the specified direction and type. Example: if A --[follows]--> B, then B.getRelationShip(Direction.OUTGOING, A, "follows") and, A.getRelationShip(Direction.INCOMING, B, "follows") Both return the same relationship defined above.- Parameters:
dir
- direction of the relationship to returnnode
- the other nodetype
- the type of relationship- Returns:
- the desired relationship or
null
-
get
<T> T get(java.lang.String name, java.lang.Class<T> type)
Get a named property and convert it into the given type.- Type Parameters:
T
- the type- Parameters:
name
- The name of the propertytype
- The class of the type- Returns:
- Return named value converted to type T or
null
if non existing or can't be converted.
-
get
<T> T get(java.lang.String name, T defaultValue)
Get a named property and convert it into the given type.- Type Parameters:
T
- the type- Parameters:
name
- The name of the propertydefaultValue
- The default value to use if the named property does not exist or cannot be converted to the requested type. The default value is also used to define the type to convert the value to. If this isnull
any existing property is not converted.- Returns:
- Return named value converted to type T or the default value if non existing or can't be converted.
-
-