Neo4j Community

org.neo4j.tooling.wrap
Class WrappedRelationship<G extends WrappedGraphDatabase>

java.lang.Object
  extended by org.neo4j.tooling.wrap.WrappedRelationship<G>
All Implemented Interfaces:
PropertyContainer, Relationship

public abstract class WrappedRelationship<G extends WrappedGraphDatabase>
extends Object
implements Relationship


Field Summary
protected  G graphdb
           
 
Constructor Summary
protected WrappedRelationship(G graphdb)
           
 
Method Summary
protected abstract  T actual()
           
 void delete()
          Deletes this relationship.
 boolean equals(Object obj)
           
 Node getEndNode()
          Returns the end node of this relationship.
 GraphDatabaseService getGraphDatabase()
          Get the GraphDatabaseService that this Node or Relationship belongs to.
 long getId()
          Returns the unique id of this relationship.
 Node[] getNodes()
          Returns the two nodes that are attached to this relationship.
 Node getOtherNode(Node node)
          A convenience operation that, given a node that is attached to this relationship, returns the other node.
 Object getProperty(String key)
          Returns the property value associated with the given key.
 Object getProperty(String key, Object defaultValue)
          Returns the property value associated with the given key, or a default value.
 Iterable<String> getPropertyKeys()
          Returns all existing property keys, or an empty iterable if this property container has no properties.
 Iterable<Object> getPropertyValues()
          Returns all currently valid property values, or an empty iterable if this node has no properties.
 Node getStartNode()
          Returns the start node of this relationship.
 RelationshipType getType()
          Returns the type of this relationship.
 int hashCode()
           
 boolean hasProperty(String key)
          Returns true if this property container has a property accessible through the given key, false otherwise.
 boolean isType(RelationshipType type)
          Indicates whether this relationship is of the type type.
 Object removeProperty(String key)
          Removes the property associated with the given key and returns the old value.
 void setProperty(String key, Object value)
          Sets the property value for the given key to value.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.neo4j.graphdb.PropertyContainer
getGraphDatabase, getProperty, getProperty, getPropertyKeys, getPropertyValues, hasProperty, removeProperty, setProperty
 

Field Detail

graphdb

protected final G extends WrappedGraphDatabase graphdb
Constructor Detail

WrappedRelationship

protected WrappedRelationship(G graphdb)
Method Detail

getId

public long getId()
Description copied from interface: Relationship
Returns the unique id of this relationship. Ids are garbage collected over time so they are only guaranteed to be unique during a specific time span: if the relationship is deleted, it's likely that a new relationship at some point will get the old id. This makes relationship ids brittle as public APIs.

Specified by:
getId in interface Relationship
Returns:
the id of this node

delete

public void delete()
Description copied from interface: Relationship
Deletes this relationship. Invoking any methods on this relationship after delete() has returned is invalid and will lead to unspecified behavior.

Specified by:
delete in interface Relationship

getStartNode

public Node getStartNode()
Description copied from interface: Relationship
Returns the start node of this relationship. For a definition of how start node relates to directions as arguments to the relationship accessors in Node, see the class documentation of Relationship.

Specified by:
getStartNode in interface Relationship
Returns:
the start node of this relationship

getEndNode

public Node getEndNode()
Description copied from interface: Relationship
Returns the end node of this relationship. For a definition of how end node relates to directions as arguments to the relationship accessors in Node, see the class documentation of Relationship.

Specified by:
getEndNode in interface Relationship
Returns:
the end node of this relationship

getOtherNode

public Node getOtherNode(Node node)
Description copied from interface: Relationship
A convenience operation that, given a node that is attached to this relationship, returns the other node. For example if node is a start node, the end node will be returned, and vice versa. This is a very convenient operation when you're manually traversing the node space by invoking one of the getRelationships() operations on a node. For example, to get the node "at the other end" of a relationship, use the following:

Node endNode = node.getSingleRelationship( MyRels.REL_TYPE ).getOtherNode( node );

This operation will throw a runtime exception if node is neither this relationship's start node nor its end node.

Specified by:
getOtherNode in interface Relationship
Parameters:
node - the start or end node of this relationship
Returns:
the other node

getNodes

