org.qi4j.api.entity

## Class EntityReference

- java.lang.Object
- - org.qi4j.api.entity.EntityReference

- All Implemented Interfaces:
    Serializable

      public final class EntityReference
      extends Object
      implements Serializable

  An EntityReference is identity of a specific Entity instance.

  When stringified, the identity is used as-is. Example:

      123456-abcde

  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `EntityReference(EntityComposite entityComposite)`
    `EntityReference(String identity)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static EntityReference` | `create(Identity identity)`
    `static EntityReference` | `entityReferenceFor(Object object)`
    `boolean` | `equals(Object o)`
    `int` | `hashCode()`
    `String` | `identity()`
    `static EntityReference` | `parseEntityReference(String identity)` Parse an Entity identity to an EntityReference.
    `static EntityReference` | `parseURI(String uri)` Parse an URI to an EntityReference.
    `String` | `toString()`
    `String` | `toURI()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### EntityReference

          public EntityReference(EntityComposite entityComposite)

      Parameters:
        `entityComposite` - a non-null EntityComposite
      Throws:
        `NullPointerException` - if entityComposite is null

    - #### EntityReference

          public EntityReference(String identity)

      Parameters:
        `identity` - reference identity
      Throws:
        `NullArgumentException` - if identity is null or empty

  - ### Method Detail

    - #### parseURI

          public static EntityReference parseURI(String uri)

      Parse an URI to an EntityReference.
      Parameters:
        `uri` - the URI to parse
      Returns:
        the EntityReference represented by the given URI

    - #### parseEntityReference

          public static EntityReference parseEntityReference(String identity)

      Parse an Entity identity to an EntityReference.
      Parameters:
        `identity` - the EntityReference identity
      Returns:
        the EntityReference represented by the given identity

    - #### entityReferenceFor

          public static EntityReference entityReferenceFor(Object object)

      Parameters:
        `object` - an EntityComposite
      Returns:
        the EntityReference for the given EntityComposite

    - #### create

          public static EntityReference create(Identity identity)

    - #### identity

          public final String identity()

      Returns:
        This EntityReference identity.

    - #### toURI

          public String toURI()

      Returns:
        An URI representation of this EntityReference.

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`
      Returns:
        This EntityReference identity.