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-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 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 T; 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; } }