
org.cache2k.jcache.provider.event.EntryEvent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cache2k-jcache Show documentation
Show all versions of cache2k-jcache Show documentation
A light weight and high performance Java caching library. JCache/JSR107 support.
Dependency to javax.cache:cache-api must be additionally declared.
package org.cache2k.jcache.provider.event;
/*
* #%L
* cache2k JSR107 support
* %%
* Copyright (C) 2000 - 2016 headissue GmbH, Munich
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import org.cache2k.CacheEntry;
import javax.cache.Cache;
import javax.cache.event.CacheEntryEvent;
import javax.cache.event.EventType;
import java.util.Iterator;
import java.util.NoSuchElementException;
/**
* Entry events without original value, for created, expired and removed events.
*
* @author Jens Wilke
*/
public class EntryEvent extends CacheEntryEvent implements Iterable> {
K key;
V value;
public EntryEvent(final Cache source, final EventType eventType, final CacheEntry _c2kEntry) {
super(source, eventType);
key = _c2kEntry.getKey();
value = _c2kEntry.getValue();
}
public EntryEvent(final Cache source, final EventType eventType, final K _key, final V _value) {
super(source, eventType);
key = _key;
value = _value;
}
@Override
public V getOldValue() {
return null;
}
@Override
public boolean isOldValueAvailable() {
return false;
}
@Override
public K getKey() {
return key;
}
@Override
public V getValue() {
return value;
}
@Override
public T unwrap(final Class clazz) {
return null;
}
@Override
public Iterator> iterator() {
return new Iterator>() {
boolean hasNext = true;
@Override
public boolean hasNext() {
return hasNext;
}
@Override
public CacheEntryEvent extends K, ? extends V> next() {
if (hasNext) {
hasNext = false;
return EntryEvent.this;
}
throw new NoSuchElementException();
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy