Package org.jboss.modules.ref
Class References
java.lang.Object
org.jboss.modules.ref.References
A set of utility methods for reference types.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,
A> Reference<T, A> create
(Reference.Type type, T value, A attachment) Create a reference of a given type with the provided value and attachment.static <T,
A> Reference<T, A> create
(Reference.Type type, T value, A attachment, ReferenceQueue<? super T> referenceQueue) Create a reference of a given type with the provided value and attachment.static <T,
A> Reference<T, A> create
(Reference.Type type, T value, A attachment, Reaper<T, A> reaper) Create a reference of a given type with the provided value and attachment.static <T,
A> Reference<T, A> Get a null reference.
-
Field Details
-
NULL
-
-
Constructor Details
-
References
private References()
-
-
Method Details
-
create
public static <T,A> Reference<T,A> create(Reference.Type type, T value, A attachment, Reaper<T, A> reaper) Create a reference of a given type with the provided value and attachment. If the reference type isReference.Type.STRONG
orReference.Type.NULL
then the reaper argument is ignored. If the reference type isReference.Type.NULL
then the value and attachment arguments are ignored.- Type Parameters:
T
- the reference value typeA
- the reference attachment type- Parameters:
type
- the reference typevalue
- the reference valueattachment
- the attachment valuereaper
- the reaper to use, if any- Returns:
- the reference
-
create
public static <T,A> Reference<T,A> create(Reference.Type type, T value, A attachment, ReferenceQueue<? super T> referenceQueue) Create a reference of a given type with the provided value and attachment. If the reference type isReference.Type.STRONG
orReference.Type.NULL
then the reference queue argument is ignored. If the reference type isReference.Type.NULL
then the value and attachment arguments are ignored.- Type Parameters:
T
- the reference value typeA
- the reference attachment type- Parameters:
type
- the reference typevalue
- the reference valueattachment
- the attachment valuereferenceQueue
- the reference queue to use, if any- Returns:
- the reference
-
create
public static <T,A> Reference<T,A> create(Reference.Type type, T value, A attachment) throws IllegalArgumentException Create a reference of a given type with the provided value and attachment. If the reference type isReference.Type.PHANTOM
then this method will throw anIllegalArgumentException
because such references are not constructable without a queue or reaper. If the reference type isReference.Type.NULL
then the value and attachment arguments are ignored.- Type Parameters:
T
- the reference value typeA
- the reference attachment type- Parameters:
type
- the reference typevalue
- the reference valueattachment
- the attachment value- Returns:
- the reference
- Throws:
IllegalArgumentException
- if the reference type isReference.Type.PHANTOM
-
getNullReference
Get a null reference. This reference type is always cleared and does not retain an attachment; as such there is only one single instance of it.- Type Parameters:
T
- the reference value typeA
- the attachment value type- Returns:
- the null reference
-