Package org.jboss.modules.ref
Class References
- java.lang.Object
-
- org.jboss.modules.ref.References
-
public final class References extends java.lang.Object
A set of utility methods for reference types.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <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, java.lang.ref.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>getNullReference()
Get a null reference.
-
-
-
Method Detail
-
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, java.lang.ref.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 java.lang.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:
java.lang.IllegalArgumentException
- if the reference type isReference.Type.PHANTOM
-
getNullReference
public static <T,A> Reference<T,A> 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
-
-