code: public static <V> Closure<V> buildSoftReferenceMemoizeFunction(final int protectedCacheSize, final MemoizeCache<Object, SoftReference<Object>> cache, final Closure<V> closure) {
          final ProtectionStorage lruProtectionStorage = protectedCacheSize > 0 ?
                  new LRUProtectionStorage(protectedCacheSize) :
                  new NullProtectionStorage(); // Nothing should be done when no elements need protection against eviction
  
          final ReferenceQueue queue = new ReferenceQueue();
  
          return new SoftReferenceMemoizeFunction<V>(cache, closure, lruProtectionStorage, queue);
      }
docs: Creates a new closure delegating to the supplied one and memoizing all return values by the arguments.
  The memoizing closure will use SoftReferences to remember the return values allowing the garbage collector
  to reclaim the memory, if needed.
  
  The supplied cache is used to store the memoized values and it is the cache's responsibility to put limits
  on the cache size or implement cache eviction strategy.
  The LRUCache, for example, allows to set the maximum cache size constraint and implements
  the LRU (Last Recently Used) eviction strategy.
  
  If the protectedCacheSize argument is greater than 0 an optional LRU (Last Recently Used) cache of hard references
  is maintained to protect recently touched memoized values against eviction by the garbage collector.
  
  @param protectedCacheSize The number of hard references to keep in order to prevent some (LRU) memoized return values from eviction
  @param cache A map to hold memoized return values
  @param closure The closure to memoize
  @param <V> The closure's return type
  @return A new memoized closure