1
2
3
4
5
6
7 package nl.tudelft.simulation.event.ref;
8
9 /***
10 * A StrongReference class represents a normal pointer relation to a reference.
11 * This class is created to complete the java.lang.ref package. This class
12 * ensures that references can be used without casting to either an object or a
13 * reference. Strong references are not created to be cleaned by the garbage
14 * collector. Since they represent normal pointer relations, they are the only
15 * ones which might be serialized. This class therefore implements
16 * <code>java.io.Serializable</code>
17 * <p>
18 * (c) copyright 2002-2005 <a href="http://www.simulation.tudelft.nl">Delft
19 * University of Technology </a>, the Netherlands.
20 * <p>
21 * See for project information <a
22 * href="http://www.simulation.tudelft.nl/dsol/event">www.simulation.tudelft.nl/event
23 * </a> <br>
24 * License of use: <a href="http://www.gnu.org/copyleft/lesser.html">Lesser
25 * General Public License (LGPL) </a>, no warranty
26 *
27 * @author <a href="http://www.peter-jacobs.com">Peter Jacobs </a>
28 * @version $Revision: 1.8 $ $Date: 2005/08/04 12:08:33 $
29 * @since 1.5
30 * @param <T> the type of the reference
31 */
32 public class StrongReference<T> extends Reference<T>
33 {
34 /*** the referent */
35 private transient T referent = null;
36
37 /***
38 * Creates a new strong reference that refers to the given object. The new
39 * reference is not registered with any queue.
40 *
41 * @param referent object the new strong reference will refer to
42 */
43 public StrongReference(final T referent)
44 {
45 this.referent = referent;
46 }
47
48 /***
49 * @see nl.tudelft.simulation.event.ref.Reference#get()
50 */
51 @Override
52 public T get()
53 {
54 return this.referent;
55 }
56
57 /***
58 * @see nl.tudelft.simulation.event.ref.Reference#set(java.lang.Object)
59 */
60 @Override
61 protected void set(final T value)
62 {
63 this.referent = value;
64 }
65 }