WeakReference (Media Authoring with Java API)
Date: 2016-02-05

tv.amwa.maj.industry

## Class WeakReference<T extends WeakReferenceTarget>

- java.lang.Object
- - tv.amwa.maj.industry.WeakReference<T>

- Type Parameters:
    `T` - Type of the target of the weak reference.
  All Implemented Interfaces:
    Cloneable, MediaEntity, MetadataObject

      public class WeakReference<T extends WeakReferenceTarget>
      extends Object
      implements MediaEntity, Cloneable

  Represents and provides a means to resolve a weak references that are stored as a field of an implementing class. Weak references can be safely persisted through object relational mapping and will resolve themselves at runtime as required.

  See Also:
    `WeakReferenceTarget`, `TypeDefinitionWeakObjectReference`, `WeakReferenceSet`, `WeakReferenceVector`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `WeakReference()`
    `WeakReference(Class<T> targetType, AUID targetIdentifier)`
    `WeakReference(T target)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `WeakReference<T>` | `clone()` Create a cloned copy of this media entity.
    `boolean` | `equals(Object o)`
    `static void` | `forgetTarget(WeakReferenceTarget target)`
    `static void` | `generateWeakReferenceORM(Node parent, String namespace, String prefix)`
    `AUID` | `getIdentifier()`
    `String` | `getIdentifierString()`
    `Long` | `getPersistentID()` Returns the persistent identifier for this media entity.
    `T` | `getTarget()`
    `int` | `hashCode()`
    `static void` | `registerTarget(WeakReferenceTarget target)`
    `void` | `setIdentifierString(String identifier)`
    `void` | `setPersistentIndex(int index)` If the media entity is an element of a strong reference vector, set the index of that element in the vector just before the value is persisted.
    `void` | `setTarget(T target)`
    `String` | `toString()`

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

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### WeakReference

          public WeakReference()

    - #### WeakReference

          public WeakReference(T target)

    - #### WeakReference

          public WeakReference(Class<T> targetType,
                               AUID targetIdentifier)

  - ### Method Detail

    - #### getTarget

          public T getTarget()

    - #### setTarget

          public void setTarget(T target)

    - #### getPersistentID

          public Long getPersistentID()

      Description copied from interface: `MediaEntity`

      Returns the persistent identifier for this media entity. This will be automatically generated by the persistence provider when the object is persisted for the first time. Before this, the identifier will be null.

      Specified by:
        `getPersistentID` in interface `MediaEntity`
      Returns:
        Persistent identifier for this media entity.

    - #### setPersistentIndex

          public void setPersistentIndex(int index)

      Description copied from interface: `MediaEntity`

      If the media entity is an element of a strong reference vector, set the index of that element in the vector just before the value is persisted. When the value is retrieved, the index will be used to restore the item to the correct position in its list. This is required to overcome a shortcoming of the Java Persistence API when persisting ordered collections.

      Specified by:
        `setPersistentIndex` in interface `MediaEntity`
      Parameters:
        `index` - Index of the entity within the list that contains it.

    - #### 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`

    - #### clone

          public WeakReference<T> clone()

      Description copied from interface: `MediaEntity`

      Create a cloned copy of this media entity. This is required for all targets of a strong reference to ensure that the target of a reference is owned by its source object.

      Specified by:
        `clone` in interface `MediaEntity`
      Overrides:
        `clone` in class `Object`
      Returns:
        Cloned copy of this media entity.

    - #### registerTarget

          public static final void registerTarget(WeakReferenceTarget target)
                                           throws NullPointerException

      Throws:
        `NullPointerException`

    - #### forgetTarget

          public static final void forgetTarget(WeakReferenceTarget target)

    - #### generateWeakReferenceORM

          public static final void generateWeakReferenceORM(Node parent,
                                                            String namespace,
                                                            String prefix)

    - #### getIdentifierString

          public String getIdentifierString()

    - #### setIdentifierString

          public void setIdentifierString(String identifier)

    - #### getIdentifier

          public AUID getIdentifier()

(c)2007-2016 Richard Cartwright, all rights reserved. Licensed under Apache 2 license and subject to the AMWA IPR policy.