Skip navigation links
com.newrelic.agent.util

Class LazyAtomicReference<T>

    • Constructor Summary

      Constructors 
      Constructor and Description
      LazyAtomicReference(java.util.concurrent.Callable<T> initializer)
      Create an atomic that will be lazily initialized if get is invoked before set.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      T get()
      Get the value of the atomic.
      void set(T newValue)
      Set the value of the atomic.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LazyAtomicReference

        public LazyAtomicReference(java.util.concurrent.Callable<T> initializer)
        Create an atomic that will be lazily initialized if get is invoked before set.
        Parameters:
        initializer - the lazy initializer. The initializer is only invoked if a client class attempts to get the value before it has been set. The initializer must not return null and must not invoke methods on the instance it is initializing.
    • Method Detail

      • get

        public T get()
        Get the value of the atomic. If the value has not been set, the initializer is invoked to provide a default value. The implementation provides certain guarantees described in the class comment.
        Returns:
        the value of the atomic, never null.
        Throws:
        java.lang.NullPointerException - - the initializer was invoked but returned null; internal error.
        java.lang.RuntimeException - - wraps any exception thrown in the initializer; internal error.
      • set

        public void set(T newValue)
        Set the value of the atomic.
        Parameters:
        newValue - the value. May not be null.