Interface GraphNode

All Superinterfaces:
Map<String,Object>

@ProviderType public interface GraphNode extends Map<String,Object>
The GraphNode represents a user in the social graph.
  • Method Details

    • getId

      String getId()
      Returns the id of this node.
      Returns:
      the id.
    • getResource

      Resource getResource()
      Returns the resource of object addressed by id or null 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, String type)
      Creates a relationship to the given node.
      Parameters:
      other - the other node
      type - the type of the relationship
      Returns:
      the relationship
      Throws:
      IllegalArgumentException - if the relationship already exists
      SocialGraphException - 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

      Iterable<Relationship> getRelationships(Direction dir, String... types)
      Returns the relationships attached to this node of the specific type and direction.
      Parameters:
      dir - the direction
      types - the types of relationships to return.
      Returns:
      a collection of relationships
    • getRelationship

      Relationship getRelationship(Direction dir, GraphNode node, 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 return
      node - the other node
      type - the type of relationship
      Returns:
      the desired relationship or null
    • get

      <T> T get(String name, 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 property
      type - 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(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 property
      defaultValue - 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 is null 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.