Class LazyAtomicReference<V>

  • Type Parameters:
    V -
    All Implemented Interfaces:
    Serializable

    public class LazyAtomicReference<V>
    extends AtomicReference<V>
    This class is a simple alternative to Lazy. It can be better in cases when memory footprint is important, because Lazy requires creation of an anonymous class which can capture "this" of the outer instance. It is also a bit simpler to use than Lazy because under the hood this is still an AtomicReference with all its convenient atomic methods.
    Since:
    2020.1
    See Also:
    Serialized Form
    • Constructor Detail

      • LazyAtomicReference

        public LazyAtomicReference​(@Nullable
                                   V initialValue)
      • LazyAtomicReference

        public LazyAtomicReference()
    • Method Detail

      • computeIfAbsent

        public V computeIfAbsent​(@NotNull
                                 Supplier<V> initializer)
      • consumeIfPresent

        public void consumeIfPresent​(@NotNull
                                     Consumer<V> consumer)