T - Type of the target of the weak reference.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.
| Constructor and Description |
|---|
WeakReference() |
WeakReference(Class<T> targetType,
AUID targetIdentifier) |
WeakReference(T target) |
| 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() |
public WeakReference()
public WeakReference(T target)
public T getTarget()
public void setTarget(T target)
public Long getPersistentID()
MediaEntityReturns 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.
getPersistentID in interface MediaEntitypublic void setPersistentIndex(int index)
MediaEntityIf 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.
setPersistentIndex in interface MediaEntityindex - Index of the entity within the list that contains it.public WeakReference<T> clone()
MediaEntityCreate 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.
clone in interface MediaEntityclone in class Objectpublic static final void registerTarget(WeakReferenceTarget target) throws NullPointerException
NullPointerExceptionpublic static final void forgetTarget(WeakReferenceTarget target)
public static final void generateWeakReferenceORM(Node parent, String namespace, String prefix)
public String getIdentifierString()
public void setIdentifierString(String identifier)
public AUID getIdentifier()
(c)2007-2016 Richard Cartwright, all rights reserved. Licensed under Apache 2 license and subject to the AMWA IPR policy.