org.neo4j.graphdb
Interface Label

All Known Implementing Classes:
DynamicLabel

public interface Label

A label is a grouping facility for Node where all nodes having a label are part of the same group. Labels on nodes are optional and any node can have an arbitrary number of labels attached to it. Objects of classes implementing this interface can be used as label representations in your code. It's very important to note that a label 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 labels are equal is by invoking equals() on their names, NOT by using Java's identity operator (==) or equals() on the Label instances. A consequence of this is that you can NOT use Label instances in hashed collections such as HashMap and HashSet.

However, you usually want to check whether a specific node instance has a certain label. That is best achieved with the Node.hasLabel(Label) method. For labels that your application know up front you should specify using an enum, and since the name is accessed using the name() method it fits nicely. public enum MyLabels implements Label { PERSON, RESTAURANT; } For labels that your application don't know up front you can make use of DynamicLabel.label(String), or your own implementation of this interface, as it's just the name that matters.

See Also:
DynamicLabel, Node

Method Summary
 String name()
          Returns the name of the label.
 

Method Detail

name

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

Returns:
the name of the label


Copyright © 2002-2013 The Neo4j Graph Database Project. All Rights Reserved.