All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.ehcache.jcache.JCacheEntry Maven / Gradle / Ivy

There is a newer version: 1.5.0-0.5
Show newest version
/**
 *  Copyright 2003-2010 Terracotta, Inc.
 *
 *  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.
 */
package net.sf.ehcache.jcache;

import net.sf.ehcache.Element;

import javax.cache.Cache;

/**
 * An implementation of CacheEntry.
 * 

* A CacheEntry is metadata about an entry in the cache. It does not include the value. * * @param the type of keys used by this JCacheEntry * @param the type of values that are loaded by this JCacheEntry * @author Greg Luck, Ryan Gardner */ public class JCacheEntry implements Cache.Entry { private Element element; /** * Constructor * * Create a new JCacheEntry for this key / value pair * * @param key * @param value */ public JCacheEntry(K key, V value) { this.element = new Element(key, value); } /** * Constructor * * @param element an element from Ehcache */ public JCacheEntry(Element element) { this.element = element; } /** * Returns the key corresponding to this entry. * * @return the key corresponding to this entry */ @Override public K getKey() { if (element != null) { return (K) element.getObjectKey(); } else { return null; } } /** * Returns the value stored in the cache when this entry was created. * * @return the value corresponding to this entry */ @Override public V getValue() { if (element != null) { return (V) element.getValue(); } else { return null; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy