renamed ValueWrapperImpl to SimpleValueWrapper (for use in Cache implementations)

This commit is contained in:
Juergen Hoeller 2011-11-28 15:52:42 +00:00
parent 372d461bef
commit bba70a7f12
3 changed files with 17 additions and 7 deletions

View File

@ -21,7 +21,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import org.springframework.cache.Cache; import org.springframework.cache.Cache;
import org.springframework.cache.support.ValueWrapperImpl; import org.springframework.cache.support.SimpleValueWrapper;
/** /**
* Simple {@link Cache} implementation based on the core JDK * Simple {@link Cache} implementation based on the core JDK
@ -96,7 +96,7 @@ public class ConcurrentMapCache implements Cache {
public ValueWrapper get(Object key) { public ValueWrapper get(Object key) {
Object value = this.store.get(key); Object value = this.store.get(key);
return (value != null ? new ValueWrapperImpl(fromStoreValue(value)) : null); return (value != null ? new SimpleValueWrapper(fromStoreValue(value)) : null);
} }
public void put(Object key, Object value) { public void put(Object key, Object value) {

View File

@ -21,7 +21,7 @@ import net.sf.ehcache.Element;
import net.sf.ehcache.Status; import net.sf.ehcache.Status;
import org.springframework.cache.Cache; import org.springframework.cache.Cache;
import org.springframework.cache.support.ValueWrapperImpl; import org.springframework.cache.support.SimpleValueWrapper;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
@ -63,7 +63,7 @@ public class EhCacheCache implements Cache {
public ValueWrapper get(Object key) { public ValueWrapper get(Object key) {
Element element = this.cache.get(key); Element element = this.cache.get(key);
return (element != null ? new ValueWrapperImpl(element.getObjectValue()) : null); return (element != null ? new SimpleValueWrapper(element.getObjectValue()) : null);
} }
public void put(Object key, Object value) { public void put(Object key, Object value) {

View File

@ -19,19 +19,29 @@ package org.springframework.cache.support;
import org.springframework.cache.Cache.ValueWrapper; import org.springframework.cache.Cache.ValueWrapper;
/** /**
* Straightforward implementation of {@link org.springframework.cache.Cache.ValueWrapper}. * Straightforward implementation of {@link org.springframework.cache.Cache.ValueWrapper},
* simply holding the value as given at construction and returning it from {@link #get()}.
* *
* @author Costin Leau * @author Costin Leau
* @since 3.1 * @since 3.1
*/ */
public class ValueWrapperImpl implements ValueWrapper { public class SimpleValueWrapper implements ValueWrapper {
private final Object value; private final Object value;
public ValueWrapperImpl(Object value) {
/**
* Create a new SimpleValueWrapper instance for exposing the given value.
* @param value the value to expose (may be <code>null</code>)
*/
public SimpleValueWrapper(Object value) {
this.value = value; this.value = value;
} }
/**
* Simply returns the value as given at construction time.
*/
public Object get() { public Object get() {
return this.value; return this.value;
} }