View Javadoc
1   package org.djutils.event.reference;
2   
3   /**
4    * A StrongReference class represents a normal pointer relation to a reference. This class is created to complete the
5    * java.lang.ref package. This class ensures that references can be used without casting to either an object or a reference.
6    * Strong references are not created to be cleaned by the garbage collector.
7    * <p>
8    * Copyright (c) 2002-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
9    * for project information <a href="https://djutils.org" target="_blank"> https://djutils.org</a>. The DJUTILS project is
10   * distributed under a three-clause BSD-style license, which can be found at
11   * <a href="https://djutils.org/docs/license.html" target="_blank"> https://djutils.org/docs/license.html</a>. This class was
12   * originally part of the DSOL project, see <a href="https://simulation.tudelft.nl/dsol/manual" target="_blank">
13   * https://simulation.tudelft.nl/dsol/manual</a>.
14   * </p>
15   * @author <a href="https://www.linkedin.com/in/peterhmjacobs">Peter Jacobs </a>
16   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
17   * @param <T> the type of the reference
18   */
19  public class StrongReference<T> extends Reference<T>
20  {
21      /** the referent. */
22      private final transient T referent;
23  
24      /**
25       * Creates a new strong reference that refers to the given object. The new reference is not registered with any queue.
26       * @param referent object the new strong reference will refer to
27       */
28      public StrongReference(final T referent)
29      {
30          this.referent = referent;
31      }
32  
33      @Override
34      public final T get()
35      {
36          return this.referent;
37      }
38  }