Class EventTypeAwareListener<K,V>

java.lang.Object
com.github.benmanes.caffeine.jcache.event.EventTypeAwareListener<K,V>
All Implemented Interfaces:
Closeable, AutoCloseable, EventListener, javax.cache.event.CacheEntryCreatedListener<K,V>, javax.cache.event.CacheEntryExpiredListener<K,V>, javax.cache.event.CacheEntryListener<K,V>, javax.cache.event.CacheEntryRemovedListener<K,V>, javax.cache.event.CacheEntryUpdatedListener<K,V>

final class EventTypeAwareListener<K,V> extends Object implements javax.cache.event.CacheEntryCreatedListener<K,V>, javax.cache.event.CacheEntryUpdatedListener<K,V>, javax.cache.event.CacheEntryRemovedListener<K,V>, javax.cache.event.CacheEntryExpiredListener<K,V>, Closeable
A decorator that dispatches the event iff the listener supports that action.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) final javax.cache.event.CacheEntryListener<? super K,? super V>
     
    (package private) static final Logger
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    EventTypeAwareListener(javax.cache.event.CacheEntryListener<? super K,? super V> listener)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    dispatch(@NonNull JCacheEntryEvent<K,V> event)
    Processes the event and logs if an exception is thrown.
    boolean
    isCompatible(@NonNull javax.cache.event.EventType eventType)
    Returns if the backing listener consumes this type of event.
    void
    onCreated(Iterable<javax.cache.event.CacheEntryEvent<? extends K,? extends V>> events)
     
    void
    onExpired(Iterable<javax.cache.event.CacheEntryEvent<? extends K,? extends V>> events)
     
    void
    onRemoved(Iterable<javax.cache.event.CacheEntryEvent<? extends K,? extends V>> events)
     
    void
    onUpdated(Iterable<javax.cache.event.CacheEntryEvent<? extends K,? extends V>> events)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • logger

      static final Logger logger
    • listener

      final javax.cache.event.CacheEntryListener<? super K,? super V> listener
  • Constructor Details

    • EventTypeAwareListener

      public EventTypeAwareListener(javax.cache.event.CacheEntryListener<? super K,? super V> listener)
  • Method Details

    • isCompatible

      public boolean isCompatible(@NonNull javax.cache.event.EventType eventType)
      Returns if the backing listener consumes this type of event.
    • dispatch

      public void dispatch(@NonNull JCacheEntryEvent<K,V> event)
      Processes the event and logs if an exception is thrown.
    • onCreated

      public void onCreated(Iterable<javax.cache.event.CacheEntryEvent<? extends K,? extends V>> events)
      Specified by:
      onCreated in interface javax.cache.event.CacheEntryCreatedListener<K,V>
    • onUpdated

      public void onUpdated(Iterable<javax.cache.event.CacheEntryEvent<? extends K,? extends V>> events)
      Specified by:
      onUpdated in interface javax.cache.event.CacheEntryUpdatedListener<K,V>
    • onRemoved

      public void onRemoved(Iterable<javax.cache.event.CacheEntryEvent<? extends K,? extends V>> events)
      Specified by:
      onRemoved in interface javax.cache.event.CacheEntryRemovedListener<K,V>
    • onExpired

      public void onExpired(Iterable<javax.cache.event.CacheEntryEvent<? extends K,? extends V>> events)
      Specified by:
      onExpired in interface javax.cache.event.CacheEntryExpiredListener<K,V>
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException