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 {@link #name 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 {@link java.util.HashMap HashMap} and {@link java.util.HashSet HashSet}.
However, you usually want to check whether a specific relationship instance is of a certain type. That is best achieved with the {@link Relationship#isType Relationship.isType} method, such as: if ( rel.isType( MyRelationshipTypes.CONTAINED_IN ) ) { ... }
|
|