Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.neo4j.graphdb
Class DynamicRelationshipType

    java.lang.Object
      org.neo4j.graphdb.DynamicRelationshipType

All Implemented Interfaces:
  RelationshipType

    public final class DynamicRelationshipType

extends Object
implements RelationshipType

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:

     RelationshipType 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.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Method Detail

### withName

    public static DynamicRelationshipType withName(String name)

  Instantiates a new DynamicRelationshipType with the given name. There's more information regarding relationship types over at `RelationshipType`.

  Parameters:
    `name` - the name of the dynamic relationship type
  Returns:
    a DynamicRelationshipType with the given name
  Throws:
    `IllegalArgumentException` - if name is `null`

### name

    public String name()

  Returns the name of this relationship type. The name uniquely identifies a relationship type, i.e. two different RelationshipType instances with different object identifiers (and possibly even different classes) are semantically equivalent if they have `equal` names.

  Specified by:
    `name` in interface `RelationshipType`
  Returns:
    the name of the relationship type

### toString

    public String toString()

  Returns a string representation of this dynamic relationship type.

  Overrides:
    `toString` in class `Object`
  Returns:
    a string representation of this dynamic relationship type
  See Also:
    `Object.toString()`

### equals

    public boolean equals(Object other)

  Implements the identity-based equals defined by `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`.

  Overrides:
    `equals` in class `Object`
  Returns:
    `true` if `other` is the same instance as this dynamic relationship type, `false` otherwise
  See Also:
    `Object.equals(java.lang.Object)`

### hashCode

    public int hashCode()

  Implements the default hash function as defined by `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.

  Overrides:
    `hashCode` in class `Object`
  Returns:
    a hash code value for this dynamic relationship type instance
  See Also:
    `Object.hashCode()`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010 Neo4j. All Rights Reserved.