View Javadoc

1   package com.atlassian.cache.impl;
2   
3   import com.atlassian.cache.CacheEntryListener;
4   
5   /**
6    * This interface is designed to support {@code Cache} implementations in working with {@code CacheEntryListener}s.
7    * <p/>
8    * The main usage pattern for which this is designed is to use delegation for add/remove (therefore the listeners are
9    * managed by the this interface) and then use notify* methods to create and deliver the actual events.
10   */
11  public interface CacheEntryListenerSupport<K, V>
12  {
13      void add(CacheEntryListener<K, V> listener, boolean includeValues);
14      void remove(CacheEntryListener<K, V> listener);
15  
16      void notifyAdd(K key, V value);
17      void notifyEvict(K key, V oldValue);
18      void notifyRemove(K key, V oldValue);
19      void notifyUpdate(K key, V value, V oldValue);
20  
21      CacheEntryListenerSupport EMPTY = new CacheEntryListenerSupport()
22      {
23          @Override
24          public void add(CacheEntryListener listener, boolean includeValues)
25          {
26          }
27  
28          @Override
29          public void remove(CacheEntryListener listener)
30          {
31          }
32  
33          @Override
34          public void notifyAdd(Object key, Object value)
35          {
36          }
37  
38          @Override
39          public void notifyEvict(Object key, Object oldValue)
40          {
41          }
42  
43          @Override
44          public void notifyRemove(Object key, Object oldValue)
45          {
46          }
47  
48          @Override
49          public void notifyUpdate(Object key, Object value, Object oldValue)
50          {
51          }
52      };
53  }