Package org.djutils.event.ref
Class StrongReference<T extends Serializable>
- java.lang.Object
-
- org.djutils.event.ref.Reference<T>
-
- org.djutils.event.ref.StrongReference<T>
-
- Type Parameters:
T
- the type of the reference
- All Implemented Interfaces:
Serializable
public class StrongReference<T extends Serializable> extends Reference<T>
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 implementsjava.io.Serializable
Copyright (c) 2002-2021 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html. This class was originally part of the DSOL project, see https://simulation.tudelft.nl/dsol/manual.
- Author:
- Peter Jacobs , Alexander Verbraeck
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description StrongReference(T referent)
Creates a new strong reference that refers to the given object.
-
-
-
Constructor Detail
-
StrongReference
public StrongReference(T referent)
Creates a new strong reference that refers to the given object. The new reference is not registered with any queue.- Parameters:
referent
- T; object the new strong reference will refer to
-
-
Method Detail
-
get
public final T get()
Returns this reference object's referent. If this reference object has been cleared, either by the program or by the garbage collector, then this method returnsnull
.- Specified by:
get
in classReference<T extends Serializable>
- Returns:
- The object to which this reference refers, or
null
if this reference object has been cleared.
-
-