Class LazyUtil.SafeLazy<T>

  • All Implemented Interfaces:
    java.util.function.Supplier<T>, Lazy<T>
    Enclosing class:
    LazyUtil

    static class LazyUtil.SafeLazy<T>
    extends java.lang.Object
    implements Lazy<T>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.concurrent.locks.Lock lock  
      private java.util.function.Supplier<T> supplier  
      private java.lang.Object value  
    • Constructor Summary

      Constructors 
      Constructor Description
      SafeLazy​(java.util.function.Supplier<T> supplier)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isInitialized()
      Indicates whether this lazy value has been initialized.
      void reset()  
      void set​(T newValue)
      Sets this lazy value to the provided value.
      java.lang.String toString()  
      T value()
      Returns the value held by this lazy.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.apache.logging.log4j.util.Lazy

        get, map
    • Field Detail

      • lock

        private final java.util.concurrent.locks.Lock lock
      • supplier

        private final java.util.function.Supplier<T> supplier
      • value

        private volatile java.lang.Object value
    • Constructor Detail

      • SafeLazy

        SafeLazy​(java.util.function.Supplier<T> supplier)
    • Method Detail

      • value

        public T value()
        Description copied from interface: Lazy
        Returns the value held by this lazy. This may cause the value to initialize if it hasn't been already.
        Specified by:
        value in interface Lazy<T>
      • set

        public void set​(T newValue)
        Description copied from interface: Lazy
        Sets this lazy value to the provided value.
        Specified by:
        set in interface Lazy<T>
      • reset

        public void reset()
      • isInitialized

        public boolean isInitialized()
        Description copied from interface: Lazy
        Indicates whether this lazy value has been initialized.
        Specified by:
        isInitialized in interface Lazy<T>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object