View Javadoc

1   package com.atlassian.user.util;
2   
3   import com.atlassian.cache.Cache;
4   
5   import java.util.Collection;
6   
7   /**
8    * Cheat to allow us to treat caches as if they have been genericised. As of now, atlassian-cache hasn't been
9    * made generic for backwards compatibility reasons.
10   */
11  @SuppressWarnings({"unchecked"})
12  public class GenericCacheWrapper<K, V>
13  {
14      private final Cache cache;
15  
16      public GenericCacheWrapper(Cache cache)
17      {
18          this.cache = cache;
19      }
20  
21      public String getName()
22      {
23          return cache.getName();
24      }
25  
26      public Collection<K> getKeys()
27      {
28          return cache.getKeys();
29      }
30  
31      public V get(K key)
32      {
33          return (V) cache.get(key);
34      }
35  
36      public void put(K key, V value)
37      {
38          cache.put(key, value);
39      }
40  
41      public void remove(K key)
42      {
43          cache.remove(key);
44      }
45  
46      public void removeAll()
47      {
48          cache.removeAll();
49      }
50  
51  }