Neo4j Community

org.neo4j.graphdb.index
Class UniqueFactory<T extends PropertyContainer>

java.lang.Object
  extended by org.neo4j.graphdb.index.UniqueFactory<T>
Type Parameters:
T - the type of entity created by this UniqueFactory.
Direct Known Subclasses:
UniqueFactory.UniqueNodeFactory, UniqueFactory.UniqueRelationshipFactory

public abstract class UniqueFactory<T extends PropertyContainer>
extends Object

A utility class for creating unique (with regard to a given index) entities. Uses the putIfAbsent() method of the referenced index.

Author:
Tobias Lindaaker

Nested Class Summary
static class UniqueFactory.UniqueEntity<T extends PropertyContainer>
           
static class UniqueFactory.UniqueNodeFactory
          Implementation of UniqueFactory for Node.
static class UniqueFactory.UniqueRelationshipFactory
          Implementation of UniqueFactory for Relationship.
 
Method Summary
 T getOrCreate(String key, Object value)
          Get the indexed entity, creating it (exactly once) if no indexed entity exists.
 UniqueFactory.UniqueEntity<T> getOrCreateWithOutcome(String key, Object value)
          Get the indexed entity, creating it (exactly once) if no indexed entity exists.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getOrCreate

public final T getOrCreate(String key,
                           Object value)
Get the indexed entity, creating it (exactly once) if no indexed entity exists.

Parameters:
key - the key to find the entity under in the index.
value - the value the key is mapped to for the entity in the index.
Returns:
the unique entity in the index.

getOrCreateWithOutcome

public final UniqueFactory.UniqueEntity<T> getOrCreateWithOutcome(String key,
                                                                  Object value)
Get the indexed entity, creating it (exactly once) if no indexed entity exists. Includes the outcome, i.e. whether the entity was created or not.

Parameters:
key - the key to find the entity under in the index.
value - the value the key is mapped to for the entity in the index.
Returns:
the unique entity in the index as well as whether or not it was created, wrapped in a UniqueFactory.UniqueEntity.

Neo4j Community

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