UniqueFactory (Neo4j Community 2.1.0-M01 API)
Date: 2014-02-20

org.neo4j.graphdb.index

## Class UniqueFactory<T extends PropertyContainer>

- java.lang.Object
- - 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

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `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

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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`.

Copyright © 2002–2014 The Neo4j Graph Database Project. All rights reserved.