You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/07/10 05:19:33 UTC

[groovy] branch GROOVY-9631 updated: Add `getAndPut` back for binary compatibility

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY-9631
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/GROOVY-9631 by this push:
     new 519ef9b  Add `getAndPut` back for binary compatibility
519ef9b is described below

commit 519ef9b2257acb2c12c381d5450dafa1b3e1b6cb
Author: Daniel Sun <su...@apache.org>
AuthorDate: Fri Jul 10 13:19:03 2020 +0800

    Add `getAndPut` back for binary compatibility
---
 .../codehaus/groovy/runtime/memoize/MemoizeCache.java   | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/codehaus/groovy/runtime/memoize/MemoizeCache.java b/src/main/java/org/codehaus/groovy/runtime/memoize/MemoizeCache.java
index fc0c2cd..957833b 100644
--- a/src/main/java/org/codehaus/groovy/runtime/memoize/MemoizeCache.java
+++ b/src/main/java/org/codehaus/groovy/runtime/memoize/MemoizeCache.java
@@ -44,7 +44,7 @@ public interface MemoizeCache<K, V> {
      * Try to get the value from cache.
      * If not found, create the value by {@link ValueProvider} and put it into the cache, at last return the value.
      *
-     * @param key
+     * @param key the key to look up
      * @param valueProvider provide the value if the associated value not found
      * @return the cached value
      */
@@ -60,6 +60,21 @@ public interface MemoizeCache<K, V> {
     }
 
     /**
+     *
+     * Try to get the value from cache.
+     * If not found, create the value by {@link ValueProvider} and put it into the cache, at last return the value.
+     *
+     * @param key the key to look up
+     * @param valueProvider provide the value if the associated value not found
+     * @return the cached value
+     * @deprecated Use {@link #getOrPut(Object, ValueProvider)} instead
+     */
+    @Deprecated
+    default V getAndPut(K key, ValueProvider<? super K, ? extends V> valueProvider) {
+        return getOrPut(key, valueProvider);
+    }
+
+    /**
      * Invoked when some of the held SoftReferences have been evicted by the garbage collector and so should be removed from the cache.
      * The implementation must ensure that concurrent invocations of all methods on the cache may occur from other threads
      * and thus should protect any shared resources.