|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.neo4j.api.core.DynamicRelationshipType
public final class DynamicRelationshipType
A dynamically instantiated and named 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:
DynamicRelationshipType type = DynamicRelationshipType.withName( "myname" );
if ( rel.isType( type ) )
{
...
}
Method Summary | |
---|---|
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, without creating it in the underlying storage. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public static DynamicRelationshipType withName(String name)
name
- the name of the dynamic relationship type
IllegalArgumentException
- if name is null
public String name()
equal
names.
name
in interface RelationshipType
public String toString()
toString
in class Object
Object.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 Object
true
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 documentation of equals
and the class documentation
for more
details.
hashCode
in class Object
Object.hashCode()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |