Class NamespacedHierarchicalStore.MemoizingSupplier

  • All Implemented Interfaces:
    java.util.function.Supplier<java.lang.Object>
    Enclosing class:
    NamespacedHierarchicalStore<N>

    private static class NamespacedHierarchicalStore.MemoizingSupplier
    extends java.lang.Object
    implements java.util.function.Supplier<java.lang.Object>
    Thread-safe Supplier that memoizes the result of calling its delegate and ensures it is called at most once.

    If the delegate throws an exception, it is stored and rethrown every time get() is called.

    See Also:
    NamespacedHierarchicalStore.StoredValue
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.function.Supplier<java.lang.Object> delegate  
      private static java.lang.Object NO_VALUE_SET  
      private java.lang.Object value  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private MemoizingSupplier​(java.util.function.Supplier<java.lang.Object> delegate)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void computeValue()  
      java.lang.Object get()  
      • Methods inherited from class java.lang.Object

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

      • NO_VALUE_SET

        private static final java.lang.Object NO_VALUE_SET
      • delegate

        private final java.util.function.Supplier<java.lang.Object> delegate
      • value

        private volatile java.lang.Object value
    • Constructor Detail

      • MemoizingSupplier

        private MemoizingSupplier​(java.util.function.Supplier<java.lang.Object> delegate)
    • Method Detail

      • get

        public java.lang.Object get()
        Specified by:
        get in interface java.util.function.Supplier<java.lang.Object>
      • computeValue

        private void computeValue()