T
- the type of entity created by this UniqueFactory
.public abstract class UniqueFactory<T extends PropertyContainer> extends Object
putIfAbsent() method
of the referenced index.Modifier and Type | Class and Description |
---|---|
static class |
UniqueFactory.UniqueNodeFactory
Implementation of
UniqueFactory for Node . |
static class |
UniqueFactory.UniqueRelationshipFactory
Implementation of
UniqueFactory for Relationship . |
Modifier and Type | Method and Description |
---|---|
protected abstract T |
create(Map<String,Object> properties)
Implement this method to create the
Node or Relationship to index. |
protected abstract void |
delete(T created)
Invoked after a new entity has been
created , but adding it to the index failed (due to being
added by another transaction concurrently). |
T |
getOrCreate(String key,
Object value)
Get the indexed entity, creating it (exactly once) if no indexed entity exists.
|
protected GraphDatabaseService |
graphDatabase()
Get the
graph database of the referenced index. |
protected Index<T> |
index()
Get the referenced index.
|
protected abstract void |
initialize(T created,
Map<String,Object> properties)
Implement this method to initialize the
Node or Relationship created for being stored in the index. |
protected abstract T create(Map<String,Object> properties)
Node
or Relationship
to index.
This method will be invoked exactly once per transaction that attempts to create an entry in the index.
The created entity might be discarded if another thread creates an entity with the same mapping concurrently.properties
- the properties that this entity will is to be indexed uniquely with.protected abstract void initialize(T created, Map<String,Object> properties)
Node
or Relationship
created for being stored in the index.
This method will be invoked exactly once per created unique entity.
The created entity might be discarded if another thread creates an entity concurrently.
This method will however only be invoked in the transaction that succeeds in creating the node.created
- the created entity to initialize.properties
- the properties that this entity was indexed uniquely with.protected abstract void delete(T created)
created
, but adding it to the index failed (due to being
added by another transaction concurrently). The purpose of this method is to undo the creation of the entity
, the default implementations of this method remove the entity. Override this method to
define a different behavior.created
- the entity that was created but was not added to the index.public final T getOrCreate(String key, Object value)
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.protected final GraphDatabaseService graphDatabase()
graph database
of the referenced index.graph database
of the referenced index.Copyright © 2002-2013 The Neo4j Graph Database Project. All Rights Reserved.