org.sdnplatform.sync.internal.store
Class JacksonStore<K,V>

java.lang.Object
  extended by org.sdnplatform.sync.internal.store.JacksonStore<K,V>
All Implemented Interfaces:
IStore<K,V>

public class JacksonStore<K,V>
extends java.lang.Object
implements IStore<K,V>

A store that will serialize and deserialize objects to JSON using Jackson


Field Summary
protected static org.slf4j.Logger logger
           
protected static com.fasterxml.jackson.databind.ObjectMapper mapper
           
 
Constructor Summary
JacksonStore(IStore<ByteArray,byte[]> delegate, java.lang.Class<K> keyClass, java.lang.Class<V> valueClass)
           
JacksonStore(IStore<ByteArray,byte[]> delegate, com.fasterxml.jackson.core.type.TypeReference<K> keyType, com.fasterxml.jackson.core.type.TypeReference<V> valueType)
           
 
Method Summary
 void close()
          Close the store.
 IClosableIterator<java.util.Map.Entry<K,java.util.List<Versioned<V>>>> entries()
          Get an iterator over pairs of entries in the store.
 java.util.List<Versioned<V>> get(K key)
          Get the value associated with the given key
 java.lang.String getName()
           
 java.util.List<IVersion> getVersions(K key)
          Get a list of the versions associated with the given key
 void put(K key, Versioned<V> value)
          Associate the value with the key and version in this store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static org.slf4j.Logger logger

mapper

protected static final com.fasterxml.jackson.databind.ObjectMapper mapper
Constructor Detail

JacksonStore

public JacksonStore(IStore<ByteArray,byte[]> delegate,
                    java.lang.Class<K> keyClass,
                    java.lang.Class<V> valueClass)

JacksonStore

public JacksonStore(IStore<ByteArray,byte[]> delegate,
                    com.fasterxml.jackson.core.type.TypeReference<K> keyType,
                    com.fasterxml.jackson.core.type.TypeReference<V> valueType)
Method Detail

get

public java.util.List<Versioned<V>> get(K key)
                                 throws SyncException
Description copied from interface: IStore
Get the value associated with the given key

Specified by:
get in interface IStore<K,V>
Parameters:
key - The key to check for
Returns:
The value associated with the key or an empty list if no values are found.
Throws:
SyncException

entries

public IClosableIterator<java.util.Map.Entry<K,java.util.List<Versioned<V>>>> entries()
Description copied from interface: IStore
Get an iterator over pairs of entries in the store. The key is the first element in the pair and the versioned value is the second element. Note that the iterator need not be threadsafe, and that it must be manually closed after use.

Specified by:
entries in interface IStore<K,V>
Returns:
An iterator over the entries in this StorageEngine.

put

public void put(K key,
                Versioned<V> value)
         throws SyncException
Description copied from interface: IStore
Associate the value with the key and version in this store

Specified by:
put in interface IStore<K,V>
Parameters:
key - The key to use
value - The value to store and its version.
Throws:
SyncException

getName

public java.lang.String getName()
Specified by:
getName in interface IStore<K,V>
Returns:
The name of the store.

close

public void close()
           throws SyncException
Description copied from interface: IStore
Close the store.

Specified by:
close in interface IStore<K,V>
Throws:
SyncException - If closing fails.

getVersions

public java.util.List<IVersion> getVersions(K key)
                                     throws SyncException
Description copied from interface: IStore
Get a list of the versions associated with the given key

Specified by:
getVersions in interface IStore<K,V>
Parameters:
key - the key
Returns:
the list of IVersion objects
Throws:
SyncException