public Node[] getNodes()
Description copied from interface: Relationship
Returns the two nodes that are attached to this relationship. The first element in the array will be the start node, the second element the end node.

Specified by:
getNodes in interface Relationship
Returns:
the two nodes that are attached to this relationship

getType

public RelationshipType getType()
Description copied from interface: Relationship
Returns the type of this relationship. A relationship's type is an immutable attribute that is specified at Relationship creation. Remember that relationship types are semantically equivalent if their names are equal. This is NOT the same as checking for identity equality using the == operator. If you want to know whether this relationship is of a certain type, use the isType() operation.

Specified by:
getType in interface Relationship
Returns:
the type of this relationship

isType

public boolean isType(RelationshipType type)
Description copied from interface: Relationship
Indicates whether this relationship is of the type type. This is a convenience method that checks for equality using the contract specified by RelationshipType, i.e. by checking for equal names.

Specified by:
isType in interface Relationship
Parameters:
type - the type to check
Returns:
true if this relationship is of the type type, false otherwise or if null

actual

protected abstract T actual()

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

getGraphDatabase

public GraphDatabaseService getGraphDatabase()
Description copied from interface: PropertyContainer
Get the GraphDatabaseService that this Node or Relationship belongs to.

Specified by:
getGraphDatabase in interface PropertyContainer
Returns:
The GraphDatabase this Node or Relationship belongs to.

hasProperty

public boolean hasProperty(String key)
Description copied from interface: PropertyContainer
Returns true if this property container has a property accessible through the given key, false otherwise. If key is null, this method returns false.

Specified by:
hasProperty in interface PropertyContainer
Parameters:
key - the property key
Returns:
true if this property container has a property accessible through the given key, false otherwise

getProperty

public Object getProperty(String key)
Description copied from interface: PropertyContainer
Returns the property value associated with the given key. The value is of one of the valid property types, i.e. a Java primitive, a String or an array of any of the valid types.

If there's no property associated with key an unchecked exception is raised. The idiomatic way to avoid an exception for an unknown key and instead get null back is to use a default value: Object valueOrNull = nodeOrRel.getProperty( key, null )

Specified by:
getProperty in interface PropertyContainer
Parameters:
key - the property key
Returns:
the property value associated with the given key

getProperty

public Object getProperty(String key,
                          Object defaultValue)
Description copied from interface: PropertyContainer
Returns the property value associated with the given key, or a default value. The value is of one of the valid property types, i.e. a Java primitive, a String or an array of any of the valid types.

Specified by:
getProperty in interface PropertyContainer
Parameters:
key - the property key
defaultValue - the default value that will be returned if no property value was associated with the given key
Returns:
the property value associated with the given key

setProperty

public void setProperty(String key,
                        Object value)
Description copied from interface: PropertyContainer
Sets the property value for the given key to value. The property value must be one of the valid property types, i.e:

This means that null is not an accepted property value.

Specified by:
setProperty in interface PropertyContainer
Parameters:
key - the key with which the new property value will be associated
value - the new property value, of one of the valid property types

removeProperty

public Object removeProperty(String key)
Description copied from interface: PropertyContainer
Removes the property associated with the given key and returns the old value. If there's no property associated with the key, null will be returned.

Specified by:
removeProperty in interface PropertyContainer
Parameters:
key - the property key
Returns:
the property value that used to be associated with the given key

getPropertyKeys

public Iterable<String> getPropertyKeys()
Description copied from interface: PropertyContainer
Returns all existing property keys, or an empty iterable if this property container has no properties.

Specified by:
getPropertyKeys in interface PropertyContainer
Returns:
all property keys on this property container

getPropertyValues

public Iterable<Object> getPropertyValues()
Description copied from interface: PropertyContainer
Returns all currently valid property values, or an empty iterable if this node has no properties. All values are of a supported property type, i.e. a Java primitive, a String or an array of any of the supported types.

Note: This method is deprecated and will be removed in future releases. Use a combination of PropertyContainer.getPropertyKeys() and PropertyContainer.getProperty(String) to achieve the same result.

Specified by:
getPropertyValues in interface PropertyContainer
Returns:
all property values

Neo4j Community

Copyright © 2002-2012 The Neo4j Graph Database Project. All Rights Reserved.