A dynamically instantiated and named {@link 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 {@link 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 {@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:
{@link RelationshipType} type = DynamicRelationshipType.{@link #withName(String) withName}( "myname" ); if ( rel. {@link Relationship#isType(RelationshipType) isType}( type ) ) { ... }