|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.neo4j.graphdb.index.UniqueFactory<T>
T
- the type of entity created by this UniqueFactory
.public abstract class UniqueFactory<T extends PropertyContainer>
A utility class for creating unique (with regard to a given index) entities.
Uses the putIfAbsent() method
of the referenced index.
Nested Class Summary | |
---|---|
static class |
UniqueFactory.UniqueNodeFactory
Implementation of UniqueFactory for Node . |
static class |
UniqueFactory.UniqueRelationshipFactory
Implementation of UniqueFactory for Relationship . |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
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.protected final Index<T> index()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |