Class References

java.lang.Object
org.jboss.modules.ref.References

public final class References extends Object
A set of utility methods for reference types.
  • Field Details

  • 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 is Reference.Type.STRONG or Reference.Type.NULL then the reaper argument is ignored. If the reference type is Reference.Type.NULL then the value and attachment arguments are ignored.
      Type Parameters:
      T - the reference value type
      A - the reference attachment type
      Parameters:
      type - the reference type
      value - the reference value
      attachment - the attachment value
      reaper - 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 is Reference.Type.STRONG or Reference.Type.NULL then the reference queue argument is ignored. If the reference type is Reference.Type.NULL then the value and attachment arguments are ignored.
      Type Parameters:
      T - the reference value type
      A - the reference attachment type
      Parameters:
      type - the reference type
      value - the reference value
      attachment - the attachment value
      referenceQueue - 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 is Reference.Type.PHANTOM then this method will throw an IllegalArgumentException because such references are not constructable without a queue or reaper. If the reference type is Reference.Type.NULL then the value and attachment arguments are ignored.
      Type Parameters:
      T - the reference value type
      A - the reference attachment type
      Parameters:
      type - the reference type
      value - the reference value
      attachment - the attachment value
      Returns:
      the reference
      Throws:
      IllegalArgumentException - if the reference type is Reference.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 type
      A - the attachment value type
      Returns:
      the null reference