View Javadoc
1   package com.atlassian.cache.impl;
2   
3   import com.atlassian.cache.CachedReferenceListener;
4   
5   /**
6    * This interface is designed to support {@code CachedReference} implementations in working with {@code CachedReferenceListener}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 CachedReferenceListenerSupport<V>
12  {
13      void add(CachedReferenceListener<V> listener, boolean includeValues);
14      void remove(CachedReferenceListener<V> listener);
15  
16      void notifyEvict(V oldValue);
17      void notifySet(V value);
18      void notifyReset(V oldValue);
19  
20      CachedReferenceListenerSupport EMPTY = new CachedReferenceListenerSupport()
21      {
22          @Override
23          public void add(CachedReferenceListener listener, boolean includeValues)
24          {
25          }
26  
27          @Override
28          public void remove(CachedReferenceListener listener)
29          {
30          }
31  
32          @Override
33          public void notifyEvict(Object oldValue)
34          {
35          }
36  
37          @Override
38          public void notifySet(Object value)
39          {
40          }
41  
42          @Override
43          public void notifyReset(Object oldValue)
44          {
45          }
46      };
47  }