public final class DynamicRelationshipType extends Object implements RelationshipType
RelationshipType. This class is
a convenience implementation of RelationshipType that is
typically used when relationship types are created and named after a
condition that can only be detected at runtime.
If all relationship types are known at compile time, it's better to use the
relationship type enum idiom as outlined in RelationshipType.
It's very important to note that a relationship type is uniquely identified
by its name, not by any particular instance that implements this interface.
This means that the proper way to check if two relationship types are equal
is by invoking equals() on their names, NOT by
using Java's identity operator (==) or equals() on
the relationship type instances. A consequence of this is that you can NOT
use relationship types in hashed collections such as
HashMap and HashSet.
However, you usually want to check whether a specific relationship
instance is of a certain type. That is best achieved with the
Relationship.isType method, such as:
RelationshipType type = DynamicRelationshipType.withName( "myname" );
if ( rel.isType( type ) )
{
...
}
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object other)
Implements the identity-based equals defined by
java.lang.Object. |
int |
hashCode()
Implements the default hash function as defined by
java.lang.Object. |
String |
name()
Returns the name of this relationship type.
|
String |
toString()
Returns a string representation of this dynamic relationship type.
|
static DynamicRelationshipType |
withName(String name)
Instantiates a new DynamicRelationshipType with the given name.
|
public static DynamicRelationshipType withName(String name)
RelationshipType.name - the name of the dynamic relationship typeIllegalArgumentException - if name is nullpublic String name()
equal
names.name in interface RelationshipTypepublic String toString()
toString in class ObjectObject.toString()public boolean equals(Object other)
java.lang.Object. This means that this dynamic relationship type
instance will NOT be equal to other relationship types with the same
name. As outlined in the documentation for RelationshipType, the proper way to check for equivalence between two
relationship types is to compare their names.equals in class Objecttrue if other is the same instance as
this dynamic relationship type, false otherwiseObject.equals(java.lang.Object)public int hashCode()
java.lang.Object. This means that if you put a dynamic relationship
instance into a hash-based collection, it most likely will NOT behave as
you expect. Please see the documentation of equals and the class documentation for
more details.hashCode in class ObjectObject.hashCode()Copyright © 2002–2015 The Neo4j Graph Database Project. All rights reserved.