org.sdnplatform.sync.internal.store
Class StoreUtils

java.lang.Object
  extended by org.sdnplatform.sync.internal.store.StoreUtils

public class StoreUtils
extends java.lang.Object

Group of store utilities


Field Summary
protected static org.slf4j.Logger logger
           
 
Constructor Summary
StoreUtils()
           
 
Method Summary
static
<K> void
assertValidKey(K key)
           
static void assertValidKeys(java.lang.Iterable<?> keys)
           
static
<V> boolean
canDelete(java.util.List<Versioned<V>> items, long tombstoneDeletion)
           
static void close(java.io.Closeable c)
          Closes a Closeable and logs a potential error instead of re-throwing the exception.
static
<K,V> java.util.Map<K,java.util.List<Versioned<V>>>
getAll(IStore<K,V> storageEngine, java.lang.Iterable<K> keys)
          Implements getAll by delegating to get.
static
<V> java.util.List<IVersion>
getVersions(java.util.List<Versioned<V>> versioneds)
           
static
<K,V> IClosableIterator<K>
keys(IClosableIterator<java.util.Map.Entry<K,V>> values)
           
static
<K,V> java.util.HashMap<K,V>
newEmptyHashMap(java.lang.Iterable<?> iterable)
          Returns an empty map with expected size matching the iterable size if it's of type Collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.slf4j.Logger logger
Constructor Detail

StoreUtils

public StoreUtils()
Method Detail

assertValidKeys

public static void assertValidKeys(java.lang.Iterable<?> keys)

assertValidKey

public static <K> void assertValidKey(K key)

getAll

public static <K,V> java.util.Map<K,java.util.List<Versioned<V>>> getAll(IStore<K,V> storageEngine,
                                                                         java.lang.Iterable<K> keys)
                                                            throws SyncException
Implements getAll by delegating to get.

Throws:
SyncException

newEmptyHashMap

public static <K,V> java.util.HashMap<K,V> newEmptyHashMap(java.lang.Iterable<?> iterable)
Returns an empty map with expected size matching the iterable size if it's of type Collection. Otherwise, an empty map with the default size is returned.


close

public static void close(java.io.Closeable c)
Closes a Closeable and logs a potential error instead of re-throwing the exception. If null is passed, this method is a no-op. This is typically used in finally blocks to prevent an exception thrown during close from hiding an exception thrown inside the try.

Parameters:
c - The Closeable to close, may be null.

getVersions

public static <V> java.util.List<IVersion> getVersions(java.util.List<Versioned<V>> versioneds)

keys

public static <K,V> IClosableIterator<K> keys(IClosableIterator<java.util.Map.Entry<K,V>> values)

canDelete

public static <V> boolean canDelete(java.util.List<Versioned<V>> items,
                                    long tombstoneDeletion)