DATAKV-99 - Add KeyValueIterator.
We now offer the possibility to iterate through available key/value pairs via a KeyValueIterator. The default implementation for java.util.Map based Adapters is a ForwardingKeyValueIterator delegating to the underlying entrySet iterator. Original pull request: #7.
This commit is contained in:
committed by
Thomas Darimont
parent
aa3204e464
commit
16dc4b5e7d
@@ -22,7 +22,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.springframework.core.CollectionFactory;
|
||||
import org.springframework.data.keyvalue.core.AbstractKeyValueAdapter;
|
||||
import org.springframework.data.keyvalue.core.ForwardingKeyValueIterator;
|
||||
import org.springframework.data.keyvalue.core.KeyValueAdapter;
|
||||
import org.springframework.data.keyvalue.core.KeyValueIterator;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
@@ -133,6 +135,15 @@ public class MapKeyValueAdapter extends AbstractKeyValueAdapter {
|
||||
return getKeySpaceMap(keyspace).values();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#entries(java.io.Serializable)
|
||||
*/
|
||||
@Override
|
||||
public KeyValueIterator<Serializable, ?> entries(Serializable keyspace) {
|
||||
return new ForwardingKeyValueIterator<Serializable, Object>(getKeySpaceMap(keyspace).entrySet().iterator());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#deleteAllOf(java.io.Serializable)
|
||||
@@ -194,4 +205,5 @@ public class MapKeyValueAdapter extends AbstractKeyValueAdapter {
|
||||
private void addMapForKeySpace(Serializable keyspace) {
|
||||
store.put(keyspace, CollectionFactory.<Serializable, Object> createMap(keySpaceMapType, 1000));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user