package nl.tudelft.simulation.event.ref;
/**
* A WeakReference. The WeakReference extends the java.lang.ref.WeakReference
and besides implementing the
* Reference interface no changes are defined.
*
* Copyright (c) 2002-2019 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
* for project information https://simulation.tudelft.nl. The DSOL
* project is distributed under a three-clause BSD-style license, which can be found at
*
* https://simulation.tudelft.nl/dsol/3.0/license.html.
*
* @author Peter Jacobs
* @author Alexander Verbraeck
* @since 1.5
* @param the type of the reference
*/
public class WeakReference extends Reference
{
/** The default serial version UID for serializable classes. */
private static final long serialVersionUID = 20140830L;
/** the reference. */
private transient java.lang.ref.WeakReference reference = null;
/**
* Creates a new weak reference that refers to the given object. The new reference is not registered with any queue.
* @param referent T; object the new weak reference will refer to
*/
public WeakReference(final T referent)
{
this.reference = new java.lang.ref.WeakReference(referent);
}
/** {@inheritDoc} */
@Override
public final T get()
{
return this.reference.get();
}
/** {@inheritDoc} */
@Override
protected final void set(final T value)
{
this.reference = new java.lang.ref.WeakReference(value);
}
}