groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: Minor refactoring: Refine caches for compatibility
Date Mon, 08 Jan 2018 15:49:10 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_5_X 04cf60b0f -> 353f38739


Minor refactoring: Refine caches for compatibility

(cherry picked from commit 0f10cb9)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/353f3873
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/353f3873
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/353f3873

Branch: refs/heads/GROOVY_2_5_X
Commit: 353f387399cd30d89a93f22d38df2f90c1ca3c25
Parents: 04cf60b
Author: sunlan <sunlan@apache.org>
Authored: Mon Jan 8 23:47:02 2018 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Mon Jan 8 23:49:05 2018 +0800

----------------------------------------------------------------------
 .../codehaus/groovy/runtime/memoize/CommonCache.java |  4 ++--
 .../runtime/memoize/ConcurrentCommonCache.java       |  4 ++--
 .../groovy/runtime/memoize/EvictableCache.java       | 15 +--------------
 .../groovy/runtime/memoize/MemoizeCache.java         | 12 ++++++++++++
 4 files changed, 17 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/353f3873/src/main/java/org/codehaus/groovy/runtime/memoize/CommonCache.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/runtime/memoize/CommonCache.java b/src/main/java/org/codehaus/groovy/runtime/memoize/CommonCache.java
index 4659459..094a465 100644
--- a/src/main/java/org/codehaus/groovy/runtime/memoize/CommonCache.java
+++ b/src/main/java/org/codehaus/groovy/runtime/memoize/CommonCache.java
@@ -119,11 +119,11 @@ public class CommonCache<K, V> implements EvictableCache<K,
V> {
      * {@inheritDoc}
      */
     @Override
-    public V getAndPut(K key, ValueProvider<K, V> valueProvider) {
+    public V getAndPut(K key, ValueProvider<? super K, ? extends V> valueProvider)
{
         return getAndPut(key, valueProvider, true);
     }
 
-    public V getAndPut(K key, ValueProvider<K, V> valueProvider, boolean shouldCache)
{
+    public V getAndPut(K key, ValueProvider<? super K, ? extends V> valueProvider,
boolean shouldCache) {
         V value = get(key);
         if (null != value) {
             return value;

http://git-wip-us.apache.org/repos/asf/groovy/blob/353f3873/src/main/java/org/codehaus/groovy/runtime/memoize/ConcurrentCommonCache.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/runtime/memoize/ConcurrentCommonCache.java
b/src/main/java/org/codehaus/groovy/runtime/memoize/ConcurrentCommonCache.java
index 9eae7cd..ec93199 100644
--- a/src/main/java/org/codehaus/groovy/runtime/memoize/ConcurrentCommonCache.java
+++ b/src/main/java/org/codehaus/groovy/runtime/memoize/ConcurrentCommonCache.java
@@ -109,12 +109,12 @@ public class ConcurrentCommonCache<K, V> extends CommonCache<K,
V> {
      * {@inheritDoc}
      */
     @Override
-    public V getAndPut(K key, ValueProvider<K, V> valueProvider) {
+    public V getAndPut(K key, ValueProvider<? super K, ? extends V> valueProvider)
{
         return getAndPut(key, valueProvider, true);
     }
 
     @Override
-    public V getAndPut(K key, ValueProvider<K, V> valueProvider, boolean shouldCache)
{
+    public V getAndPut(K key, ValueProvider<? super K, ? extends V> valueProvider,
boolean shouldCache) {
         V value;
 
         readLock.lock();

http://git-wip-us.apache.org/repos/asf/groovy/blob/353f3873/src/main/java/org/codehaus/groovy/runtime/memoize/EvictableCache.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/runtime/memoize/EvictableCache.java b/src/main/java/org/codehaus/groovy/runtime/memoize/EvictableCache.java
index 34a0b8d..c764808 100644
--- a/src/main/java/org/codehaus/groovy/runtime/memoize/EvictableCache.java
+++ b/src/main/java/org/codehaus/groovy/runtime/memoize/EvictableCache.java
@@ -49,7 +49,7 @@ public interface EvictableCache<K, V> extends MemoizeCache<K, V>
{
      * @param key
      * @return the cached value
      */
-    V getAndPut(K key, ValueProvider<K, V> valueProvider);
+    V getAndPut(K key, ValueProvider<? super K, ? extends V> valueProvider);
 
     /**
      * Get all cached values
@@ -77,19 +77,6 @@ public interface EvictableCache<K, V> extends MemoizeCache<K,
V> {
     int size();
 
     /**
-     * Represents a provider used to create value
-     * @param <K> type of the key
-     * @param <V> type of the value
-     */
-    interface ValueProvider<K, V> {
-        /**
-         * Provide the created value
-         * @return
-         */
-        V provide(K key);
-    }
-
-    /**
      * Represents a eviction strategy for the cache with limited size
      */
     enum EvictionStrategy {

http://git-wip-us.apache.org/repos/asf/groovy/blob/353f3873/src/main/java/org/codehaus/groovy/runtime/memoize/MemoizeCache.java
----------------------------------------------------------------------
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 aa0eb8e..3a7f35c 100644
--- a/src/main/java/org/codehaus/groovy/runtime/memoize/MemoizeCache.java
+++ b/src/main/java/org/codehaus/groovy/runtime/memoize/MemoizeCache.java
@@ -48,4 +48,16 @@ public interface MemoizeCache<K, V> {
      * and thus should protect any shared resources.
      */
     void cleanUpNullReferences();
+
+    /**
+     * Represents a provider used to create value
+     * @param <K> type of the key
+     * @param <V> type of the value
+     */
+    interface ValueProvider<K, V> {
+        /**
+         * Provide the created value
+         */
+        V provide(K key);
+    }
 }


Mime
View raw message