001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.commons.jcs3.jcache; 020 021import javax.cache.Cache; 022import javax.cache.event.CacheEntryEvent; 023import javax.cache.event.EventType; 024 025public class JCSCacheEntryEvent<K, V> extends CacheEntryEvent<K, V> 026{ 027 /** Serial version */ 028 private static final long serialVersionUID = 4761272981003897488L; 029 030 private final V old; 031 private final K key; 032 private final V value; 033 034 public JCSCacheEntryEvent(final Cache<K, V> source, final EventType eventType, final V old, final K key, final V value) 035 { 036 super(source, eventType); 037 this.old = old; 038 this.key = key; 039 this.value = value; 040 } 041 042 @Override 043 public V getOldValue() 044 { 045 return old; 046 } 047 048 @Override 049 public boolean isOldValueAvailable() 050 { 051 return old != null; 052 } 053 054 @Override 055 public K getKey() 056 { 057 return key; 058 } 059 060 @Override 061 public V getValue() 062 { 063 return value; 064 } 065 066 @Override 067 public <T> T unwrap(final Class<T> clazz) 068 { 069 if (clazz.isInstance(this)) 070 { 071 return clazz.cast(this); 072 } 073 throw new IllegalArgumentException(clazz.getName() + " not supported in unwrap"); 074 } 075}