1 package com.atlassian.cache; 2 3 import javax.annotation.Nonnull; 4 import javax.annotation.Nullable; 5 6 import com.atlassian.annotations.PublicApi; 7 8 /** 9 * A cache event. 10 * <p/> 11 * NOTE: Although Cache does not support {@code null} as a valid value we are using it in {@code getValue} and 12 * {@code getOldValue} as a way to represent missing value. We have the following reasons for this: 13 * <ul> 14 * <li>Firstly, some events inherently do not have value or old value. For instance addition does not have 15 * an old value as the corresponding element was just added to the cache</li> 16 * <li>Secondly, in some implementations the information for the value and/or old value is not available at all.</li> 17 * <li>Thirdly, the listener can be added as a valueless listener</li> 18 * </ul> 19 * 20 * @since 2.4 21 */ 22 @PublicApi 23 public interface CacheEntryEvent<K, V> 24 { 25 /** 26 * Returns the key the event was fired for 27 * 28 * @return the key 29 */ 30 @Nonnull 31 K getKey(); 32 33 /** 34 * Returns the current value for this key 35 * 36 * @return the value. For details why is this method marked as {@code Nullable} please refer to the 37 * class level documentation 38 */ 39 @Nullable 40 V getValue(); 41 42 /** 43 * Returns the old value for this key 44 * 45 * @return the old value. For details why is this method marked as {@code Nullable} please refer to the 46 * class level documentation 47 */ 48 @Nullable 49 V getOldValue(); 50 }