package nl.tudelft.simulation.event.ref; /** * A StrongReference class represents a normal pointer relation to a reference. This class is created to complete the * java.lang.ref package. This class ensures that references can be used without casting to either an object or a * reference. Strong references are not created to be cleaned by the garbage collector. Since they represent normal * pointer relations, they are the only ones which might be serialized. This class therefore implements * java.io.Serializable *

* copyright (c) 2002-2018 Delft University of Technology.
* BSD-style license. See DSOL License.
* @author Peter Jacobs * @author Alexander Verbraeck * @since 1.5 * @param the type of the reference */ public class StrongReference extends Reference { /** The default serial version UID for serializable classes. */ private static final long serialVersionUID = 1L; /** the referent. */ private transient T referent = null; /** * Creates a new strong reference that refers to the given object. The new reference is not registered with any * queue. * @param referent object the new strong reference will refer to */ public StrongReference(final T referent) { this.referent = referent; } /** {@inheritDoc} */ @Override public final T get() { return this.referent; } /** {@inheritDoc} */ @Override protected final void set(final T value) { this.referent = value; } }